detailedList.vue 27 KB

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