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.

1128 lines
36 KiB

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