details.vue 13 KB

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