list.vue 10 KB

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