index-data.vue 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925
  1. <template>
  2. <div>
  3. <!-- 数据表格 -->
  4. <ele-pro-table
  5. ref="table"
  6. :columns="newColumns"
  7. :datasource="datasource"
  8. :need-page="true"
  9. :selection.sync="selection"
  10. :current.sync="rowCurrent"
  11. @sort-change="onSortChange"
  12. highlight-current-row
  13. height="calc(100vh - 412px)"
  14. full-height="calc(100vh - 116px)"
  15. tool-class="ele-toolbar-form"
  16. :page-size="pageSize"
  17. :initLoad="false"
  18. @columns-change="handleColumnChange"
  19. :cache-key="cacheKeyUrl"
  20. v-if="pageShow"
  21. >
  22. <!-- 表头工具栏 -->
  23. <template v-slot:toolbar>
  24. <el-button
  25. size="small"
  26. type="primary"
  27. icon="el-icon-plus"
  28. class="ele-btn-icon"
  29. @click="openEdit({}, 2)"
  30. v-if="$hasPermission('main:category:save')"
  31. >
  32. 新建
  33. </el-button>
  34. <div
  35. class="upload"
  36. v-if="rootTreeId == 6 && $hasPermission('main:category:update')"
  37. >
  38. <el-upload
  39. v-if="!isLoading"
  40. :show-file-list="false"
  41. class="upload-demo"
  42. action=""
  43. :before-upload="beforeUpload"
  44. :on-success="successUpload"
  45. :on-error="errorUpload"
  46. >
  47. <slot>
  48. <el-button
  49. type="primary"
  50. size="small"
  51. plain
  52. icon="el-icon-upload2"
  53. >导入</el-button
  54. >
  55. </slot>
  56. </el-upload>
  57. <el-button
  58. v-else
  59. type="primary"
  60. size="small"
  61. icon="el-icon-upload2"
  62. plain
  63. :loading="isLoading"
  64. >导入</el-button
  65. >
  66. </div>
  67. <el-button
  68. v-if="$hasPermission('main:category:update') && rootTreeId != 6"
  69. type="primary"
  70. size="small"
  71. icon="el-icon-upload2"
  72. plain
  73. @click="uploadFile"
  74. >导入</el-button
  75. >
  76. <el-button
  77. type="warning"
  78. icon="el-icon-download"
  79. size="mini"
  80. @click="handleExport()"
  81. :loading="exportLoading"
  82. >导出</el-button
  83. >
  84. <el-button
  85. size="small"
  86. :disabled="selection.length == 0"
  87. icon="el-icon-thumb"
  88. class="ele-btn-icon"
  89. @click="moveTo()"
  90. v-if="$hasPermission('main:category:update')"
  91. >
  92. 设置采购员
  93. </el-button>
  94. <!-- <el-button
  95. v-if="rootTreeId == 9"
  96. size="small"
  97. type="primary"
  98. @click="handleLink('4')"
  99. >关联设备</el-button
  100. >
  101. <el-button
  102. v-if="rootTreeId == 9"
  103. size="small"
  104. type="primary"
  105. @click="handleLink('5')"
  106. >关联模具</el-button
  107. >
  108. <el-button
  109. v-if="rootTreeId == 9"
  110. size="small"
  111. type="primary"
  112. @click="handleLink('8')"
  113. >关联舟皿</el-button
  114. >
  115. <el-button
  116. v-if="rootTreeId == 4"
  117. size="small"
  118. type="primary"
  119. @click="handleLink('5')"
  120. >关联模具</el-button
  121. >
  122. <el-button
  123. v-if="rootTreeId == 4"
  124. size="small"
  125. type="primary"
  126. @click="handleLink('6')"
  127. >关联备品备件</el-button
  128. >-->
  129. </template>
  130. <template v-slot:componentAttribute="{ row }">
  131. <div>
  132. <!-- {{ }} -->
  133. {{ getDictValueFn(row.componentAttribute) }}
  134. </div>
  135. </template>
  136. <template v-slot:action="{ row }">
  137. <el-link
  138. type="primary"
  139. :underline="false"
  140. @click="openEdit(row, 1)"
  141. v-if="$hasPermission('main:category:save')"
  142. >
  143. 复制
  144. </el-link>
  145. <el-link
  146. type="primary"
  147. :underline="false"
  148. @click="openEdit(row, 0)"
  149. v-if="$hasPermission('main:category:update')"
  150. >
  151. 修改
  152. </el-link>
  153. <el-popconfirm
  154. class="ele-action"
  155. title="确定要删除此物料吗?"
  156. @confirm="remove(row)"
  157. v-if="$hasPermission('main:category:delete')"
  158. >
  159. <template v-slot:reference>
  160. <el-link type="danger" :underline="false"> 删除 </el-link>
  161. </template>
  162. </el-popconfirm>
  163. <!-- <el-link
  164. type="primary"
  165. v-if="row.isProduct == 1"
  166. :underline="false"
  167. @click="openParam(row)"
  168. >
  169. 工艺参数
  170. </el-link> -->
  171. <el-link type="primary" :underline="false" @click="toBomManager(row)">
  172. BOM
  173. </el-link>
  174. <!-- <el-link
  175. type="primary"
  176. v-if="row.isProduct == 1"
  177. :underline="false"
  178. @click="openMaterial(row)"
  179. >
  180. 物料BOM
  181. </el-link> -->
  182. <!-- <el-link
  183. type="primary"
  184. v-if="row.isProduct == 1"
  185. :underline="false"
  186. @click="openMould(row)"
  187. >
  188. 模具
  189. </el-link> -->
  190. <el-link
  191. type="primary"
  192. v-if="row.categoryLevelPathIdParent == 7"
  193. :underline="false"
  194. @click="handAllocation(row)"
  195. >
  196. 货位
  197. </el-link>
  198. <el-link
  199. type="primary"
  200. v-if="row.categoryLevelPathIdParent == 11"
  201. :underline="false"
  202. @click="handleAridRegion(row)"
  203. >
  204. 干燥区
  205. </el-link>
  206. </template>
  207. </ele-pro-table>
  208. <!-- 编辑弹窗 -->
  209. <!-- <dict-edit :visible.sync="showEdit" :id="id" @done="reload" /> -->
  210. <!-- 选择物料 -->
  211. <MaterialModal
  212. :visible.sync="materialEdit"
  213. :data="current"
  214. ref="materialRefs"
  215. ></MaterialModal>
  216. <!-- 工艺参数 -->
  217. <ParamEdit
  218. :visible.sync="paramEditShow"
  219. :paramData="current"
  220. ref="paramRefs"
  221. ></ParamEdit>
  222. <!-- 模具 -->
  223. <mouldDialog
  224. :visible.sync="mouldShow"
  225. :data="current"
  226. ref="mouldRefs"
  227. ></mouldDialog>
  228. <linkMaterialDialog ref="linkMaterialDialogRef" @success="success" />
  229. <!-- 货位 -->
  230. <goodsAllocation ref="allocationRef"></goodsAllocation>
  231. <!-- 干燥区 -->
  232. <aridRegion ref="aridRegionRef"></aridRegion>
  233. <!-- 导入错误弹框 -->
  234. <el-dialog
  235. title="导入失败"
  236. :visible.sync="exportErrorDioalogVisible"
  237. width="60%"
  238. >
  239. <el-table :data="errorData" style="width: 100%">
  240. <el-table-column label="名称" prop="name"> </el-table-column>
  241. <el-table-column label="型号" prop="modeType"> </el-table-column>
  242. <el-table-column label="编号" prop="codeNo"> </el-table-column>
  243. <el-table-column label="物料组" prop="code"> </el-table-column>
  244. <el-table-column label="失败原因" prop="remark"> </el-table-column>
  245. </el-table>
  246. <span slot="footer" class="dialog-footer">
  247. <el-button @click="exportErrorDioalogVisible = false">取 消</el-button>
  248. <el-button type="primary" @click="exportErrorDioalogVisible = false"
  249. >确 定</el-button
  250. >
  251. </span>
  252. </el-dialog>
  253. <importDialog
  254. :defModule="moudleName"
  255. ref="importDialogRef"
  256. :fileUrl="'/main/category/downLoadTemplate'"
  257. fileName="产品_物品导入模板"
  258. @success="reload"
  259. />
  260. <!-- 产品管理 -->
  261. <BomDetailsPop ref="bomDrawer"></BomDetailsPop>
  262. <DialogMoveTo ref="DialogMoveToRef" @success="success"></DialogMoveTo>
  263. </div>
  264. </template>
  265. <script>
  266. import {
  267. getMaterialList,
  268. removeMaterial,
  269. importCategorySparePart,
  270. exportFile
  271. } from '@/api/material/list.js';
  272. import { getBomGetById } from '@/api/material/BOM.js';
  273. import MaterialModal from './MaterialModal.vue';
  274. import ParamEdit from '@/views/technology/productParam/components/user-edit.vue';
  275. import mouldDialog from './mouldDialog';
  276. import linkMaterialDialog from './link-material-dialog.vue';
  277. import goodsAllocation from './goodsAllocation.vue';
  278. import BomDetailsPop from '../../BOMmanage/detailsPop.vue';
  279. import dictMixins from '@/mixins/dictMixins';
  280. import aridRegion from './aridRegion';
  281. import importDialog from '@/components/upload/import-dialogNew.vue';
  282. import { fieldModel } from '@/api/codeManagement';
  283. import DialogMoveTo from './DialogMoveTo.vue';
  284. import tabMixins from '@/mixins/tableColumnsMixin';
  285. import { produceTypeList } from '@/enum/dict.js';
  286. import request from '@/utils/request';
  287. import { download } from '@/utils/file';
  288. const attributeList = [
  289. {
  290. label: '总装',
  291. value: 1
  292. },
  293. {
  294. label: '部件',
  295. value: 2
  296. },
  297. {
  298. label: '零件',
  299. value: 3
  300. },
  301. {
  302. label: '原材料',
  303. value: 4
  304. }
  305. ];
  306. const measureTypeList = [
  307. {
  308. label: '数量',
  309. value: 1
  310. },
  311. {
  312. label: '重量',
  313. value: 2
  314. },
  315. {
  316. label: '体积',
  317. value: 3
  318. },
  319. {
  320. label: '容积',
  321. value: 4
  322. },
  323. {
  324. label: '面积',
  325. value: 5
  326. }
  327. ];
  328. export default {
  329. mixins: [dictMixins, tabMixins],
  330. components: {
  331. importDialog,
  332. MaterialModal,
  333. ParamEdit,
  334. mouldDialog,
  335. linkMaterialDialog,
  336. goodsAllocation,
  337. aridRegion,
  338. BomDetailsPop,
  339. DialogMoveTo
  340. },
  341. props: {
  342. // 物料组id
  343. currentId: [Number, String],
  344. data: [Array, Object],
  345. rootId: [Number, String],
  346. rootTreeId: [Number, String],
  347. lyType: [String],
  348. oneProduct: Boolean,
  349. currentData: Object,
  350. //table-cacheKeyUrl
  351. cacheKeyUrl: String
  352. },
  353. data() {
  354. return {
  355. exportLoading: false,
  356. moudleName: 'mainCategory',
  357. errorData: [],
  358. exportErrorDioalogVisible: false,
  359. pagination: {
  360. total: 0
  361. },
  362. bomShow: false,
  363. whereData: {},
  364. pageShow: false,
  365. // 表格列配置
  366. columns: [
  367. {
  368. width: 45,
  369. type: 'selection',
  370. columnKey: 'selection',
  371. align: 'center'
  372. },
  373. {
  374. columnKey: 'index',
  375. type: 'index',
  376. width: 50,
  377. align: 'center',
  378. showOverflowTooltip: true,
  379. label: '序号'
  380. },
  381. {
  382. prop: 'code',
  383. label: '编码',
  384. align: 'center',
  385. showOverflowTooltip: true,
  386. sortable: true,
  387. minWidth: 110
  388. },
  389. {
  390. prop: 'name',
  391. label: '名称',
  392. align: 'center',
  393. showOverflowTooltip: true,
  394. minWidth: 110
  395. },
  396. {
  397. prop: 'categoryLevelPath',
  398. label: '分类',
  399. align: 'center',
  400. showOverflowTooltip: true
  401. },
  402. {
  403. prop: 'brandNum',
  404. align: 'center',
  405. label: '牌号',
  406. showOverflowTooltip: true
  407. },
  408. {
  409. prop: 'modelType',
  410. label: '型号',
  411. align: 'center',
  412. showOverflowTooltip: true
  413. },
  414. {
  415. prop: 'specification',
  416. label: '规格',
  417. align: 'center',
  418. showOverflowTooltip: true
  419. },
  420. {
  421. prop: 'level',
  422. label: '级别',
  423. align: 'center',
  424. showOverflowTooltip: true
  425. },
  426. {
  427. prop: 'isUnpack',
  428. label: '是否允许拆包',
  429. align: 'center',
  430. minWidth: 120,
  431. formatter: (row, column) => {
  432. return row.isUnpack == 1 ? '是' : '否';
  433. },
  434. showOverflowTooltip: true
  435. },
  436. {
  437. prop: 'isComeCheck',
  438. label: '是否来料检验',
  439. align: 'center',
  440. minWidth: 120,
  441. formatter: (row, column) => {
  442. return row.isComeCheck == 1 ? '是' : '否';
  443. },
  444. showOverflowTooltip: true
  445. },
  446. {
  447. prop: 'measuringUnit',
  448. label: '计量单位',
  449. showOverflowTooltip: true,
  450. minWidth: 90
  451. },
  452. {
  453. prop: 'weightUnit',
  454. label: '重量单位',
  455. showOverflowTooltip: true,
  456. minWidth: 90
  457. },
  458. {
  459. prop: 'roughWeight',
  460. label: '毛重',
  461. showOverflowTooltip: true,
  462. minWidth: 90
  463. },
  464. {
  465. prop: 'netWeight',
  466. label: '净重',
  467. showOverflowTooltip: true,
  468. minWidth: 90
  469. },
  470. {
  471. prop: 'packingUnit',
  472. align: 'center',
  473. label: '包装单位',
  474. showOverflowTooltip: true
  475. },
  476. {
  477. prop: 'componentAttribute',
  478. slot: 'componentAttribute',
  479. align: 'center',
  480. label: '属性类型',
  481. showOverflowTooltip: true
  482. // formatter: (row, column) => {
  483. // return row?.produceType
  484. // ?.map((item) => {
  485. // {{row}}
  486. // return this.getDictValueFn(item);
  487. // })
  488. // ?.toString();
  489. // }
  490. },
  491. {
  492. prop: 'attributeType',
  493. align: 'center',
  494. label: '存货类型',
  495. showOverflowTooltip: true,
  496. formatter: (row, column) => {
  497. return attributeList.find(
  498. (item) => item.value == row.attributeType
  499. )?.label;
  500. }
  501. },
  502. {
  503. prop: 'produceType',
  504. align: 'center',
  505. label: '生产类型',
  506. showOverflowTooltip: true,
  507. formatter: (row, column) => {
  508. return produceTypeList.find(
  509. (item) => item.value == row.produceType
  510. )?.label;
  511. }
  512. },
  513. {
  514. prop: 'measureType',
  515. align: 'center',
  516. label: '计量类型',
  517. showOverflowTooltip: true,
  518. formatter: (row, column) => {
  519. return measureTypeList.find(
  520. (item) => item.value == row.measureType
  521. )?.label;
  522. }
  523. },
  524. {
  525. prop: 'isEnabled',
  526. align: 'center',
  527. label: '状态',
  528. showOverflowTooltip: true,
  529. formatter: (row, column) => {
  530. return row.isEnabled === 0
  531. ? '停用'
  532. : row.isEnabled === 1
  533. ? '启用'
  534. : '';
  535. }
  536. }
  537. ],
  538. sxtList: [
  539. {
  540. label: '自制件',
  541. value: 1
  542. },
  543. {
  544. label: '采购件',
  545. value: 2
  546. },
  547. {
  548. label: '外协件',
  549. value: 3
  550. },
  551. {
  552. label: '受托件',
  553. value: 4
  554. }
  555. ],
  556. newColumns: [],
  557. // 表格选中数据
  558. selection: [],
  559. // 是否显示编辑弹窗
  560. showEdit: false,
  561. id: null,
  562. materialEdit: false,
  563. paramEditShow: false,
  564. mouldShow: false,
  565. current: null,
  566. rowCurrent: null,
  567. isLoading: false,
  568. pageSize: this.$store.state.tablePageSize
  569. };
  570. },
  571. created() {
  572. this.requestDict('生产类型');
  573. this.getFieldModel();
  574. },
  575. methods: {
  576. onSortChange(e) {
  577. console.log(e, '99999999');
  578. let sort = {
  579. orderBy: e.order,
  580. sortName: e.prop
  581. };
  582. this.sort = sort;
  583. this.reload();
  584. },
  585. getDictValueFn(e) {
  586. // console.log(e,'3333333333333');
  587. if (e.length) {
  588. let arr = [];
  589. e.map((v) => {
  590. arr.push(this.findFn(v)?.label);
  591. });
  592. return arr.join(',');
  593. } else {
  594. return '';
  595. }
  596. // let a =
  597. // return a?.label||''
  598. },
  599. findFn(e) {
  600. return this.sxtList.find((item) => item.value == Number(e));
  601. },
  602. toBomManager(row) {
  603. let rowData = {
  604. categoryId: row.id,
  605. categoryName: row.name,
  606. code: row.code,
  607. rootPathIdParent: row.categoryLevelPathIdParent,
  608. isProduct: row.isProduct == 1
  609. };
  610. this.$refs.bomDrawer.open(rowData);
  611. },
  612. //采购
  613. moveTo() {
  614. this.$refs.DialogMoveToRef.open(this.selection);
  615. },
  616. successUpload(response) {
  617. this.isLoading = false;
  618. },
  619. errorUpload(response) {
  620. this.isLoading = false;
  621. },
  622. // 上传备品备件
  623. beforeUpload(file) {
  624. if (file.size / 1024 / 1024 > this.size) {
  625. this.$message.error(`大小不能超过 ${this.size}MB`);
  626. return false;
  627. }
  628. if (this.limit > 0 && this.fileList.length === this.limit) {
  629. this.$message.error(`最多上传 ${this.limit}个文件`);
  630. return false;
  631. }
  632. let formData = new FormData();
  633. formData.append('file', file);
  634. this.isLoading = true;
  635. return importCategorySparePart(formData).then((res) => {
  636. if (res.data.length > 0) {
  637. this.exportErrorDioalogVisible = true;
  638. this.errorData = res.data;
  639. } else {
  640. this.$message.success('导入成功!');
  641. }
  642. this.isLoading = false;
  643. return false;
  644. });
  645. },
  646. /* 表格数据源 */
  647. async datasource({ page, limit, where, order }) {
  648. let labs = getMaterialList({
  649. pageNum: page,
  650. size: limit,
  651. ...this.sort,
  652. ...where,
  653. categoryLevelId: this.currentId
  654. });
  655. this.whereData = {
  656. pageNum: page,
  657. size: limit,
  658. ...this.sort,
  659. ...where,
  660. categoryLevelId: this.currentId
  661. };
  662. let a = await labs;
  663. return labs;
  664. },
  665. /* 刷新表格 */
  666. reload(where) {
  667. let labs = {
  668. page: 1,
  669. where: where,
  670. categoryLevelId: this.currentId
  671. };
  672. this.whereData = labs;
  673. this.$refs.table.reload({
  674. page: 1,
  675. where: where,
  676. categoryLevelId: this.currentId
  677. });
  678. },
  679. getFieldModel() {
  680. fieldModel({ relevance: 't_main_category' }).then((res) => {
  681. const privateColumn = [
  682. {
  683. columnKey: 'action',
  684. label: '操作',
  685. width: 220,
  686. align: 'center',
  687. resizable: false,
  688. slot: 'action',
  689. fixed: 'right'
  690. }
  691. ];
  692. let newRes = res.map((m) => {
  693. return {
  694. prop: 'extField.' + m.prop,
  695. label: m.label,
  696. align: 'center',
  697. showOverflowTooltip: true
  698. };
  699. });
  700. this.newColumns = [...this.columns, ...newRes, ...privateColumn];
  701. this.getTabColumns();
  702. this.$forceUpdate();
  703. });
  704. },
  705. /* 显示编辑 */
  706. openEdit(row, status) {
  707. console.log(status, this.currentData, 'status');
  708. let isUpdate;
  709. if (status == 2) {
  710. isUpdate = 0;
  711. } else {
  712. isUpdate = 1;
  713. }
  714. this.$router.push({
  715. path: '/material/product/detail',
  716. query: {
  717. lyType: this.lyType,
  718. id: row.id ? row.id : null,
  719. status: status,
  720. rootId: this.rootId,
  721. isUpdate: isUpdate,
  722. oneProduct: this.oneProduct,
  723. t: new Date().getTime(),
  724. rootTreeId: this.rootTreeId,
  725. ...this.currentData
  726. }
  727. });
  728. },
  729. /* 删除 */
  730. remove(row) {
  731. const loading = this.$loading({ lock: true });
  732. removeMaterial(row.id)
  733. .then((msg) => {
  734. this.$refs.table.reload({
  735. page: 1,
  736. categoryLevelId: this.currentId
  737. });
  738. loading.close();
  739. })
  740. .catch((e) => {
  741. loading.close();
  742. });
  743. },
  744. openMaterial(row) {
  745. this.current = row;
  746. this.materialEdit = true;
  747. this.$refs.materialRefs.$refs.form &&
  748. this.$refs.materialRefs.$refs.form.clearValidate();
  749. },
  750. openParam(row) {
  751. this.paramEditShow = true;
  752. this.current = row;
  753. this.$refs.paramRefs.$refs.form &&
  754. this.$refs.paramRefs.$refs.form.clearValidate();
  755. },
  756. openMould(row) {
  757. this.current = row;
  758. this.mouldShow = true;
  759. this.$refs.mouldRefs.$refs.form &&
  760. this.$refs.mouldRefs.$refs.form.clearValidate();
  761. },
  762. handleLink(type) {
  763. if (!this.rowCurrent) {
  764. return this.$message.error(
  765. this.rootTreeId == 9
  766. ? '请选择产品!'
  767. : this.rootTreeId == 4
  768. ? '请选择设备!'
  769. : ''
  770. );
  771. }
  772. this.$refs.linkMaterialDialogRef.open(type, this.rowCurrent);
  773. },
  774. success() {
  775. this.reload();
  776. },
  777. handAllocation(row) {
  778. this.$refs.allocationRef.open(row);
  779. },
  780. handleAridRegion(row) {
  781. this.$refs.aridRegionRef.open(row);
  782. },
  783. uploadFile() {
  784. this.$refs.importDialogRef.open();
  785. },
  786. /** 导出按钮操作 */
  787. handleExport() {
  788. debugger;
  789. const data = this.whereData;
  790. if (!data || data === {} || !data.categoryLevelId) {
  791. this.$message.warning('请选择物品类别');
  792. return;
  793. }
  794. this.exportLoading = true;
  795. request
  796. .post('/main/category/export', data, {
  797. responseType: 'blob'
  798. })
  799. .then((res) => {
  800. debugger;
  801. download(res.data, '产品/物品数据.xlsx');
  802. })
  803. .catch((e) => {
  804. console.error(e);
  805. })
  806. .finally(() => {
  807. this.exportLoading = false;
  808. });
  809. /*exportFile(this.whereData);
  810. console.log(this.whereData, 'whereForm');*/
  811. },
  812. /** 下载模板操作 */
  813. importTemplate() {
  814. importTemplate(this.whereForm).then((res) => {
  815. this.$message.success('模板下载成功');
  816. });
  817. }
  818. },
  819. watch: {
  820. // 监听物料组id变化
  821. currentId() {
  822. this.reload();
  823. },
  824. $route: {
  825. handler(route) {
  826. this.pageShow = false;
  827. if (route.query && route.query.isWt) {
  828. getBomGetById(route.query.businessId).then((res) => {
  829. let rowData = {
  830. categoryId: res.data.categoryId,
  831. categoryName: res.data.name,
  832. code: res.data.categoryCode,
  833. rootPathIdParent: res.data.rootCategoryLevelId,
  834. isProduct: res.data.rootCategoryLevelId == 9 ? true : false,
  835. versions: res.data.versions,
  836. bomType: res.data.bomType,
  837. isWt: true,
  838. isBtn: route.query.isBtn
  839. };
  840. this.$nextTick(() => {
  841. this.$refs.bomDrawer.open(rowData);
  842. this.pageShow = true;
  843. });
  844. });
  845. } else {
  846. this.pageShow = true;
  847. }
  848. },
  849. immediate: true
  850. }
  851. }
  852. };
  853. </script>
  854. <style lang="scss" scoped>
  855. .upload {
  856. display: inline-block;
  857. width: 100px;
  858. margin-left: 10px;
  859. }
  860. </style>