list.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278
  1. <template>
  2. <a-card :bordered="false" class="productInfoList-wrap">
  3. <!-- 搜索条件 -->
  4. <div class="table-page-search-wrapper">
  5. <a-form layout="inline" @keyup.enter.native="$refs.table.refresh(true)">
  6. <a-row :gutter="15">
  7. <a-col :md="6" :sm="24">
  8. <a-form-item label="产品编码">
  9. <a-input id="productInfoList-bundleName" v-model.trim="queryParam.bundleName" allowClear placeholder="请输入产品编码"/>
  10. </a-form-item>
  11. </a-col>
  12. <a-col :md="6" :sm="24">
  13. <a-form-item label="产品名称">
  14. <a-input id="productInfoList-bundleName" v-model.trim="queryParam.bundleName" allowClear placeholder="请输入产品名称"/>
  15. </a-form-item>
  16. </a-col>
  17. <a-col :md="6" :sm="24">
  18. <a-form-item label="原厂编码">
  19. <a-input id="productInfoList-bundleName" v-model.trim="queryParam.bundleName" allowClear placeholder="请输入原厂编码"/>
  20. </a-form-item>
  21. </a-col>
  22. <template v-if="advanced">
  23. <a-col :md="6" :sm="24">
  24. <a-form-item label="产品品牌">
  25. <a-select placeholder="请选择" id="productInfoList-state" allowClear v-model="queryParam.dataSourceNo" :showSearch="true" option-filter-prop="children" :filter-option="filterOption">
  26. <a-select-option v-for="item in brandData" :key="item.salesChannelNo" :value="item.salesChannelNo">{{ item.salesChannelName }}</a-select-option>
  27. </a-select>
  28. </a-form-item>
  29. </a-col>
  30. <a-col :md="6" :sm="24">
  31. <a-form-item label="产品类别">
  32. <a-cascader :options="typeData" id="productInfoList-state" placeholder="请选择产品类别" allowClear v-model="queryParam.brand" />
  33. </a-form-item>
  34. </a-col>
  35. <a-col :md="6" :sm="24">
  36. <a-form-item label="状态">
  37. <v-select code="CHECK_ENABLE_STATE" id="productInfoList-state" v-model="queryParam.state" allowClear placeholder="请选择状态"></v-select>
  38. </a-form-item>
  39. </a-col>
  40. <a-col :md="6" :sm="24">
  41. <a-form-item label="产品来源">
  42. <v-select code="CHECK_ENABLE_STATE" id="productInfoList-state" v-model="queryParam.state" allowClear placeholder="请选择产品来源"></v-select>
  43. </a-form-item>
  44. </a-col>
  45. <a-col :md="6" :sm="24">
  46. <a-form-item label="创建时间">
  47. <a-range-picker
  48. style="width:100%"
  49. id="customerManagementList-creatTime"
  50. :disabledDate="disabledDate"
  51. v-model="creatTime"
  52. :format="dateFormat"
  53. :placeholder="['开始时间', '结束时间']" />
  54. </a-form-item>
  55. </a-form-item>
  56. </a-col>
  57. </template>
  58. <a-col :md="6" :sm="24">
  59. <a-button style="margin-bottom: 18px;" type="primary" @click="$refs.table.refresh(true)" :disabled="disabled" id="productInfoList-refresh">查询</a-button>
  60. <a-button style="margin: 0 0 18px 8px" @click="resetSearchForm" :disabled="disabled" id="productInfoList-reset">重置</a-button>
  61. <a-button style="margin: 0 0 18px 8px" type="danger" @click="handleExport" :disabled="disabled" :loading="exportLoading" id="inventoryQueryList-export">导出</a-button>
  62. <a @click="advanced=!advanced" style="margin-left: 8px">
  63. {{ advanced ? '收起' : '展开' }}
  64. <a-icon :type="advanced ? 'up' : 'down'"/>
  65. </a>
  66. </a-col>
  67. </a-row>
  68. </a-form>
  69. </div>
  70. <!-- 操作按钮 -->
  71. <div class="table-operator">
  72. <a-button id="productInfoList-add" type="primary" @click="handleAdd">新增产品</a-button>
  73. <a-button id="productInfoList-import" @click="handleImport" style="margin: 0 15px;">批量导入产品</a-button>
  74. <a-button id="productInfoList-state" @click="handleEditState">批量修改状态</a-button>
  75. </div>
  76. <!-- 列表 -->
  77. <s-table
  78. class="sTable"
  79. ref="table"
  80. size="default"
  81. :rowKey="(record) => record.id"
  82. :columns="columns"
  83. :data="loadData"
  84. bordered>
  85. <!-- 产品编码 -->
  86. <template slot="productCode" slot-scope="text, record">
  87. <a-badge count="箭是冠" :offset="[28,-10]" :number-style="{ backgroundColor: '#fff', color: '#ff0000', boxShadow: '0 0 0 1px #d9d9d9 inset', }" > {{record.productCode}} </a-badge>
  88. </template>
  89. <!-- 产品类别 -->
  90. <!-- 自定义表头 -->
  91. <template slot="productTypeCustomTitle">
  92. <a-tooltip placement="top">
  93. <template slot="title">
  94. <span>列表中只显示第三级分类的名称,鼠标移动至文字上,查看上级分类</span>
  95. </template>
  96. 产品类别<a-icon type="question-circle" :style="{ color: '#ff0000', marginLeft: '10px' }" />
  97. </a-tooltip>
  98. </template>
  99. <template slot="productType" slot-scope="text, record">
  100. <a-tooltip placement="top">
  101. <template slot="title">
  102. <span>{{record.productType}}</span>
  103. </template>
  104. {{record.productType}}
  105. </a-tooltip>
  106. </template>
  107. <!-- 状态 -->
  108. <template slot="state" slot-scope="text, record">
  109. <span>{{record.state == 1 ? '已启用' : '已禁用'}}</span>
  110. </template>
  111. <!-- 操作 -->
  112. <template slot="action" slot-scope="text, record">
  113. <a-button type="primary" @click="handleEdit(record)" id="productInfoList-edit-btn">编辑</a-button>
  114. <a-button @click="handleDetail(record)" id="productInfoList-detail-btn" style="margin-left: 15px;">详情</a-button>
  115. </template>
  116. </s-table>
  117. <!-- 产品详情 -->
  118. <product-info-detail-modal :openModal="openModal" :itemId="itemId" @close="closeModal" />
  119. </a-card>
  120. </template>
  121. <script>
  122. import moment from 'moment'
  123. // import { customerBundleDelayList, customerBundleExportDelay } from '@/api/FinancialManagement'
  124. import { STable, VSelect } from '@/components'
  125. import productInfoDetailModal from './detailModal.vue'
  126. export default {
  127. components: { STable, VSelect, productInfoDetailModal },
  128. data () {
  129. return {
  130. advanced: false, // 高级搜索 展开/关闭
  131. queryParam: { // 查询条件
  132. bundleName: '', // 供应商名称
  133. state: undefined, // 状态
  134. },
  135. disabled: false, // 查询、重置按钮是否可操作
  136. exportLoading: false, // 导出loading
  137. brandData: [], // 下拉数据
  138. typeData: [], // 产品类别 下拉数据
  139. dateFormat: 'YYYY-MM-DD',
  140. creatTime: [], // 创建时间
  141. columns: [
  142. { title: '序号', dataIndex: 'no', width: 70, align: 'center' },
  143. { title: '产品编码', scopedSlots: { customRender: 'productCode' }, width: 200, align: 'center' },
  144. { title: '产品名称', dataIndex: 'productOldNum', width: 160, align: 'center', ellipsis: true, customRender: function (text) { return text || '--' } },
  145. { title: '原厂编码', dataIndex: 'productBrand', width: 200, align: 'center', customRender: function (text) { return text || '--' } },
  146. { title: '产品品牌', dataIndex: 'productType', width: 200, align: 'center', customRender: function (text) { return text || '--' } },
  147. { slots: { title: 'productTypeCustomTitle' }, scopedSlots: { customRender: 'productType' }, width: 180, align: 'center' },
  148. { title: '终端价(售价)', dataIndex: 'inventoryMoney', width: 180, align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  149. { title: '创建时间', dataIndex: 'createTime', width: 180, align: 'center' },
  150. { title: '状态', scopedSlots: { customRender: 'state' }, width: 180, align: 'center' },
  151. { title: '操作', scopedSlots: { customRender: 'action' }, width: 240, align: 'center' }
  152. ],
  153. // 加载数据方法 必须为 Promise 对象
  154. loadData: parameter => {
  155. this.disabled = true
  156. // return customerBundleDelayList( Object.assign(parameter, this.queryParam) ).then(res => {
  157. // const data = res.data
  158. // const no = (data.pageNo - 1) * data.pageSize
  159. // for (var i = 0; i < data.list.length; i++) {
  160. // data.list[i].no = no + i + 1
  161. // }
  162. // this.disabled = false
  163. // return data
  164. // })
  165. const _this = this
  166. return new Promise(function(resolve, reject){
  167. const data = {
  168. pageNo: 1,
  169. pageSize: 10,
  170. list: [
  171. { id: '1', productCode: '产品编码12', productNum: 'jgqp11111111111', productName: '产品1', productOldNum: 'jgqp111123545', productBrand: '箭冠品牌', productType: '产品分类1', inventoryNum: '5', inventoryMoney: '122' }
  172. ]
  173. }
  174. const no = (data.pageNo - 1) * data.pageSize
  175. for (var i = 0; i < data.list.length; i++) {
  176. data.list[i].no = no + i + 1
  177. }
  178. _this.disabled = false
  179. resolve(data)
  180. })
  181. },
  182. openModal: false, // 查看客户详情 弹框
  183. itemId: '' // 当前产品id
  184. }
  185. },
  186. methods: {
  187. // 不可选日期
  188. disabledDate (date, dateStrings) {
  189. return date && date.valueOf() > Date.now()
  190. },
  191. // 重置
  192. resetSearchForm () {
  193. this.queryParam.orderBundleNo = ''
  194. this.queryParam.orderBundle.custMobile = ''
  195. this.queryParam.bundleName = ''
  196. this.queryParam.itemName = ''
  197. this.oldTime = undefined
  198. this.newTime = undefined
  199. this.$refs.table.refresh(true)
  200. },
  201. // 新增
  202. handleAdd(){
  203. this.$router.push({ path: '/productManagement/productInfo/add' })
  204. },
  205. // 编辑
  206. handleEdit(row){
  207. this.$router.push({ path: `/productManagement/productInfo/edit/${row.id}` })
  208. },
  209. // 批量导入
  210. handleImport(){
  211. },
  212. // 批量修改
  213. handleEditState(){},
  214. filterOption(input, option) {
  215. return (
  216. option.componentOptions.children[0].text.toLowerCase().indexOf(input.toLowerCase()) >= 0
  217. )
  218. },
  219. // 详情
  220. handleDetail(row){
  221. this.itemId = row.id
  222. this.openModal = true
  223. },
  224. // 关闭弹框
  225. closeModal(){
  226. this.itemId = ''
  227. this.openModal = false
  228. },
  229. // 导出
  230. handleExport () {
  231. const params = this.queryParam
  232. if (this.oldTime && this.oldTime.length > 0) {
  233. params.beginOldExpiryDate = moment(this.oldTime[0]).format('YYYY-MM-DD')
  234. params.endOldExpirydDate = moment(this.oldTime[1]).format('YYYY-MM-DD')
  235. } else {
  236. params.beginOldExpiryDate = ''
  237. params.endOldExpirydDate = ''
  238. }
  239. if (this.newTime && this.newTime.length > 0) {
  240. params.beginDate = moment(this.newTime[0]).format('YYYY-MM-DD')
  241. params.endDate = moment(this.newTime[1]).format('YYYY-MM-DD')
  242. } else {
  243. params.beginDate = ''
  244. params.endDate = ''
  245. }
  246. this.exportLoading = true
  247. customerBundleExportDelay(params).then(res => {
  248. this.exportLoading = false
  249. this.download(res)
  250. })
  251. },
  252. download (data) {
  253. if (!data) { return }
  254. const url = window.URL.createObjectURL(new Blob([data]))
  255. const link = document.createElement('a')
  256. link.style.display = 'none'
  257. link.href = url
  258. const a = moment().format('YYYYMMDDHHmmss')
  259. const fname = '产品信息表' + a
  260. link.setAttribute('download', fname + '.xlsx')
  261. document.body.appendChild(link)
  262. link.click()
  263. }
  264. }
  265. }
  266. </script>
  267. <style lang="less">
  268. .productInfoList-wrap{
  269. .sTable{
  270. table{
  271. width: auto;
  272. }
  273. }
  274. }
  275. </style>