diff --git a/src/api/rohs/rohs.js b/src/api/rohs/rohs.js index cc2606e..98015b1 100644 --- a/src/api/rohs/rohs.js +++ b/src/api/rohs/rohs.js @@ -6,6 +6,9 @@ export const getRohsList = params => createAPI(`/rohs/list`, 'get', params); // 获取详情 export const getRohsDetail = (site, referenceNo) => createAPI(`/rohs/info`, 'get', { site, referenceNo }); +// 查询项目物料(用于RoHs材料明细选择) +export const getRohsProjectMaterialList = params => createAPI(`/rohs/projectMaterialList`, 'get', params); + // 新增 export const saveRohs = data => createAPI(`/rohs/save`, 'post', data); diff --git a/src/views/modules/rohs/rohsRecord.vue b/src/views/modules/rohs/rohsRecord.vue index 5ef72b7..44341bb 100644 --- a/src/views/modules/rohs/rohsRecord.vue +++ b/src/views/modules/rohs/rohsRecord.vue @@ -324,11 +324,28 @@
- - - + + + 新增材料 + 删除材料 + + + + + + + +
@@ -383,6 +400,56 @@ + + + + + + + + + + + + + + + + 查询 + + + + + + + + + + + + + 确定 + 取消 + + + @@ -581,9 +648,18 @@
- - - + + + + + + +
@@ -716,12 +792,26 @@ export default { modalFlag: false, uploadDialog: false, chooseProjectListFlag: false, + projectMaterialDialogFlag: false, searchProjectData: { site: '', projectId: undefined, projectName: undefined, customerId: undefined, }, + projectMaterialSearchData: { + testPartNo: '', + partDesc: '', + finalPartNo: '', + customerPartNo: '' + }, + projectMaterialList: [], + projectMaterialSelections: [], + materialSelections: [], + projectMaterialPageIndex: 1, + projectMaterialPageSize: 20, + projectMaterialTotal: 0, + projectMaterialLoading: false, projectList: [], fileList: [], approvalList: [], @@ -783,6 +873,7 @@ export default { npdRemark: '', isSameMaterialDiffSize: '', ifsPartNo: '', + materialList: [], createBy2: '', isReject: 'Y', tpProcessControl: 'N', @@ -806,6 +897,12 @@ export default { }) }, methods: { + materialDialogHeaderCellStyle () { + return { + whiteSpace: 'nowrap', + wordBreak: 'keep-all' + } + }, displayYesNo (value) { if (value === 'Y') { return '是' @@ -891,10 +988,16 @@ export default { } else { this.currentRow = row || {} } + if (!Array.isArray(this.currentRow.materialList)) { + this.$set(this.currentRow, 'materialList', []) + } this.loadCurrentRowNames() this.refreshCurrentTabTable() }).catch(() => { this.currentRow = row || {} + if (!Array.isArray(this.currentRow.materialList)) { + this.$set(this.currentRow, 'materialList', []) + } this.loadCurrentRowNames() this.refreshCurrentTabTable() }) @@ -902,6 +1005,9 @@ export default { currentChange (val) { this.currentRow = val || {} if (val) { + if (!Array.isArray(this.currentRow.materialList)) { + this.$set(this.currentRow, 'materialList', []) + } this.loadCurrentRowNames() this.refreshCurrentTabTable() } else { @@ -1156,6 +1262,18 @@ export default { this.uploadDialog = false this.submitModalFlag = false this.rejectOpinion = '' + this.projectMaterialDialogFlag = false + this.projectMaterialSelections = [] + this.materialSelections = [] + this.projectMaterialPageIndex = 1 + this.projectMaterialTotal = 0 + this.projectMaterialList = [] + this.projectMaterialSearchData = { + testPartNo: '', + partDesc: '', + finalPartNo: '', + customerPartNo: '' + } this.showModalFlag = !!(row && row.status === '已完成') if (row) { @@ -1166,6 +1284,7 @@ export default { this.$set(this.modalData, 'qualificationDocumentsNeededList', this.modalData.qualificationDocumentsNeeded ? this.modalData.qualificationDocumentsNeeded.split(';').filter(item => item) : []) this.$set(this.modalData, 'testReportIncludingItemsList', this.modalData.testReportIncludingItems ? this.modalData.testReportIncludingItems.split(';').filter(item => item) : []) this.$set(this.modalData, 'materialClassifyList', this.modalData.materialClassify ? this.modalData.materialClassify.split(';').filter(item => item) : []) + this.$set(this.modalData, 'materialList', Array.isArray(this.modalData.materialList) ? this.modalData.materialList : []) // Initialize names for display if needed this.$set(this.modalData, 'applicantName', '') this.$set(this.modalData, 'pmName', '') @@ -1264,6 +1383,7 @@ export default { npdRemark: '', isSameMaterialDiffSize: '', ifsPartNo: '', + materialList: [], createBy2: '', isReject: 'Y', tpProcessControl: 'N', @@ -1280,6 +1400,14 @@ export default { this.modalData.qualificationDocumentsNeeded = this.modalData.qualificationDocumentsNeededList.join(';') this.modalData.testReportIncludingItems = this.modalData.testReportIncludingItemsList.join(';') this.modalData.materialClassify = this.modalData.materialClassifyList.join(';') + this.modalData.materialList = (this.modalData.materialList || []).map((item, index) => { + return { + ...item, + lineNo: index + 1, + projectId: this.modalData.projectId + } + }) + this.modalData.ifsPartNo = this.modalData.materialList.length > 0 ? this.modalData.materialList[0].testPartNo : '' const submitMethod = this.modalTitle === 'RoHs 新增' ? api.saveRohs : api.updateRohs submitMethod(this.modalData).then(({data}) => { @@ -1387,6 +1515,116 @@ export default { }) }) }, + openProjectMaterialDialog () { + if (!this.modalData.projectId) { + this.$message.warning('请先选择项目编码') + return + } + if (!this.modalData.endCustomer) { + this.$message.warning('请先选择最终客户') + return + } + this.projectMaterialDialogFlag = true + this.projectMaterialPageIndex = 1 + this.searchProjectMaterialList() + }, + searchProjectMaterialList () { + if (!this.modalData.projectId) { + this.projectMaterialList = [] + this.projectMaterialTotal = 0 + return + } + this.projectMaterialLoading = true + const params = { + page: this.projectMaterialPageIndex, + limit: this.projectMaterialPageSize, + site: this.$store.state.user.site, + projectId: this.modalData.projectId, + endCustomer: this.modalData.endCustomer, + testPartNo: this.projectMaterialSearchData.testPartNo, + partDesc: this.projectMaterialSearchData.partDesc, + finalPartNo: this.projectMaterialSearchData.finalPartNo, + customerPartNo: this.projectMaterialSearchData.customerPartNo + } + api.getRohsProjectMaterialList(params).then(({data}) => { + if (data && data.code === 0 && data.page) { + this.projectMaterialList = data.page.list || [] + this.projectMaterialTotal = data.page.totalCount || 0 + this.$nextTick(() => { + if (this.$refs.projectMaterialTable) { + this.$refs.projectMaterialTable.clearSelection() + } + }) + } else { + this.projectMaterialList = [] + this.projectMaterialTotal = 0 + this.$message.error(data.msg || '项目物料查询失败') + } + this.projectMaterialLoading = false + }).catch(() => { + this.projectMaterialList = [] + this.projectMaterialTotal = 0 + this.projectMaterialLoading = false + }) + }, + projectMaterialSelectionChange (rows) { + this.projectMaterialSelections = rows || [] + }, + projectMaterialSizeChangeHandle (val) { + this.projectMaterialPageSize = val + this.projectMaterialPageIndex = 1 + this.searchProjectMaterialList() + }, + projectMaterialCurrentChangeHandle (val) { + this.projectMaterialPageIndex = val + this.searchProjectMaterialList() + }, + confirmProjectMaterialSelection () { + if (!this.projectMaterialSelections || this.projectMaterialSelections.length === 0) { + this.$message.warning('请至少选择一条项目物料') + return + } + this.appendMaterialRows(this.projectMaterialSelections) + this.projectMaterialDialogFlag = false + }, + appendMaterialRows (rows) { + const materialList = Array.isArray(this.modalData.materialList) ? [...this.modalData.materialList] : [] + const exists = new Set(materialList.map(item => item.testPartNo)) + rows.forEach(row => { + const testPartNo = row.testPartNo || row.test_part_no + if (!testPartNo || exists.has(testPartNo)) { + return + } + exists.add(testPartNo) + materialList.push({ + site: this.modalData.site, + referenceNo: this.modalData.referenceNo, + projectId: this.modalData.projectId, + testPartNo: testPartNo, + finalPartNo: row.finalPartNo || row.final_part_no || '', + customerPartNo: row.customerPartNo || row.customer_part_no || '', + partDesc: row.partDesc || row.part_desc || '', + partSpec: row.partSpec || row.part_spec || '' + }) + }) + this.$set(this.modalData, 'materialList', materialList) + }, + materialSelectionChange (rows) { + this.materialSelections = rows || [] + }, + removeSelectedMaterialRows () { + if (this.showModalFlag) { + return + } + if (!this.materialSelections || this.materialSelections.length === 0) { + this.$message.warning('请先选择要删除的材料') + return + } + const removeSet = new Set(this.materialSelections.map(item => item.testPartNo)) + const materialList = (this.modalData.materialList || []).filter(item => !removeSet.has(item.testPartNo)) + this.$set(this.modalData, 'materialList', materialList) + this.materialSelections = [] + }, // ======== chooseList相关方法 ======== // 获取基础数据列表 getBaseList (val, type) { @@ -1442,6 +1680,7 @@ export default { this.modalData.endCustomerName = val.Customer_desc this.modalData.projectId = '' this.modalData.projectName = '' + this.$set(this.modalData, 'materialList', []) } } if (this.tagNo === 103) { @@ -1482,6 +1721,7 @@ export default { this.modalData.projectId = '' this.modalData.projectName = '' this.modalData.projectIdFlag = true + this.$set(this.modalData, 'materialList', []) return } let params = { @@ -1499,18 +1739,21 @@ export default { this.modalData.projectId = '' this.modalData.projectName = '' this.modalData.projectIdFlag = true + this.$set(this.modalData, 'materialList', []) } } else { this.modalData.endCustomerName = '' this.modalData.projectId = '' this.modalData.projectName = '' this.modalData.projectIdFlag = true + this.$set(this.modalData, 'materialList', []) } }).catch((error) => { this.modalData.endCustomerName = '' this.modalData.projectId = '' this.modalData.projectName = '' this.modalData.projectIdFlag = true + this.$set(this.modalData, 'materialList', []) }) }, handleQueryProjectByCustomer() { @@ -1541,6 +1784,7 @@ export default { }) }, projectClickRow(row) { + const oldProjectId = this.modalData.projectId this.modalData.projectId = row.projectId this.modalData.projectName = row.projectName if (this.modalData.endCustomer && this.modalData.endCustomer !== '') { @@ -1549,6 +1793,9 @@ export default { this.modalData.endCustomer = row.customerId this.modalData.endCustomerName = row.customerName } + if (oldProjectId && oldProjectId !== row.projectId) { + this.$set(this.modalData, 'materialList', []) + } this.chooseProjectListFlag = false }, searchProjectInfoList() { @@ -1757,4 +2004,9 @@ export default { /deep/ .customer-tab .el-tabs__content { padding: 0 !important; } + +/deep/ .rohs-material-table .el-table__header-wrapper th > .cell { + white-space: nowrap; + word-break: keep-all; +}