detailsPop.vue 21 KB

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