list.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253
  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" :value="time" @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="productType" slot-scope="text, record">
  69. <span v-if="record.productTypeName2 || record.productTypeName3">{{ record.productTypeName2 }} {{ record.productTypeName3 ? '>' : '' }} {{ record.productTypeName3 }}</span>
  70. <span v-else>--</span>
  71. </template>
  72. <!-- 操作 -->
  73. <template slot="action" slot-scope="text, record">
  74. <a-button
  75. size="small"
  76. type="link"
  77. class="button-success"
  78. @click="handleDetail(record)"
  79. id="productInfoList-detail-btn">详情</a-button>
  80. </template>
  81. </s-table>
  82. </a-spin>
  83. </a-card>
  84. </template>
  85. <script>
  86. import { commonMixin } from '@/utils/mixin'
  87. import { queryNewProductPage, queryOnlinePageList } from '@/api/product'
  88. import { STable, VSelect } from '@/components'
  89. import ProductBrand from '@/views/common/productBrand.js'
  90. import productTypeAll from '@/views/common/productTypeAll.js'
  91. import rangeDate from '@/views/common/rangeDate.vue'
  92. import moment from 'moment'
  93. import getDate from '@/libs/getDate.js'
  94. export default {
  95. name: 'NewProductList',
  96. mixins: [commonMixin],
  97. components: { STable, VSelect, rangeDate, ProductBrand, productTypeAll },
  98. data () {
  99. return {
  100. spinning: false,
  101. advanced: true, // 高级搜索 展开/关闭
  102. tableHeight: 0,
  103. productType: [],
  104. queryParam: { // 查询条件
  105. beginDate: '',
  106. endDate: '',
  107. code: '', // 产品编码
  108. name: '', // 产品名称
  109. origCode: '', // 原厂编码
  110. sysFlag: '0',
  111. productBrandSn: undefined, // 产品品牌
  112. productTypeSn1: '', // 产品一级分类
  113. productTypeSn2: '', // 产品二级分类
  114. productTypeSn3: '', // 产品三级分类
  115. enabledFlag: undefined // 状态
  116. },
  117. disabled: false, // 查询、重置按钮是否可操作
  118. exportLoading: false, // 导出loading
  119. time: [
  120. moment(getDate.getCurrMonthDays().starttime, 'YYYY-MM-DD'),
  121. moment(getDate.getCurrMonthDays().endtime, 'YYYY-MM-DD')
  122. ],
  123. columns: [
  124. { title: '序号', dataIndex: 'no', width: 50, align: 'center' },
  125. { slots: { title: 'auditTimeTit' }, dataIndex: 'auditTime', width: 140, align: 'center',customRender: function (text) { return text || '--' } },
  126. { title: '产品品牌', dataIndex: 'productBrandName', width: 120, align: 'center', customRender: function (text) { return text || '--' } },
  127. { title: '产品分类', scopedSlots: { customRender: 'productType' }, width: 140, align: 'center' },
  128. { title: '产品名称', dataIndex: 'name', align: 'center', ellipsis: true, customRender: function (text) { return text || '--' } },
  129. { title: '产品编码', dataIndex: 'code', width: 180, align: 'center', customRender: function (text) { return text || '--' } },
  130. { title: '单位', dataIndex: 'unit', width: 60, align: 'center', customRender: function (text) { return text || '--' } },
  131. { title: '原厂编码', dataIndex: 'origCode', width: 140, align: 'center', customRender: function (text) { return text || '--' } },
  132. { title: '操作', scopedSlots: { customRender: 'action' }, width: 80, align: 'center', fixed: 'right' }
  133. ],
  134. // 加载数据方法 必须为 Promise 对象
  135. loadData: parameter => {
  136. this.disabled = true
  137. this.spinning = true
  138. const ajaxName = this.$route.params.type == 'onlineInfo' ? queryOnlinePageList : queryNewProductPage
  139. if (this.$route.params.type == 'onlineInfo') {
  140. if (this.queryParam.beginDate || this.queryParam.endDate) {
  141. this.queryParam.onlineFalg = 1
  142. this.queryParam.newProductDateScope = 9999
  143. } else {
  144. this.queryParam.onlineFalg = undefined
  145. this.queryParam.newProductDateScope = undefined
  146. }
  147. } else {
  148. this.queryParam.onlineFalg = this.$route.params.onlineFalg
  149. }
  150. return ajaxName(Object.assign(parameter, this.queryParam)).then(res => {
  151. let data
  152. if (res.status == 200) {
  153. data = res.data
  154. const no = (data.pageNo - 1) * data.pageSize
  155. for (var i = 0; i < data.list.length; i++) {
  156. data.list[i].no = no + i + 1
  157. }
  158. this.disabled = false
  159. }
  160. this.spinning = false
  161. return data
  162. })
  163. },
  164. openModal: false, // 查看详情 弹框
  165. itemId: '' // 当前产品productSn
  166. }
  167. },
  168. methods: {
  169. // 创建时间 change
  170. dateChange (date) {
  171. this.queryParam.beginDate = date[0] || ''
  172. this.queryParam.endDate = date[1] || ''
  173. },
  174. // 重置
  175. resetSearchForm () {
  176. this.$refs.rangeDate.resetDate()
  177. this.queryParam.code = ''
  178. this.queryParam.name = ''
  179. this.queryParam.origCode = ''
  180. this.queryParam.productBrandSn = undefined
  181. this.queryParam.productTypeSn1 = ''
  182. this.queryParam.productTypeSn2 = ''
  183. this.queryParam.productTypeSn3 = ''
  184. this.queryParam.enabledFlag = undefined
  185. this.productType = []
  186. if (this.$route.params.type == 'onlineInfo') {
  187. this.$refs.rangeDate.resetDate(this.time)
  188. this.queryParam.beginDate = getDate.getCurrMonthDays().starttime
  189. this.queryParam.endDate = getDate.getCurrMonthDays().endtime
  190. } else {
  191. this.queryParam.beginDate = ''
  192. this.queryParam.endDate = ''
  193. this.time = []
  194. this.$refs.rangeDate.resetDate([])
  195. }
  196. this.$refs.table.refresh(true)
  197. },
  198. // 详情
  199. handleDetail (row) {
  200. this.itemId = row.productSn
  201. this.$router.push({ name: 'viewProduct', params: { sn: row.productSn } })
  202. },
  203. // 产品分类 change
  204. changeProductType (val, opt) {
  205. this.queryParam.productTypeSn1 = val[0] ? val[0] : ''
  206. this.queryParam.productTypeSn2 = val[1] ? val[1] : ''
  207. this.queryParam.productTypeSn3 = val[2] ? val[2] : ''
  208. },
  209. pageInit () {
  210. const _this = this
  211. this.$nextTick(() => { // 页面渲染完成后的回调
  212. _this.setTableH()
  213. })
  214. },
  215. setTableH () {
  216. const tableSearchH = this.$refs.tableSearch.offsetHeight
  217. this.tableHeight = window.innerHeight - tableSearchH - 215
  218. }
  219. },
  220. watch: {
  221. advanced (newValue, oldValue) {
  222. const _this = this
  223. this.$nextTick(() => { // 页面渲染完成后的回调
  224. _this.setTableH()
  225. })
  226. },
  227. '$store.state.app.winHeight' (newValue, oldValue) { // 窗口变更时,需同时更改表格高度
  228. this.setTableH()
  229. }
  230. },
  231. mounted () {
  232. if (!this.$store.state.app.isNewTab) { // 页签刷新时调用
  233. this.pageInit()
  234. this.resetSearchForm()
  235. }
  236. },
  237. activated () {
  238. // 如果是新页签打开,则重置当前页面
  239. if (this.$store.state.app.isNewTab) {
  240. this.pageInit()
  241. this.resetSearchForm()
  242. }
  243. // 仅刷新列表,不重置页面
  244. if (this.$store.state.app.updateList) {
  245. this.pageInit()
  246. this.$refs.table.refresh()
  247. }
  248. },
  249. beforeRouteEnter (to, from, next) {
  250. next(vm => {})
  251. }
  252. }
  253. </script>