You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

1241 lines
41 KiB

2 years ago
2 years ago
1 year ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
1 year ago
2 years ago
1 year ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
1 year ago
2 years ago
2 years ago
1 year ago
2 years ago
2 years ago
1 year ago
2 years ago
2 years ago
1 year ago
1 year ago
1 year ago
2 years ago
2 years ago
1 year ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
1 year ago
2 years ago
2 years ago
1 year ago
2 years ago
2 years ago
2 years ago
1 year ago
1 year ago
2 years ago
2 years ago
2 years ago
1 year ago
2 years ago
1 year ago
2 years ago
  1. <script>
  2. import {
  3. removeExternalPart,
  4. saveExternalPart,
  5. selectExternalPartList,
  6. selectUnitList,
  7. updateExternalPart
  8. } from '../../../api/part/external'
  9. import dayjs from 'dayjs'
  10. import PictureModule from './picture/picture.vue'
  11. import LinkedCustomer from './customer/linkedCustomer.vue'
  12. import {getExternalPartCustomerList} from '../../../api/part/externalPartCustomer'
  13. import {getExternalPartPictureList} from '../../../api/part/externalPartPicture'
  14. import LinkedManufacturer from './manufacturer/linkedManufacturer.vue'
  15. import {getExternalPartManufacturerList} from '../../../api/part/externalPartManufacturer'
  16. import {getTableDefaultListLanguage, getTableUserListLanguage} from '../../../api/table'
  17. import {Decimal} from 'decimal.js'
  18. import {getCategoryList} from '../../../api/category/category'
  19. import {countryList} from '../../../api/dict/country'
  20. let part = {
  21. site:'',
  22. partNo:'',
  23. partDesc:'',
  24. umId:'',
  25. freeInfo:'',
  26. freeInfo2:'',
  27. rev:'',
  28. active:'',
  29. moldCode:'',
  30. category:'',
  31. qtyPerCarton:0,
  32. qtyPerRoll:0,
  33. rollsPerCarton:0,
  34. }
  35. export default {
  36. name: "ExternalPart",
  37. components: {LinkedManufacturer, LinkedCustomer, PictureModule},
  38. props:{
  39. height:{
  40. type:Number,
  41. default: 370
  42. },
  43. ofComponents: {
  44. type:Boolean,
  45. default: false
  46. }
  47. },
  48. data(){
  49. return{
  50. part: {
  51. ...part
  52. },
  53. savePart:{
  54. ...part,
  55. active:'Y',
  56. },
  57. partCategoryList:[
  58. ],
  59. category:{},
  60. partRules:{
  61. partNo: [{ required: true, message: 'Please input Part No', trigger: ['blur','change'] }],
  62. partDesc: [{ required: true, message: 'Please input Part Description', trigger: ['blur','change'] }],
  63. umId: [{ required: true, message: 'Please select UM', trigger: ['blur','change'] }],
  64. rev: [{ required: true, message: 'Please select Rev No', trigger: ['blur','change'] }],
  65. moldCode: [{ required: true, message: 'Please select Mold Code', trigger: ['blur','change'] }],
  66. qtyPerCarton: [{ required: true, message: 'Please input Qty Per Carton', trigger: ['blur','change'] }],
  67. qtyPerRoll: [{ required: true, message: 'Please input Qty Per Roll', trigger: ['blur','change'] }],
  68. rollsPerCarton: [{ required: true, message: 'Please input Rolls Per Carton', trigger: ['blur','change'] }],
  69. freeInfo2: [{ required: true, message: 'Please select OOC', trigger: ['blur','change'] }],
  70. },
  71. savePartVisible:false,
  72. partTableLoading:false,
  73. partList:[],
  74. unitList:[],
  75. columnList:[
  76. {
  77. userId: this.$store.state.user.name,
  78. functionId: 10002,
  79. serialNumber: '10002TablePartNo',
  80. tableId: "10002Table",
  81. tableName: "外部料号信息表",
  82. columnProp: "partNo",
  83. headerAlign: "center",
  84. align: "left",
  85. columnLabel: "Part No",
  86. columnHidden: false,
  87. columnImage: false,
  88. columnSortable: false,
  89. sortLv: 10,
  90. status: true,
  91. fixed: '',
  92. columnWidth: 80
  93. },{
  94. userId: this.$store.state.user.name,
  95. functionId: 10002,
  96. serialNumber: '10002TablePartDesc',
  97. tableId: "10002Table",
  98. tableName: "外部料号信息表",
  99. columnProp: "partDesc",
  100. headerAlign: "center",
  101. align: "left",
  102. columnLabel: "Part Description",
  103. columnHidden: false,
  104. columnImage: false,
  105. columnSortable: false,
  106. sortLv: 10,
  107. status: true,
  108. fixed: '',
  109. columnWidth: 140
  110. },{
  111. userId: this.$store.state.user.name,
  112. functionId: 10002,
  113. serialNumber: '10002TableRev',
  114. tableId: "10002Table",
  115. tableName: "外部料号信息表",
  116. columnProp: "rev",
  117. headerAlign: "center",
  118. align: "left",
  119. columnLabel: "REV No",
  120. columnHidden: false,
  121. columnImage: false,
  122. columnSortable: false,
  123. sortLv: 10,
  124. status: true,
  125. fixed: '',
  126. columnWidth: 80
  127. },{
  128. userId: this.$store.state.user.name,
  129. functionId: 10002,
  130. serialNumber: '10002TableCategory',
  131. tableId: "10002Table",
  132. tableName: "外部料号信息表",
  133. columnProp: "category",
  134. headerAlign: "center",
  135. align: "left",
  136. columnLabel: "Part Category",
  137. columnHidden: false,
  138. columnImage: false,
  139. columnSortable: false,
  140. sortLv: 10,
  141. status: true,
  142. fixed: '',
  143. columnWidth: 140
  144. },
  145. {
  146. userId: this.$store.state.user.name,
  147. functionId: 10002,
  148. serialNumber: '10002TableUmName',
  149. tableId: "10002Table",
  150. tableName: "外部料号信息表",
  151. columnProp: "moldCode",
  152. headerAlign: "center",
  153. align: "left",
  154. columnLabel: "Mold Code",
  155. columnHidden: false,
  156. columnImage: false,
  157. columnSortable: false,
  158. sortLv: 10,
  159. status: true,
  160. fixed: '',
  161. columnWidth: 80
  162. },{
  163. userId: this.$store.state.user.name,
  164. functionId: 10002,
  165. serialNumber: '10002TableUmName',
  166. tableId: "10002Table",
  167. tableName: "外部料号信息表",
  168. columnProp: "manufacturer",
  169. headerAlign: "center",
  170. align: "left",
  171. columnLabel: "Manufacturer",
  172. columnHidden: false,
  173. columnImage: false,
  174. columnSortable: false,
  175. sortLv: 10,
  176. status: true,
  177. fixed: '',
  178. columnWidth: 120
  179. },{
  180. userId: this.$store.state.user.name,
  181. functionId: 10002,
  182. serialNumber: '10002TableUmName',
  183. tableId: "10002Table",
  184. tableName: "外部料号信息表",
  185. columnProp: "umName",
  186. headerAlign: "center",
  187. align: "left",
  188. columnLabel: "UM",
  189. columnHidden: false,
  190. columnImage: false,
  191. columnSortable: false,
  192. sortLv: 10,
  193. status: true,
  194. fixed: '',
  195. columnWidth: 60
  196. },
  197. {
  198. userId: this.$store.state.user.name,
  199. functionId: 10002,
  200. serialNumber: '10002TableQtyPerRoll',
  201. tableId: "10002Table",
  202. tableName: "外部料号信息表",
  203. columnProp: "qtyPerRoll",
  204. headerAlign: "center",
  205. align: "left",
  206. columnLabel: "Qty Per Roll",
  207. columnHidden: false,
  208. columnImage: false,
  209. columnSortable: false,
  210. sortLv: 10,
  211. status: true,
  212. fixed: '',
  213. columnWidth: 120
  214. },{
  215. userId: this.$store.state.user.name,
  216. functionId: 10002,
  217. serialNumber: '10002TableRollsPerCarton',
  218. tableId: "10002Table",
  219. tableName: "外部料号信息表",
  220. columnProp: "rollsPerCarton",
  221. headerAlign: "center",
  222. align: "left",
  223. columnLabel: "Rolls Per Carton",
  224. columnHidden: false,
  225. columnImage: false,
  226. columnSortable: false,
  227. sortLv: 10,
  228. status: true,
  229. fixed: '',
  230. columnWidth: 120
  231. },{
  232. userId: this.$store.state.user.name,
  233. functionId: 10002,
  234. serialNumber: '10002TableQtyPerCarton',
  235. tableId: "10002Table",
  236. tableName: "外部料号信息表",
  237. columnProp: "qtyPerCarton",
  238. headerAlign: "center",
  239. align: "left",
  240. columnLabel: "Qty Per Carton",
  241. columnHidden: false,
  242. columnImage: false,
  243. columnSortable: false,
  244. sortLv: 10,
  245. status: true,
  246. fixed: '',
  247. columnWidth: 120
  248. },
  249. {
  250. userId: this.$store.state.user.name,
  251. functionId: 10002,
  252. serialNumber: '10002TableFreeInfo',
  253. tableId: "10002Table",
  254. tableName: "外部料号信息表",
  255. columnProp: "freeInfo",
  256. headerAlign: "center",
  257. align: "left",
  258. columnLabel: "Free Info1",
  259. columnHidden: false,
  260. columnImage: false,
  261. columnSortable: false,
  262. sortLv: 10,
  263. status: true,
  264. fixed: '',
  265. columnWidth: 120
  266. },{
  267. userId: this.$store.state.user.name,
  268. functionId: 10002,
  269. serialNumber: '10002TableFreeInfo2',
  270. tableId: "10002Table",
  271. tableName: "外部料号信息表",
  272. columnProp: "freeInfo2",
  273. headerAlign: "center",
  274. align: "left",
  275. columnLabel: "Free Info2",
  276. columnHidden: false,
  277. columnImage: false,
  278. columnSortable: false,
  279. sortLv: 10,
  280. status: true,
  281. fixed: '',
  282. columnWidth: 120
  283. },{
  284. userId: this.$store.state.user.name,
  285. functionId: 10002,
  286. serialNumber: '10002TableActive',
  287. tableId: "10002Table",
  288. tableName: "外部料号信息表",
  289. columnProp: "active",
  290. headerAlign: "center",
  291. align: "left",
  292. columnLabel: "Active",
  293. columnHidden: false,
  294. columnImage: false,
  295. columnSortable: false,
  296. sortLv: 10,
  297. status: true,
  298. fixed: '',
  299. columnWidth: 80
  300. },{
  301. userId: this.$store.state.user.name,
  302. functionId: 10002,
  303. serialNumber: '10002TableCreateBy',
  304. tableId: "10002Table",
  305. tableName: "外部料号信息表",
  306. columnProp: "createBy",
  307. headerAlign: "center",
  308. align: "left",
  309. columnLabel: "Created By",
  310. columnHidden: false,
  311. columnImage: false,
  312. columnSortable: false,
  313. sortLv: 10,
  314. status: true,
  315. fixed: '',
  316. columnWidth: 80
  317. },{
  318. userId: this.$store.state.user.name,
  319. functionId: 10002,
  320. serialNumber: '10002TableCreateTime',
  321. tableId: "10002Table",
  322. tableName: "外部料号信息表",
  323. columnProp: "createTime",
  324. headerAlign: "center",
  325. align: "left",
  326. columnLabel: "Created Time",
  327. columnHidden: false,
  328. columnImage: false,
  329. columnSortable: false,
  330. sortLv: 10,
  331. status: true,
  332. fixed: '',
  333. columnWidth: 140
  334. },{
  335. userId: this.$store.state.user.name,
  336. functionId: 10002,
  337. serialNumber: '10002TableUpdateBy',
  338. tableId: "10002Table",
  339. tableName: "外部料号信息表",
  340. columnProp: "updateBy",
  341. headerAlign: "center",
  342. align: "left",
  343. columnLabel: "Updated By",
  344. columnHidden: false,
  345. columnImage: false,
  346. columnSortable: false,
  347. sortLv: 10,
  348. status: true,
  349. fixed: '',
  350. columnWidth: 80
  351. },{
  352. userId: this.$store.state.user.name,
  353. functionId: 10002,
  354. serialNumber: '10002TableUpdateTime',
  355. tableId: "10002Table",
  356. tableName: "外部料号信息表",
  357. columnProp: "updateTime",
  358. headerAlign: "center",
  359. align: "left",
  360. columnLabel: "Updated Time",
  361. columnHidden: false,
  362. columnImage: false,
  363. columnSortable: false,
  364. sortLv: 10,
  365. status: true,
  366. fixed: '',
  367. columnWidth: 140
  368. },
  369. ],
  370. pictureColumnList:[
  371. {
  372. userId: this.$store.state.user.name,
  373. functionId: 10002,
  374. serialNumber: '10002Table22PictureNo',
  375. tableId: "10002Table2",
  376. tableName: "外部料号图片信息表",
  377. columnProp: "pictureNo",
  378. headerAlign: "center",
  379. align: "left",
  380. columnLabel: "Document No",
  381. columnHidden: false,
  382. columnImage: false,
  383. columnSortable: false,
  384. sortLv: 10,
  385. status: true,
  386. fixed: '',
  387. columnWidth: 80
  388. },{
  389. userId: this.$store.state.user.name,
  390. functionId: 10002,
  391. serialNumber: '10002Table22PictureDesc',
  392. tableId: "10002Table2",
  393. tableName: "外部料号图片信息表",
  394. columnProp: "pictureDesc",
  395. headerAlign: "center",
  396. align: "left",
  397. columnLabel: "Document Desc",
  398. columnHidden: false,
  399. columnImage: false,
  400. columnSortable: false,
  401. sortLv: 10,
  402. status: true,
  403. fixed: '',
  404. columnWidth: 180
  405. },{
  406. userId: this.$store.state.user.name,
  407. functionId: 10002,
  408. serialNumber: '10002Table22CreateBy',
  409. tableId: "10002Table2",
  410. tableName: "外部料号图片信息表",
  411. columnProp: "createBy",
  412. headerAlign: "center",
  413. align: "left",
  414. columnLabel: "Created By",
  415. columnHidden: false,
  416. columnImage: false,
  417. columnSortable: false,
  418. sortLv: 10,
  419. status: true,
  420. fixed: '',
  421. columnWidth: 80
  422. },{
  423. userId: this.$store.state.user.name,
  424. functionId: 10002,
  425. serialNumber: '10002Table22CreateTime',
  426. tableId: "10002Table2",
  427. tableName: "外部料号图片信息表",
  428. columnProp: "createTime",
  429. headerAlign: "center",
  430. align: "center",
  431. columnLabel: "Created Time",
  432. columnHidden: false,
  433. columnImage: false,
  434. columnSortable: false,
  435. sortLv: 10,
  436. status: true,
  437. fixed: '',
  438. columnWidth: 180
  439. },{
  440. userId: this.$store.state.user.name,
  441. functionId: 10002,
  442. serialNumber: '10002Table22UpdateBy',
  443. tableId: "10002Table2",
  444. tableName: "外部料号图片信息表",
  445. columnProp: "updateBy",
  446. headerAlign: "center",
  447. align: "left",
  448. columnLabel: "Updated By",
  449. columnHidden: false,
  450. columnImage: false,
  451. columnSortable: false,
  452. sortLv: 10,
  453. status: true,
  454. fixed: '',
  455. columnWidth: 80
  456. },{
  457. userId: this.$store.state.user.name,
  458. functionId: 10002,
  459. serialNumber: '10002Table22UpdateTime',
  460. tableId: "10002Table2",
  461. tableName: "外部料号图片信息表",
  462. columnProp: "updateTime",
  463. headerAlign: "center",
  464. align: "center",
  465. columnLabel: "Updated Time",
  466. columnHidden: false,
  467. columnImage: false,
  468. columnSortable: false,
  469. sortLv: 10,
  470. status: true,
  471. fixed: '',
  472. columnWidth: 180
  473. },
  474. ],
  475. customerColumnList:[
  476. {
  477. userId: this.$store.state.user.name,
  478. functionId: 10002,
  479. serialNumber: '10002Table3CustomerNo',
  480. tableId: "10002Table3",
  481. tableName: "外部料号客户信息表",
  482. columnProp: "customerNo",
  483. headerAlign: "center",
  484. align: "left",
  485. columnLabel: "Customer No",
  486. columnHidden: false,
  487. columnImage: false,
  488. columnSortable: false,
  489. sortLv: 10,
  490. status: true,
  491. fixed: '',
  492. columnWidth: 80
  493. },{
  494. userId: this.$store.state.user.name,
  495. functionId: 10002,
  496. serialNumber: '10002Table3CustomerName',
  497. tableId: "10002Table3",
  498. tableName: "外部料号客户信息表",
  499. columnProp: "customerName",
  500. headerAlign: "center",
  501. align: "left",
  502. columnLabel: "Customer Name",
  503. columnHidden: false,
  504. columnImage: false,
  505. columnSortable: false,
  506. sortLv: 10,
  507. status: true,
  508. fixed: '',
  509. columnWidth: 120
  510. },{
  511. userId: this.$store.state.user.name,
  512. functionId: 10002,
  513. serialNumber: '10002Table3CreateTime',
  514. tableId: "10002Table3",
  515. tableName: "外部料号客户信息表",
  516. columnProp: "createTime",
  517. headerAlign: "center",
  518. align: "center",
  519. columnLabel: "Created Time",
  520. columnHidden: false,
  521. columnImage: false,
  522. columnSortable: false,
  523. sortLv: 10,
  524. status: true,
  525. fixed: '',
  526. columnWidth: 140
  527. },{
  528. userId: this.$store.state.user.name,
  529. functionId: 10002,
  530. serialNumber: '10002Table3CreateBy',
  531. tableId: "10002Table3",
  532. tableName: "外部料号客户信息表",
  533. columnProp: "createBy",
  534. headerAlign: "center",
  535. align: "left",
  536. columnLabel: "Created By",
  537. columnHidden: false,
  538. columnImage: false,
  539. columnSortable: false,
  540. sortLv: 10,
  541. status: true,
  542. fixed: '',
  543. columnWidth: 80
  544. },{
  545. userId: this.$store.state.user.name,
  546. functionId: 10002,
  547. serialNumber: '10002Table3UpdateTime',
  548. tableId: "10002Table3",
  549. tableName: "外部料号客户信息表",
  550. columnProp: "updateTime",
  551. headerAlign: "center",
  552. align: "center",
  553. columnLabel: "Updated Time",
  554. columnHidden: false,
  555. columnImage: false,
  556. columnSortable: false,
  557. sortLv: 10,
  558. status: true,
  559. fixed: '',
  560. columnWidth: 140
  561. },{
  562. userId: this.$store.state.user.name,
  563. functionId: 10002,
  564. serialNumber: '10002Table3UpdateBy',
  565. tableId: "10002Table3",
  566. tableName: "外部料号客户信息表",
  567. columnProp: "updateBy",
  568. headerAlign: "center",
  569. align: "left",
  570. columnLabel: "Updated By",
  571. columnHidden: false,
  572. columnImage: false,
  573. columnSortable: false,
  574. sortLv: 10,
  575. status: true,
  576. fixed: '',
  577. columnWidth: 80
  578. },
  579. ],
  580. manufacturerColumnList:[
  581. {
  582. userId: this.$store.state.user.name,
  583. functionId: 10002,
  584. serialNumber: '10002Table4ManufacturerNo',
  585. tableId: "10002Table4",
  586. tableName: "外部料号供应商信息表",
  587. columnProp: "manufacturerNo",
  588. headerAlign: "center",
  589. align: "left",
  590. columnLabel: "Manufacturer No",
  591. columnHidden: false,
  592. columnImage: false,
  593. columnSortable: false,
  594. sortLv: 10,
  595. status: true,
  596. fixed: '',
  597. columnWidth: 80
  598. },{
  599. userId: this.$store.state.user.name,
  600. functionId: 10002,
  601. serialNumber: '10002Table4ManufacturerName',
  602. tableId: "10002Table4",
  603. tableName: "外部料号供应商信息表",
  604. columnProp: "manufacturerName",
  605. headerAlign: "center",
  606. align: "left",
  607. columnLabel: "Manufacturer Name",
  608. columnHidden: false,
  609. columnImage: false,
  610. columnSortable: false,
  611. sortLv: 10,
  612. status: true,
  613. fixed: '',
  614. columnWidth: 120
  615. },{
  616. userId: this.$store.state.user.name,
  617. functionId: 10002,
  618. serialNumber: '10002Table4CreateTime',
  619. tableId: "10002Table4",
  620. tableName: "外部料号供应商信息表",
  621. columnProp: "createTime",
  622. headerAlign: "center",
  623. align: "center",
  624. columnLabel: "Created Time",
  625. columnHidden: false,
  626. columnImage: false,
  627. columnSortable: false,
  628. sortLv: 10,
  629. status: true,
  630. fixed: '',
  631. columnWidth: 140
  632. },{
  633. userId: this.$store.state.user.name,
  634. functionId: 10002,
  635. serialNumber: '10002Table4CreateBy',
  636. tableId: "10002Table4",
  637. tableName: "外部料号供应商信息表",
  638. columnProp: "createBy",
  639. headerAlign: "center",
  640. align: "left",
  641. columnLabel: "Created By",
  642. columnHidden: false,
  643. columnImage: false,
  644. columnSortable: false,
  645. sortLv: 10,
  646. status: true,
  647. fixed: '',
  648. columnWidth: 80
  649. },{
  650. userId: this.$store.state.user.name,
  651. functionId: 10002,
  652. serialNumber: '10002Table4UpdateTime',
  653. tableId: "10002Table4",
  654. tableName: "外部料号供应商信息表",
  655. columnProp: "updateTime",
  656. headerAlign: "center",
  657. align: "center",
  658. columnLabel: "Updated Time",
  659. columnHidden: false,
  660. columnImage: false,
  661. columnSortable: false,
  662. sortLv: 10,
  663. status: true,
  664. fixed: '',
  665. columnWidth: 140
  666. },{
  667. userId: this.$store.state.user.name,
  668. functionId: 10002,
  669. serialNumber: '10002Table4UpdateBy',
  670. tableId: "10002Table4",
  671. tableName: "外部料号供应商信息表",
  672. columnProp: "updateBy",
  673. headerAlign: "center",
  674. align: "left",
  675. columnLabel: "Updated By",
  676. columnHidden: false,
  677. columnImage: false,
  678. columnSortable: false,
  679. sortLv: 10,
  680. status: true,
  681. fixed: '',
  682. columnWidth: 80
  683. },
  684. ],
  685. activeName:'partPicture',
  686. currentPart:{},
  687. externalPartCustomerList:[],
  688. pictureList:[],
  689. externalPartManufacturerList:[],
  690. base64List:[],
  691. countryList:[],
  692. }
  693. },
  694. watch:{
  695. currentPart(newVal,oldVal){
  696. if (!this.ofComponents){
  697. // 调用 子组件信息查询
  698. this.getExternalPartCustomerList();
  699. this.getExternalPartPictureList();
  700. this.getExternalPartManufacturerList();
  701. }
  702. },
  703. "savePart.partNo"(newVal,oldVal){
  704. this.savePart.partNo = newVal.toUpperCase()
  705. },
  706. "savePart.category"(newVal,oldVal){
  707. const category = this.partCategoryList.find((item)=>item.categoryValue === newVal);
  708. if (category){
  709. this.savePart.manufacturerRequired = category.manufacturerRequired;
  710. this.savePart.moldCodeRequired = category.moldCodeRequired;
  711. this.savePart.serialNumberRequired = category.serialNumberRequired;
  712. this.savePart.rollLabelRequired = category.rollLabelRequired;
  713. if (this.savePart.serialNumberRequired === 'Y'){
  714. this.savePart.qtyPerRoll = 1;
  715. this.savePart.rollsPerCarton = 1;
  716. }
  717. if (category.showCartonQtyPerRoll === 'N'){
  718. this.savePart.qtyPerRoll = 1;
  719. }
  720. if (category.showCartonRollsPerCarton === 'N'){
  721. this.savePart.rollsPerCarton = 1;
  722. }
  723. this.partRules.rollsPerCarton[0].message = `Please input ${category.qtyPerRollPart}`
  724. this.savePart.qtyPerCarton = this.qtyPerCarton();
  725. this.category = JSON.parse(JSON.stringify(category))
  726. }
  727. },
  728. "part.partNo"(newVal,oldVal){
  729. this.part.partNo = newVal.toUpperCase()
  730. },
  731. "savePart.qtyPerRoll"(newVal,oldVal){
  732. this.savePart.qtyPerCarton = this.qtyPerCarton();
  733. },
  734. "savePart.rollsPerCarton"(newVal,oldVal){
  735. this.savePart.qtyPerCarton = this.qtyPerCarton();
  736. },
  737. },
  738. methods:{
  739. getExternalPartPictureList(){
  740. let params = {
  741. partNo: this.currentPart.partNo,
  742. site: this.currentPart.site,
  743. }
  744. getExternalPartPictureList(params).then(({data})=>{
  745. if (data && data.code === 0){
  746. this.pictureList = data.rows;
  747. }else {
  748. this.$message.warning(data.msg)
  749. }
  750. }).catch((error)=>{
  751. this.$message.error(error)
  752. })
  753. },
  754. rowPartStyle({row}){
  755. if (row.partNo === this.currentPart.partNo){
  756. return {
  757. background: 'rgb(232,246,246)',
  758. }
  759. }
  760. },
  761. selectUnitList(){
  762. selectUnitList().then(({data})=>{
  763. if (data && data.code === 0){
  764. this.unitList = data.rows;
  765. if (this.unitList.length > 0){
  766. this.savePart.umId = this.unitList[0].umId;
  767. }
  768. }else {
  769. this.$message.warning(data.msg)
  770. }
  771. }).catch((error)=>{
  772. this.$message.error(error)
  773. })
  774. },
  775. selectExternalPartList(){
  776. let params = {
  777. ...this.part,
  778. site: this.$store.state.user.site,
  779. }
  780. selectExternalPartList(params).then(({data})=>{
  781. if (data && data.code === 0){
  782. this.partList = data.rows;
  783. if (this.partList.length > 0 && !this.ofComponents){
  784. this.currentPart = {...this.partList[0]}
  785. }
  786. }else {
  787. this.$message.warning(data.msg)
  788. }
  789. }).catch((error)=>{
  790. this.$message.error(error)
  791. })
  792. },
  793. handleSave(){
  794. if (this.savePartVisible){
  795. this.$refs.savePartForm.validate((valid,obj) => {
  796. if (valid) {
  797. if (this.savePart.qtyPerCarton === 0){
  798. this.$message.warning('Qty Per Carton can not be 0')
  799. return
  800. }
  801. let params = {
  802. ...this.savePart,
  803. site: this.$store.state.user.site,
  804. createBy: this.$store.state.user.name,
  805. createTime: dayjs().format('YYYY-MM-DD HH:mm:ss'),
  806. }
  807. saveExternalPart(params).then(({data})=>{
  808. if (data && data.code === 0){
  809. this.selectExternalPartList()
  810. this.savePartVisible = false
  811. this.$message.success(data.msg)
  812. }else {
  813. this.$message.warning(data.msg)
  814. }
  815. }).catch((error)=>{
  816. this.$message.error(error)
  817. })
  818. }else {
  819. for (let i = 0; i < Object.keys(obj).length; i++) {
  820. this.$message.warning(obj[Object.keys(obj)[i]][0].message)
  821. break
  822. }
  823. }
  824. })
  825. }else {
  826. this.savePart = {
  827. ...part,
  828. active: 'Y',
  829. umId: this.unitList.length > 0 ? this.unitList[0].umId : '',
  830. category: '',
  831. manufacturerRequired: 'N',
  832. moldCodeRequired: 'N',
  833. serialNumberRequired: 'N',
  834. }
  835. this.getCountryList();
  836. this.savePart.category = this.partCategoryList.length > 0 ? this.partCategoryList[0].categoryValue : ''
  837. this.savePartVisible = true;
  838. }
  839. },
  840. closeSavePart(){
  841. this.savePart = {
  842. ...part,
  843. active: 'Y',
  844. }
  845. if (this.unitList.length > 0){
  846. this.savePart.umId = this.unitList[0].umId;
  847. }
  848. this.$refs.savePartForm.resetFields()
  849. },
  850. removeExternalPart(row){
  851. removeExternalPart(row).then(({data})=>{
  852. if (data && data.code === 0){
  853. this.selectExternalPartList()
  854. this.$message.success(data.msg)
  855. }else {
  856. this.$message.warning(data.msg)
  857. }
  858. }).catch((error)=>{
  859. this.$message.error(error)
  860. })
  861. },
  862. handleRowClick(row, column, event,type){
  863. this.currentPart = {...row}
  864. if (type === 0){
  865. this.getCountryList();
  866. this.savePart = {...row}
  867. this.savePartVisible = true;
  868. }
  869. },
  870. handleDblRowClick(row, column, event,type){
  871. if (this.ofComponents){
  872. this.$emit('rowClick',row)
  873. }else {
  874. this.currentPart = {...row}
  875. if (type === 0){
  876. this.savePart = {...row}
  877. this.savePartVisible = true;
  878. }
  879. }
  880. },
  881. handleUpdate(){
  882. this.$refs.savePartForm.validate((valid,obj) => {
  883. if (valid) {
  884. if (this.savePart.qtyPerCarton === 0){
  885. this.$message.warning('Qty Per Carton can not be 0')
  886. return
  887. }
  888. let params = {
  889. ...this.savePart,
  890. site: this.$store.state.user.site,
  891. createBy: undefined,
  892. createTime: undefined,
  893. updateBy: this.$store.state.user.name,
  894. updateTime: dayjs().format('YYYY-MM-DD HH:mm:ss'),
  895. }
  896. updateExternalPart(params).then(({data})=>{
  897. if (data && data.code === 0){
  898. this.selectExternalPartList()
  899. this.savePartVisible = false
  900. this.$message.success(data.msg)
  901. }else {
  902. this.$message.warning(data.msg)
  903. }
  904. }).catch((error)=>{
  905. this.$message.error(error)
  906. })
  907. }else {
  908. for (let i = 0; i < Object.keys(obj).length; i++) {
  909. this.$message.warning(obj[Object.keys(obj)[i]][0].message)
  910. break
  911. }
  912. }
  913. })
  914. },
  915. getExternalPartCustomerList(){
  916. let params = {
  917. partNo: this.currentPart.partNo,
  918. site: this.currentPart.site,
  919. }
  920. getExternalPartCustomerList(params).then(({data})=>{
  921. if (data && data.code === 0){
  922. this.externalPartCustomerList = data.rows;
  923. }else {
  924. this.$message.warning(data.msg)
  925. }
  926. }).catch((error)=>{
  927. this.$message.error(error)
  928. })
  929. },
  930. getExternalPartManufacturerList(){
  931. let params = {
  932. partNo: this.currentPart.partNo,
  933. site: this.currentPart.site,
  934. }
  935. getExternalPartManufacturerList(params).then(({data})=>{
  936. if (data && data.code === 0){
  937. this.externalPartManufacturerList = data.rows;
  938. }else {
  939. this.$message.warning(data.msg)
  940. }
  941. }).catch((error)=>{
  942. this.$message.error(error)
  943. })
  944. },
  945. async convertToBase64(fileUrls) {
  946. this.base64List = []
  947. for (const fileUrl of fileUrls) {
  948. const base64Url = await this.getFileAsBase64(fileUrl);
  949. this.base64List.push(base64Url);
  950. }
  951. },
  952. getFileAsBase64(fileUrl) {
  953. return new Promise((resolve, reject) => {
  954. const img = new Image();
  955. img.crossOrigin = 'Anonymous';
  956. img.src = fileUrl;
  957. img.onload = () => {
  958. const canvas = document.createElement('canvas');
  959. const ctx = canvas.getContext('2d');
  960. canvas.width = img.width;
  961. canvas.height = img.height;
  962. ctx.drawImage(img, 0, 0);
  963. const base64data = canvas.toDataURL('image/jpeg');
  964. resolve(base64data);
  965. };
  966. img.onerror = (error) => {
  967. reject(error);
  968. };
  969. });
  970. },
  971. async getTableUserColumn (tableId, columnId) {
  972. let queryTableUser = {
  973. userId: this.$store.state.user.name,
  974. functionId: this.$route.meta.menuId,
  975. tableId: tableId,
  976. status: true,
  977. languageCode: this.$i18n.locale
  978. }
  979. await getTableUserListLanguage(queryTableUser).then(({data}) => {
  980. if (data.rows.length > 0) {
  981. this.caseTable(data.rows,columnId)
  982. } else {
  983. this.getColumnList(tableId, columnId)
  984. }
  985. })
  986. },
  987. // 获取 tableDefault 列
  988. async getColumnList (tableId, columnId) {
  989. let queryTable = {
  990. functionId: this.$route.meta.menuId,
  991. tableId: tableId,
  992. languageCode: this.$i18n.locale
  993. }
  994. await getTableDefaultListLanguage(queryTable).then(({data}) => {
  995. if (!data.rows.length === 0) {
  996. this.caseTable(data.rows,columnId)
  997. } else {
  998. }
  999. })
  1000. },
  1001. caseTable(list,columnId){
  1002. if (list.length > 0){
  1003. switch (columnId) {
  1004. case 1:
  1005. this.columnList = list
  1006. break;
  1007. case 2:
  1008. this.pictureColumnList = list
  1009. break;
  1010. case 3:
  1011. this.customerColumnList = list
  1012. break;
  1013. case 4:
  1014. this.manufacturerColumnList = list
  1015. break;
  1016. }
  1017. }
  1018. },
  1019. qtyPerCarton(){
  1020. return new Decimal(this.savePart.qtyPerRoll).mul(this.savePart.rollsPerCarton).toNumber();
  1021. },
  1022. getCategoryList(){
  1023. let params = {};
  1024. getCategoryList(params).then(({data})=>{
  1025. if (data && data.code === 0){
  1026. this.partCategoryList = data.rows;
  1027. }else {
  1028. this.$message.warning(data.msg)
  1029. }
  1030. }).catch((error)=>{
  1031. this.$message.error(error)
  1032. })
  1033. },
  1034. changeQtyRollCarton(){
  1035. this.savePart.qtyPerRoll = this.savePart.qtyPerCarton;
  1036. },
  1037. getCountryList(){
  1038. let params = {
  1039. }
  1040. countryList(params).then(({data})=>{
  1041. if (data && data.code === 0){
  1042. this.countryList = data.rows
  1043. }else {
  1044. this.$message.warning(data.msg)
  1045. }
  1046. }).catch((error)=>{
  1047. this.$message.error(error)
  1048. })
  1049. }
  1050. },
  1051. computed:{
  1052. },
  1053. created () {
  1054. this.selectUnitList();
  1055. this.getCategoryList();
  1056. // this.getCountryList();
  1057. this.selectExternalPartList();
  1058. this.getTableUserColumn("10002Table", 1)
  1059. this.getTableUserColumn("10002Table2", 2)
  1060. this.getTableUserColumn("10002Table3", 3)
  1061. this.getTableUserColumn("10002Table4", 4)
  1062. }
  1063. }
  1064. </script>
  1065. <template>
  1066. <div>
  1067. <el-form :inline="true" label-position="top" :model="part" label-width="100px">
  1068. <el-form-item label="Part No">
  1069. <el-input v-model="part.partNo"></el-input>
  1070. </el-form-item>
  1071. <el-form-item label="Part Description">
  1072. <el-input v-model="part.partDesc"></el-input>
  1073. </el-form-item>
  1074. <el-form-item label="Part Category">
  1075. <el-select v-model="part.category" placeholder="">
  1076. <el-option label="All" value=""></el-option>
  1077. <el-option :label="item.categoryName" :value="item.categoryValue" :key="item.id" v-for="item in partCategoryList"></el-option>
  1078. </el-select>
  1079. </el-form-item>
  1080. <el-form-item label="Active">
  1081. <el-select v-model="part.active" placeholder="">
  1082. <el-option label="All" value=""></el-option>
  1083. <el-option label="Active" value="Y"></el-option>
  1084. <el-option label="Not Active" value="N"></el-option>
  1085. </el-select>
  1086. </el-form-item>
  1087. <el-form-item label=" ">
  1088. <el-button type="primary" @click="handleSave" v-if="!ofComponents">New</el-button>
  1089. <el-button type="primary" @click="selectExternalPartList">Query</el-button>
  1090. </el-form-item>
  1091. </el-form>
  1092. <el-table :data="partList" :height="height" :row-style="rowPartStyle" @row-click="handleRowClick" @row-dblclick="handleDblRowClick" :loading="partTableLoading" border style="width: 100%;margin-top: 5px">
  1093. <el-table-column v-if="!ofComponents"
  1094. header-align="center"
  1095. align="center"
  1096. width="100"
  1097. fixed="left"
  1098. label="Actions">
  1099. <template slot-scope="scope">
  1100. <el-link style="cursor:pointer;" @click="handleRowClick(scope.row,null,null,0)">Edit</el-link>
  1101. <el-link style="cursor:pointer;" @click="removeExternalPart(scope.row)">Delete</el-link>
  1102. </template>
  1103. </el-table-column>
  1104. <el-table-column
  1105. v-for="(item,index) in columnList" :key="index"
  1106. :sortable="item.columnSortable"
  1107. :prop="item.columnProp"
  1108. :header-align="item.headerAlign"
  1109. :show-overflow-tooltip="item.showOverflowTooltip"
  1110. :align="item.align"
  1111. :fixed="item.fixed==''?false:item.fixed"
  1112. :min-width="item.columnWidth"
  1113. :label="item.columnLabel">
  1114. <template slot-scope="scope">
  1115. <span v-if="!item.columnHidden"> {{ scope.row[item.columnProp] }}</span>
  1116. <span v-if="item.columnImage"><img :src="scope.row[item.columnProp]"
  1117. style="width: 100px; height: 80px"/></span>
  1118. </template>
  1119. </el-table-column>
  1120. </el-table>
  1121. <el-tabs v-model="activeName" v-if="!ofComponents">
  1122. <el-tab-pane label="Part Picture" name="partPicture">
  1123. <picture-module :column-list="pictureColumnList" :part="currentPart" :data-list="pictureList" @refresh="getExternalPartPictureList"></picture-module>
  1124. </el-tab-pane>
  1125. <el-tab-pane label="Linked Customer" name="linkedCustomer">
  1126. <linked-customer :column-list="customerColumnList" :part="currentPart" :data-list="externalPartCustomerList" @refresh="getExternalPartCustomerList"></linked-customer>
  1127. </el-tab-pane>
  1128. <el-tab-pane label="Linked Manufacturer" name="linkedManufacturer">
  1129. <linked-manufacturer :column-list="manufacturerColumnList" :part="currentPart" :data-list="externalPartManufacturerList" @refresh="getExternalPartManufacturerList"></linked-manufacturer>
  1130. </el-tab-pane>
  1131. </el-tabs>
  1132. <el-dialog v-drag :title="`Part`" :close-on-click-modal="false" @close="closeSavePart" width="600px" :visible.sync="savePartVisible">
  1133. <el-form :model="savePart" label-position="top" ref="savePartForm" :rules="partRules">
  1134. <el-row :gutter="10">
  1135. <el-col :span="7">
  1136. <el-form-item label="Part No" prop="partNo" :show-message="false">
  1137. <el-input :readonly="savePart.site !== ''" :disabled="savePart.site !== ''" v-model="savePart.partNo"></el-input>
  1138. </el-form-item>
  1139. </el-col>
  1140. <el-col :span="17">
  1141. <el-form-item label="Part Description" prop="partDesc" :show-message="false">
  1142. <el-input v-model="savePart.partDesc"></el-input>
  1143. </el-form-item>
  1144. </el-col>
  1145. <el-col :span="7">
  1146. <el-form-item label="Part Category" prop="category" :show-message="false">
  1147. <el-select v-model="savePart.category" placeholder="" style="width: 100%">
  1148. <el-option :label="item.categoryName" :value="item.categoryValue" :key="item.id" v-for="item in partCategoryList"></el-option>
  1149. </el-select>
  1150. </el-form-item>
  1151. </el-col>
  1152. <el-col :span="5">
  1153. <el-form-item label="UM" prop="umId" :show-message="false">
  1154. <el-select v-model="savePart.umId" placeholder="" :show-message="false">
  1155. <el-option v-for="item in unitList" :key="item.umId" :label="item.umName" :value="item.umId"></el-option>
  1156. </el-select>
  1157. </el-form-item>
  1158. </el-col>
  1159. <el-col :span="7" :offset="2">
  1160. <el-form-item v-if="savePart.moldCodeRequired === 'Y'" key="moldCode" label="Mold Code" prop="moldCode" :show-message="false">
  1161. <el-input v-model="savePart.moldCode"></el-input>
  1162. </el-form-item>
  1163. <el-form-item v-else label="Mold Code">
  1164. <el-input v-model="savePart.moldCode" disabled></el-input>
  1165. </el-form-item>
  1166. </el-col>
  1167. </el-row>
  1168. <el-row :gutter="10">
  1169. <el-col :span="7" v-if="category.rollLabelRequired === 'Y'">
  1170. <el-form-item label="Qty Per Roll" prop="qtyPerRoll" :show-message="false">
  1171. <el-input-number :step="0" :min="0" :controls="false" :disabled="this.savePart.serialNumberRequired === 'Y'" v-model="savePart.qtyPerRoll"></el-input-number>
  1172. </el-form-item>
  1173. </el-col>
  1174. <el-col :span="7" v-if="category.rollLabelRequired === 'Y'">
  1175. <el-form-item label="Rolls Per Carton" prop="rollsPerCarton" :show-message="false">
  1176. <el-input-number :step="0" :min="0" :controls="false" :disabled="this.savePart.serialNumberRequired === 'Y'" v-model="savePart.rollsPerCarton"></el-input-number>
  1177. </el-form-item>
  1178. </el-col>
  1179. <el-col :span="7">
  1180. <el-form-item :label="category.qtyPerRollPart" prop="qtyPerCarton" :show-message="false">
  1181. <el-input-number :step="0" :min="0" :controls="false" @change="changeQtyRollCarton" :disabled="category.editQtyPerCarton === 'N'" v-model="savePart.qtyPerCarton"></el-input-number>
  1182. </el-form-item>
  1183. </el-col>
  1184. </el-row>
  1185. <el-row :gutter="10">
  1186. <el-col :span="7">
  1187. <el-form-item label="Rev No" prop="rev" :show-message="false">
  1188. <el-input v-model="savePart.rev"></el-input>
  1189. </el-form-item>
  1190. </el-col>
  1191. <el-col :span="17">
  1192. <el-form-item label="Free Info1" :show-message="false">
  1193. <el-input v-model="savePart.freeInfo"></el-input>
  1194. </el-form-item>
  1195. <!-- <el-form-item label="Free Info" :show-message="false">-->
  1196. <!-- <el-input v-model="savePart.freeInfo"></el-input>-->
  1197. <!-- </el-form-item>-->
  1198. </el-col>
  1199. <el-col :span="7">
  1200. <el-form-item label=" " :show-message="false">
  1201. <el-checkbox v-model="savePart.active" true-label="Y" false-label="N">Active</el-checkbox>
  1202. </el-form-item>
  1203. </el-col>
  1204. <el-col :span="17">
  1205. <el-form-item label="Free Info2" :show-message="false">
  1206. <el-input v-model="savePart.freeInfo2"></el-input>
  1207. </el-form-item>
  1208. </el-col>
  1209. <!-- <el-form-item label="OOC" :show-message="false" prop="freeInfo2">-->
  1210. <!-- <el-select v-model="savePart.freeInfo2" placeholder="" style="width: 100%">-->
  1211. <!-- <el-option v-for="item in countryList" :label="item.countryNo" :value="item.countryNo" :key="item.countryNo"></el-option>-->
  1212. <!-- </el-select>-->
  1213. <!-- </el-form-item>-->
  1214. </el-row>
  1215. </el-form>
  1216. <div slot="footer" class="dialog-footer">
  1217. <el-button type="primary" v-if="savePart.site !== ''" @click="handleUpdate">Save</el-button>
  1218. <el-button type="primary" v-else @click="handleSave">Save</el-button>
  1219. <el-button @click="savePartVisible = false">Cancel</el-button>
  1220. </div>
  1221. </el-dialog>
  1222. <div v-show="false">
  1223. <img :src="item" v-for="(item,index) in base64List" :key="index" style="display: none">
  1224. </div>
  1225. </div>
  1226. </template>
  1227. <style scoped>
  1228. </style>