link-msg.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549
  1. <template>
  2. <div class="link-msg">
  3. <headerTitle title="关联信息"></headerTitle>
  4. <el-tabs v-model="activeTab">
  5. <el-tab-pane label="可用模具">
  6. <ele-pro-table :columns="moduleColumn" :datasource="moduleData">
  7. </ele-pro-table>
  8. </el-tab-pane>
  9. <el-tab-pane label="BOM">
  10. <ele-pro-table :columns="BOMColumn" :datasource="bomData">
  11. </ele-pro-table
  12. ></el-tab-pane>
  13. <el-tab-pane label="工艺路线">
  14. <ele-pro-table :columns="pathColumn" :datasource="pathData">
  15. <template v-slot:bomCategoryType="{ row }">
  16. {{
  17. row.bomCategoryType == 2
  18. ? 'MBOM'
  19. : row.bomCategoryType == 1
  20. ? 'PBOM'
  21. : row.bomCategoryType == 3
  22. ? 'ABom'
  23. : ''
  24. }}
  25. </template>
  26. </ele-pro-table></el-tab-pane
  27. >
  28. <!-- <el-tab-pane label="质量标准"></el-tab-pane> -->
  29. <!-- <el-tab-pane label="文件">
  30. <ele-pro-table :columns="fileColumn" :datasource="[]"> </ele-pro-table
  31. ></el-tab-pane> -->
  32. <el-tab-pane label="关联设备">
  33. <ele-pro-table :columns="equiColumn" :datasource="eqData">
  34. </ele-pro-table
  35. ></el-tab-pane>
  36. <el-tab-pane label="供应商">
  37. <ele-pro-table
  38. :columns="supplierColumn"
  39. :datasource="supplierData"
  40. :need-page="false"
  41. ref="supplierRef"
  42. >
  43. <template v-slot:toolbar>
  44. <el-button
  45. size="small"
  46. type="primary"
  47. icon="el-icon-plus"
  48. class="ele-btn-icon"
  49. @click="handParent()"
  50. v-if="id && !disabled"
  51. >
  52. 添加供应商
  53. </el-button>
  54. </template>
  55. <!-- 操作列 -->
  56. <template v-slot:action="{ row }">
  57. <el-popconfirm
  58. class="ele-action"
  59. title="确定要删除此供应商吗?"
  60. @confirm="deleteSupplie(row)"
  61. v-if="!disabled"
  62. >
  63. <template v-slot:reference>
  64. <el-link type="danger" :underline="false" icon="el-icon-delete">
  65. 删除
  66. </el-link>
  67. </template>
  68. </el-popconfirm>
  69. </template>
  70. </ele-pro-table>
  71. </el-tab-pane>
  72. <el-tab-pane label="生产厂家">
  73. <ele-pro-table
  74. :columns="supplierColumn"
  75. :datasource="manufacturerData"
  76. :need-page="false"
  77. ref="supplierRef"
  78. >
  79. <template v-slot:toolbar>
  80. <el-button
  81. size="small"
  82. type="primary"
  83. icon="el-icon-plus"
  84. class="ele-btn-icon"
  85. @click="handParent()"
  86. v-if="id && !disabled"
  87. >
  88. 添加生产厂家
  89. </el-button>
  90. </template>
  91. </ele-pro-table>
  92. </el-tab-pane>
  93. <el-tab-pane label="客户">
  94. <ele-pro-table
  95. :columns="supplierColumn"
  96. :datasource="contactData"
  97. :need-page="false"
  98. ref="supplierRef"
  99. >
  100. <template v-slot:toolbar>
  101. <el-button
  102. size="small"
  103. type="primary"
  104. icon="el-icon-plus"
  105. class="ele-btn-icon"
  106. @click="handParent()"
  107. v-if="id && !disabled"
  108. >
  109. 添加客户
  110. </el-button>
  111. </template>
  112. </ele-pro-table>
  113. </el-tab-pane>
  114. </el-tabs>
  115. <vendorDialog
  116. ref="vendorDialogRef"
  117. :is-all="true"
  118. @success="success"
  119. :ids="ids"
  120. :title="title"
  121. ></vendorDialog>
  122. </div>
  123. </template>
  124. <script>
  125. import {
  126. getBomRoutingList,
  127. getBomAssociationList
  128. } from '@/api/material/list.js';
  129. import { saveSupplier, deleteSupplie } from '@/api/material/BOM.js';
  130. import { getRelatesInformationList } from '@/api/material/product.js';
  131. import dictMixins from '@/mixins/dictMixins';
  132. import storage from '@/api/warehouseManagement/index.js';
  133. //供应商弹窗
  134. import vendorDialog from '@/views/factoryModel/qualificationManagement/components/vendorDialog.vue';
  135. export default {
  136. mixins: [dictMixins],
  137. props: {
  138. id: [Number, String],
  139. categoryLevelId: [Number, String],
  140. code: [Number, String],
  141. categoryLevelGroupId: [Number, String],
  142. disabled: {
  143. type: Boolean,
  144. default: false
  145. }
  146. },
  147. components: {
  148. vendorDialog
  149. },
  150. data() {
  151. return {
  152. activeTab: '0',
  153. moduleColumn: [
  154. {
  155. type: 'index',
  156. label: '序号',
  157. width: '55px',
  158. align: 'center'
  159. },
  160. {
  161. label: '编码',
  162. prop: 'code'
  163. },
  164. {
  165. label: '名称',
  166. prop: 'name'
  167. },
  168. {
  169. label: '牌号',
  170. prop: 'brandNum'
  171. },
  172. {
  173. label: '型号',
  174. prop: 'modelType'
  175. },
  176. {
  177. label: '收缩系数',
  178. prop: 'extendInfo.shrinkEffictive'
  179. },
  180. {
  181. label: '大模体型号',
  182. prop: 'extendInfo.maxMoldType'
  183. },
  184. // {
  185. // label: '物品类型',
  186. // prop: ''
  187. // },
  188. {
  189. label: '分类',
  190. prop: 'categoryLevelGroupName'
  191. }
  192. ],
  193. BOMColumn: [
  194. {
  195. label: 'BOM编码',
  196. prop: 'code'
  197. },
  198. {
  199. label: 'BOM名称',
  200. prop: 'name'
  201. },
  202. {
  203. label: '版本号',
  204. prop: 'versions'
  205. },
  206. {
  207. label: '基本数量',
  208. prop: 'baseCount'
  209. },
  210. {
  211. label: '单位',
  212. prop: 'unit'
  213. }
  214. ],
  215. pathColumn: [
  216. {
  217. label: 'BOM编码',
  218. prop: 'bomCategoryCode'
  219. },
  220. {
  221. label: 'BOM名称',
  222. prop: 'bomCategoryName'
  223. },
  224. {
  225. slot: 'bomCategoryType',
  226. label: 'BOM类型',
  227. showOverflowTooltip: true
  228. },
  229. {
  230. label: 'BOM版本',
  231. prop: 'bomCategoryVersion'
  232. },
  233. {
  234. label: '工艺路线编码',
  235. prop: 'code'
  236. },
  237. {
  238. label: '工艺路线名称',
  239. prop: 'name'
  240. },
  241. {
  242. label: '工艺类型',
  243. prop: 'produceVersionName'
  244. },
  245. {
  246. label: '工艺路线版本',
  247. prop: 'version'
  248. }
  249. ],
  250. fileColumn: [
  251. {
  252. label: '文件编码'
  253. },
  254. {
  255. label: '文件名称'
  256. }
  257. ],
  258. equiColumn: [
  259. // {
  260. // type: 'selection'
  261. // },
  262. {
  263. label: '设备分类',
  264. prop: 'categoryLevelGroupName'
  265. },
  266. {
  267. label: '设备编码',
  268. prop: 'code'
  269. },
  270. {
  271. label: '设备名称',
  272. prop: 'name'
  273. },
  274. {
  275. label: '产能',
  276. formatter: (row) => {
  277. return (
  278. row.quantity &&
  279. `${row.quantity}/${this.getDictValue(
  280. '重量单位',
  281. row.quantityUnitId
  282. )}`
  283. );
  284. }
  285. }
  286. ],
  287. supplierColumn: [
  288. {
  289. prop: 'code',
  290. label: '编码',
  291. align: 'center',
  292. showOverflowTooltip: true,
  293. minWidth: 140
  294. },
  295. {
  296. prop: 'name',
  297. label: '名称',
  298. align: 'center',
  299. slot: 'name',
  300. showOverflowTooltip: true,
  301. minWidth: 200
  302. },
  303. {
  304. prop: 'serialNo',
  305. label: '代号',
  306. align: 'center',
  307. showOverflowTooltip: true,
  308. minWidth: 140
  309. },
  310. {
  311. prop: 'phone',
  312. label: '电话',
  313. align: 'center',
  314. showOverflowTooltip: true,
  315. minWidth: 120
  316. },
  317. {
  318. prop: 'addressName',
  319. label: '注册地址',
  320. align: 'center',
  321. showOverflowTooltip: true,
  322. minWidth: 120,
  323. formatter: (_row, _column, cellValue) => {
  324. return (
  325. (_row.addressName ? _row.addressName.replaceAll(',', '') : '') +
  326. (_row.address || '')
  327. );
  328. }
  329. },
  330. {
  331. prop: 'otherAddressName',
  332. label: '联系地址',
  333. align: 'center',
  334. showOverflowTooltip: true,
  335. minWidth: 120,
  336. formatter: (_row, _column, cellValue) => {
  337. return (
  338. (_row.otherAddressName
  339. ? _row.otherAddressName.replaceAll(',', '')
  340. : '') + (_row.otherAddress || '')
  341. );
  342. }
  343. },
  344. {
  345. prop: 'linkName',
  346. label: '联系人',
  347. align: 'center',
  348. showOverflowTooltip: true,
  349. minWidth: 120
  350. },
  351. {
  352. prop: 'linkPhone',
  353. label: '联系人电话',
  354. align: 'center',
  355. showOverflowTooltip: true,
  356. minWidth: 120
  357. },
  358. {
  359. prop: 'status',
  360. label: '状态',
  361. align: 'center',
  362. showOverflowTooltip: true,
  363. minWidth: 100,
  364. formatter: (_row, _column, cellValue) => {
  365. return _row.status === 1 ? '启用' : '禁用';
  366. }
  367. },
  368. {
  369. prop: 'createUsername',
  370. label: '创建人',
  371. align: 'center',
  372. showOverflowTooltip: true,
  373. minWidth: 100
  374. },
  375. {
  376. prop: 'createTime',
  377. label: '创建时间',
  378. align: 'center',
  379. showOverflowTooltip: true,
  380. minWidth: 160,
  381. formatter: (_row, _column, cellValue) => {
  382. return this.$util.toDateString(cellValue);
  383. }
  384. }
  385. ],
  386. moduleData: [],
  387. eqData: [],
  388. bomData: [],
  389. pathData: [],
  390. supplierData: [], //供应商
  391. manufacturerData: [], //生产厂家
  392. contactData: [], //客户
  393. ids: '',
  394. title: ''
  395. };
  396. },
  397. watch: {
  398. id: {
  399. handler(val) {
  400. if (val) {
  401. this.getBomData();
  402. this.getRoutingData();
  403. this.contactQueryByCategoryIdsAPI(1);
  404. this.contactQueryByCategoryIdsAPI(2);
  405. this.contactQueryByCategoryIdsAPI(3);
  406. }
  407. },
  408. immediate: true
  409. },
  410. categoryLevelId: {
  411. handler(val) {
  412. if (val) {
  413. this.getModuleData();
  414. this.getEqData();
  415. }
  416. },
  417. immediate: true
  418. }
  419. },
  420. created() {
  421. this.requestDict('重量单位');
  422. },
  423. methods: {
  424. getTableData(data) {
  425. if (Array.isArray(data)) {
  426. return data;
  427. }
  428. if (Array.isArray(data?.list)) {
  429. return data.list;
  430. }
  431. if (Array.isArray(data?.records)) {
  432. return data.records;
  433. }
  434. if (data && typeof data === 'object') {
  435. return Object.values(data).reduce((list, item) => {
  436. return list.concat(Array.isArray(item) ? item : []);
  437. }, []);
  438. }
  439. return [];
  440. },
  441. //BOM列表
  442. async getBomData() {
  443. const data = await getBomAssociationList({
  444. categoryId: this.id,
  445. versions: '',
  446. bomType: 1,
  447. isTemp: 0
  448. });
  449. this.bomData = this.getTableData(data);
  450. },
  451. //工艺路线
  452. async getRoutingData() {
  453. const data = await getBomRoutingList(this.id);
  454. this.pathData = this.getTableData(data);
  455. },
  456. // 关联设备
  457. async getEqData() {
  458. const data = await getRelatesInformationList({
  459. mainCategoryId: this.categoryLevelId,
  460. categoryLevelRootId: 4, //设备
  461. categoryLevelGroupId: this.categoryLevelGroupId
  462. });
  463. this.eqData = this.getTableData(data);
  464. },
  465. // 关联舟皿
  466. async getModuleData() {
  467. const data = await getRelatesInformationList({
  468. mainCategoryId: this.categoryLevelId,
  469. categoryLevelRootId: 5, //模具
  470. categoryLevelGroupId: this.categoryLevelGroupId
  471. });
  472. this.moduleData = this.getTableData(data);
  473. },
  474. // 关联供应商/生产厂家
  475. async contactQueryByCategoryIdsAPI(type) {
  476. const data = await storage.contactQueryByCategoryIdsAPI({
  477. categoryIds: [this.id],
  478. type
  479. });
  480. if (type == 1) {
  481. this.contactData = data[this.id] || [];
  482. }
  483. if (type == 2) {
  484. this.supplierData = data[this.id] || [];
  485. }
  486. if (type == 3) {
  487. this.manufacturerData = data[this.id] || [];
  488. }
  489. },
  490. handParent() {
  491. if (this.activeTab == '4') {
  492. this.ids = '19';
  493. this.title = '选择供应商';
  494. }
  495. if (this.activeTab == '5') {
  496. this.ids = '20250317001';
  497. this.title = '选择生产厂家';
  498. }
  499. if (this.activeTab == '6') {
  500. this.ids = '17';
  501. this.title = '选择客户';
  502. }
  503. this.$refs.vendorDialogRef.open(
  504. this.activeTab == '4'
  505. ? this.supplierData.map((item) => item.id)
  506. : this.activeTab == '5'
  507. ? this.manufacturerData.map((item) => item.id)
  508. : this.contactData.map((item) => item.id)
  509. );
  510. },
  511. success(list) {
  512. saveSupplier({
  513. productId: this.id,
  514. supplierIds: list.map((item) => item.id)
  515. }).then((res) => {
  516. if (this.activeTab == '4') {
  517. this.contactQueryByCategoryIdsAPI(2);
  518. } else if (this.activeTab == '5') {
  519. this.contactQueryByCategoryIdsAPI(3);
  520. } else {
  521. this.contactQueryByCategoryIdsAPI(1);
  522. }
  523. });
  524. },
  525. deleteSupplie(row) {
  526. deleteSupplie({
  527. productId: this.id,
  528. supplierId: row.id
  529. }).then((res) => {
  530. this.contactQueryByCategoryIdsAPI(2);
  531. });
  532. }
  533. }
  534. };
  535. </script>
  536. <style lang="scss" scoped>
  537. .link-msg {
  538. background: #fff;
  539. padding: 1px 17px;
  540. }
  541. </style>