detailedList.vue 25 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033
  1. <template>
  2. <div class="ele-body">
  3. <BOMSearch @search="reload" :statusOpt="statusOpt" />
  4. <!-- :header-cell-style="headerCellStyle" -->
  5. <ele-pro-table
  6. ref="table"
  7. :key="tableKey"
  8. :columns="columns"
  9. :pagination="pagination"
  10. :datasource="datasource"
  11. class="dict-table"
  12. tool-class="ele-toolbar-actions"
  13. >
  14. <template v-slot:toolbar>
  15. <div class="toolbar_box">
  16. <div
  17. v-if="
  18. attributeData.status != 1 && attributeData.approvalStatus != 1
  19. "
  20. >
  21. <el-button
  22. type="primary"
  23. size="mini"
  24. @click="handleAdd"
  25. v-if="!isWt && attributeData.attributeType != 4"
  26. >新增</el-button
  27. >
  28. <el-button
  29. type="primary"
  30. size="mini"
  31. @click="handleSave"
  32. v-if="!isWt"
  33. >保存</el-button
  34. >
  35. </div>
  36. <div class="toolbar_box_right"
  37. ><span>基本数量</span>
  38. <el-input
  39. placeholder="请输入"
  40. v-model.number="attributeData.baseCount"
  41. disabled
  42. >
  43. <template #append>
  44. {{
  45. attributeData.category && attributeData.category.measuringUnit
  46. }}</template
  47. >
  48. </el-input>
  49. </div>
  50. </div>
  51. </template>
  52. <!-- 用量 -->
  53. <template v-slot:dosageHead="{ column }">
  54. <div>
  55. <span class="is-required">{{ column.label }}</span>
  56. </div>
  57. </template>
  58. <template v-slot:dosage="{ row }">
  59. <el-input
  60. v-model="row.dosage"
  61. placeholder="请输入"
  62. size="mini"
  63. style="width: 68px"
  64. >
  65. </el-input>
  66. </template>
  67. <template v-slot:versions="{ row }"> V{{ row.versions }}.0 </template>
  68. <template v-slot:rootCategoryLevelId="{ row }"
  69. >{{ rootCategoryLevelIdText(row.rootCategoryLevelId) }}
  70. </template>
  71. <template v-slot:produceType="{ row }">
  72. <el-select
  73. v-model="row.produceType"
  74. filterable
  75. multiple
  76. disabled
  77. class="ele-block"
  78. size="mini"
  79. >
  80. <el-option
  81. v-for="item in produceTypeList"
  82. :key="item.value"
  83. :value="item.value"
  84. :label="item.label"
  85. ></el-option>
  86. </el-select>
  87. </template>
  88. <template v-slot:attributeType="{ row }">
  89. <!-- <el-select
  90. v-model="row.attributeType"
  91. filterable
  92. disabled
  93. class="ele-block"
  94. size="mini"
  95. >
  96. <el-option
  97. v-for="item in attributeList"
  98. :key="item.value"
  99. :value="item.value"
  100. :label="item.label"
  101. ></el-option>
  102. </el-select> -->
  103. {{ attributeTypeText(row.attributeType) }}
  104. </template>
  105. <template v-slot:componentAttribute="{ row }">
  106. <div>
  107. <el-select
  108. v-model="row.componentAttribute"
  109. filterable
  110. multiple
  111. disabled
  112. class="ele-block"
  113. size="mini"
  114. >
  115. <el-option
  116. v-for="item in sxtList"
  117. :key="item.value"
  118. :value="item.value"
  119. :label="item.label"
  120. ></el-option>
  121. </el-select>
  122. </div>
  123. </template>
  124. <template v-slot:resourceBomVersion="{ row }">
  125. <div>
  126. <el-select
  127. v-model="row.resourceBomVersion"
  128. class="ele-block"
  129. size="mini"
  130. :disabled="row.approvalStatus == 2 || row.approvalStatus == 1"
  131. @change="resourceBomVersionFn($event, row)"
  132. >
  133. <el-option
  134. v-for="item in row.resourceBomVersionList"
  135. :key="item.versions"
  136. :value="item.versions"
  137. :label="'V' + item.versions + '.0'"
  138. ></el-option>
  139. </el-select>
  140. </div>
  141. <!-- <div v-if="!row.id">
  142. <el-select
  143. v-model="row.resourceBomVersion"
  144. disabled
  145. class="ele-block"
  146. size="mini"
  147. @change="resourceBomVersionFn($event, row)"
  148. >
  149. <el-option
  150. v-for="item in row.resourceBomVersionList"
  151. :key="item.versions"
  152. :value="item.versions"
  153. :label="'V' + item.versions + '.0'"
  154. ></el-option>
  155. </el-select>
  156. </div>
  157. <div v-else-if="row.resourceBomVersion">
  158. {{ 'V' + row.resourceBomVersion + '.0' }}
  159. </div> -->
  160. </template>
  161. <template v-slot:materielDesignation="{ row }">
  162. <el-input
  163. v-model="row.materielDesignation"
  164. placeholder="请输入物料代号"
  165. size="mini"
  166. style="width: 120px"
  167. >
  168. </el-input>
  169. </template>
  170. <template v-slot:supplierId="{ row }">
  171. <el-select
  172. v-model="row.supplierId"
  173. size="mini"
  174. clearable
  175. class="ele-block"
  176. filterable
  177. placeholder="请选择供应商"
  178. >
  179. <el-option
  180. v-for="(item, index) in gysList"
  181. :key="item.id + index"
  182. :value="item.id"
  183. :label="item.name"
  184. ></el-option>
  185. </el-select>
  186. </template>
  187. <template v-slot:factories="{ row }">
  188. <div style="display: flex">
  189. <el-input
  190. v-model="row.factories"
  191. disabled
  192. :value="row.factories"
  193. placeholder="请选择生产厂家"
  194. size="mini"
  195. style="width: 120px"
  196. >
  197. </el-input>
  198. <!-- -->
  199. <el-button
  200. type="primary"
  201. @click="factoriesFn(row.code)"
  202. v-if="row.approvalStatus != 2 && row.approvalStatus != 1"
  203. >选择</el-button
  204. >
  205. <!-- <el-select v-model="row.factories" size="mini" clearable class="ele-block" filterable placeholder="请选择生产厂家">
  206. <el-option v-for="(item, index) in sccjList" :key="item.id + index" :value="item.id"
  207. :label="item.name"></el-option>
  208. </el-select> -->
  209. </div>
  210. <!-- <el-input v-model="row.factories" placeholder="请输入生产厂家" size="mini" style="width: 120px">
  211. </el-input> -->
  212. </template>
  213. <!-- 表头工具栏 -->
  214. <template v-slot:action="{ row, $index }">
  215. <el-link
  216. v-if="
  217. attributeData.approvalStatus != 1 &&
  218. attributeData.approvalStatus != 2 &&
  219. !isWt
  220. "
  221. type="danger"
  222. :underline="false"
  223. icon="el-icon-delete"
  224. @click="handleDel(row, $index)"
  225. >
  226. 删除
  227. </el-link>
  228. </template>
  229. </ele-pro-table>
  230. <bomTreeDialog ref="bomTreeDialogRef" @reload="bomClose" />
  231. <standardOutput
  232. ref="standardOutputRefs"
  233. @selection="chooseStandardList"
  234. ></standardOutput>
  235. <clientDialog
  236. ref="clientSelectionRef"
  237. @success="confirmSelection"
  238. ></clientDialog>
  239. </div>
  240. </template>
  241. <script>
  242. import BOMSearch from './BOM-search.vue';
  243. import {
  244. getBomPageCategoryId,
  245. contactList,
  246. deleteBomTreeList,
  247. updateBatchBOM,
  248. sourceBomVersion
  249. } from '@/api/material/BOM';
  250. import clientDialog from './clientDialog.vue';
  251. import { getByCode } from '@/api/system/dictionary-data';
  252. import bomTreeDialog from './bomTreeDialog.vue';
  253. import { produceTypeList } from '@/enum/dict.js';
  254. import standardOutput from './standardOutput.vue';
  255. export default {
  256. name: 'SystemDictionary',
  257. components: { BOMSearch, bomTreeDialog, standardOutput, clientDialog },
  258. data() {
  259. return {
  260. produceTypeList,
  261. pagination: {
  262. tableTotal: 0
  263. },
  264. // 表格列配置
  265. columns: [
  266. {
  267. label: '序号',
  268. columnKey: 'index',
  269. type: 'index',
  270. width: 55,
  271. align: 'center',
  272. showOverflowTooltip: true
  273. },
  274. {
  275. prop: 'code',
  276. label: 'BOM编码',
  277. showOverflowTooltip: true,
  278. width: 120
  279. },
  280. {
  281. prop: 'categoryCode',
  282. label: '物品编码',
  283. showOverflowTooltip: true,
  284. width: 120
  285. },
  286. {
  287. prop: 'name',
  288. label: '名称',
  289. width: 150
  290. },
  291. {
  292. prop: 'level',
  293. label: '层级'
  294. },
  295. {
  296. prop: 'brandNum',
  297. label: '牌号'
  298. },
  299. {
  300. prop: 'modelType',
  301. label: '型号',
  302. align: 'center',
  303. showOverflowTooltip: true
  304. },
  305. {
  306. prop: 'specification',
  307. label: '规格',
  308. align: 'center',
  309. showOverflowTooltip: true
  310. },
  311. {
  312. prop: 'rootCategoryLevelId',
  313. slot: 'rootCategoryLevelId',
  314. label: '物品分类',
  315. align: 'center',
  316. showOverflowTooltip: true
  317. },
  318. {
  319. prop: 'dosage',
  320. slot: 'dosage',
  321. label: '用量',
  322. width: 100,
  323. headerSlot: 'dosageHead'
  324. },
  325. {
  326. prop: 'measuringUnit',
  327. label: '计量单位',
  328. showOverflowTooltip: true
  329. },
  330. {
  331. prop: 'produceType',
  332. slot: 'produceType',
  333. label: '生产类型',
  334. width: 260
  335. },
  336. {
  337. prop: 'attributeType',
  338. slot: 'attributeType',
  339. label: '存货类型',
  340. width: 260
  341. },
  342. {
  343. prop: 'componentAttribute',
  344. slot: 'componentAttribute',
  345. label: '属性类型',
  346. width: 260
  347. },
  348. {
  349. prop: 'materielDesignation',
  350. slot: 'materielDesignation',
  351. label: '物料代号',
  352. width: 150
  353. },
  354. {
  355. prop: 'supplierId',
  356. slot: 'supplierId',
  357. label: '供应商',
  358. width: 150
  359. },
  360. {
  361. prop: 'factories',
  362. slot: 'factories',
  363. label: '生产厂家',
  364. width: 180
  365. },
  366. {
  367. prop: 'resourceBomVersion',
  368. slot: 'resourceBomVersion',
  369. label: '来源版本',
  370. width: 180
  371. },
  372. {
  373. prop: 'versions',
  374. slot: 'versions',
  375. label: '版本'
  376. },
  377. {
  378. prop: 'status ',
  379. label: '状态',
  380. formatter: (row) => {
  381. return this.statusOpt[+row.status];
  382. }
  383. },
  384. {
  385. prop: 'createName',
  386. label: '创建人',
  387. showOverflowTooltip: true
  388. },
  389. {
  390. prop: 'createTime',
  391. label: '创建日期',
  392. width: 160
  393. },
  394. {
  395. action: 'action',
  396. slot: 'action',
  397. fixed: 'right',
  398. label: '操作',
  399. width: 120
  400. }
  401. ],
  402. statusOpt: {
  403. '': '全部',
  404. 0: '草稿',
  405. 1: '已发布'
  406. },
  407. dictList: [
  408. {
  409. label: '加工',
  410. value: 1
  411. },
  412. {
  413. label: '装配',
  414. value: 3
  415. }
  416. ],
  417. attributeList: [
  418. // {
  419. // label: '总装',
  420. // value: 1
  421. // },
  422. // {
  423. // label: '部件',
  424. // value: 2
  425. // },
  426. // {
  427. // label: '零件',
  428. // value: 3
  429. // },
  430. // {
  431. // label: '原材料',
  432. // value: 4
  433. // }
  434. ],
  435. sxtList: [
  436. {
  437. label: '自制件',
  438. value: 1
  439. },
  440. {
  441. label: '采购件',
  442. value: 2
  443. },
  444. {
  445. label: '外协件',
  446. value: 3
  447. },
  448. {
  449. label: '受托件',
  450. value: 4
  451. }
  452. ],
  453. rootCategoryLevelIdList: [
  454. {
  455. label: '产品',
  456. value: 9
  457. },
  458. {
  459. label: '物料',
  460. value: 1
  461. },
  462. {
  463. label: '生产设备',
  464. value: 4
  465. },
  466. {
  467. label: '模具',
  468. value: 5
  469. },
  470. {
  471. label: '备品备件',
  472. value: 6
  473. },
  474. {
  475. label: '零部件',
  476. value: 3
  477. },
  478. {
  479. label: '舟皿',
  480. value: 8
  481. },
  482. {
  483. label: '消耗材料',
  484. value: 10
  485. },
  486. {
  487. label: '包装材料',
  488. value: 13
  489. },
  490. {
  491. label: '生产辅助设备',
  492. value: 14
  493. },
  494. {
  495. label: '仪表计量设备',
  496. value: 15
  497. },
  498. {
  499. label: '会计科目',
  500. value: 23
  501. },
  502. {
  503. label: '周转盘',
  504. value: 26
  505. },
  506. {
  507. label: '废品',
  508. value: 28
  509. },
  510. {
  511. label: '周转车',
  512. value: 7
  513. }
  514. ],
  515. isList: false,
  516. isId: null,
  517. tableKey: '',
  518. list: [], //表格数据
  519. listTow: [],
  520. newList: [],
  521. gysList: [],
  522. sccjList: [],
  523. newTreeId: null,
  524. responsesList: []
  525. // dictList: []
  526. };
  527. },
  528. created() {
  529. this.getAttriButeList('inventory_type');
  530. // this.getDictList('productionType');
  531. // this.getZeroPartPros('zeroPartPros');
  532. this.getContactList();
  533. },
  534. mounted() {},
  535. props: {
  536. attributeData: {
  537. type: Object,
  538. default: {}
  539. },
  540. isWt: {
  541. type: Boolean,
  542. default: false
  543. },
  544. treeId: {
  545. type: String,
  546. default: ''
  547. },
  548. isTemp: {
  549. type: Number,
  550. default: 0
  551. }
  552. },
  553. watch: {
  554. treeId: {
  555. handler(val) {
  556. this.newTreeId = val;
  557. },
  558. deep: true,
  559. immediate: true
  560. },
  561. 'attributeData.id': {
  562. handler(val) {
  563. this.$nextTick(() => {
  564. console.log(val, '66666666');
  565. this.reload();
  566. });
  567. },
  568. deep: true,
  569. immediate: true
  570. },
  571. data: {
  572. handler(val) {
  573. console.log(val);
  574. // this.$nextTick(() => {
  575. // this.reload();
  576. // });
  577. },
  578. deep: true,
  579. immediate: true
  580. }
  581. },
  582. // computed: {
  583. // processedItems() {
  584. // return this.list.map(item => {
  585. // // 处理逻辑
  586. // console.log(item);
  587. // // return processedItem;
  588. // });
  589. // }
  590. // },
  591. mounted() {},
  592. methods: {
  593. attributeTypeText(v) {
  594. if (v) {
  595. let a = this.attributeList.find((item) => item.value == v);
  596. return a.label;
  597. }
  598. },
  599. async getAttriButeList(code) {
  600. let { data: res } = await getByCode(code);
  601. this.attributeList = res.map((item) => {
  602. let values = Object.keys(item);
  603. return {
  604. value: Number(values[0]),
  605. label: item[values[0]]
  606. };
  607. });
  608. },
  609. rootCategoryLevelIdText(v) {
  610. console.log(v, '111111');
  611. console.log(
  612. this.rootCategoryLevelIdList,
  613. 'this.rootCategoryLevelIdList'
  614. );
  615. if (v) {
  616. let a = this.rootCategoryLevelIdList.find((item) => item.value == v);
  617. return a ? a.label : '';
  618. }
  619. },
  620. factoriesFn(code) {
  621. this.isId = code;
  622. this.$refs.clientSelectionRef.open();
  623. },
  624. // 选择工厂
  625. confirmSelection(obj) {
  626. let list = this.$refs.table.getData();
  627. list.map((v) => {
  628. if (v.code == this.isId) {
  629. v.factories = obj.name;
  630. }
  631. });
  632. console.log(list, 'list');
  633. // arr.factories = obj.name;
  634. this.$nextTick(() => {
  635. this.list = [...list];
  636. this.listTow = JSON.parse(JSON.stringify(this.list));
  637. this.$refs.table.setData(this.list);
  638. this.updateFn();
  639. this.tableKey = Date.now();
  640. });
  641. this.$forceUpdate();
  642. },
  643. updateFn(list) {
  644. this.isList = true;
  645. this.reload();
  646. setTimeout(() => {
  647. this.isList = false;
  648. }, 1000);
  649. },
  650. /* 表格数据源 */
  651. datasource({ where, page, limit }) {
  652. // let that = this;
  653. // console.log(getBomPageCategoryId({
  654. // ...where,
  655. // pageNum: page,
  656. // size: limit,
  657. // id: this.attributeData.id,
  658. // bomType: this.attributeData.bomType
  659. // }));
  660. // return new Promise((resolve, reject) => {
  661. // getBomPageCategoryId({
  662. // ...where,
  663. // pageNum: page,
  664. // size: limit,
  665. // id: that.attributeData.id,
  666. // bomType: that.attributeData.bomType
  667. // }).then((res) => {
  668. // console.log(res, '111111111111');
  669. // if(res.list && res.list.length ){
  670. // const arrays = []
  671. // res.list.map((item) => {
  672. // arrays.push(item.categoryId);
  673. // });
  674. // that.getResourceBomVersionListFn(arrays).then(v => {
  675. // v.map(element => {
  676. // res.list.map((item2, i) => {
  677. // if (element.categoryId == item2.id) {
  678. // item2.resourceBomVersionList.push(element);
  679. // }
  680. // item2.resourceBomVersion = item2.resourceBomVersionList[0].versions;
  681. // item2.resourceBomId = item2.resourceBomVersionList[0].resourceBomId;
  682. // // item2.id ="";
  683. // })
  684. // })
  685. // this.$nextTick(() => {
  686. // resolve(res);
  687. // })
  688. // })
  689. // }
  690. // })
  691. // .catch((err) => {
  692. // reject(err);
  693. // });
  694. // });
  695. let data = getBomPageCategoryId({
  696. ...where,
  697. pageNum: page,
  698. size: limit,
  699. id: this.attributeData.id,
  700. bomType: this.attributeData.bomType
  701. });
  702. if (this.isList) {
  703. data = this.listTow;
  704. }
  705. console.log(data, 'data');
  706. return data;
  707. },
  708. /* 刷新表格 */
  709. reload(where) {
  710. this.$refs.table.reload({ where });
  711. },
  712. async getDictList(code) {
  713. let { data: res } = await getByCode(code);
  714. this.dictList = res.map((item) => {
  715. let values = Object.keys(item);
  716. return {
  717. value: Number(values[0]),
  718. label: item[values[0]]
  719. };
  720. });
  721. },
  722. // async getZeroPartPros(code) {
  723. // let { data: res } = await getByCode(code);
  724. // let sxtList = res.map((item) => {
  725. // let values = Object.keys(item);
  726. // return {
  727. // value: Number(values[0]),
  728. // label: item[values[0]]
  729. // };
  730. // });
  731. // this.$nextTick(() => {
  732. // this.$set(this, 'sxtList', sxtList);
  733. // });
  734. // },
  735. getContactList() {
  736. let param = {
  737. pageNum: 1,
  738. type: 2,
  739. size: -1,
  740. status: 1
  741. };
  742. contactList(param).then((res) => {
  743. console.log(res, 'res11111111111');
  744. this.gysList = res.list;
  745. });
  746. },
  747. handleAdd() {
  748. // // 打开树形对话框
  749. // this.$refs.bomTreeDialogRef.open(
  750. // this.attributeData.bomType,
  751. // this.attributeData.versions,
  752. // this.attributeData.categoryId,
  753. // this.newTreeId,
  754. // this.isTemp
  755. // );
  756. let _list = this.$refs.table.getData() ?? [];
  757. this.$refs.standardOutputRefs.open(_list);
  758. },
  759. // 勾选
  760. async chooseStandardList(data) {
  761. const that = this;
  762. const arrays = [];
  763. data.map((m) => {
  764. m.parentId = this.newTreeId;
  765. m.createTime = '';
  766. m.bomType = this.attributeData.bomType;
  767. m.level = Number(this.attributeData.level) + 1;
  768. m.categoryCode = m.code;
  769. m.code = '';
  770. m.versions = this.attributeData.versions;
  771. m.categoryId = m.id;
  772. // m.dosage = 1;
  773. m.componentAttribute = m.componentAttribute;
  774. m.rootCategoryLevelId = m.categoryLevelPathIdParent;
  775. m.resourceBomVersionList = [];
  776. arrays.push(m.id);
  777. });
  778. this.getResourceBomVersionListFn(arrays).then((v) => {
  779. if (v.length) {
  780. v.map((element) => {
  781. data.map((item2, i) => {
  782. if (element.categoryId == item2.id) {
  783. item2.resourceBomVersionList.push(element);
  784. }
  785. if (item2.resourceBomVersionList.length) {
  786. item2.resourceBomVersion =
  787. item2.resourceBomVersionList[0].versions;
  788. item2.resourceBomId =
  789. item2.resourceBomVersionList[0].resourceBomId;
  790. }
  791. setTimeout(() => {
  792. item2.id = '';
  793. }, 100);
  794. });
  795. });
  796. }
  797. this.$nextTick(() => {
  798. data.map((v) => {
  799. v.id = '';
  800. });
  801. this.list = [...data, ...this.$refs.table.getData()];
  802. this.$refs.table._data.tableTotal = this.list.length;
  803. this.$refs.table.setData(this.list);
  804. });
  805. });
  806. // this.$nextTick(() => {
  807. // this.list = [...data, ...this.$refs.table.getData()];
  808. // console.log(this.list,'9999999999');
  809. // // this.$refs.table.setData(this.list);
  810. // console.log(this.$refs.table._data,'this.$refs.table');
  811. // // this.$refs.table._data.tableData = [];
  812. // //
  813. // // this.$set(this.$refs.table._data,"tableData",this.list);
  814. // // this.bomClose();
  815. // });
  816. },
  817. resourceBomVersionFn(e, row) {
  818. let arr = row.resourceBomVersionList.find((item) => item.versions == e);
  819. row.resourceBomVersion = arr.versions;
  820. row.resourceBomId = arr.resourceBomId;
  821. this.$forceUpdate();
  822. console.log(row);
  823. },
  824. async getResourceBomVersionListFn(id) {
  825. return new Promise((resolve, reject) => {
  826. sourceBomVersion({
  827. bomType: this.attributeData.bomType,
  828. categoryIds: id
  829. }).then((res) => {
  830. resolve(res.data);
  831. });
  832. });
  833. },
  834. bomClose() {
  835. this.$nextTick(() => {
  836. this.$refs.table.reload({
  837. pageNum: 1
  838. });
  839. });
  840. },
  841. handleDel(row, i) {
  842. this.$confirm('是否确认删除?', '提示', {
  843. confirmButtonText: '确定',
  844. cancelButtonText: '取消',
  845. type: 'warning'
  846. })
  847. .then(() => {
  848. if (row.id) {
  849. deleteBomTreeList([row.id]).then((msg) => {
  850. this.$message.success('删除' + msg);
  851. this.$refs.table.reload({
  852. pageNum: 1
  853. });
  854. });
  855. } else {
  856. let _list = this.$refs.table.getData() ?? [];
  857. _list.splice(i, 1);
  858. // _list = _list.filter((item) => item.id !== row.id);
  859. this.$refs.table.setData(_list);
  860. }
  861. })
  862. .catch(() => {});
  863. },
  864. handleSave() {
  865. let _list = this.$refs.table.getData() ?? [];
  866. if (_list.length == 0) {
  867. return this.$message.info('明细表最少有一条数据');
  868. }
  869. let list = JSON.parse(JSON.stringify(_list));
  870. console.log(list, 'list');
  871. const arr = list.every((v) => {
  872. return v.dosage && v.quantity !== '';
  873. });
  874. if (!arr) {
  875. return this.$message.info('用量不能为空');
  876. }
  877. // console.log(list);
  878. // return
  879. updateBatchBOM(list).then((res) => {
  880. if (res) {
  881. this.$message.success('保存成功');
  882. this.reload();
  883. // this.$refs.table.reload({
  884. // pageNum: 1
  885. // });
  886. }
  887. });
  888. }
  889. }
  890. };
  891. </script>
  892. <style lang="scss" scoped>
  893. .ele-body {
  894. height: 100%;
  895. ::v-deep .el-card {
  896. height: 100%;
  897. .el-card__body {
  898. height: 100%;
  899. display: flex;
  900. flex-direction: column;
  901. .dict-table {
  902. flex: 1;
  903. overflow: hidden;
  904. display: flex;
  905. flex-direction: column;
  906. .el-table {
  907. flex: 1;
  908. overflow-y: auto;
  909. }
  910. }
  911. }
  912. }
  913. }
  914. .toolbar_box {
  915. display: flex;
  916. justify-content: space-between;
  917. align-items: center;
  918. .toolbar_box_right {
  919. display: flex;
  920. align-items: center;
  921. justify-content: center;
  922. margin-right: 10px;
  923. > span {
  924. width: 150px;
  925. }
  926. > div {
  927. margin-left: 10px;
  928. }
  929. }
  930. }
  931. </style>