list.vue 9.0 KB

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