index-data.vue 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942
  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. import { getByCode } from '@/api/system/dictionary-data';
  289. /*const attributeList = [
  290. {
  291. label: '总装',
  292. value: 1
  293. },
  294. {
  295. label: '部件',
  296. value: 2
  297. },
  298. {
  299. label: '零件',
  300. value: 3
  301. },
  302. {
  303. label: '原材料',
  304. value: 4
  305. }
  306. ];*/
  307. const measureTypeList = [
  308. {
  309. label: '数量',
  310. value: 1
  311. },
  312. {
  313. label: '重量',
  314. value: 2
  315. },
  316. {
  317. label: '体积',
  318. value: 3
  319. },
  320. {
  321. label: '容积',
  322. value: 4
  323. },
  324. {
  325. label: '面积',
  326. value: 5
  327. }
  328. ];
  329. export default {
  330. mixins: [dictMixins, tabMixins],
  331. components: {
  332. importDialog,
  333. MaterialModal,
  334. ParamEdit,
  335. mouldDialog,
  336. linkMaterialDialog,
  337. goodsAllocation,
  338. aridRegion,
  339. BomDetailsPop,
  340. DialogMoveTo
  341. },
  342. props: {
  343. // 物料组id
  344. currentId: [Number, String],
  345. data: [Array, Object],
  346. rootId: [Number, String],
  347. rootTreeId: [Number, String],
  348. lyType: [String],
  349. oneProduct: Boolean,
  350. currentData: Object,
  351. //table-cacheKeyUrl
  352. cacheKeyUrl: String
  353. },
  354. data() {
  355. return {
  356. attributeList: [],
  357. exportLoading: false,
  358. moudleName: 'mainCategory',
  359. errorData: [],
  360. exportErrorDioalogVisible: false,
  361. pagination: {
  362. total: 0
  363. },
  364. bomShow: false,
  365. whereData: {},
  366. pageShow: false,
  367. // 表格列配置
  368. columns: [
  369. {
  370. width: 45,
  371. type: 'selection',
  372. columnKey: 'selection',
  373. align: 'center'
  374. },
  375. {
  376. columnKey: 'index',
  377. type: 'index',
  378. width: 50,
  379. align: 'center',
  380. showOverflowTooltip: true,
  381. label: '序号'
  382. },
  383. {
  384. prop: 'code',
  385. label: '编码',
  386. align: 'center',
  387. showOverflowTooltip: true,
  388. sortable: true,
  389. minWidth: 110
  390. },
  391. {
  392. prop: 'name',
  393. label: '名称',
  394. align: 'center',
  395. showOverflowTooltip: true,
  396. minWidth: 110
  397. },
  398. {
  399. prop: 'categoryLevelPath',
  400. label: '分类',
  401. align: 'center',
  402. showOverflowTooltip: true
  403. },
  404. {
  405. prop: 'brandNum',
  406. align: 'center',
  407. label: '牌号',
  408. showOverflowTooltip: true
  409. },
  410. {
  411. prop: 'modelType',
  412. label: '型号',
  413. align: 'center',
  414. showOverflowTooltip: true
  415. },
  416. {
  417. prop: 'specification',
  418. label: '规格',
  419. align: 'center',
  420. showOverflowTooltip: true
  421. },
  422. {
  423. prop: 'level',
  424. label: '级别',
  425. align: 'center',
  426. showOverflowTooltip: true
  427. },
  428. {
  429. prop: 'isUnpack',
  430. label: '是否允许拆包',
  431. align: 'center',
  432. minWidth: 120,
  433. formatter: (row, column) => {
  434. return row.isUnpack == 1 ? '是' : '否';
  435. },
  436. showOverflowTooltip: true
  437. },
  438. {
  439. prop: 'isComeCheck',
  440. label: '是否采购来料检验',
  441. align: 'center',
  442. minWidth: 120,
  443. formatter: (row, column) => {
  444. return row.isComeCheck == 1 ? '是' : '否';
  445. },
  446. showOverflowTooltip: true
  447. },
  448. {
  449. prop: 'isOutsourcingCheck',
  450. label: '是否委外来料检验',
  451. align: 'center',
  452. minWidth: 120,
  453. formatter: (row, column) => {
  454. return row.isOutsourcingCheck == 1 ? '是' : '否';
  455. },
  456. showOverflowTooltip: true
  457. },
  458. {
  459. prop: 'measuringUnit',
  460. label: '计量单位',
  461. showOverflowTooltip: true,
  462. minWidth: 90
  463. },
  464. {
  465. prop: 'weightUnit',
  466. label: '重量单位',
  467. showOverflowTooltip: true,
  468. minWidth: 90
  469. },
  470. {
  471. prop: 'roughWeight',
  472. label: '毛重',
  473. showOverflowTooltip: true,
  474. minWidth: 90
  475. },
  476. {
  477. prop: 'netWeight',
  478. label: '净重',
  479. showOverflowTooltip: true,
  480. minWidth: 90
  481. },
  482. {
  483. prop: 'packingUnit',
  484. align: 'center',
  485. label: '包装单位',
  486. showOverflowTooltip: true
  487. },
  488. {
  489. prop: 'componentAttribute',
  490. slot: 'componentAttribute',
  491. align: 'center',
  492. label: '属性类型',
  493. showOverflowTooltip: true
  494. // formatter: (row, column) => {
  495. // return row?.produceType
  496. // ?.map((item) => {
  497. // {{row}}
  498. // return this.getDictValueFn(item);
  499. // })
  500. // ?.toString();
  501. // }
  502. },
  503. {
  504. prop: 'attributeType',
  505. align: 'center',
  506. label: '存货类型',
  507. showOverflowTooltip: true,
  508. formatter: (row, column) => {
  509. const item = this.attributeList.find(
  510. (item) => item[row.attributeType] !== undefined
  511. );
  512. return item ? item[row.attributeType] : null; // 如果找不到返回 null
  513. }
  514. },
  515. {
  516. prop: 'produceType',
  517. align: 'center',
  518. label: '生产类型',
  519. showOverflowTooltip: true,
  520. formatter: (row, column) => {
  521. return produceTypeList.find(
  522. (item) => item.value == row.produceType
  523. )?.label;
  524. }
  525. },
  526. {
  527. prop: 'measureType',
  528. align: 'center',
  529. label: '计量类型',
  530. showOverflowTooltip: true,
  531. formatter: (row, column) => {
  532. return measureTypeList.find(
  533. (item) => item.value == row.measureType
  534. )?.label;
  535. }
  536. },
  537. {
  538. prop: 'isEnabled',
  539. align: 'center',
  540. label: '状态',
  541. showOverflowTooltip: true,
  542. formatter: (row, column) => {
  543. return row.isEnabled === 0
  544. ? '停用'
  545. : row.isEnabled === 1
  546. ? '启用'
  547. : '';
  548. }
  549. }
  550. ],
  551. sxtList: [
  552. {
  553. label: '自制件',
  554. value: 1
  555. },
  556. {
  557. label: '采购件',
  558. value: 2
  559. },
  560. {
  561. label: '外协件',
  562. value: 3
  563. },
  564. {
  565. label: '受托件',
  566. value: 4
  567. }
  568. ],
  569. newColumns: [],
  570. // 表格选中数据
  571. selection: [],
  572. // 是否显示编辑弹窗
  573. showEdit: false,
  574. id: null,
  575. materialEdit: false,
  576. paramEditShow: false,
  577. mouldShow: false,
  578. current: null,
  579. rowCurrent: null,
  580. isLoading: false,
  581. pageSize: this.$store.state.tablePageSize
  582. };
  583. },
  584. created: function () {
  585. getByCode('inventory_type').then((res) => {
  586. if (res.code === '0') {
  587. this.attributeList = res.data;
  588. }
  589. });
  590. this.requestDict('生产类型');
  591. this.getFieldModel();
  592. },
  593. methods: {
  594. onSortChange(e) {
  595. console.log(e, '99999999');
  596. let sort = {
  597. orderBy: e.order,
  598. sortName: e.prop
  599. };
  600. this.sort = sort;
  601. this.reload();
  602. },
  603. getDictValueFn(e) {
  604. // console.log(e,'3333333333333');
  605. if (e.length) {
  606. let arr = [];
  607. e.map((v) => {
  608. arr.push(this.findFn(v)?.label);
  609. });
  610. return arr.join(',');
  611. } else {
  612. return '';
  613. }
  614. // let a =
  615. // return a?.label||''
  616. },
  617. findFn(e) {
  618. return this.sxtList.find((item) => item.value == Number(e));
  619. },
  620. toBomManager(row) {
  621. let rowData = {
  622. categoryId: row.id,
  623. categoryName: row.name,
  624. code: row.code,
  625. rootPathIdParent: row.categoryLevelPathIdParent,
  626. isProduct: row.isProduct == 1
  627. };
  628. this.$refs.bomDrawer.open(rowData);
  629. },
  630. //采购
  631. moveTo() {
  632. this.$refs.DialogMoveToRef.open(this.selection);
  633. },
  634. successUpload(response) {
  635. this.isLoading = false;
  636. },
  637. errorUpload(response) {
  638. this.isLoading = false;
  639. },
  640. // 上传备品备件
  641. beforeUpload(file) {
  642. if (file.size / 1024 / 1024 > this.size) {
  643. this.$message.error(`大小不能超过 ${this.size}MB`);
  644. return false;
  645. }
  646. if (this.limit > 0 && this.fileList.length === this.limit) {
  647. this.$message.error(`最多上传 ${this.limit}个文件`);
  648. return false;
  649. }
  650. let formData = new FormData();
  651. formData.append('file', file);
  652. this.isLoading = true;
  653. return importCategorySparePart(formData).then((res) => {
  654. if (res.data.length > 0) {
  655. this.exportErrorDioalogVisible = true;
  656. this.errorData = res.data;
  657. } else {
  658. this.$message.success('导入成功!');
  659. }
  660. this.isLoading = false;
  661. return false;
  662. });
  663. },
  664. /* 表格数据源 */
  665. async datasource({ page, limit, where, order }) {
  666. let labs = getMaterialList({
  667. pageNum: page,
  668. size: limit,
  669. ...this.sort,
  670. ...where,
  671. categoryLevelId: this.currentId
  672. });
  673. this.whereData = {
  674. pageNum: page,
  675. size: limit,
  676. ...this.sort,
  677. ...where,
  678. categoryLevelId: this.currentId
  679. };
  680. let a = await labs;
  681. return labs;
  682. },
  683. /* 刷新表格 */
  684. reload(where) {
  685. let labs = {
  686. page: 1,
  687. where: where,
  688. categoryLevelId: this.currentId
  689. };
  690. this.whereData = labs;
  691. this.$refs.table.reload({
  692. page: 1,
  693. where: where,
  694. categoryLevelId: this.currentId
  695. });
  696. },
  697. getFieldModel() {
  698. fieldModel({ relevance: 't_main_category' }).then((res) => {
  699. const privateColumn = [
  700. {
  701. columnKey: 'action',
  702. label: '操作',
  703. width: 220,
  704. align: 'center',
  705. resizable: false,
  706. slot: 'action',
  707. fixed: 'right'
  708. }
  709. ];
  710. let newRes = res.map((m) => {
  711. return {
  712. prop: 'extField.' + m.prop,
  713. label: m.label,
  714. align: 'center',
  715. showOverflowTooltip: true
  716. };
  717. });
  718. this.newColumns = [...this.columns, ...newRes, ...privateColumn];
  719. this.getTabColumns();
  720. this.$forceUpdate();
  721. });
  722. },
  723. /* 显示编辑 */
  724. openEdit(row, status) {
  725. console.log(status, this.currentData, 'status');
  726. let isUpdate;
  727. if (status == 2) {
  728. isUpdate = 0;
  729. } else {
  730. isUpdate = 1;
  731. }
  732. this.$router.push({
  733. path: '/material/product/detail',
  734. query: {
  735. lyType: this.lyType,
  736. id: row.id ? row.id : null,
  737. status: status,
  738. rootId: this.rootId,
  739. isUpdate: isUpdate,
  740. oneProduct: this.oneProduct,
  741. t: new Date().getTime(),
  742. rootTreeId: this.rootTreeId,
  743. ...this.currentData
  744. }
  745. });
  746. },
  747. /* 删除 */
  748. remove(row) {
  749. const loading = this.$loading({ lock: true });
  750. removeMaterial(row.id)
  751. .then((msg) => {
  752. this.$refs.table.reload({
  753. page: 1,
  754. categoryLevelId: this.currentId
  755. });
  756. loading.close();
  757. })
  758. .catch((e) => {
  759. loading.close();
  760. });
  761. },
  762. openMaterial(row) {
  763. this.current = row;
  764. this.materialEdit = true;
  765. this.$refs.materialRefs.$refs.form &&
  766. this.$refs.materialRefs.$refs.form.clearValidate();
  767. },
  768. openParam(row) {
  769. this.paramEditShow = true;
  770. this.current = row;
  771. this.$refs.paramRefs.$refs.form &&
  772. this.$refs.paramRefs.$refs.form.clearValidate();
  773. },
  774. openMould(row) {
  775. this.current = row;
  776. this.mouldShow = true;
  777. this.$refs.mouldRefs.$refs.form &&
  778. this.$refs.mouldRefs.$refs.form.clearValidate();
  779. },
  780. handleLink(type) {
  781. if (!this.rowCurrent) {
  782. return this.$message.error(
  783. this.rootTreeId == 9
  784. ? '请选择产品!'
  785. : this.rootTreeId == 4
  786. ? '请选择设备!'
  787. : ''
  788. );
  789. }
  790. this.$refs.linkMaterialDialogRef.open(type, this.rowCurrent);
  791. },
  792. success() {
  793. this.reload();
  794. },
  795. handAllocation(row) {
  796. this.$refs.allocationRef.open(row);
  797. },
  798. handleAridRegion(row) {
  799. this.$refs.aridRegionRef.open(row);
  800. },
  801. uploadFile() {
  802. this.$refs.importDialogRef.open();
  803. },
  804. /** 导出按钮操作 */
  805. handleExport() {
  806. const data = this.whereData;
  807. if (!data || data === {} || !data.categoryLevelId) {
  808. this.$message.warning('请选择物品类别');
  809. return;
  810. }
  811. this.exportLoading = true;
  812. request
  813. .post('/main/category/export', data, {
  814. responseType: 'blob'
  815. })
  816. .then((res) => {
  817. debugger;
  818. download(res.data, '产品/物品数据.xlsx');
  819. })
  820. .catch((e) => {
  821. console.error(e);
  822. })
  823. .finally(() => {
  824. this.exportLoading = false;
  825. });
  826. /*exportFile(this.whereData);
  827. console.log(this.whereData, 'whereForm');*/
  828. },
  829. /** 下载模板操作 */
  830. importTemplate() {
  831. importTemplate(this.whereForm).then((res) => {
  832. this.$message.success('模板下载成功');
  833. });
  834. }
  835. },
  836. watch: {
  837. // 监听物料组id变化
  838. currentId() {
  839. this.reload();
  840. },
  841. $route: {
  842. handler(route) {
  843. this.pageShow = false;
  844. if (route.query && route.query.isWt) {
  845. getBomGetById(route.query.businessId).then((res) => {
  846. let rowData = {
  847. categoryId: res.data.categoryId,
  848. categoryName: res.data.name,
  849. code: res.data.categoryCode,
  850. rootPathIdParent: res.data.rootCategoryLevelId,
  851. isProduct: res.data.rootCategoryLevelId == 9 ? true : false,
  852. versions: res.data.versions,
  853. bomType: res.data.bomType,
  854. isWt: true,
  855. isBtn: route.query.isBtn
  856. };
  857. this.$nextTick(() => {
  858. this.$refs.bomDrawer.open(rowData);
  859. this.pageShow = true;
  860. });
  861. });
  862. } else {
  863. this.pageShow = true;
  864. }
  865. },
  866. immediate: true
  867. }
  868. }
  869. };
  870. </script>
  871. <style lang="scss" scoped>
  872. .upload {
  873. display: inline-block;
  874. width: 100px;
  875. margin-left: 10px;
  876. }
  877. </style>