details.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530
  1. <template>
  2. <div class="ele-body">
  3. <el-card shadow="never">
  4. <ele-split-layout
  5. width="260px"
  6. allow-collapse
  7. :resizable="true"
  8. :min-size="200"
  9. :max-size="-200"
  10. :left-style="{
  11. overflow: 'hidden',
  12. width: '100%'
  13. }"
  14. :right-style="{ overflow: 'hidden' }"
  15. :responsive="false"
  16. >
  17. <div class="ele-border-lighter sys-organization-list">
  18. <div class="radio_box rx-cc">
  19. <el-radio-group
  20. size="small"
  21. v-model="currentNodeData.bomType"
  22. @change="bomChange"
  23. >
  24. <el-radio-button :label="1"
  25. >PBOM
  26. </el-radio-button>
  27. <el-radio-button
  28. v-if="isProduct || [1, 9].includes(rootPathIdParent)"
  29. :label="2"
  30. >MBOM</el-radio-button
  31. >
  32. <el-radio-button
  33. v-if="isProduct || [1, 9].includes(rootPathIdParent)"
  34. :label="3"
  35. >ABOM</el-radio-button
  36. >
  37. </el-radio-group>
  38. </div>
  39. <el-input
  40. size="small"
  41. placeholder="在结构中查找"
  42. v-model="filterText"
  43. >
  44. </el-input>
  45. <el-tree
  46. class="treeData"
  47. :data="treeList"
  48. :expand-on-click-node="false"
  49. :props="defaultProps"
  50. ref="treeRef"
  51. :default-expanded-keys="current && current.id ? [current.id] : []"
  52. :highlight-current="true"
  53. node-key="id"
  54. @node-click="handleNodeClick"
  55. >
  56. <span class="custom-tree-node" slot-scope="{ node, data }">
  57. {{ node.label }} / {{ data.code }}
  58. </span>
  59. </el-tree>
  60. </div>
  61. <template v-slot:content>
  62. <div class="pbom-box">
  63. <div class="button-list">
  64. <el-dropdown @command="handleDown">
  65. <el-button type="primary" size="mini" icon="el-icon-plus">
  66. 新建<i class="el-icon-arrow-down el-icon--right"></i>
  67. </el-button>
  68. <el-dropdown-menu slot="dropdown">
  69. <el-dropdown-item command="a">新建PBOM</el-dropdown-item>
  70. <el-dropdown-item command="a">新建MBOM</el-dropdown-item>
  71. <el-dropdown-item command="a">新建ABOM</el-dropdown-item>
  72. </el-dropdown-menu>
  73. </el-dropdown>
  74. <el-button
  75. v-if="
  76. (currentNodeData.bomType == 2 ||
  77. currentNodeData.bomType == 3) &&
  78. currentNodeData.children?.length <= 0
  79. "
  80. type="danger"
  81. size="mini"
  82. icon="el-icon-delete"
  83. plain
  84. @click="remove"
  85. >删除</el-button
  86. >
  87. <el-button
  88. v-if="currentNodeData.bomType == 1"
  89. type="primary"
  90. size="mini"
  91. icon="el-icon-download"
  92. plain
  93. >导出</el-button
  94. >
  95. <el-button
  96. @click="uploadFile"
  97. v-if="currentNodeData.bomType == 1"
  98. type="primary"
  99. size="mini"
  100. icon="el-icon-upload2"
  101. plain
  102. >导入</el-button
  103. >
  104. <el-button
  105. type="primary"
  106. size="mini"
  107. icon="el-icon-refresh"
  108. plain
  109. @click="transformation('M')"
  110. v-if="currentNodeData.bomType == 1"
  111. >转换MBOM</el-button
  112. >
  113. <el-button
  114. type="primary"
  115. size="mini"
  116. icon="el-icon-refresh"
  117. plain
  118. @click="transformation('A')"
  119. v-if="currentNodeData.bomType == 1"
  120. >转换ABOM</el-button
  121. >
  122. <div v-if="!noBack" class="back-btn">
  123. <el-button size="mini" icon="el-icon-back" @click="back"
  124. >返回</el-button
  125. >
  126. </div>
  127. </div>
  128. <baseInfo :dataInfo="currentNodeData" />
  129. <el-tabs
  130. v-model="activeName"
  131. class="tab-box"
  132. type="border-card"
  133. @tab-click="handleClick"
  134. >
  135. <el-tab-pane label="属性" name="属性">
  136. <attribute :attributeData="currentNodeData"></attribute>
  137. </el-tab-pane>
  138. <el-tab-pane
  139. :label="
  140. currentNodeData.bomType == 1
  141. ? 'PBOM明细表'
  142. : currentNodeData.bomType == 2
  143. ? 'MBOM明细表'
  144. : 'ABOM明细表'
  145. "
  146. name="明细表"
  147. >
  148. <!-- <document></document> -->
  149. <detailedList :attributeData="currentNodeData"></detailedList>
  150. </el-tab-pane>
  151. <el-tab-pane
  152. label="工艺路线"
  153. name="工艺路线"
  154. v-if="
  155. [1, 9].includes(rootPathIdParent) &&
  156. currentNodeData.bomType != 1
  157. "
  158. >
  159. <routing
  160. ref="routingRef"
  161. :taskParam="currentNodeData"
  162. ></routing>
  163. </el-tab-pane>
  164. <el-tab-pane
  165. label="工序配置"
  166. name="工序配置"
  167. v-if="
  168. [1, 9].includes(rootPathIdParent) &&
  169. currentNodeData.bomType != 1
  170. "
  171. >
  172. <workmanship
  173. ref="workmanshipRef"
  174. :taskParam="currentNodeData"
  175. ></workmanship>
  176. </el-tab-pane>
  177. </el-tabs>
  178. </div>
  179. </template>
  180. </ele-split-layout>
  181. </el-card>
  182. <bomTreeDialog ref="bomTreeDialogRef" @reload="bomTreeDialogReload" />
  183. <importDialog
  184. :defModule="moudleName"
  185. ref="importDialogRef"
  186. @success="reload"
  187. />
  188. </div>
  189. </template>
  190. <script>
  191. import {
  192. getBomTreeList,
  193. getBomGetById,
  194. convert,
  195. convertABom,
  196. convertCBom,
  197. deleteBomTreeList
  198. } from '@/api/material/BOM.js';
  199. import { getTreeByGroup } from '@/api/classifyManage';
  200. import attribute from './components/attribute.vue';
  201. import routing from './components/routing.vue';
  202. import baseInfo from './components/baseInfo.vue';
  203. // import document from './components/document.vue';
  204. import workmanship from './components/workmanship.vue';
  205. import bomTreeDialog from './components/bomTreeDialog.vue';
  206. import importDialog from './qualityTesting/import-dialog.vue';
  207. import detailedList from './components/detailedList.vue';
  208. export default {
  209. name: 'BOMmanage',
  210. components: {
  211. attribute,
  212. baseInfo,
  213. // document,
  214. workmanship,
  215. bomTreeDialog,
  216. routing,
  217. importDialog,
  218. detailedList
  219. },
  220. data() {
  221. return {
  222. activeName: '属性',
  223. currentNodeData: {
  224. bomType: 1,
  225. children: []
  226. },
  227. taskParam: [],
  228. current: {},
  229. treeList: [],
  230. treeLoading: false,
  231. rootTreeId: null,
  232. defaultProps: {
  233. children: 'children',
  234. label: 'name'
  235. },
  236. loading: false,
  237. filterText: null,
  238. categoryId: 1,
  239. versions: null,
  240. loadingInstance: null,
  241. noBack: false,
  242. treeId: null,
  243. moudleName: 'mainUser',
  244. rootPathIdParent: null,
  245. isProduct: false
  246. };
  247. },
  248. watch: {
  249. // 监听$route.query对象的变化
  250. '$route.query': {
  251. immediate: true, // 启用立即执行
  252. handler(newQuery, oldQuery) {
  253. this.rootPathIdParent = Number(newQuery.categoryLevelPathIdParent);
  254. this.isProduct = newQuery.isProduct == 'true' ? true : false;
  255. }
  256. }
  257. },
  258. mounted() {
  259. this.initData();
  260. },
  261. activated() {
  262. this.initData();
  263. },
  264. methods: {
  265. bomTreeDialogReload(versions) {
  266. this.versions = versions;
  267. if (!this.$route.query.versions) {
  268. this.$router.replace({
  269. path: '/material/BOMmanage/details',
  270. query: { categoryId: this.categoryId, versions: versions }
  271. });
  272. }
  273. this.getTreeData();
  274. },
  275. initData() {
  276. this.versions = this.$route.query.versions;
  277. this.categoryId = this.$route.query.categoryId;
  278. this.noBack = this.$route.query.noBack;
  279. if (!this.isProduct) {
  280. this.currentNodeData = {
  281. bomType: 2,
  282. children: []
  283. };
  284. } else {
  285. this.currentNodeData = {
  286. bomType: this.$route.query.bType || 1,
  287. children: []
  288. };
  289. }
  290. this.getTreeData();
  291. },
  292. handleClick(tab) {
  293. if (
  294. tab.name === '工艺路线' &&
  295. this.currentNodeData.children?.length < 1
  296. ) {
  297. this.$refs.routingRef.reload();
  298. }
  299. if (
  300. tab.name === '工序配置' &&
  301. this.currentNodeData.children?.length < 1
  302. ) {
  303. this.$refs.workmanshipRef.reload();
  304. }
  305. },
  306. remove() {
  307. this.$confirm('是否确认删除?', '提示', {
  308. confirmButtonText: '确定',
  309. cancelButtonText: '取消',
  310. type: 'warning'
  311. })
  312. .then(() => {
  313. const loading = this.$loading({ lock: true });
  314. deleteBomTreeList([this.currentNodeData.id])
  315. .then((msg) => {
  316. loading.close();
  317. this.$message.success('删除' + msg);
  318. this.getTreeData();
  319. })
  320. .catch((e) => {
  321. loading.close();
  322. });
  323. })
  324. .catch(() => {
  325. this.$message({
  326. type: 'info',
  327. message: '已取消删除'
  328. });
  329. });
  330. },
  331. bomChange(e) {
  332. this.currentNodeData.bomType = e;
  333. this.getTreeData();
  334. },
  335. back() {
  336. this.$router.go(-1);
  337. },
  338. transformation(tt) {
  339. this.loadingInstance = this.$loading({
  340. lock: true,
  341. text: '转换中...',
  342. background: 'rgba(0, 0, 0, 0.7)'
  343. });
  344. let ULR = tt == 'M' ? convert : tt == 'A' ? convertABom : '';
  345. ULR({ versions: this.versions, categoryId: this.categoryId }).then(
  346. (data) => {
  347. if (data.code == '0') {
  348. this.loadingInstance.close();
  349. this.$message.success('转换成功');
  350. }
  351. }
  352. );
  353. },
  354. handleDown(command) {
  355. this.add();
  356. },
  357. add() {
  358. this.$refs.bomTreeDialogRef.open(
  359. this.currentNodeData.bomType,
  360. this.versions,
  361. this.categoryId,
  362. this.treeId
  363. );
  364. },
  365. async getTreeData() {
  366. try {
  367. this.treeLoading = true;
  368. const res = await getBomTreeList({
  369. categoryId: this.categoryId,
  370. versions: this.versions,
  371. bomType: this.currentNodeData.bomType,
  372. isTemp: this.$route.query.isTemp == '1' ? 1 : 0
  373. });
  374. this.treeLoading = false;
  375. if (res?.code === '0') {
  376. if (res.data?.length > 0) {
  377. this.treeList = res.data;
  378. this.$nextTick(() => {
  379. // 默认高亮第一个
  380. this.$refs.treeRef.setCurrentKey(res.data[0].id);
  381. this.handleNodeClick(res.data[0]);
  382. });
  383. } else {
  384. this.treeList = [];
  385. }
  386. return this.treeList;
  387. }
  388. } catch (error) {
  389. console.log(error);
  390. }
  391. this.treeLoading = false;
  392. },
  393. handleNodeClick(data) {
  394. this.treeId = data.id;
  395. this.handBomDetails(data.id);
  396. },
  397. handBomDetails(id) {
  398. if (id) {
  399. getBomGetById(id).then((res) => {
  400. // this.versions = res.data.versions;
  401. this.currentNodeData = res.data;
  402. if (
  403. this.activeName == '工艺路线' &&
  404. this.currentNodeData.children?.length < 1
  405. ) {
  406. this.$nextTick(() => {
  407. this.$refs.routingRef.reload();
  408. });
  409. }
  410. if (
  411. this.activeName == '工序配置' &&
  412. this.currentNodeData.children?.length < 1
  413. ) {
  414. this.$nextTick(() => {
  415. this.$refs.workmanshipRef.reload();
  416. });
  417. }
  418. });
  419. } else {
  420. this.currentNodeData = {
  421. bomType: 1,
  422. children: []
  423. };
  424. }
  425. },
  426. uploadFile() {
  427. this.$refs.importDialogRef.open();
  428. },
  429. reload(where) {
  430. this.getTreeData();
  431. }
  432. }
  433. };
  434. </script>
  435. <style lang="scss" scoped>
  436. .sys-organization-list {
  437. height: calc(100vh - 165px);
  438. box-sizing: border-box;
  439. border-width: 1px;
  440. border-style: solid;
  441. overflow: auto;
  442. padding: 0 10px;
  443. box-sizing: border-box;
  444. display: flex;
  445. flex-direction: column;
  446. overflow: hidden;
  447. .treeData {
  448. height: 0 1 auto;
  449. overflow-y: auto;
  450. }
  451. }
  452. .pbom-box,
  453. .mbom-box {
  454. height: calc(100vh - 165px);
  455. display: flex;
  456. flex-direction: column;
  457. .tab-box {
  458. flex: 1;
  459. display: flex;
  460. flex-direction: column;
  461. overflow: hidden;
  462. ::v-deep .el-tabs__content {
  463. flex: 1;
  464. overflow-y: auto !important;
  465. .table_box {
  466. height: 100%;
  467. }
  468. }
  469. }
  470. }
  471. .radio_box {
  472. margin: 12px 0;
  473. ::v-deep .el-radio-group {
  474. width: 100%;
  475. display: flex;
  476. .el-radio-button {
  477. flex: 1;
  478. > span {
  479. width: 100%;
  480. }
  481. }
  482. }
  483. }
  484. .sys-organization-list :deep(.el-tree-node__content) {
  485. height: 30px;
  486. & > .el-tree-node__expand-icon {
  487. margin-left: 4px;
  488. }
  489. }
  490. .button-list {
  491. display: flex;
  492. align-items: center;
  493. background-color: #f4f4f4;
  494. border: 1px solid #e3e5e5;
  495. padding: 10px;
  496. box-sizing: border-box;
  497. border-bottom: 0;
  498. .back-btn {
  499. flex: 1;
  500. text-align: right;
  501. }
  502. }
  503. </style>