list.vue 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141
  1. <template>
  2. <a-card size="small" :bordered="false" class="associatedProductList-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="associatedProductList-productName" v-model.trim="queryParam.supplierName" 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="associatedProductList-productName" v-model.trim="queryParam.product.name" 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="associatedProductList-productCode" v-model.trim="queryParam.product.queryWord" 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. <ProductType id="associatedProduct-productType" v-model="productType" @change="changeProductType"></ProductType>
  26. </a-form-item>
  27. </a-col>
  28. <a-col :md="6" :sm="24">
  29. <a-form-item label="品牌">
  30. <ProductBrand id="associatedProduct-productBrandSn" v-model="queryParam.product.productBrandSn"></ProductBrand>
  31. </a-form-item>
  32. </a-col>
  33. </template>
  34. <a-col :md="6" :sm="24">
  35. <a-button style="margin-bottom: 18px;" type="primary" @click="$refs.table.refresh(true)" :disabled="disabled" id="associatedProductList-refresh">查询</a-button>
  36. <a-button style="margin: 0 0 18px 8px" @click="resetSearchForm" :disabled="disabled" id="associatedProductList-reset">重置</a-button>
  37. <a @click="advanced=!advanced" style="margin-left: 8px">
  38. {{ advanced ? '收起' : '展开' }}
  39. <a-icon :type="advanced ? 'up' : 'down'"/>
  40. </a>
  41. </a-col>
  42. </a-row>
  43. </a-form>
  44. </div>
  45. <!-- 列表 -->
  46. <s-table
  47. class="sTable"
  48. ref="table"
  49. size="default"
  50. :rowKey="(record) => record.id"
  51. :columns="columns"
  52. :data="loadData"
  53. :scroll="{ x: 1470, y: tableHeight }"
  54. bordered>
  55. <!-- 产品分类 -->
  56. <template slot="productType" slot-scope="text, record">
  57. <span v-if="record.product.productTypeName2 || record.product.productTypeName3">{{ record.product.productTypeName2 }} {{ record.product.productTypeName3 ? '>' : '' }} {{ record.product.productTypeName3 }}</span>
  58. <span v-else>--</span>
  59. </template>
  60. </s-table>
  61. </a-card>
  62. </template>
  63. <script>
  64. import { STable, VSelect } from '@/components'
  65. import ProductType from '@/views/common/productType.js'
  66. import ProductBrand from '@/views/common/productBrand.js'
  67. import { supplierProductList } from '@/api/supplier'
  68. export default {
  69. components: { STable, VSelect, ProductBrand, ProductType },
  70. data () {
  71. return {
  72. advanced: false, // 高级搜索 展开/关闭
  73. tableHeight: 0,
  74. queryParam: { // 查询条件
  75. supplierName: '',
  76. product: {
  77. name: '', // 产品名称
  78. queryWord: '', // 产品编码/原厂编码
  79. productBrandSn: undefined, // 产品品牌
  80. productTypeSn1: '', // 产品一级分类
  81. productTypeSn2: '', // 产品二级分类
  82. productTypeSn3: '' // 产品三级分类
  83. }
  84. },
  85. disabled: false, // 查询、重置按钮是否可操作
  86. productType: [],
  87. columns: [
  88. { title: '序号', dataIndex: 'no', width: 80, align: 'center' },
  89. { title: '供应商名称', dataIndex: 'supplierName', align: 'center', customRender: function (text) { return text || '--' }, ellipsis: true },
  90. { title: '品牌', dataIndex: 'product.productBrandName', width: 200, align: 'center', customRender: function (text) { return text || '--' } },
  91. { title: '产品分类', scopedSlots: { customRender: 'productType' }, width: 200, align: 'center' },
  92. { title: '产品名称', dataIndex: 'product.name', width: 220, align: 'center', customRender: function (text) { return text || '--' }, ellipsis: true },
  93. { title: '产品编码', dataIndex: 'product.code', width: 220, align: 'center', customRender: function (text) { return text || '--' } },
  94. { title: '成本价(¥)', dataIndex: 'cost', width: 110, align: 'center', customRender: function (text) { return ((text || text == 0) ? '¥' + text : '--') } },
  95. { title: '原厂编码', dataIndex: 'product.origCode', width: 220, align: 'center', customRender: function (text) { return text || '--' } }
  96. ],
  97. // 加载数据方法 必须为 Promise 对象
  98. loadData: parameter => {
  99. this.disabled = true
  100. if (this.tableHeight == 0) {
  101. this.tableHeight = window.innerHeight - 320
  102. }
  103. return supplierProductList(Object.assign(parameter, this.queryParam)).then(res => {
  104. const data = res.data
  105. const no = (data.pageNo - 1) * data.pageSize
  106. for (var i = 0; i < data.list.length; i++) {
  107. data.list[i].no = no + i + 1
  108. }
  109. this.disabled = false
  110. return data
  111. })
  112. }
  113. }
  114. },
  115. methods: {
  116. // 重置
  117. resetSearchForm () {
  118. this.queryParam.supplierName = ''
  119. this.queryParam.product.name = ''
  120. this.queryParam.product.queryWord = ''
  121. this.queryParam.product.productBrandSn = undefined
  122. this.queryParam.product.productTypeSn1 = ''
  123. this.queryParam.product.productTypeSn2 = ''
  124. this.queryParam.product.productTypeSn3 = ''
  125. this.productType = []
  126. this.$refs.table.refresh(true)
  127. },
  128. // 产品分类 change
  129. changeProductType (val, opt) {
  130. this.queryParam.product.productTypeSn1 = val[0] ? val[0] : ''
  131. this.queryParam.product.productTypeSn2 = val[1] ? val[1] : ''
  132. this.queryParam.product.productTypeSn3 = val[2] ? val[2] : ''
  133. }
  134. },
  135. beforeRouteEnter (to, from, next) {
  136. next(vm => {
  137. })
  138. }
  139. }
  140. </script>