list.vue 9.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232
  1. <template>
  2. <a-card size="small" :bordered="false" class="productInfoList-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="productInfoList-code" v-model.trim="queryParam.code" 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="productInfoList-name" v-model.trim="queryParam.name" allowClear placeholder="请输入产品名称"/>
  16. </a-form-item>
  17. </a-col>
  18. <a-col :md="6" :sm="24">
  19. <a-form-model-item :label="($route.params.onlineFalg=='1'?'上':'下')+'线时间'">
  20. <rangeDate ref="rangeDate" @change="dateChange" />
  21. </a-form-model-item>
  22. </a-col>
  23. <template v-if="advanced">
  24. <a-col :md="6" :sm="24">
  25. <a-form-item label="产品品牌">
  26. <ProductBrand id="productInfoList-productBrandSn" v-model="queryParam.productBrandSn"></ProductBrand>
  27. </a-form-item>
  28. </a-col>
  29. <a-col :md="6" :sm="24">
  30. <a-form-item label="产品分类">
  31. <productTypeAll placeholder="请选择产品分类" @change="changeProductType" v-model="productType" id="productInfoList-productType"></productTypeAll>
  32. </a-form-item>
  33. </a-col>
  34. <a-col :md="6" :sm="24">
  35. <a-form-item label="原厂编码">
  36. <a-input id="productInfoList-origCode" v-model.trim="queryParam.origCode" allowClear placeholder="请输入原厂编码"/>
  37. </a-form-item>
  38. </a-col>
  39. </template>
  40. <a-col :md="6" :sm="24" style="margin-bottom: 10px;">
  41. <a-button type="primary" @click="$refs.table.refresh(true)" :disabled="disabled" id="productInfoList-refresh">查询</a-button>
  42. <a-button style="margin-left: 5px" @click="resetSearchForm" :disabled="disabled" id="productInfoList-reset">重置</a-button>
  43. <a @click="advanced=!advanced" style="margin-left: 5px">
  44. {{ advanced ? '收起' : '展开' }}
  45. <a-icon :type="advanced ? 'up' : 'down'"/>
  46. </a>
  47. </a-col>
  48. </a-row>
  49. </a-form>
  50. </div>
  51. <!-- 列表 -->
  52. <s-table
  53. class="sTable fixPagination"
  54. ref="table"
  55. :style="{ height: tableHeight+84.5+'px' }"
  56. size="small"
  57. :rowKey="(record) => record.id"
  58. :columns="columns"
  59. :data="loadData"
  60. :defaultLoadData="false"
  61. :scroll="{ x: 1090, y: tableHeight }"
  62. bordered>
  63. <!-- 上/下线时间 表头 -->
  64. <template slot="auditTimeTit">
  65. {{ $route.params.onlineFalg=='1'?'上':'下' }}线时间
  66. </template>
  67. <!-- 上/下线时间 内容 -->
  68. <template slot="auditTime" slot-scope="text, record">
  69. {{ $route.params.onlineFalg=='1'?record.onlineAuditTime:record.offlineAuditTime }}
  70. </template>
  71. <!-- 产品分类 -->
  72. <template slot="productType" slot-scope="text, record">
  73. <span v-if="record.productTypeName2 || record.productTypeName3">{{ record.productTypeName2 }} {{ record.productTypeName3 ? '>' : '' }} {{ record.productTypeName3 }}</span>
  74. <span v-else>--</span>
  75. </template>
  76. <!-- 操作 -->
  77. <template slot="action" slot-scope="text, record">
  78. <a-button
  79. size="small"
  80. type="link"
  81. class="button-success"
  82. @click="handleDetail(record)"
  83. id="productInfoList-detail-btn">详情</a-button>
  84. </template>
  85. </s-table>
  86. </a-spin>
  87. </a-card>
  88. </template>
  89. <script>
  90. import { commonMixin } from '@/utils/mixin'
  91. import { queryNewProductPage } from '@/api/product'
  92. import { STable, VSelect } from '@/components'
  93. import ProductBrand from '@/views/common/productBrand.js'
  94. import productTypeAll from '@/views/common/productTypeAll.js'
  95. import rangeDate from '@/views/common/rangeDate.vue'
  96. export default {
  97. name: 'NewProductList',
  98. mixins: [commonMixin],
  99. components: { STable, VSelect, rangeDate, ProductBrand, productTypeAll },
  100. data () {
  101. return {
  102. spinning: false,
  103. advanced: true, // 高级搜索 展开/关闭
  104. tableHeight: 0,
  105. productType: [],
  106. queryParam: { // 查询条件
  107. beginDate: '',
  108. endDate: '',
  109. code: '', // 产品编码
  110. name: '', // 产品名称
  111. origCode: '', // 原厂编码
  112. sysFlag: '0',
  113. productBrandSn: undefined, // 产品品牌
  114. productTypeSn1: '', // 产品一级分类
  115. productTypeSn2: '', // 产品二级分类
  116. productTypeSn3: '', // 产品三级分类
  117. enabledFlag: undefined // 状态
  118. },
  119. disabled: false, // 查询、重置按钮是否可操作
  120. exportLoading: false, // 导出loading
  121. columns: [
  122. { title: '序号', dataIndex: 'no', width: 50, align: 'center' },
  123. { slots: { title: 'auditTimeTit' }, scopedSlots: { customRender: 'auditTime' }, width: 140, align: 'center' },
  124. { title: '产品品牌', dataIndex: 'productBrandName', width: 120, align: 'center', customRender: function (text) { return text || '--' } },
  125. { title: '产品分类', scopedSlots: { customRender: 'productType' }, width: 140, align: 'center' },
  126. { title: '产品名称', dataIndex: 'name', align: 'center', ellipsis: true, customRender: function (text) { return text || '--' } },
  127. { title: '产品编码', dataIndex: 'code', width: 180, align: 'center', customRender: function (text) { return text || '--' } },
  128. { title: '单位', dataIndex: 'unit', width: 60, align: 'center', customRender: function (text) { return text || '--' } },
  129. { title: '原厂编码', dataIndex: 'origCode', width: 140, align: 'center', customRender: function (text) { return text || '--' } },
  130. { title: '操作', scopedSlots: { customRender: 'action' }, width: 80, align: 'center', fixed: 'right' }
  131. ],
  132. // 加载数据方法 必须为 Promise 对象
  133. loadData: parameter => {
  134. this.disabled = true
  135. this.spinning = true
  136. return queryNewProductPage(Object.assign(parameter, this.queryParam, { onlineFalg: this.$route.params.onlineFalg })).then(res => {
  137. let data
  138. if (res.status == 200) {
  139. data = res.data
  140. const no = (data.pageNo - 1) * data.pageSize
  141. for (var i = 0; i < data.list.length; i++) {
  142. data.list[i].no = no + i + 1
  143. }
  144. this.disabled = false
  145. }
  146. this.spinning = false
  147. return data
  148. })
  149. },
  150. openModal: false, // 查看详情 弹框
  151. itemId: '', // 当前产品productSn
  152. }
  153. },
  154. methods: {
  155. // 创建时间 change
  156. dateChange (date) {
  157. this.queryParam.beginDate = date[0] || ''
  158. this.queryParam.endDate = date[1] || ''
  159. },
  160. // 重置
  161. resetSearchForm () {
  162. this.$refs.rangeDate.resetDate()
  163. this.queryParam.beginDate = ''
  164. this.queryParam.endDate = ''
  165. this.queryParam.code = ''
  166. this.queryParam.name = ''
  167. this.queryParam.origCode = ''
  168. this.queryParam.productBrandSn = undefined
  169. this.queryParam.productTypeSn1 = ''
  170. this.queryParam.productTypeSn2 = ''
  171. this.queryParam.productTypeSn3 = ''
  172. this.queryParam.enabledFlag = undefined
  173. this.productType = []
  174. this.$refs.table.refresh(true)
  175. },
  176. // 详情
  177. handleDetail (row) {
  178. this.itemId = row.productSn
  179. this.$router.push({ name: 'viewProduct', params: { sn: row.productSn } })
  180. },
  181. // 产品分类 change
  182. changeProductType (val, opt) {
  183. this.queryParam.productTypeSn1 = val[0] ? val[0] : ''
  184. this.queryParam.productTypeSn2 = val[1] ? val[1] : ''
  185. this.queryParam.productTypeSn3 = val[2] ? val[2] : ''
  186. },
  187. pageInit () {
  188. const _this = this
  189. this.$nextTick(() => { // 页面渲染完成后的回调
  190. _this.setTableH()
  191. })
  192. },
  193. setTableH () {
  194. const tableSearchH = this.$refs.tableSearch.offsetHeight
  195. this.tableHeight = window.innerHeight - tableSearchH - 215
  196. }
  197. },
  198. watch: {
  199. advanced (newValue, oldValue) {
  200. const _this = this
  201. this.$nextTick(() => { // 页面渲染完成后的回调
  202. _this.setTableH()
  203. })
  204. },
  205. '$store.state.app.winHeight' (newValue, oldValue) { // 窗口变更时,需同时更改表格高度
  206. this.setTableH()
  207. }
  208. },
  209. mounted () {
  210. if (!this.$store.state.app.isNewTab) { // 页签刷新时调用
  211. this.pageInit()
  212. this.resetSearchForm()
  213. }
  214. },
  215. activated () {
  216. // 如果是新页签打开,则重置当前页面
  217. if (this.$store.state.app.isNewTab) {
  218. this.pageInit()
  219. this.resetSearchForm()
  220. }
  221. // 仅刷新列表,不重置页面
  222. if (this.$store.state.app.updateList) {
  223. this.pageInit()
  224. this.$refs.table.refresh()
  225. }
  226. },
  227. beforeRouteEnter (to, from, next) {
  228. next(vm => {})
  229. }
  230. }
  231. </script>