detailedList.vue 26 KB

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