index.vue 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934
  1. <template>
  2. <div class="ele-body">
  3. <el-card shadow="never">
  4. <BOMSearch
  5. @search="reload"
  6. :statusOpt="statusOpt"
  7. :categoryCode="where.categoryCode"
  8. :isUpload="isUpload"
  9. />
  10. <!-- -->
  11. <el-tabs v-model="activeName" type="border-card" @tab-click="handleClick">
  12. <el-tab-pane label="EBOM" name="4"> </el-tab-pane>
  13. <el-tab-pane label="PBOM" name="1"> </el-tab-pane>
  14. <el-tab-pane label="MBOM" name="2"> </el-tab-pane>
  15. <el-tab-pane label="ABOM" name="3"> </el-tab-pane>
  16. <ele-pro-table
  17. ref="table"
  18. :columns="columns"
  19. :datasource="datasource"
  20. class="dict-table"
  21. tool-class="ele-toolbar-actions"
  22. @sort-change="onSortChange"
  23. :page-size="pageSize"
  24. @columns-change="handleColumnChange"
  25. :cache-key="useNewColumns ? cacheKeyUrl : cacheKeyUrlOld"
  26. >
  27. <template v-slot:approvalStatus="{ row }">
  28. <el-link
  29. type="primary"
  30. :underline="false"
  31. @click="handleDetails(row)"
  32. >
  33. {{ approvalStatusOpt[+row.approvalStatus] }}
  34. </el-link>
  35. </template>
  36. <!-- 序号:前端自己渲染行号 -->
  37. <template v-slot:rowIndex="{ $index }">{{
  38. (currentPage - 1) * currentLimit + $index + 1
  39. }}</template>
  40. <!-- 总重:前端按 用量 × 单重 计算(用量/单重改了立即跟着变) -->
  41. <template v-slot:totalWeight="{ row }">{{ totalWeightOf(row) }}</template>
  42. <template v-slot:code="{ row }">
  43. <el-link
  44. type="primary"
  45. :underline="false"
  46. @click="handelDetail(row)"
  47. >{{ row.code }}</el-link
  48. >
  49. </template>
  50. <template v-slot:versions="{ row }">
  51. <!-- 版本为空就留空,不显示"无" -->
  52. <template v-if="row.versions">V{{ row.versions }}.0</template>
  53. </template>
  54. <template v-slot:isTemp="{ row }">
  55. <el-tag size="mini" v-if="row.isTemp == 1">主数据</el-tag>
  56. </template>
  57. <template v-slot:rootCategoryLevelId="{ row }">
  58. {{ rootCategoryLevelIdText(row.rootCategoryLevelId) }}
  59. </template>
  60. <template v-slot:componentAttribute="{ row }">
  61. <el-select
  62. v-model="row.componentAttribute"
  63. filterable
  64. multiple
  65. disabled
  66. class="ele-block"
  67. size="mini"
  68. >
  69. <el-option
  70. v-for="item in sxtList"
  71. :key="item.value"
  72. :value="item.value"
  73. :label="item.label"
  74. ></el-option>
  75. </el-select>
  76. <!-- {{ attributeTypeText(row.attributeType) }} -->
  77. </template>
  78. <template v-slot:attributeType="{ row }">
  79. {{ attributeTypeText(row.attributeType) }}
  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. <!-- 表头工具栏 -->
  99. <template v-slot:action="{ row }">
  100. <!-- <el-link type="primary" @click="handelDetail(row)">详情</el-link> -->
  101. <el-link
  102. v-if="
  103. row.status != 1 &&
  104. (row.approvalStatus == 0 || row.approvalStatus == 3) &&
  105. $hasPermission('main:bomcategory:delete')
  106. "
  107. type="primary"
  108. @click="handSubmit(row)"
  109. >发布</el-link
  110. >
  111. <el-link
  112. v-if="
  113. row.approvalStatus == 1 &&
  114. $hasPermission('main:bomcategory:withdraw')
  115. "
  116. type="primary"
  117. @click="handWithdraw(row)"
  118. >撤回</el-link
  119. >
  120. <el-link
  121. type="danger"
  122. :underline="false"
  123. v-if="
  124. activeName == 1 &&
  125. row.status != 1 &&
  126. (row.approvalStatus == 0 || row.approvalStatus == 3) &&
  127. $hasPermission('main:bomcategory:delete')
  128. "
  129. @click="handDel(row)"
  130. >
  131. 删除
  132. </el-link>
  133. </template>
  134. </ele-pro-table>
  135. </el-tabs>
  136. </el-card>
  137. <el-dialog
  138. title="发布"
  139. :visible.sync="isSubmit"
  140. v-if="isSubmit"
  141. width="30%"
  142. center
  143. >
  144. <div>
  145. <el-radio v-model="radioSubmit" :label="1">药品</el-radio>
  146. <el-radio v-model="radioSubmit" :label="2">器械</el-radio>
  147. </div>
  148. <span slot="footer" class="dialog-footer">
  149. <el-button @click="isSubmit = false">取 消</el-button>
  150. <el-button type="primary" @click="handJsSubmit()">确 定</el-button>
  151. </span>
  152. </el-dialog>
  153. <LCdetail ref="detailRef"></LCdetail>
  154. <process-submit-dialog
  155. api-fun-name="purchaseinquiryStatusAPI"
  156. :processSubmitDialogFlag.sync="processSubmitDialogFlag"
  157. v-if="processSubmitDialogFlag"
  158. ref="processSubmitDialogRef"
  159. @reload="reload"
  160. ></process-submit-dialog>
  161. <BomDetailsPop ref="bomDrawer"></BomDetailsPop>
  162. </div>
  163. </template>
  164. <script>
  165. import tabMixins from '@/mixins/tableColumnsMixin';
  166. import { produceTypeList } from '@/enum/dict.js';
  167. import processSubmitDialog from '@/components/processSubmitDialog/processSubmitDialog.vue';
  168. import BOMSearch from './components/BOM-search.vue';
  169. import {
  170. getBomPageList,
  171. startAndStop,
  172. bomSubmit,
  173. jsBomSubmit,
  174. deviceBomSubmit,
  175. deleteBomTreeList,
  176. withdrawBom
  177. } from '@/api/material/BOM';
  178. import LCdetail from './components/LCdetail.vue';
  179. import { getByCode, parameterGetByCode } from '@/api/system/dictionary-data';
  180. import BomDetailsPop from '../BOMmanage/detailsPop.vue';
  181. import { mapGetters } from 'vuex';
  182. export default {
  183. name: 'SystemDictionary',
  184. components: { BOMSearch, LCdetail, BomDetailsPop, processSubmitDialog },
  185. mixins: [tabMixins],
  186. data() {
  187. return {
  188. produceTypeList,
  189. processSubmitDialogFlag: false,
  190. // 老 columns 方案(默认 20 列全部可见)
  191. oldColumnsConfig: [
  192. {
  193. label: '序号',
  194. columnKey: 'index',
  195. type: 'index',
  196. width: 55,
  197. align: 'center',
  198. showOverflowTooltip: true
  199. },
  200. {
  201. prop: 'code',
  202. label: 'BOM编码',
  203. showOverflowTooltip: true,
  204. slot: 'code',
  205. width: 120,
  206. sortable: true
  207. },
  208. {
  209. prop: 'name',
  210. label: 'BOM名称',
  211. showOverflowTooltip: true,
  212. slot: 'name',
  213. width: 120,
  214. sortable: true
  215. },
  216. {
  217. prop: 'categoryCode',
  218. label: '编码',
  219. showOverflowTooltip: true
  220. },
  221. {
  222. prop: 'categoryName',
  223. label: '名称',
  224. showOverflowTooltip: true
  225. },
  226. {
  227. prop: 'specification',
  228. label: '规格',
  229. showOverflowTooltip: true
  230. },
  231. {
  232. prop: 'modelType',
  233. label: '型号',
  234. showOverflowTooltip: true
  235. },
  236. {
  237. prop: 'rootCategoryLevelId',
  238. slot: 'rootCategoryLevelId',
  239. label: '物品分类',
  240. showOverflowTooltip: true
  241. },
  242. {
  243. slot: 'componentAttribute',
  244. prop: 'componentAttribute',
  245. label: '属性类型',
  246. showOverflowTooltip: true,
  247. minWidth: 180
  248. },
  249. {
  250. slot: 'attributeType',
  251. prop: 'attributeType',
  252. label: '存货类型',
  253. showOverflowTooltip: true
  254. },
  255. {
  256. prop: 'produceType',
  257. slot: 'produceType',
  258. label: '生产类型',
  259. showOverflowTooltip: true,
  260. minWidth: 180
  261. },
  262. {
  263. prop: 'versions',
  264. slot: 'versions',
  265. label: '版本'
  266. },
  267. {
  268. prop: 'resourceBomVersion',
  269. label: '来源版本',
  270. showOverflowTooltip: true,
  271. minWidth: 180
  272. },
  273. {
  274. prop: 'status',
  275. label: '状态',
  276. formatter: (row) => {
  277. return this.statusOpt[+row.status];
  278. }
  279. },
  280. {
  281. prop: 'approvalStatus',
  282. label: '审核状态',
  283. slot: 'approvalStatus'
  284. },
  285. // {
  286. // width: 100,
  287. // prop: 'isTemp',
  288. // slot: 'isTemp',
  289. // label: '主数据'
  290. // },
  291. {
  292. prop: 'createName',
  293. label: '创建人',
  294. showOverflowTooltip: true
  295. },
  296. {
  297. prop: 'createTime',
  298. label: '创建时间',
  299. showOverflowTooltip: true,
  300. slot: 'createTime',
  301. sortable: true
  302. },
  303. {
  304. prop: 'updateTime',
  305. label: '修改时间',
  306. showOverflowTooltip: true,
  307. slot: 'updateTime',
  308. sortable: true
  309. },
  310. {
  311. columnKey: 'action',
  312. slot: 'action',
  313. label: '操作',
  314. width: 170,
  315. align: 'center'
  316. }
  317. ],
  318. // 新 columns 方案(PBOM + is_runtian===1 时使用),内容与 detailedList.vue 的 newColumnsConfig 保持一致
  319. newColumnsConfig: [
  320. {
  321. prop: 'level',
  322. label: '零部件层级',
  323. align: 'center',
  324. showOverflowTooltip: true,
  325. width: 100
  326. },
  327. {
  328. // 序号:普通列 + 前端插槽渲染行号(见模板 v-slot:rowIndex)
  329. // 不能用 type: 'index':index 列不在列设置缓存里,ele-pro-table(columnsSort 默认 true)
  330. // 会把找不到缓存位置的列排到最前面,所以它永远显示在第一列。
  331. prop: 'rowIndex',
  332. columnKey: 'rowIndex',
  333. label: '序号',
  334. width: 90,
  335. align: 'center',
  336. showOverflowTooltip: true,
  337. slot: 'rowIndex'
  338. },
  339. {
  340. prop: 'code',
  341. label: '物料编码',
  342. slot: 'code',
  343. showOverflowTooltip: true,
  344. width: 180
  345. },
  346. {
  347. prop: 'imgCode',
  348. label: '零部件图号(规格型号)',
  349. showOverflowTooltip: true,
  350. width: 120
  351. },
  352. {
  353. prop: 'versions',
  354. slot: 'versions',
  355. label: '图纸版本',
  356. showOverflowTooltip: true,
  357. align: 'center',
  358. width: 90
  359. },
  360. {
  361. prop: 'updateTime',
  362. label: '修改时间',
  363. width: 160,
  364. showOverflowTooltip: true
  365. },
  366. {
  367. prop: 'name',
  368. label: '零件名称',
  369. showOverflowTooltip: true,
  370. width: 150
  371. },
  372. {
  373. prop: 'dosage',
  374. slot: 'dosage',
  375. label: '单台用量',
  376. width: 100,
  377. headerSlot: 'dosageHead'
  378. },
  379. {
  380. prop: 'measuringUnit',
  381. label: '计量单位',
  382. showOverflowTooltip: true,
  383. align: 'center',
  384. width: 90
  385. },
  386. {
  387. prop: 'brandNum',
  388. label: '材质',
  389. showOverflowTooltip: true,
  390. width: 100
  391. },
  392. {
  393. prop: 'netWeight',
  394. label: '单重',
  395. showOverflowTooltip: true,
  396. align: 'right',
  397. width: 100
  398. },
  399. {
  400. prop: 'totalWeight',
  401. label: '总重',
  402. slot: 'totalWeight',
  403. showOverflowTooltip: true,
  404. align: 'right',
  405. width: 100
  406. },
  407. {
  408. prop: 'remark',
  409. label: '备注',
  410. showOverflowTooltip: true,
  411. width: 100
  412. },
  413. {
  414. prop: 'createName',
  415. label: '创建人',
  416. showOverflowTooltip: true,
  417. width: 100
  418. },
  419. {
  420. prop: 'createTime',
  421. label: '创建日期',
  422. width: 160,
  423. showOverflowTooltip: true
  424. }
  425. ],
  426. // 系统参数 is_runtian 原始值(false=未加载/失败,其他=接口返回值)
  427. isRuntianValue: false,
  428. sxtList: [
  429. {
  430. label: '自制件',
  431. value: 1
  432. },
  433. {
  434. label: '采购件',
  435. value: 2
  436. },
  437. {
  438. label: '外协件',
  439. value: 3
  440. },
  441. {
  442. label: '受托件',
  443. value: 4
  444. }
  445. ],
  446. statusOpt: {
  447. 0: '草稿',
  448. 1: '已发布',
  449. 2: '已停用'
  450. },
  451. approvalStatusOpt: {
  452. 0: '未提交',
  453. 1: '审核中',
  454. 2: '审核通过',
  455. 3: '审核不通过'
  456. },
  457. loading: false,
  458. loadingInstance: null,
  459. dictList: [],
  460. where: {},
  461. attributeList: [
  462. // {
  463. // label: '总装',
  464. // value: 1
  465. // },
  466. // {
  467. // label: '部件',
  468. // value: 2
  469. // },
  470. // {
  471. // label: '零件',
  472. // value: 3
  473. // },
  474. // {
  475. // label: '原材料',
  476. // value: 4
  477. // }
  478. ],
  479. sort: {},
  480. // 当前分页位置:序号要跨页连续(第 2 页从 21 开始,不重置)
  481. currentPage: 1,
  482. currentLimit: 20,
  483. rootCategoryLevelIdList: [
  484. {
  485. label: '产品',
  486. value: 9
  487. },
  488. {
  489. label: '物料',
  490. value: 1
  491. },
  492. {
  493. label: '生产设备',
  494. value: 4
  495. },
  496. {
  497. label: '模具',
  498. value: 5
  499. },
  500. {
  501. label: '备品备件',
  502. value: 6
  503. },
  504. {
  505. label: '零部件',
  506. value: 3
  507. },
  508. {
  509. label: '舟皿',
  510. value: 8
  511. },
  512. {
  513. label: '消耗材料',
  514. value: 10
  515. },
  516. {
  517. label: '包装材料',
  518. value: 13
  519. },
  520. {
  521. label: '生产辅助设备',
  522. value: 14
  523. },
  524. {
  525. label: '仪表计量设备',
  526. value: 15
  527. },
  528. {
  529. label: '会计科目',
  530. value: 23
  531. },
  532. {
  533. label: '周转盘',
  534. value: 26
  535. },
  536. {
  537. label: '废品',
  538. value: 28
  539. }
  540. ],
  541. activeName: '1',
  542. isSubmit: false,
  543. JsRId: null,
  544. radioSubmit: 1,
  545. currentNodeData: {},
  546. pageSize: this.$store.state.tablePageSize,
  547. // 是否启用新 columns 方案(true=新方案,false=老方案);层级序号只在新方案生效
  548. useNewColumns: true,
  549. // 序号列由 type:index 改成 rowIndex 数据列,换 key 清一次列设置缓存
  550. // (ele-pro-table 按列 key 从 localStorage 恢复列顺序,新列不在旧缓存里会被排到最前)
  551. cacheKeyUrl: '68be265a-material-BOMmanage-v3',
  552. cacheKeyUrlOld: '68be265a-material-BOMmanage-old-v1',
  553. isUpload: true
  554. };
  555. },
  556. computed: {
  557. clientEnvironmentId() {
  558. return this.$store.state.user.info.clientEnvironmentId;
  559. },
  560. ...mapGetters(['user']),
  561. // 新方案默认展示的 prop 集合(自动从 newColumnsConfig 推导,避免漏配导致老列覆盖新列)
  562. newPropSet() {
  563. const set = new Set();
  564. this.newColumnsConfig.forEach((c) => {
  565. if (c.prop) set.add(c.prop);
  566. });
  567. return set;
  568. },
  569. // 操作列:固定右侧,不参与新老的合并
  570. actionColumn() {
  571. return {
  572. columnKey: 'action',
  573. slot: 'action',
  574. label: '操作',
  575. width: 170,
  576. align: 'center'
  577. };
  578. },
  579. // 表格列:按 useNewColumns 决定输出老方案还是新方案
  580. columns() {
  581. if (this.useNewColumns) {
  582. // 老方案里独有、且不在新方案里的列 → 追加到末尾,默认隐藏,用户可手动显示
  583. const extras = this.oldColumnsConfig
  584. .filter((c) => {
  585. if (c.columnKey === 'action') return false; // 操作列单独追加
  586. if (c.type === 'index' || c.columnKey === 'index') return false;
  587. if (c.prop && this.newPropSet.has(c.prop)) return false;
  588. return true;
  589. })
  590. .map((c) => ({ ...c, show: false }));
  591. return [...this.newColumnsConfig, ...extras, this.actionColumn];
  592. }
  593. // 老方案:保持原有顺序
  594. return [...this.oldColumnsConfig];
  595. }
  596. },
  597. created() {
  598. this.getDictList('productionType');
  599. this.getAttriButeList('inventory_type');
  600. this.getRuntianConfig();
  601. // 新老两套列方案各有自己的列设置缓存,打开页面时自愈一次
  602. this.healColumnsCache(this.cacheKeyUrlOld, this.oldColumnsConfig);
  603. this.healColumnsCache(this.cacheKeyUrl, this.newColumnsConfig);
  604. },
  605. methods: {
  606. // 总重 = 单台用量 × 单重(前端计算)
  607. totalWeightOf(row) {
  608. const toNumber = (v) =>
  609. v === null || v === undefined || v === '' ? null : Number(v);
  610. const dosage = toNumber(row && row.dosage);
  611. const netWeight = toNumber(row && row.netWeight);
  612. if (dosage === null || netWeight === null) {
  613. return '';
  614. }
  615. if (isNaN(dosage) || isNaN(netWeight)) {
  616. return '';
  617. }
  618. return (dosage * netWeight).toFixed(2);
  619. },
  620. // ele-pro-table 的列顺序是按 localStorage 里的列缓存恢复的:配置里新增/删除列之后,
  621. // 旧缓存里没有新列 → 新列会被排到第一列(表现为“序号跑到第一列,点列重置才恢复”)。
  622. // 这里做一次自愈:缓存的列集合与当前配置不一致就清掉,让列顺序回到配置顺序。
  623. healColumnsCache(cacheKey, columns) {
  624. const key = cacheKey + 'Cols';
  625. try {
  626. const raw = localStorage.getItem(key);
  627. if (!raw) {
  628. return;
  629. }
  630. const cached = JSON.parse(raw);
  631. if (!Array.isArray(cached) || !cached.length) {
  632. return;
  633. }
  634. const wanted = (columns || [])
  635. .filter((c) => c && c.type !== 'index' && c.columnKey !== 'index')
  636. .map((c) => c.columnKey || c.prop)
  637. .filter((k) => !!k);
  638. const cachedKeys = cached.map((c) => c.id);
  639. // 只判断“配置里有、缓存里没有”的列(这类列才会被 ele-pro-table 排到第一列);
  640. // 缓存里多出来的列(比如操作列)不用管。
  641. const missing = wanted.filter((k) => !cachedKeys.includes(k));
  642. if (missing.length) {
  643. localStorage.removeItem(key);
  644. }
  645. } catch (e) {
  646. localStorage.removeItem(key);
  647. }
  648. },
  649. attributeTypeText(v) {
  650. if (v) {
  651. let a = this.attributeList.find((item) => item.value == v);
  652. return a ? a.label : '';
  653. }
  654. },
  655. rootCategoryLevelIdText(v) {
  656. if (v) {
  657. let a = this.rootCategoryLevelIdList.find((item) => item.value == v);
  658. if (a) return a.label;
  659. }
  660. },
  661. async getAttriButeList(code) {
  662. let { data: res } = await getByCode(code);
  663. this.attributeList = res.map((item) => {
  664. let values = Object.keys(item);
  665. return {
  666. value: Number(values[0]),
  667. label: item[values[0]]
  668. };
  669. });
  670. },
  671. async getDictList(code) {
  672. let { data: res } = await getByCode(code);
  673. this.dictList = res.map((item) => {
  674. let values = Object.keys(item);
  675. return {
  676. value: Number(values[0]),
  677. label: item[values[0]]
  678. };
  679. });
  680. },
  681. // 取系统参数 is_runtian 的原始值(新 columns 方案已固定启用,这里仅保留参数读取)
  682. // 兼容常见返回:'1' / 1 / { value: 1 } / { paramValue: '1' } / true
  683. async getRuntianConfig() {
  684. try {
  685. const data = await parameterGetByCode({ code: 'is_runtian' });
  686. this.isRuntianValue =
  687. typeof data === 'object' && data !== null
  688. ? data.value ?? data.paramValue ?? data.val
  689. : data;
  690. } catch (e) {
  691. this.isRuntianValue = false;
  692. }
  693. },
  694. // 撤回
  695. handWithdraw(row) {
  696. const params = {
  697. processInstanceId: row.processInstanceId,
  698. businessId: row.id,
  699. processDefinitionKey:
  700. this.clientEnvironmentId == 5
  701. ? this.radioSubmit == 1
  702. ? 'bom_release'
  703. : 'bom_release_device'
  704. : 'bom_approver'
  705. };
  706. this.$confirm('是否确认撤回?', '提示', {
  707. confirmButtonText: '确定',
  708. cancelButtonText: '取消',
  709. type: 'warning'
  710. })
  711. .then(() => {
  712. withdrawBom(params)
  713. .then((res) => {
  714. if (res?.code == '0') {
  715. this.$message.success('撤回成功');
  716. this.reload();
  717. }
  718. })
  719. .catch((err) => {
  720. // this.$message.error(err.message);
  721. });
  722. })
  723. .catch(() => {});
  724. },
  725. handSubmit(row) {
  726. this.currentNodeData = row;
  727. if (this.clientEnvironmentId == 5) {
  728. // this.JsRId = row.id;
  729. this.isSubmit = true;
  730. } else {
  731. this.submit();
  732. // this.$alert('确定要发布吗?', '提示', {
  733. // confirmButtonText: '确定',
  734. // cancelButtonText: '取消',
  735. // type: 'warning'
  736. // })
  737. // .then(() => {
  738. // bomSubmit({ businessId: row.id }).then((res) => {
  739. // if (res?.code == '0') {
  740. // this.$message.success('发布成功');
  741. // this.reload();
  742. // }
  743. // });
  744. // })
  745. // .catch(() => {});
  746. }
  747. },
  748. submit(businessKey) {
  749. this.processSubmitDialogFlag = true;
  750. this.$nextTick(() => {
  751. let params = {
  752. businessId: this.currentNodeData.id,
  753. businessKey: businessKey || 'bom_approver',
  754. formCreateUserId: this.user.info.userId,
  755. variables: {
  756. businessCode: this.currentNodeData.code,
  757. businessName: this.currentNodeData.name,
  758. businessType:
  759. this.activeName == 1
  760. ? 'PBOM'
  761. : this.activeName == 2
  762. ? 'MBOM'
  763. : this.activeName == 3
  764. ? 'ABOM'
  765. : 'EBOM'
  766. }
  767. };
  768. this.$refs.processSubmitDialogRef.init(params);
  769. });
  770. },
  771. handJsSubmit() {
  772. if (!this.radioSubmit) {
  773. return this.$message.warning('请选择提交的BOM的类型!');
  774. }
  775. this.submit(
  776. this.radioSubmit == 1 ? 'bom_release' : 'bom_release_device'
  777. );
  778. this.isSubmit = false;
  779. // let URL = this.radioSubmit == 1 ? jsBomSubmit : deviceBomSubmit;
  780. // this.$alert('确定要发布吗?', '提示', {
  781. // confirmButtonText: '确定',
  782. // cancelButtonText: '取消',
  783. // type: 'warning'
  784. // })
  785. // .then(() => {
  786. // URL({ businessId: this.JsRId }).then((res) => {
  787. // this.isSubmit = false;
  788. // this.$message.success('发布成功');
  789. // this.reload();
  790. // });
  791. // })
  792. // .catch(() => {});
  793. },
  794. /* 表格数据源 */
  795. datasource({ where, page, limit, sorter }) {
  796. // 序号跨页连续用
  797. this.currentPage = page || 1;
  798. this.currentLimit = limit || this.pageSize || 20;
  799. // 排序用表格维护的 sorter:翻页时 ele-pro-table 会把它一起带过来,不会被重置
  800. const sortProp =
  801. sorter && sorter.order
  802. ? sorter.prop || (sorter.column && sorter.column.prop)
  803. : null;
  804. const sortOrder = sorter && sorter.order ? sorter.order : null;
  805. this.sort = sortProp && sortOrder ? { orderBy: sortOrder, sortName: sortProp } : {};
  806. return getBomPageList({
  807. ...where,
  808. ...this.sort,
  809. bomType: Number(this.activeName),
  810. isTemp: true,
  811. pageNum: page,
  812. size: limit
  813. });
  814. },
  815. handelDetail(row) {
  816. let rowData = {
  817. categoryId: row.categoryId,
  818. categoryName: row.categoryName,
  819. code: row.code,
  820. versions: row.versions,
  821. rootPathIdParent: row.categoryLevelPathIdParent,
  822. isProduct: true,
  823. bomType: Number(this.activeName),
  824. isTemp: row.isTemp
  825. };
  826. this.$refs.bomDrawer.open(rowData);
  827. },
  828. /* 刷新表格 */
  829. reload(where) {
  830. this.$refs.table.reload({ where });
  831. },
  832. handleClick(tab) {
  833. this.activeName = tab.name;
  834. this.reload();
  835. },
  836. onSortChange(e) {
  837. // 排序状态交给表格保存:翻页时 ele-pro-table 会把 sorter 一起带下来,
  838. // 这样“点了表头排序、翻页后又变回默认顺序”的问题就没了。
  839. this.$refs.table.reload({ sorter: { prop: e.prop, order: e.order } });
  840. },
  841. handDel(row) {
  842. this.$confirm('是否确认删除?', '提示', {
  843. confirmButtonText: '确定',
  844. cancelButtonText: '取消',
  845. type: 'warning'
  846. })
  847. .then(() => {
  848. deleteBomTreeList([row.id]).then(() => {
  849. this.reload();
  850. });
  851. })
  852. .catch(() => {
  853. this.$message({
  854. type: 'info',
  855. message: '已取消删除'
  856. });
  857. });
  858. },
  859. handleDetails(row) {
  860. if (!row.processInstanceId) {
  861. this.$message.info('未提交没有审核流程');
  862. } else {
  863. this.$refs.detailRef.open(row.processInstanceId);
  864. }
  865. }
  866. }
  867. };
  868. </script>
  869. <style lang="scss" scoped>
  870. .ele-body {
  871. height: 100%;
  872. ::v-deep .el-card {
  873. height: 100%;
  874. .el-card__body {
  875. height: 100%;
  876. display: flex;
  877. flex-direction: column;
  878. .dict-table {
  879. flex: 1;
  880. overflow: hidden;
  881. display: flex;
  882. flex-direction: column;
  883. .el-table {
  884. flex: 1;
  885. overflow-y: auto;
  886. }
  887. }
  888. }
  889. }
  890. }
  891. </style>