diff --git a/src/views/modules/proofing/requestForProofing.vue b/src/views/modules/proofing/requestForProofing.vue index 3018ac3..254445a 100644 --- a/src/views/modules/proofing/requestForProofing.vue +++ b/src/views/modules/proofing/requestForProofing.vue @@ -216,15 +216,15 @@ - + - 客户编码 - @@ -237,17 +237,17 @@ - + - + - @@ -256,7 +256,7 @@ + :disabled="headerFieldDisabled('requiredDeliveryDate')"> @@ -265,9 +265,9 @@ - 项目号 - @@ -280,37 +280,37 @@ - + CS - - + + - + NPI工程师 - - + + - + Approver - - + + - + DelegateAccess - - + + @@ -318,21 +318,21 @@ - + - + - + @@ -968,40 +968,11 @@ export default { } }, - columnFlagByHeader() { - return (value) => { - if (this.modalData.flag === '1') { - return false - } - if (!this.columnFieldList1) { - return true - } - let arr = this.columnFieldList1.filter(a => a.fieldId === value) - if (arr.length > 0) { - return arr[0].updateFlag === 'N' - } - return true - } - }, - columnFlagByDelegateAccess() { - return (value) => { - if (this.modalData.flag === '1') { - return false - } - if (!this.columnFieldList2) { - return true - } - let arr = this.columnFieldList2.filter(a => a.fieldId === value) - if (arr.length > 0) { - return arr[0].updateFlag === 'N' - } - return true - } - }, }, data() { return { issuingSet: {}, + editFormKey: 0, approvalList: [], selectionDelegateAccess: [], selectionDelegateAccess2: [], @@ -2301,6 +2272,26 @@ export default { }, methods: { + headerFieldDisabled(fieldId) { + return this.detailVisible || this.columnFlagByHeader(fieldId) + }, + delegateFieldDisabled(fieldId) { + return this.detailVisible || this.columnFlagByDelegateAccess(fieldId) + }, + // 新增都可填。编辑只有当前节点明确勾选可编辑(updateFlag 为 Y)的字段才能改。 + columnFlagByHeader(value) { + return !this.fieldEditable(this.columnFieldList1, value) + }, + columnFlagByDelegateAccess(value) { + return !this.fieldEditable(this.columnFieldList2, value) + }, + fieldEditable(list, fieldId) { + if (this.modalData.flag === '1') { + return true + } + const rows = (list || []).filter(item => item.fieldId === fieldId) + return rows.length > 0 && rows.every(item => item.updateFlag === 'Y') + }, fetchNodeOptions() { getNodeList(this.searchData).then(({ data }) => { @@ -2588,6 +2579,9 @@ export default { addModal() { this.searchDelegateAccessByUser(); this.modalData.createBy = this.$store.state.user.name + this.columnFieldList1 = [] + this.columnFieldList2 = [] + this.editFormKey += 1 this.modalDisableFlag = false this.modalFlag = true }, @@ -2648,6 +2642,7 @@ export default { sendSamplesUsage: row.sendSamplesUsage } this.searchDelegateAccessByUser(); + this.editFormKey += 1 this.modalDisableFlag = true this.modalFlag = true }, @@ -2704,6 +2699,7 @@ export default { sendSamplesUsage: row.sendSamplesUsage } this.searchDelegateAccessByUser(); + this.editFormKey += 1 this.modalDisableFlag = true this.modalFlag = true }, @@ -2774,7 +2770,7 @@ export default { * 客户信息新增/编辑 */ saveData() { - this.$refs.modalForm.validate((valid, obj) => { + this.$refs.modalForm.validate(async (valid, obj) => { if (!valid) { let i = 1; for (let key in obj) { @@ -2785,6 +2781,9 @@ export default { i++; } } else { + if (!(await this.validateCustomerAndProject())) { + return + } if (this.projectPartListSelections.length <= 0) { this.$message.warning('请选择项目料号') return @@ -3647,7 +3646,11 @@ export default { return s }, closeModalDiaLog() { - this.$refs.modalForm.resetFields(); + this.columnFieldList1 = [] + this.columnFieldList2 = [] + if (this.$refs.modalForm) { + this.$refs.modalForm.resetFields(); + } this.modalData = { flag: '1', title: '打样新增', @@ -3988,57 +3991,136 @@ export default { // 获取流程的配置权限 async getNodeAuthority(row) { + this.columnFieldList1 = [] + this.columnFieldList2 = [] let tempData = { site: row.site, stepId: row.stepId, - menuId: this.$route.meta.menuId + menuId: this.$route.meta.menuId, + currentNodeOnly: true } await getNodeAuthority(tempData).then(({data}) => { if (data && data.code === 0) { - this.columnFieldList1 = data.rows.plm_proofing_information - this.columnFieldList2 = data.rows.plm_proofing_delegate_access + this.columnFieldList1 = (data.rows && data.rows.plm_proofing_information) || [] + this.columnFieldList2 = (data.rows && data.rows.plm_proofing_delegate_access) || [] } }) }, handleQueryCustomer() { - let params = { - site: this.$store.state.user.site, - customerNo: this.modalData.customerNo + const customerNo = (this.modalData.customerNo || '').trim() + if (!customerNo) { + this.modalData.customerDesc = '' + return } - queryCustomer(params).then(({data}) => { - if (data && data.code === 0) { - if (data.rows && data.rows.length === 1) { - this.modalData.customerDesc = data.rows[0].customerDesc - } else { - this.modalData.customerDesc = '' - } - } else { + this.lookupCustomer().then(ok => { + if (ok === false) { + this.$message.warning('客户编码不存在或已失效') + } + }) + }, + handleQueryProjectByCustomer() { + const projectId = (this.modalData.projectId || '').trim() + if (!projectId) { + this.modalData.projectName = '' + return + } + if (!(this.modalData.customerNo || '').trim()) { + this.modalData.projectName = '' + this.$message.warning('请先填写客户编码') + return + } + this.lookupProject().then(ok => { + if (ok === false) { + this.$message.warning('项目号不存在,或不属于该客户') + } + }) + }, + lookupCustomer() { + const customerNo = (this.modalData.customerNo || '').trim() + if (!customerNo) { + this.modalData.customerDesc = '' + return Promise.resolve(false) + } + return queryCustomer({ + site: this.$store.state.user.site, + customerNo + }).then(({data}) => { + if (data && data.code !== 0) { this.$message.warning(data.msg) + this.modalData.customerDesc = '' + return 'error' } + const site = this.$store.state.user.site + const rows = ((data && data.rows) || []).filter(row => !row.site || row.site === site) + if (rows.length === 1) { + this.modalData.customerDesc = rows[0].customerDesc + return true + } + this.modalData.customerDesc = '' + return false }).catch((error) => { this.$message.error(error) + this.modalData.customerDesc = '' + return 'error' }) }, - handleQueryProjectByCustomer() { - let params = { - site: this.$store.state.user.site, - customerId: this.modalData.customerNo, - projectId: this.modalData.projectId + lookupProject() { + const customerNo = (this.modalData.customerNo || '').trim() + const projectId = (this.modalData.projectId || '').trim() + if (!customerNo || !projectId) { + this.modalData.projectName = '' + return Promise.resolve(false) } - queryProjectByCustomer(params).then(({data}) => { - if (data && data.code === 0) { - if (data.rows && data.rows.length === 1) { - this.modalData.projectName = data.rows[0].projectName - } else { - this.modalData.projectName = '' - } - } else { + return queryProjectByCustomer({ + site: this.$store.state.user.site, + customerId: customerNo, + projectId + }).then(({data}) => { + if (data && data.code !== 0) { this.$message.warning(data.msg) + this.modalData.projectName = '' + return 'error' + } + const rows = (data && data.rows) || [] + if (rows.length === 1) { + this.modalData.projectName = rows[0].projectName + return true } + this.modalData.projectName = '' + return false }).catch((error) => { this.$message.error(error) + this.modalData.projectName = '' + return 'error' }) }, + async validateCustomerAndProject() { + const customerNo = (this.modalData.customerNo || '').trim() + if (!customerNo) { + this.$message.warning('请选择客户编码!') + return false + } + const customerOk = await this.lookupCustomer() + if (customerOk !== true) { + if (customerOk === false) { + this.$message.warning('客户编码不存在或已失效') + } + return false + } + const projectId = (this.modalData.projectId || '').trim() + if (!projectId) { + this.$message.warning('请选择项目号!') + return false + } + const projectOk = await this.lookupProject() + if (projectOk !== true) { + if (projectOk === false) { + this.$message.warning('项目号不存在,或不属于该客户') + } + return false + } + return true + }, // 查询审批信息 getApprovalList() { let tempData = {