detailsPop.vue 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750
  1. <template>
  2. <div>
  3. <el-drawer
  4. title=""
  5. :visible.sync="drawer"
  6. :custom-class="isFullscreen ? 'not-fullscreen' : 'is-fullscreen'"
  7. :before-close="handleClose"
  8. :with-header="false"
  9. >
  10. <!-- 自定义头部 -->
  11. <div class="custom-drawer-header">
  12. <div class="radio_box rx-cc">
  13. <el-radio-group
  14. size="small"
  15. v-model="currentNodeData.bomType"
  16. @change="bomChange"
  17. >
  18. <el-radio-button :label="4">EBOM </el-radio-button>
  19. <el-radio-button :label="1">PBOM </el-radio-button>
  20. <el-radio-button
  21. :label="2"
  22. v-if="
  23. searchObj.isProduct ||
  24. [1, 9].includes(searchObj.rootPathIdParent)
  25. "
  26. >MBOM
  27. </el-radio-button>
  28. <el-radio-button
  29. :label="3"
  30. v-if="
  31. searchObj.isProduct ||
  32. [1, 9].includes(searchObj.rootPathIdParent)
  33. "
  34. >ABOM
  35. </el-radio-button>
  36. </el-radio-group>
  37. <div style="margin-left: 100px">
  38. <el-button
  39. type="primary"
  40. size="mini"
  41. icon="el-icon-plus"
  42. @click="handleAdd"
  43. >
  44. 新建
  45. </el-button>
  46. <el-button
  47. type="danger"
  48. size="mini"
  49. icon="el-icon-delete"
  50. @click="remove"
  51. >
  52. 删除
  53. </el-button>
  54. <el-button
  55. v-if="currentNodeData.bomType == 1"
  56. type="primary"
  57. size="mini"
  58. icon="el-icon-download"
  59. plain
  60. >导出</el-button
  61. >
  62. <el-button
  63. @click="uploadFile"
  64. v-if="currentNodeData.bomType == 1"
  65. type="primary"
  66. size="mini"
  67. icon="el-icon-upload2"
  68. plain
  69. >导入</el-button
  70. >
  71. <el-button
  72. type="primary"
  73. size="mini"
  74. icon="el-icon-refresh"
  75. plain
  76. @click="transformation('P')"
  77. v-if="currentNodeData.bomType == 4"
  78. >转换PBOM</el-button
  79. >
  80. <el-button
  81. type="primary"
  82. size="mini"
  83. icon="el-icon-refresh"
  84. plain
  85. @click="transformation('E')"
  86. v-if="currentNodeData.bomType == 1"
  87. >转换EBOM</el-button
  88. >
  89. <el-button
  90. type="primary"
  91. size="mini"
  92. icon="el-icon-refresh"
  93. plain
  94. @click="transformation('M')"
  95. v-if="
  96. currentNodeData.bomType == 1 &&
  97. (searchObj.isProduct ||
  98. [1, 9].includes(searchObj.rootPathIdParent))
  99. "
  100. >转换MBOM</el-button
  101. >
  102. <el-button
  103. type="primary"
  104. size="mini"
  105. icon="el-icon-refresh"
  106. plain
  107. @click="transformation('A')"
  108. v-if="
  109. currentNodeData.bomType == 1 &&
  110. (searchObj.isProduct ||
  111. [1, 9].includes(searchObj.rootPathIdParent))
  112. "
  113. >转换ABOM</el-button
  114. >
  115. <el-button
  116. type="primary"
  117. size="mini"
  118. @click="handSubmit"
  119. v-if="
  120. currentNodeData.approvalStatus == 0 ||
  121. currentNodeData.approvalStatus == 3
  122. "
  123. >
  124. 提交发布
  125. </el-button>
  126. <el-button
  127. type="primary"
  128. size="mini"
  129. @click="handleSave"
  130. v-if="currentNodeData.status != 1"
  131. >
  132. 保存
  133. </el-button>
  134. </div>
  135. </div>
  136. <div>
  137. <el-button
  138. type="text"
  139. @click="handleDetails()"
  140. v-if="isNotData && currentNodeData.approvalStatus == 1"
  141. :underline="false"
  142. >
  143. {{ approvalStatusOpt[+currentNodeData.approvalStatus] }}
  144. </el-button>
  145. <el-button
  146. type="text"
  147. style="color: #f56c6c"
  148. v-if="isNotData && currentNodeData.approvalStatus == 3"
  149. :underline="false"
  150. >
  151. {{ approvalStatusOpt[+currentNodeData.approvalStatus] }}
  152. </el-button>
  153. <el-button
  154. icon="el-icon-full-screen"
  155. type="text"
  156. @click="handleFull"
  157. >{{ isFullscreen ? '全屏' : '缩小' }}</el-button
  158. >
  159. <el-button
  160. icon="el-icon-circle-close"
  161. type="text"
  162. @click="handleClose"
  163. >关闭</el-button
  164. >
  165. </div>
  166. </div>
  167. <!-- 抽屉内容 -->
  168. <div class="drawer_content">
  169. <ele-split-layout
  170. width="260px"
  171. allow-collapse
  172. :resizable="true"
  173. :min-size="200"
  174. :max-size="-200"
  175. :left-style="{
  176. overflow: 'hidden',
  177. width: '100%'
  178. }"
  179. :right-style="{ overflow: 'hidden' }"
  180. :responsive="false"
  181. >
  182. <div class="ele-border-lighter sys-organization-list">
  183. <div>
  184. 版本号: &nbsp; &nbsp;
  185. <el-select
  186. size="mini"
  187. style="width: 72%; margin: 6px 0"
  188. v-model="searchObj.versions"
  189. placeholder="请选择bom版本"
  190. @change="getTreeData"
  191. >
  192. <el-option
  193. v-for="item in versList"
  194. :label="'V' + item.versions + '.0'"
  195. :value="item.versions"
  196. :key="item.id"
  197. >
  198. </el-option>
  199. </el-select>
  200. </div>
  201. <el-tree
  202. class="treeData"
  203. :data="treeList"
  204. :expand-on-click-node="false"
  205. :props="defaultProps"
  206. ref="treeRef"
  207. :default-expanded-keys="current && current.id ? [current.id] : []"
  208. :highlight-current="true"
  209. node-key="id"
  210. @node-click="handleNodeClick"
  211. >
  212. <span class="custom-tree-node" slot-scope="{ node, data }">
  213. {{ node.label }} / {{ data.code }}
  214. </span>
  215. </el-tree>
  216. </div>
  217. <template v-slot:content v-if="isNotData">
  218. <baseInfo :dataInfo="currentNodeData" />
  219. <el-tabs
  220. v-model="activeName"
  221. class="tab-box"
  222. type="border-card"
  223. @tab-click="handleClick"
  224. >
  225. <el-tab-pane label="属性" name="属性">
  226. <attribute :attributeData="currentNodeData"></attribute>
  227. </el-tab-pane>
  228. <el-tab-pane
  229. :label="
  230. currentNodeData.bomType == 1
  231. ? 'PBOM明细表'
  232. : currentNodeData.bomType == 2
  233. ? 'MBOM明细表'
  234. : currentNodeData.bomType == 3
  235. ? 'ABOM明细表'
  236. : 'EBOM明细表'
  237. "
  238. name="明细表"
  239. >
  240. <detailedList
  241. v-if="activeName == '明细表'"
  242. :attributeData="currentNodeData"
  243. :treeId="treeId"
  244. ></detailedList>
  245. </el-tab-pane>
  246. <el-tab-pane
  247. label="工艺路线"
  248. name="工艺路线"
  249. v-if="currentNodeData.bomType != 4"
  250. >
  251. <routing
  252. v-if="activeName == '工艺路线'"
  253. ref="routingRef"
  254. :attributeData="currentNodeData"
  255. :taskParam="currentNodeData"
  256. ></routing>
  257. </el-tab-pane>
  258. <el-tab-pane
  259. label="工序配置"
  260. name="工序配置"
  261. v-if="
  262. currentNodeData.bomType != 4 &&
  263. (searchObj.isProduct ||
  264. [1, 9].includes(searchObj.rootPathIdParent))
  265. "
  266. >
  267. <workmanship
  268. v-if="activeName == '工序配置'"
  269. ref="workmanshipRef"
  270. :attributeData="currentNodeData"
  271. :taskParam="currentNodeData"
  272. ></workmanship>
  273. </el-tab-pane>
  274. </el-tabs>
  275. </template>
  276. <template v-slot:content v-else>
  277. <el-empty
  278. :image-size="200"
  279. :description="
  280. currentNodeData.bomType == 1
  281. ? 'PBOM 暂无数据,请先新建'
  282. : currentNodeData.bomType == 2
  283. ? 'MBOM 暂无数据,请先新建'
  284. : currentNodeData.bomType == 3
  285. ? 'ABOM 暂无数据,请先新建'
  286. : 'EBOM 暂无数据,请先新建'
  287. "
  288. ></el-empty>
  289. </template>
  290. </ele-split-layout>
  291. </div>
  292. </el-drawer>
  293. <baseInfoSave
  294. v-if="baseInfoShow"
  295. @close="baseClose"
  296. :categoryObj="currentNodeData"
  297. :categoryId="searchObj.categoryId"
  298. :categoryName="searchObj.categoryName"
  299. ></baseInfoSave>
  300. <importDialog
  301. :defModule="moudleName"
  302. ref="importDialogRef"
  303. @success="getTreeData"
  304. />
  305. <el-dialog
  306. title="发布"
  307. :visible.sync="isSubmit"
  308. v-if="isSubmit"
  309. width="30%"
  310. center
  311. >
  312. <div>
  313. <el-radio v-model="radioSubmit" :label="1">药品</el-radio>
  314. <el-radio v-model="radioSubmit" :label="2">器械</el-radio>
  315. </div>
  316. <span slot="footer" class="dialog-footer">
  317. <el-button @click="isSubmit = false">取 消</el-button>
  318. <el-button type="primary" @click="handJsSubmit()">确 定</el-button>
  319. </span>
  320. </el-dialog>
  321. <LCdetail ref="detailRef"></LCdetail>
  322. </div>
  323. </template>
  324. <script>
  325. import {
  326. getBomTreeList,
  327. versionList,
  328. getBomGetById,
  329. convert,
  330. convertABom,
  331. convertEBOM,
  332. convertEBomToPBOM,
  333. deleteBomTreeList,
  334. bomSubmit,
  335. jsBomSubmit,
  336. deviceBomSubmit,
  337. hasNewVersion
  338. } from '@/api/material/BOM.js';
  339. import baseInfo from './components/baseInfo.vue';
  340. import baseInfoSave from './components/baseInfoSave.vue';
  341. import attribute from './components/attribute.vue';
  342. import detailedList from './components/detailedList.vue';
  343. import importDialog from './qualityTesting/import-dialog.vue';
  344. import LCdetail from './components/LCdetail.vue';
  345. import routing from './components/routing.vue';
  346. import workmanship from './components/workmanship.vue';
  347. export default {
  348. components: {
  349. baseInfo,
  350. baseInfoSave,
  351. attribute,
  352. detailedList,
  353. importDialog,
  354. LCdetail,
  355. routing,
  356. workmanship
  357. },
  358. data() {
  359. return {
  360. drawer: false,
  361. isFullscreen: true,
  362. currentNodeData: {
  363. bomType: 1,
  364. children: []
  365. },
  366. current: {},
  367. treeList: [],
  368. versList: [],
  369. treeLoading: false,
  370. defaultProps: {
  371. children: 'children',
  372. label: 'name'
  373. },
  374. searchObj: {
  375. versions: '',
  376. categoryId: '',
  377. isProduct: false,
  378. isTemp: 0
  379. },
  380. activeName: '属性',
  381. baseInfoShow: false,
  382. isNotData: true,
  383. moudleName: 'mainUser',
  384. isSubmit: false,
  385. radioSubmit: 1,
  386. treeId: null,
  387. approvalStatusOpt: {
  388. 0: '未提交',
  389. 1: '审核中',
  390. 2: '审核通过',
  391. 3: '审核不通过'
  392. }
  393. };
  394. },
  395. computed: {
  396. clientEnvironmentId() {
  397. return this.$store.state.user.info.clientEnvironmentId;
  398. }
  399. },
  400. methods: {
  401. open(row) {
  402. this.searchObj = row;
  403. if (Object.prototype.hasOwnProperty.call(row, 'bomType')) {
  404. this.currentNodeData.bomType = row.bomType;
  405. }
  406. this.drawer = true;
  407. this.getTreeData();
  408. this.getVersion();
  409. },
  410. handleClose() {
  411. this.searchObj = {
  412. versions: '',
  413. categoryId: '',
  414. isProduct: false,
  415. isTemp: 0
  416. };
  417. this.activeName = '属性';
  418. this.drawer = false;
  419. },
  420. handleFull() {
  421. this.isFullscreen = !this.isFullscreen;
  422. this.$forceUpdate();
  423. },
  424. bomChange(e) {
  425. this.searchObj.versions = '';
  426. this.currentNodeData.bomType = e;
  427. this.getTreeData();
  428. this.getVersion();
  429. },
  430. async getTreeData() {
  431. try {
  432. this.treeLoading = true;
  433. const res = await getBomTreeList({
  434. categoryId: this.searchObj.categoryId,
  435. versions: this.searchObj.versions,
  436. bomType: this.currentNodeData.bomType,
  437. isTemp: this.searchObj.isTemp
  438. });
  439. this.treeLoading = false;
  440. if (res?.code === '0') {
  441. if (res.data?.length > 0) {
  442. this.treeList = res.data;
  443. this.$nextTick(() => {
  444. this.isNotData = true;
  445. // 默认高亮第一个
  446. this.$refs.treeRef.setCurrentKey(res.data[0].id);
  447. this.handleNodeClick(res.data[0]);
  448. });
  449. } else {
  450. this.isNotData = false;
  451. this.treeList = [];
  452. }
  453. return this.treeList;
  454. }
  455. } catch (error) {
  456. console.log(error);
  457. }
  458. this.treeLoading = false;
  459. },
  460. handleNodeClick(data) {
  461. this.treeId = data.id;
  462. this.handBomDetails(data.id);
  463. },
  464. handBomDetails(id) {
  465. if (id) {
  466. getBomGetById(id).then((res) => {
  467. this.currentNodeData = res.data;
  468. this.searchObj.versions = this.currentNodeData.versions;
  469. this.$forceUpdate();
  470. });
  471. } else {
  472. this.currentNodeData = {
  473. bomType: 1,
  474. children: []
  475. };
  476. }
  477. },
  478. getVersion(type) {
  479. let param = {
  480. categoryId: this.searchObj.categoryId,
  481. bomType: this.currentNodeData.bomType,
  482. isTemp: this.searchObj.isTemp || 0
  483. };
  484. versionList(param).then((res) => {
  485. this.versList = res || [];
  486. if (type == 'del' || type == 'add') {
  487. if (this.versList.length >= 1) {
  488. this.searchObj.versions =
  489. this.versList[this.versList.length - 1].versions;
  490. } else {
  491. this.searchObj.versions = '';
  492. }
  493. this.getTreeData();
  494. }
  495. });
  496. },
  497. handleClick(tab) {},
  498. remove() {
  499. if (this.currentNodeData.status == 1) {
  500. return this.$message.warning('已发布版本不能删除');
  501. }
  502. this.$confirm('是否确认删除?', '提示', {
  503. confirmButtonText: '确定',
  504. cancelButtonText: '取消',
  505. type: 'warning'
  506. })
  507. .then(() => {
  508. deleteBomTreeList([this.currentNodeData.id]).then((msg) => {
  509. this.$message.success('删除' + msg);
  510. this.getVersion('del');
  511. });
  512. })
  513. .finally(() => {});
  514. },
  515. async transformation(tt) {
  516. if (this.currentNodeData.status != 1) {
  517. return this.$message.warning('只有已发布版本才可以转换');
  518. }
  519. let _type = tt == 'P' ? 1 : tt == 'M' ? 2 : tt == 'A' ? 3 : 4;
  520. if (!this.isEdit) {
  521. let isHas = await this.hasVersionFn(_type);
  522. if (!isHas) return;
  523. }
  524. this.loadingInstance = this.$loading({
  525. lock: true,
  526. text: '转换中...',
  527. background: 'rgba(0, 0, 0, 0.7)'
  528. });
  529. let ULR =
  530. tt == 'M'
  531. ? convert
  532. : tt == 'A'
  533. ? convertABom
  534. : tt == 'E'
  535. ? convertEBOM
  536. : tt == 'P'
  537. ? convertEBomToPBOM
  538. : '';
  539. ULR({
  540. versions: this.searchObj.versions,
  541. categoryId: this.searchObj.categoryId
  542. }).then((data) => {
  543. if (data.code == '0') {
  544. this.loadingInstance.close();
  545. this.$message.success('转换成功');
  546. this.currentNodeData.bomType = _type;
  547. this.getTreeData();
  548. this.getVersion();
  549. }
  550. });
  551. },
  552. handleAdd() {
  553. this.baseInfoShow = true;
  554. },
  555. baseClose(val) {
  556. if (val) {
  557. this.getVersion('add');
  558. }
  559. this.activeName = '属性';
  560. this.baseInfoShow = false;
  561. },
  562. uploadFile() {
  563. this.$refs.importDialogRef.open();
  564. },
  565. handleSave() {
  566. this.$message.success('保存成功');
  567. this.handleClose();
  568. },
  569. handSubmit() {
  570. if (this.clientEnvironmentId == 4) {
  571. this.isSubmit = true;
  572. } else {
  573. this.$alert('确定要发布吗?', '提示', {
  574. confirmButtonText: '确定',
  575. cancelButtonText: '取消',
  576. type: 'warning'
  577. })
  578. .then(() => {
  579. bomSubmit({ businessId: this.currentNodeData.id }).then((res) => {
  580. if (res?.code == 0) {
  581. this.$message.success('发布成功');
  582. this.getTreeData();
  583. }
  584. });
  585. })
  586. .catch(() => {});
  587. }
  588. },
  589. handJsSubmit() {
  590. let URL = this.radioSubmit == 1 ? jsBomSubmit : deviceBomSubmit;
  591. this.$alert('确定要发布吗?', '提示', {
  592. confirmButtonText: '确定',
  593. cancelButtonText: '取消',
  594. type: 'warning'
  595. })
  596. .then(() => {
  597. URL({ businessId: this.currentNodeData.id }).then((res) => {
  598. this.isSubmit = false;
  599. this.$message.success('发布成功');
  600. this.getTreeData();
  601. });
  602. })
  603. .catch(() => {});
  604. },
  605. handleDetails() {
  606. if (!this.currentNodeData.processInstanceId) {
  607. this.$message.info('未提交没有审核流程');
  608. } else {
  609. this.$refs.detailRef.open(this.currentNodeData.processInstanceId);
  610. }
  611. },
  612. async hasVersionFn(bomType) {
  613. return new Promise((resolve) => {
  614. let param = {
  615. categoryId: this.searchObj.categoryId,
  616. bomType: bomType
  617. };
  618. hasNewVersion(param).then((res) => {
  619. if (res.data == 1) {
  620. this.$confirm('已经草稿版本存在,是否覆盖?', '提示', {
  621. confirmButtonText: '覆盖',
  622. cancelButtonText: '取消',
  623. type: 'warning'
  624. })
  625. .then(() => {
  626. resolve(true);
  627. })
  628. .catch(() => {
  629. resolve(false);
  630. });
  631. } else {
  632. resolve(true);
  633. }
  634. });
  635. });
  636. }
  637. }
  638. };
  639. </script>
  640. <style lang="scss" scoped>
  641. /* 自定义全屏样式 */
  642. ::v-deep .is-fullscreen {
  643. width: 100vw !important;
  644. height: 100vh !important;
  645. overflow: hidden !important; /* 隐藏滚动条 */
  646. }
  647. ::v-deep .not-fullscreen {
  648. width: calc(100vw - 260px) !important;
  649. height: 100vh !important;
  650. overflow: hidden !important; /* 隐藏滚动条 */
  651. }
  652. .custom-drawer-header {
  653. display: flex;
  654. justify-content: space-between;
  655. align-items: center;
  656. padding: 4px 15px;
  657. background-color: #f5f7fa; /* 自定义背景色 */
  658. border-bottom: 1px solid #ebeef5; /* 自定义边框,与抽屉内容分隔 */
  659. }
  660. .drawer_content {
  661. margin: 10px 20px;
  662. box-sizing: border-box;
  663. }
  664. .sys-organization-list {
  665. height: calc(100vh - 65px);
  666. box-sizing: border-box;
  667. border-width: 1px;
  668. border-style: solid;
  669. overflow: auto;
  670. padding: 0 10px;
  671. box-sizing: border-box;
  672. display: flex;
  673. flex-direction: column;
  674. overflow: hidden;
  675. .treeData {
  676. height: 0 1 auto;
  677. overflow-y: auto;
  678. }
  679. }
  680. .tab-box {
  681. margin-top: 12px;
  682. }
  683. </style>