list.vue 8.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206
  1. <template>
  2. <a-card size="small" :bordered="false" class="costSetRecordList-wrap">
  3. <a-spin :spinning="spinning" tip="Loading...">
  4. <!-- 搜索条件 -->
  5. <div ref="tableSearch" class="table-page-search-wrapper">
  6. <a-form layout="inline" @keyup.enter.native="$refs.table.refresh(true)">
  7. <a-row :gutter="15">
  8. <a-col :md="6" :sm="24">
  9. <a-form-item label="产品名称">
  10. <a-input id="costSetList-productName" v-model.trim="queryParam.product.name" allowClear placeholder="请输入产品名称"/>
  11. </a-form-item>
  12. </a-col>
  13. <a-col :md="6" :sm="24">
  14. <a-form-item label="产品编码/原厂编码">
  15. <a-input id="costSetList-productCode" v-model.trim="queryParam.product.queryWord" allowClear placeholder="请输入产品编码"/>
  16. </a-form-item>
  17. </a-col>
  18. <a-col :md="6" :sm="24">
  19. <a-form-item label="品牌">
  20. <ProductBrand id="costSetRecord-productBrandSn" v-model="queryParam.product.productBrandSn"></ProductBrand>
  21. </a-form-item>
  22. </a-col>
  23. <a-col :md="6" :sm="24">
  24. <a-form-item label="产品分类">
  25. <ProductType id="costSetRecord-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. <a-input id="costSetList-productName" v-model.trim="queryParam.supplierName" allowClear placeholder="请输入供应商名称"/>
  31. </a-form-item>
  32. </a-col>
  33. <a-col :md="6" :sm="24" style="margin-bottom: 10px;">
  34. <a-button type="primary" @click="$refs.table.refresh(true)" :disabled="disabled" id="costSetList-refresh">查询</a-button>
  35. <a-button style="margin-left: 5px" @click="resetSearchForm" :disabled="disabled" id="costSetList-reset">重置</a-button>
  36. <a-button
  37. style="margin-left: 10px"
  38. type="primary"
  39. class="button-warning"
  40. @click="handleExport"
  41. :disabled="disabled"
  42. :loading="exportLoading"
  43. id="costSetDetailList-export">导出</a-button>
  44. </a-col>
  45. </a-row>
  46. </a-form>
  47. </div>
  48. <!-- 列表 -->
  49. <s-table
  50. class="sTable fixPagination"
  51. ref="table"
  52. :style="{ height: tableHeight+84.5+'px' }"
  53. size="small"
  54. :rowKey="(record) => record.id"
  55. :columns="columns"
  56. :data="loadData"
  57. :scroll="{ y: tableHeight }"
  58. :defaultLoadData="false"
  59. bordered>
  60. <!-- 产品分类 -->
  61. <template slot="productType" slot-scope="text, record">
  62. <span v-if="record.product&&(record.product.productTypeName2 || record.product.productTypeName3)">{{ record.product.productTypeName2 }} {{ record.product.productTypeName3 ? '>' : '' }} {{ record.product.productTypeName3 }}</span>
  63. <span v-else>--</span>
  64. </template>
  65. </s-table>
  66. </a-spin>
  67. </a-card>
  68. </template>
  69. <script>
  70. import { commonMixin } from '@/utils/mixin'
  71. import { STable, VSelect } from '@/components'
  72. import { hdExportExcel } from '@/libs/exportExcel'
  73. import ProductType from '@/views/common/productType.js'
  74. import ProductBrand from '@/views/common/productBrand.js'
  75. import { supplierProductCostLogList,supplierProductCostLogExport } from '@/api/supplier'
  76. export default {
  77. name: 'costSetRecordList',
  78. mixins: [commonMixin],
  79. components: { STable, VSelect, ProductBrand, ProductType },
  80. data () {
  81. return {
  82. spinning: false,
  83. advanced: true, // 高级搜索 展开/关闭
  84. tableHeight: 0,
  85. queryParam: { // 查询条件
  86. supplierName: '',
  87. product: {
  88. name: '', // 产品名称
  89. queryWord: '', // 产品编码/原厂编码
  90. productBrandSn: undefined, // 产品品牌
  91. productTypeSn1: '', // 产品一级分类
  92. productTypeSn2: '', // 产品二级分类
  93. productTypeSn3: '' // 产品三级分类
  94. }
  95. },
  96. columns: [
  97. { title: '序号', dataIndex: 'no', width: '4%', align: 'center' },
  98. { title: '变更时间', dataIndex: 'auditTime', width: '10%', align: 'center', customRender: function (text) { return text || '--' } },
  99. { title: '产品名称', dataIndex: 'product.name', width: '15%', align: 'center', customRender: function (text) { return text || '--' } },
  100. { title: '产品编码', dataIndex: 'product.code', width: '10%', align: 'center', customRender: function (text) { return text || '--' } },
  101. { title: '原厂编码', dataIndex: 'product.origCode', width: '10%', align: 'center', customRender: function (text) { return text || '--' } },
  102. { title: '产品品牌', dataIndex: 'product.productBrandName', width: '10%', align: 'center', customRender: function (text) { return text || '--' } },
  103. { title: '产品分类', scopedSlots: { customRender: 'productType' }, width: '12%', align: 'center' },
  104. { title: '供应商名称', dataIndex: 'supplierName', width: '15%', align: 'center', customRender: function (text) { return text || '--' } },
  105. { title: '变更前', dataIndex: 'oldCost', width: '7%', align: 'center', customRender: function (text) { return text || '--' } },
  106. { title: '变更后', dataIndex: 'newCost', width: '7%', align: 'center', customRender: function (text) { return text || '--' } }
  107. ],
  108. disabled: false, // 查询、重置按钮是否可操作
  109. productType: [],
  110. // 加载数据方法 必须为 Promise 对象
  111. loadData: parameter => {
  112. this.disabled = true
  113. this.spinning = true
  114. return supplierProductCostLogList(Object.assign(parameter, this.queryParam)).then(res => {
  115. let data
  116. if (res.status == 200) {
  117. data = res.data
  118. const no = (data.pageNo - 1) * data.pageSize
  119. for (var i = 0; i < data.list.length; i++) {
  120. data.list[i].no = no + i + 1
  121. }
  122. this.disabled = false
  123. }
  124. this.spinning = false
  125. return data
  126. })
  127. }
  128. }
  129. },
  130. methods: {
  131. // 导出明细
  132. handleExport () {
  133. const _this = this
  134. const params = _this.queryParam
  135. _this.exportLoading = true
  136. _this.spinning = true
  137. hdExportExcel(supplierProductCostLogExport, params, '成本变更记录', function () {
  138. _this.exportLoading = false
  139. _this.spinning = false
  140. })
  141. },
  142. // 重置
  143. resetSearchForm () {
  144. this.queryParam.supplierName = ''
  145. this.queryParam.product.name = ''
  146. this.queryParam.product.queryWord = ''
  147. this.queryParam.product.productBrandSn = undefined
  148. this.queryParam.product.productTypeSn1 = ''
  149. this.queryParam.product.productTypeSn2 = ''
  150. this.queryParam.product.productTypeSn3 = ''
  151. this.productType = []
  152. this.$refs.table.refresh(true)
  153. },
  154. // 产品分类 change
  155. changeProductType (val, opt) {
  156. this.queryParam.product.productTypeSn1 = val[0] ? val[0] : ''
  157. this.queryParam.product.productTypeSn2 = val[1] ? val[1] : ''
  158. this.queryParam.product.productTypeSn3 = val[2] ? val[2] : ''
  159. },
  160. pageInit () {
  161. const _this = this
  162. this.$nextTick(() => { // 页面渲染完成后的回调
  163. _this.setTableH()
  164. })
  165. },
  166. setTableH () {
  167. const tableSearchH = this.$refs.tableSearch.offsetHeight
  168. this.tableHeight = window.innerHeight - tableSearchH - 195
  169. }
  170. },
  171. watch: {
  172. advanced (newValue, oldValue) {
  173. const _this = this
  174. this.$nextTick(() => { // 页面渲染完成后的回调
  175. _this.setTableH()
  176. })
  177. },
  178. '$store.state.app.winHeight' (newValue, oldValue) { // 窗口变更时,需同时更改表格高度
  179. this.setTableH()
  180. }
  181. },
  182. mounted () {
  183. if (!this.$store.state.app.isNewTab) { // 页签刷新时调用
  184. this.pageInit()
  185. this.resetSearchForm()
  186. }
  187. },
  188. activated () {
  189. // 如果是新页签打开,则重置当前页面
  190. if (this.$store.state.app.isNewTab) {
  191. this.pageInit()
  192. this.resetSearchForm()
  193. }
  194. // 仅刷新列表,不重置页面
  195. if (this.$store.state.app.updateList) {
  196. this.pageInit()
  197. this.$refs.table.refresh()
  198. }
  199. },
  200. beforeRouteEnter (to, from, next) {
  201. next(vm => {})
  202. }
  203. }
  204. </script>