list.vue 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184
  1. <template>
  2. <a-card size="small" :bordered="false" class="productChangeRecordList-wrap jg-page-wrap">
  3. <!-- 搜索条件 -->
  4. <div ref="tableSearch" 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="productUniversalList-productCode" v-model.trim="queryParam.productCode" 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="productUniversalList-productName" v-model.trim="queryParam.productName" allowClear placeholder="请输入产品名称"/>
  15. </a-form-item>
  16. </a-col>
  17. <a-col :md="6" :sm="24">
  18. <a-form-item label="产品状态">
  19. <v-select code="ONLINE_FLAG" id="productUniversalList-onlineFalg" v-model="queryParam.onlineFalg" allowClear placeholder="请选择上线状态"></v-select>
  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-input id="productUniversalList-productCommonCode" v-model.trim="queryParam.productCommonCode" allowClear placeholder="请输入通用产品编码"/>
  26. </a-form-item>
  27. </a-col>
  28. <a-col :md="6" :sm="24">
  29. <a-form-item label="通用产品名称">
  30. <a-input id="productUniversalList-productCommonName" v-model.trim="queryParam.productCommonName" allowClear placeholder="请输入通用产品名称"/>
  31. </a-form-item>
  32. </a-col>
  33. </template>
  34. <a-col :md="6" :sm="24" style="margin-bottom: 10px;">
  35. <a-button type="primary" @click="$refs.table.refresh(true)" :disabled="disabled" id="productUniversalList-refresh">查询</a-button>
  36. <a-button style="margin-left: 5px" @click="resetSearchForm" :disabled="disabled" id="productUniversalList-reset">重置</a-button>
  37. <a @click="advanced=!advanced" style="margin-left: 5px">
  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 fixPagination"
  48. ref="table"
  49. :style="{ height: tableHeight+84.5+'px' }"
  50. size="small"
  51. :rowKey="(record) => record.id"
  52. :columns="columns"
  53. :data="loadData"
  54. :scroll="{ y: tableHeight }"
  55. :defaultLoadData="false"
  56. bordered>
  57. <!-- 产品分类 -->
  58. <template slot="productType" slot-scope="text, record">
  59. <span v-if="record.productCommon.productTypeName2 || record.productCommon.productTypeName3">{{ record.productCommon.productTypeName2 }} {{ record.productCommon.productTypeName3 ? '>' : '' }} {{ record.productCommon.productTypeName3 }}</span>
  60. <span v-else>--</span>
  61. </template>
  62. </s-table>
  63. </a-card>
  64. </template>
  65. <script>
  66. import { commonMixin } from '@/utils/mixin'
  67. import { STable, VSelect } from '@/components'
  68. import { productUniversalCodeList } from '@/api/productUniversalCode'
  69. export default {
  70. name: 'ProductUniversalList',
  71. mixins: [commonMixin],
  72. components: { STable, VSelect },
  73. data () {
  74. return {
  75. spinning: false,
  76. advanced: true, // 高级搜索 展开/关闭
  77. tableHeight: 0,
  78. queryParam: { // 查询条件
  79. productCode: '',
  80. productName: '',
  81. onlineFalg: undefined,
  82. productCommonName: '',
  83. productCommonCode: ''
  84. },
  85. productType: [],
  86. disabled: false, // 查询、重置按钮是否可操作
  87. exportLoading: false, // 导出loading
  88. columns: [
  89. { title: '序号', dataIndex: 'no', width: '4%', align: 'center' },
  90. { title: '创建时间', dataIndex: 'createDate', width: '8%', align: 'center', customRender: function (text) { return text || '--' } },
  91. { title: '产品编码', dataIndex: 'productCode', width: '10%', align: 'center', customRender: function (text) { return text || '--' } },
  92. { title: '产品名称', dataIndex: 'product.name', align: 'center', width: '20%', customRender: function (text) { return text || '--' }, ellipsis: true },
  93. { title: '上线状态', dataIndex: 'product.onlineFalgDictValue', width: '6%', align: 'center', customRender: function (text) { return text || '--' } },
  94. { title: '通用产品编码', dataIndex: 'productCommonCode', width: '10%', align: 'center', customRender: function (text) { return text || '--' } },
  95. { title: '通用产品名称', dataIndex: 'productCommon.name', width: '12%', align: 'center', customRender: function (text) { return text || '--' }, ellipsis: true },
  96. { title: '通用产品分类', scopedSlots: { customRender: 'productType' }, width: '12%', align: 'center' },
  97. { title: '通用产品状态', dataIndex: 'productCommon.onlineFalgDictValue', width: '8%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } }
  98. ],
  99. // 加载数据方法 必须为 Promise 对象
  100. loadData: parameter => {
  101. this.disabled = true
  102. this.spinning = true
  103. return productUniversalCodeList(Object.assign(parameter, this.queryParam)).then(res => {
  104. let data
  105. if (res.status == 200) {
  106. data = res.data
  107. const no = (data.pageNo - 1) * data.pageSize
  108. for (var i = 0; i < data.list.length; i++) {
  109. data.list[i].no = no + i + 1
  110. }
  111. this.disabled = false
  112. }
  113. this.spinning = false
  114. return data
  115. })
  116. },
  117. openModal: false, // 编辑 弹框
  118. itemId: '' // 当前id
  119. }
  120. },
  121. methods: {
  122. // 重置
  123. resetSearchForm () {
  124. this.queryParam.productCode = ''
  125. this.queryParam.productName = ''
  126. this.queryParam.onlineFalg = undefined
  127. this.queryParam.productCommonName = ''
  128. this.queryParam.productCommonCode = ''
  129. this.$refs.table.refresh(true)
  130. },
  131. pageInit () {
  132. const _this = this
  133. this.$nextTick(() => { // 页面渲染完成后的回调
  134. _this.setTableH()
  135. })
  136. },
  137. setTableH () {
  138. const tableSearchH = this.$refs.tableSearch.offsetHeight
  139. this.tableHeight = window.innerHeight - tableSearchH - 235
  140. }
  141. },
  142. watch: {
  143. advanced (newValue, oldValue) {
  144. const _this = this
  145. this.$nextTick(() => { // 页面渲染完成后的回调
  146. _this.setTableH()
  147. })
  148. },
  149. '$store.state.app.winHeight' (newValue, oldValue) { // 窗口变更时,需同时更改表格高度
  150. this.setTableH()
  151. }
  152. },
  153. mounted () {
  154. if (!this.$store.state.app.isNewTab) { // 页签刷新时调用
  155. this.pageInit()
  156. this.resetSearchForm()
  157. }
  158. },
  159. activated () {
  160. // 如果是新页签打开,则重置当前页面
  161. if (this.$store.state.app.isNewTab) {
  162. this.pageInit()
  163. this.resetSearchForm()
  164. }
  165. // 仅刷新列表,不重置页面
  166. if (this.$store.state.app.updateList) {
  167. this.pageInit()
  168. this.$refs.table.refresh()
  169. }
  170. },
  171. beforeRouteEnter (to, from, next) {
  172. next(vm => {})
  173. }
  174. }
  175. </script>
  176. <style lang="less" scoped>
  177. .productChangeRecordList-wrap{
  178. .red{
  179. color: #ed1c24;
  180. }
  181. }
  182. </style>