list.vue 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610
  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-name" v-model.trim="queryParam.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="productInfoList-queryWord" v-model.trim="queryParam.queryWord" allowClear placeholder="请输入产品编码/原厂编码"/>
  16. </a-form-item>
  17. </a-col>
  18. <a-col :md="4" :sm="24">
  19. <a-form-item label="品牌">
  20. <ProductBrand id="productInfoList-productBrandSn" v-model="queryParam.productBrandSn"></ProductBrand>
  21. </a-form-item>
  22. </a-col>
  23. <template v-if="advanced">
  24. <a-col :md="4" :sm="24">
  25. <a-form-item label="产品分类">
  26. <productTypeAll placeholder="请选择产品分类" @change="changeProductType" v-model="productType" id="productInfoList-productType"></productTypeAll>
  27. </a-form-item>
  28. </a-col>
  29. <a-col :md="4" :sm="24">
  30. <a-form-item label="产品状态">
  31. <v-select code="PRODUCT_STATUS" id="productInfoList-state" v-model="queryParam.state" allowClear placeholder="请选择产品状态"></v-select>
  32. </a-form-item>
  33. </a-col>
  34. <a-col :md="4" :sm="24">
  35. <a-form-item label="定价状态">
  36. <v-select code="PRICING_STATUS" id="productInfoList-pricingState" v-model="queryParam.pricingState" allowClear placeholder="请选择定价状态"></v-select>
  37. </a-form-item>
  38. </a-col>
  39. <a-col :md="4" :sm="24">
  40. <a-form-item label="产品图片">
  41. <a-select id="productInfoList-picFlag" v-model="queryParam.picFlag" allowClear placeholder="请选择产品图片">
  42. <a-select-option value="1">
  43. 有图片
  44. </a-select-option>
  45. <a-select-option value="0">
  46. 无图片
  47. </a-select-option>
  48. </a-select>
  49. </a-form-item>
  50. </a-col>
  51. <a-col :md="6" :sm="24">
  52. <a-form-model-item label="最近修改时间">
  53. <rangeDate ref="rangeDate" @change="dateChange" />
  54. </a-form-model-item>
  55. </a-col>
  56. </template>
  57. <a-col :md="7" :sm="24" style="margin-bottom: 10px;">
  58. <a-button type="primary" @click="$refs.table.refresh(true)" :disabled="disabled" id="productInfoList-refresh">查询</a-button>
  59. <a-button style="margin-left: 5px" @click="resetSearchForm" :disabled="disabled" id="productInfoList-reset">重置</a-button>
  60. <a-button
  61. v-if="$hasPermissions('B_productInfo_export')"
  62. style="margin-left: 5px"
  63. type="primary"
  64. class="button-warning"
  65. @click="handleExport"
  66. :disabled="disabled"
  67. :loading="exportLoading"
  68. id="productInfoList-export">导出</a-button>
  69. <a @click="advanced=!advanced" style="margin-left: 5px">
  70. {{ advanced ? '收起' : '展开' }}
  71. <a-icon :type="advanced ? 'up' : 'down'"/>
  72. </a>
  73. </a-col>
  74. </a-row>
  75. </a-form>
  76. </div>
  77. <!-- 操作按钮 -->
  78. <div class="table-operator">
  79. <a-button id="productInfoList-add" type="primary" v-if="$hasPermissions('B_productInfo_add')" class="button-error" @click="handleEdit()">新增</a-button>
  80. <a-button
  81. id="productInfoList-batchAudit"
  82. type="primary"
  83. v-if="$hasPermissions('B_productInfo_batchAudit')"
  84. class="button-warning"
  85. :loading="loadingAudit"
  86. @click="handleBatchAudit"
  87. style="margin: 0 10px;">批量审核</a-button>
  88. <a-button
  89. id="productInfoList-batchLaunch"
  90. type="primary"
  91. v-if="$hasPermissions('B_productInfo_batchLaunch')"
  92. class="button-primary"
  93. :loading="loadingLaunch"
  94. @click="handleBatchLaunch"
  95. style="margin: 0 10px;">批量上线</a-button>
  96. <a-button
  97. id="productInfoList-batchDownline"
  98. type="primary"
  99. v-if="$hasPermissions('B_productInfo_batchDownline')"
  100. class="button-grey"
  101. :loading="loadingDownline"
  102. @click="handleBatchDownline"
  103. style="margin: 0 10px;">批量下线</a-button>
  104. <a-button
  105. id="productInfoList-batchImport"
  106. v-if="$hasPermissions('B_productInfo_batchImport')"
  107. type="primary"
  108. class="button-error"
  109. @click="openGuideModal=true"
  110. style="margin: 0 10px;">批量导入</a-button>
  111. <span style="margin-left: 8px" v-if="$hasPermissions('B_productInfo_batchAudit') || $hasPermissions('B_productInfo_batchLaunch') || $hasPermissions('B_productInfo_batchDownline')">
  112. <template v-if="rowSelectionInfo && rowSelectionInfo.selectedRowKeys.length>0">{{ `已选 ${rowSelectionInfo.selectedRowKeys.length} 项` }}</template>
  113. </span>
  114. </div>
  115. <s-table
  116. class="sTable fixPagination"
  117. ref="table"
  118. :style="{ height: tableHeight+84.5+'px' }"
  119. size="small"
  120. :row-selection=" showSelect?{ columnWidth: 40 }:null"
  121. :rowKey="(record) => record.id"
  122. @rowSelection="rowSelectionFun"
  123. :columns="columns"
  124. :data="loadData"
  125. :scroll="{ y: tableHeight }"
  126. :defaultLoadData="false"
  127. bordered>
  128. <!-- 自定义表头 -->
  129. <template slot="arrowFalgTitle">
  130. <a-tooltip placement="top">
  131. <template slot="title">
  132. <span>自有即箭冠产品,非自有即非箭冠产品</span>
  133. </template>
  134. 自有<a-icon type="question-circle" :style="{ marginLeft: '10px' }" />
  135. </a-tooltip>
  136. </template>
  137. <template slot="arrowFalg" slot-scope="text, record">
  138. <span v-if="record.arrowFalg">{{ record.arrowFalg == 1 ? '是' : '否' }}</span>
  139. <span v-else>--</span>
  140. </template>
  141. <!-- 产品分类 -->
  142. <template slot="productType" slot-scope="text, record">
  143. <span v-if="record.productTypeName2 || record.productTypeName3">{{ record.productTypeName2 }} {{ record.productTypeName3 ? '>' : '' }} {{ record.productTypeName3 }}</span>
  144. <span v-else>--</span>
  145. </template>
  146. <!-- 产品图片 -->
  147. <template slot="imageUrl" slot-scope="text, record">
  148. <div v-if="record.productPicList && record.productPicList.length>0">
  149. <img :src="record.productPicList[0].imageUrl+'?x-oss-process=image/resize,h_30,m_lfit' || ''" width="30" height="30" class="imageUrl" @click="inited(record.productPicList)" />
  150. </div>
  151. <span v-else>--</span>
  152. </template>
  153. <!-- 操作 -->
  154. <template slot="action" slot-scope="text, record">
  155. <a-button
  156. size="small"
  157. type="link"
  158. v-if="record.state=='WAIT' && $hasPermissions('B_productInfo_audit')"
  159. class="button-warning"
  160. @click="handleAudit(record)"
  161. id="productInfoList-audit-btn">审核</a-button>
  162. <a-button
  163. size="small"
  164. type="link"
  165. v-if="(record.state=='WAIT_ONLINE'||record.state=='OFFLINE') && $hasPermissions('B_productInfo_launch')"
  166. class="button-primary"
  167. @click="handleLaunch(record)"
  168. id="productInfoList-launch-btn">上线</a-button>
  169. <a-button
  170. size="small"
  171. type="link"
  172. v-if="record.state=='ONLINE' && $hasPermissions('B_productInfo_downline')"
  173. class="button-grey"
  174. @click="handleDownline(record)"
  175. id="productInfoList-downline-btn">下线</a-button>
  176. <a-button
  177. size="small"
  178. type="link"
  179. v-if="$hasPermissions('B_productInfo_edit')"
  180. class="button-info"
  181. @click="handleEdit(record)"
  182. id="productInfoList-edit-btn">编辑</a-button>
  183. <a-button
  184. size="small"
  185. type="link"
  186. v-if="$hasPermissions('B_productInfo_detail')"
  187. class="button-success"
  188. @click="handleDetail(record)"
  189. id="productInfoList-detail-btn">详情</a-button>
  190. <a-button
  191. size="small"
  192. type="link"
  193. v-if="record.state=='WAIT' && $hasPermissions('B_productInfo_del')"
  194. class="button-error"
  195. @click="handleDel(record)"
  196. id="productInfoList-del-btn">删除</a-button>
  197. <span v-if="!(record.state=='WAIT' && $hasPermissions('B_productInfo_audit')) && !((record.state=='WAIT_ONLINE'||record.state=='OFFLINE') && $hasPermissions('B_productInfo_launch')) && !(record.state=='ONLINE' && $hasPermissions('B_productInfo_downline')) && !$hasPermissions('B_productInfo_edit') && !$hasPermissions('B_productInfo_detail') && !(record.state=='WAIT' && $hasPermissions('B_productInfo_del'))">--</span>
  198. </template>
  199. </s-table>
  200. </a-spin>
  201. <!-- 产品详情 -->
  202. <product-info-detail-modal v-drag :openModal="openModal" :itemSn="itemSn" @close="closeModal" />
  203. <!-- 产品下线 -->
  204. <product-info-offline-modal v-drag :openModal="openOfflineModal" :offlineProductList="offlineProductList" @close="closeOfflineModal" @ok="$refs.table.refresh()" />
  205. <!-- 导入产品 -->
  206. <importGuideModal :openModal="openGuideModal" @close="openGuideModal=false" @ok="hanldeOk" />
  207. </a-card>
  208. </template>
  209. <script>
  210. import { commonMixin } from '@/utils/mixin'
  211. import { STable, VSelect } from '@/components'
  212. import productInfoDetailModal from './detailModal.vue'
  213. import productInfoOfflineModal from './offlineModal.vue'
  214. import ProductBrand from '@/views/common/productBrand.js'
  215. import productTypeAll from '@/views/common/productTypeAll.js'
  216. import { exportExcel } from '@/libs/JGPrint.js'
  217. import rangeDate from '@/views/common/rangeDate.vue'
  218. import importGuideModal from './importGuideModal.vue'
  219. import { productList, productAudit, productBatchAudit, productDel, productOnline, productBatchOnline, productExport, saveBatchImportProduct } from '@/api/product'
  220. export default {
  221. name: 'ProductInfoList',
  222. mixins: [commonMixin],
  223. components: { STable, VSelect, productInfoDetailModal, productInfoOfflineModal, ProductBrand, productTypeAll, rangeDate, importGuideModal },
  224. data () {
  225. return {
  226. spinning: false,
  227. advanced: true, // 高级搜索 展开/关闭
  228. tableHeight: 0,
  229. queryParam: { // 查询条件
  230. updateBeginDate: '',
  231. updateEndDate: '',
  232. name: '', // 产品名称
  233. queryWord: '', // 产品编码/原厂编码
  234. productBrandSn: undefined, // 产品品牌
  235. productTypeSn1: '', // 产品一级分类
  236. productTypeSn2: '', // 产品二级分类
  237. productTypeSn3: '', // 产品三级分类
  238. state: undefined, // 产品状态
  239. pricingState: undefined, // 定价状态
  240. picFlag: undefined
  241. },
  242. productType: [],
  243. disabled: false, // 查询、重置按钮是否可操作
  244. exportLoading: false,
  245. openGuideModal: false,
  246. columns: [
  247. { title: '序号', dataIndex: 'no', width: '4%', align: 'center' },
  248. { title: '创建时间', dataIndex: 'createDate', width: '8%', align: 'center', customRender: function (text) { return text || '--' } },
  249. { title: '产品名称', dataIndex: 'name', align: 'center', width: '15%', ellipsis: true, customRender: function (text) { return text || '--' } },
  250. { title: '产品编码', dataIndex: 'code', width: '6%', align: 'center', customRender: function (text) { return text || '--' } },
  251. { title: '原厂编码', dataIndex: 'origCode', width: '6%', align: 'center', customRender: function (text) { return text || '--' } },
  252. { title: '品牌', dataIndex: 'productBrandName', width: '6%', align: 'center', customRender: function (text) { return text || '--' } },
  253. { title: '产品分类', scopedSlots: { customRender: 'productType' }, width: '10%', align: 'center' },
  254. { slots: { title: 'arrowFalgTitle' }, scopedSlots: { customRender: 'arrowFalg' }, width: '6%', align: 'center' },
  255. { title: '最近修改时间', dataIndex: 'updateDate', width: '8%', align: 'center', customRender: function (text) { return text || '--' } },
  256. { title: '最新定价时间', dataIndex: 'pricingTime', width: '8%', align: 'center', customRender: function (text) { return text || '--' } },
  257. { title: '产品状态', dataIndex: 'stateDictValue', width: '6%', align: 'center', customRender: function (text) { return text || '--' } },
  258. { title: '定价状态', dataIndex: 'pricingStateDictValue', width: '6%', align: 'center', customRender: function (text) { return text || '--' } },
  259. { title: '产品图片', scopedSlots: { customRender: 'imageUrl' }, width: '7%', align: 'center' },
  260. { title: '操作', scopedSlots: { customRender: 'action' }, width: '10%', align: 'center' }
  261. ],
  262. loadingAudit: false,
  263. loadingLaunch: false,
  264. loadingDownline: false,
  265. // 加载数据方法 必须为 Promise 对象
  266. loadData: parameter => {
  267. this.disabled = true
  268. this.spinning = true
  269. return productList(Object.assign(parameter, this.queryParam)).then(res => {
  270. let data
  271. if (res.status == 200) {
  272. data = res.data
  273. const no = (data.pageNo - 1) * data.pageSize
  274. for (var i = 0; i < data.list.length; i++) {
  275. data.list[i].no = no + i + 1
  276. }
  277. this.disabled = false
  278. }
  279. this.spinning = false
  280. return data
  281. })
  282. },
  283. openModal: false, // 查看详情 弹框
  284. itemSn: '', // 当前sn
  285. openOfflineModal: false, // 下线 弹框
  286. offlineProductList: [], // 下线 当前所选数据
  287. pageFromInfo: null,
  288. rowSelectionInfo: null
  289. }
  290. },
  291. computed: {
  292. // 是否显示table选择框
  293. showSelect () {
  294. return this.$hasPermissions('B_productInfo_batchAudit') || this.$hasPermissions('B_productInfo_batchLaunch') || this.$hasPermissions('B_productInfo_batchDownline')
  295. }
  296. },
  297. methods: {
  298. // 创建时间 change
  299. dateChange (date) {
  300. this.queryParam.updateBeginDate = date[0] || ''
  301. this.queryParam.updateEndDate = date[1] || ''
  302. },
  303. // 表格选中项
  304. rowSelectionFun (obj) {
  305. this.rowSelectionInfo = obj || null
  306. },
  307. // 批量导入产品
  308. hanldeOk (obj) {
  309. this.spinning = true
  310. saveBatchImportProduct(obj).then(res => {
  311. if (res.status == 200) {
  312. this.resetSearchForm()
  313. }
  314. this.spinning = false
  315. })
  316. },
  317. // 审核
  318. handleAudit (row) {
  319. const _this = this
  320. this.$confirm({
  321. title: '提示',
  322. content: '确认要审核吗?',
  323. centered: true,
  324. onOk () {
  325. _this.spinning = true
  326. productAudit({ sn: row.productSn }).then(res => {
  327. if (res.status == 200) {
  328. _this.$message.success(res.message)
  329. _this.$refs.table.refresh()
  330. _this.spinning = false
  331. } else {
  332. _this.spinning = false
  333. }
  334. })
  335. }
  336. })
  337. },
  338. // 批量审核
  339. handleBatchAudit () {
  340. const _this = this
  341. if (!_this.rowSelectionInfo || (_this.rowSelectionInfo && _this.rowSelectionInfo.selectedRowKeys.length < 1)) {
  342. _this.$message.warning('请在列表勾选后再进行批量操作!')
  343. return
  344. }
  345. let num = 0
  346. const obj = []
  347. _this.rowSelectionInfo && _this.rowSelectionInfo.selectedRows.map(item => {
  348. if (item.state == 'WAIT') {
  349. num++
  350. obj.push(item.productSn)
  351. }
  352. })
  353. if (num < 1) {
  354. _this.$message.warning('当前数据不可操作!')
  355. return
  356. }
  357. this.$confirm({
  358. title: '提示',
  359. content: '已选有效数据' + num + '条,确认要批量审核吗?',
  360. centered: true,
  361. onOk () {
  362. _this.loadingAudit = true
  363. _this.spinning = true
  364. productBatchAudit(obj).then(res => {
  365. _this.loadingAudit = false
  366. if (res.status == 200) {
  367. _this.$refs.table.clearSelected() // 清空表格选中项
  368. _this.$message.success(res.message)
  369. _this.$refs.table.refresh()
  370. _this.spinning = false
  371. } else {
  372. _this.spinning = false
  373. }
  374. })
  375. }
  376. })
  377. },
  378. // 预览图片
  379. inited (viewer) {
  380. if (viewer) {
  381. const imageUrl = []
  382. viewer.map(item => {
  383. imageUrl.push(item.imageUrl)
  384. })
  385. this.$viewerApi({
  386. images: imageUrl
  387. })
  388. }
  389. },
  390. // 批量上线
  391. handleBatchLaunch () {
  392. const _this = this
  393. if (!_this.rowSelectionInfo || (_this.rowSelectionInfo && _this.rowSelectionInfo.selectedRowKeys.length < 1)) {
  394. _this.$message.warning('请在列表勾选后再进行批量操作!')
  395. return
  396. }
  397. let num = 0
  398. const obj = []
  399. _this.rowSelectionInfo && _this.rowSelectionInfo.selectedRows.map(item => {
  400. if (item.state == 'WAIT_ONLINE' || item.state == 'OFFLINE') {
  401. num++
  402. obj.push(item.productSn)
  403. }
  404. })
  405. if (num < 1) {
  406. _this.$message.warning('当前数据不可操作!')
  407. return
  408. }
  409. this.$confirm({
  410. title: '提示',
  411. content: '已选有效数据' + num + '条,确认要批量上线吗?',
  412. centered: true,
  413. onOk () {
  414. _this.loadingLaunch = true
  415. _this.spinning = true
  416. productBatchOnline(obj).then(res => {
  417. _this.loadingLaunch = false
  418. if (res.status == 200) {
  419. _this.$refs.table.clearSelected() // 清空表格选中项
  420. _this.$message.success(res.message)
  421. _this.$refs.table.refresh()
  422. _this.spinning = false
  423. } else {
  424. _this.spinning = false
  425. }
  426. })
  427. }
  428. })
  429. },
  430. // 批量下线
  431. handleBatchDownline () {
  432. const _this = this
  433. if (!_this.rowSelectionInfo || (_this.rowSelectionInfo && _this.rowSelectionInfo.selectedRowKeys.length < 1)) {
  434. _this.$message.warning('请在列表勾选后再进行批量操作!')
  435. return
  436. }
  437. let num = 0
  438. _this.offlineProductList = []
  439. _this.rowSelectionInfo && _this.rowSelectionInfo.selectedRows.map(item => {
  440. if (item.state == 'ONLINE') {
  441. num++
  442. _this.offlineProductList.push({ productSn: item.productSn, code: item.code, commonProductList: [] })
  443. }
  444. })
  445. if (num < 1) {
  446. _this.$message.warning('当前数据不可操作!')
  447. return
  448. }
  449. this.openOfflineModal = true
  450. },
  451. // 重置
  452. resetSearchForm () {
  453. this.queryParam.name = ''
  454. this.queryParam.queryWord = ''
  455. this.queryParam.productBrandSn = undefined
  456. this.queryParam.productTypeSn1 = ''
  457. this.queryParam.productTypeSn2 = ''
  458. this.queryParam.productTypeSn3 = ''
  459. this.queryParam.state = undefined
  460. this.queryParam.pricingState = undefined
  461. this.queryParam.picFlag = undefined
  462. this.productType = []
  463. if (this.advanced) {
  464. this.$refs.rangeDate.resetDate()
  465. this.queryParam.updateBeginDate = ''
  466. this.queryParam.updateEndDate = ''
  467. }
  468. this.$refs.table.refresh(true)
  469. },
  470. // 新增/编辑
  471. handleEdit (row) {
  472. if (row) { // 编辑
  473. this.$router.push({ path: `/productManagement/productInfo/edit/${row.id}/${row.productSn}` })
  474. } else { // 新增
  475. this.$router.push({ path: '/productManagement/productInfo/add' })
  476. }
  477. },
  478. // 上线
  479. handleLaunch (row) {
  480. const _this = this
  481. this.$confirm({
  482. title: '提示',
  483. content: '确认要上线吗?',
  484. centered: true,
  485. onOk () {
  486. _this.spinning = true
  487. productOnline({ sn: row.productSn }).then(res => {
  488. if (res.status == 200) {
  489. _this.$message.success(res.message)
  490. _this.$refs.table.refresh()
  491. _this.spinning = false
  492. } else {
  493. _this.spinning = false
  494. }
  495. })
  496. }
  497. })
  498. },
  499. // 下线
  500. handleDownline (row) {
  501. this.offlineProductList.push({ productSn: row.productSn, code: row.code, commonProductList: [] })
  502. this.openOfflineModal = true
  503. },
  504. // 删除
  505. handleDel (row) {
  506. const _this = this
  507. this.$confirm({
  508. title: '提示',
  509. content: '确认要删除吗?',
  510. centered: true,
  511. onOk () {
  512. _this.spinning = true
  513. productDel({ sn: row.productSn }).then(res => {
  514. if (res.status == 200) {
  515. _this.$message.success(res.message)
  516. _this.$refs.table.refresh()
  517. _this.spinning = false
  518. } else {
  519. _this.spinning = false
  520. }
  521. })
  522. }
  523. })
  524. },
  525. // 详情
  526. handleDetail (row) {
  527. this.itemSn = row.productSn
  528. this.openModal = true
  529. },
  530. // 关闭弹框
  531. closeModal () {
  532. this.itemSn = ''
  533. this.openModal = false
  534. },
  535. // 关闭下线弹框
  536. closeOfflineModal () {
  537. this.$refs.table.clearSelected() // 清空表格选中项
  538. this.offlineProductList = []
  539. this.openOfflineModal = false
  540. },
  541. // 导出
  542. handleExport () {
  543. const _this = this
  544. const params = this.queryParam
  545. this.spinning = true
  546. exportExcel(productExport, params, '产品列表', function () {
  547. _this.spinning = false
  548. })
  549. },
  550. // 产品分类 change
  551. changeProductType (val, opt) {
  552. this.queryParam.productTypeSn1 = val[0] ? val[0] : ''
  553. this.queryParam.productTypeSn2 = val[1] ? val[1] : ''
  554. this.queryParam.productTypeSn3 = val[2] ? val[2] : ''
  555. },
  556. pageInit () {
  557. const _this = this
  558. this.$nextTick(() => { // 页面渲染完成后的回调
  559. _this.setTableH()
  560. })
  561. },
  562. setTableH () {
  563. const tableSearchH = this.$refs.tableSearch.offsetHeight
  564. this.tableHeight = window.innerHeight - tableSearchH - 235
  565. }
  566. },
  567. watch: {
  568. advanced (newValue, oldValue) {
  569. const _this = this
  570. this.$nextTick(() => { // 页面渲染完成后的回调
  571. _this.setTableH()
  572. })
  573. },
  574. '$store.state.app.winHeight' (newValue, oldValue) { // 窗口变更时,需同时更改表格高度
  575. this.setTableH()
  576. }
  577. },
  578. mounted () {
  579. if (!this.$store.state.app.isNewTab) { // 页签刷新时调用
  580. this.pageInit()
  581. this.resetSearchForm()
  582. }
  583. },
  584. activated () {
  585. const _this = this
  586. // 如果是新页签打开,则重置当前页面
  587. if (this.$store.state.app.isNewTab) {
  588. this.pageInit()
  589. this.resetSearchForm()
  590. }
  591. // 仅刷新列表,不重置页面
  592. if (this.$store.state.app.updateList) {
  593. this.pageInit()
  594. setTimeout(() => { // 解决 编辑页 返回列表 请求先前页的数据。新增页 返回列表 请求第一页的数据。延迟是为了解决先执行activated 后执行beforeRouteEnter的问题
  595. if (_this.pageFromInfo && _this.pageFromInfo.name == 'productInfoAdd') {
  596. _this.resetSearchForm()
  597. } else {
  598. _this.$refs.table.refresh()
  599. }
  600. }, 100)
  601. }
  602. },
  603. beforeRouteEnter (to, from, next) {
  604. next(vm => {
  605. vm.pageFromInfo = from
  606. })
  607. }
  608. }
  609. </script>