detailsPop.vue 21 KB

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