diff --git a/src/api/rohs/rohs.js b/src/api/rohs/rohs.js index 8abcc31..cc2606e 100644 --- a/src/api/rohs/rohs.js +++ b/src/api/rohs/rohs.js @@ -21,5 +21,8 @@ export const submitRohs = data => createAPI(`/rohs/submit`, 'post', data); // 查询审批信息 export const getRohsApprovalList = data => createAPI(`/rohs/approvalList`, 'post', data); +// 查询按钮控制信息 +export const getRohsButtonCondition = data => createAPI(`/rohs/buttonCondition`, 'post', data); + // 导出 export const exportRohs = params => createAPI(`/rohs/export`, 'get', params); diff --git a/src/views/modules/rohs/rohsRecord.vue b/src/views/modules/rohs/rohsRecord.vue index 5d086d5..39a1354 100644 --- a/src/views/modules/rohs/rohsRecord.vue +++ b/src/views/modules/rohs/rohsRecord.vue @@ -289,10 +289,10 @@ - 保存 + 保存 关闭 - 同意 - 驳回 + 同意 + 驳回 @@ -567,6 +567,7 @@ export default { authFilePreview: false, authDelete: false, superAdmin: false, + createBy2: this.$store.state.user.name, height: 400, secondHeight: 200, currentRow: {}, @@ -636,6 +637,7 @@ export default { approvalList: [], modalTitle: 'RoHs 新增', activeName: 'basicInfo', + showModalFlag: false, submitModalFlag: false, rejectOpinion: '', submitLoading: false, @@ -678,7 +680,11 @@ export default { hsfSupplierClassification: '', materialDesc: '', isSameMaterialDiffSize: '', - ifsPartNo: '' + ifsPartNo: '', + createBy2: '', + isReject: 'Y', + tpProcessControl: 'N', + csProcessControl: 'N' } } }, @@ -707,6 +713,49 @@ export default { } return value || '' }, + isCurrentApprover () { + return this.superAdmin || (this.modalData.createBy2 && this.modalData.createBy2.split(';').includes(this.createBy2)) + }, + canSaveAction () { + return !this.showModalFlag && (this.modalData.status === '草稿' || (this.modalData.status === '审批中' && this.isCurrentApprover())) + }, + canAgreeAction () { + return this.authSubmit && this.isCurrentApprover() && this.modalData.status === '审批中' && this.modalData.tpProcessControl !== 'Y' && this.modalData.csProcessControl !== 'Y' + }, + canRejectAction () { + return this.authReject && this.isCurrentApprover() && this.modalData.status === '审批中' && this.modalData.isReject === 'Y' + }, + loadModalButtonCondition () { + if (!this.modalData.site || !this.modalData.referenceNo || this.modalData.status !== '审批中') { + this.$set(this.modalData, 'createBy2', '') + this.$set(this.modalData, 'isReject', 'Y') + this.$set(this.modalData, 'tpProcessControl', 'N') + this.$set(this.modalData, 'csProcessControl', 'N') + return + } + let params = { + site: this.modalData.site, + referenceNo: this.modalData.referenceNo + } + api.getRohsButtonCondition(params).then(({data}) => { + if (data && data.code === 0 && data.data) { + this.$set(this.modalData, 'createBy2', data.data.createBy2 || '') + this.$set(this.modalData, 'isReject', data.data.isReject || 'Y') + this.$set(this.modalData, 'tpProcessControl', data.data.tpProcessControl || 'N') + this.$set(this.modalData, 'csProcessControl', data.data.csProcessControl || 'N') + } else { + this.$set(this.modalData, 'createBy2', '') + this.$set(this.modalData, 'isReject', 'Y') + this.$set(this.modalData, 'tpProcessControl', 'N') + this.$set(this.modalData, 'csProcessControl', 'N') + } + }).catch(() => { + this.$set(this.modalData, 'createBy2', '') + this.$set(this.modalData, 'isReject', 'Y') + this.$set(this.modalData, 'tpProcessControl', 'N') + this.$set(this.modalData, 'csProcessControl', 'N') + }) + }, // 列表行选中变色 rowStyle ({row}) { if (this.currentRow && this.currentRow.referenceNo === row.referenceNo) { @@ -968,6 +1017,7 @@ export default { this.uploadDialog = false this.submitModalFlag = false this.rejectOpinion = '' + this.showModalFlag = !!(row && row.status === '已完成') if (row) { this.modalTitle = 'RoHs 编辑' @@ -987,6 +1037,10 @@ export default { // 编辑时允许重新选择客户和项目 this.$set(this.modalData, 'endCustomerFlag', false) this.$set(this.modalData, 'projectIdFlag', !this.modalData.endCustomer) + this.$set(this.modalData, 'createBy2', '') + this.$set(this.modalData, 'isReject', 'Y') + this.$set(this.modalData, 'tpProcessControl', 'N') + this.$set(this.modalData, 'csProcessControl', 'N') // Try to trigger verify data on open to fetch names this.applicantBlur(103) @@ -995,10 +1049,12 @@ export default { this.technicalPlanBlur(103) this.handleQueryCustomer() this.handleQueryProjectByCustomer() + this.loadModalButtonCondition() } }) } else { this.modalTitle = 'RoHs 新增' + this.showModalFlag = false // 生成一个临时ID用于附件上传绑定 const tempReferenceNo = 'TEMP-' + new Date().getTime() + '-' + Math.floor(Math.random() * 1000) this.modalData = { @@ -1048,14 +1104,18 @@ export default { hsfSupplierClassification: '', materialDesc: '', isSameMaterialDiffSize: '', - ifsPartNo: '' + ifsPartNo: '', + createBy2: '', + isReject: 'Y', + tpProcessControl: 'N', + csProcessControl: 'N' } } }, // 表单提交 dataFormSubmit () { - if (!this.authUpdate) { - this.$message.warning('没有保存权限') + if (!this.canSaveAction()) { + this.$message.warning('当前状态不允许保存') return } this.modalData.qualificationDocumentsNeeded = this.modalData.qualificationDocumentsNeededList.join(';') @@ -1075,8 +1135,8 @@ export default { }, // 同意 agreeSubmit () { - if (!this.authSubmit) { - this.$message.warning('没有同意权限') + if (!this.canAgreeAction()) { + this.$message.warning('当前状态不允许同意') return } this.$confirm('确认同意该申请单?', '提示', { @@ -1088,8 +1148,8 @@ export default { }) }, openRejectModal () { - if (!this.authReject) { - this.$message.warning('没有驳回权限') + if (!this.canRejectAction()) { + this.$message.warning('当前状态不允许驳回') return } this.rejectOpinion = '' @@ -1104,12 +1164,12 @@ export default { this.submitRohs('N') }, submitRohs (nodeConclusion) { - if (nodeConclusion === 'Y' && !this.authSubmit) { - this.$message.warning('没有同意权限') + if (nodeConclusion === 'Y' && !this.canAgreeAction()) { + this.$message.warning('当前状态不允许同意') return } - if (nodeConclusion === 'N' && !this.authReject) { - this.$message.warning('没有驳回权限') + if (nodeConclusion === 'N' && !this.canRejectAction()) { + this.$message.warning('当前状态不允许驳回') return } if (!this.modalData.site || !this.modalData.referenceNo) { @@ -1152,7 +1212,8 @@ export default { }).then(() => { let params = { site: row.site, - referenceNo: row.referenceNo + referenceNo: row.referenceNo, + menuId: this.menuId } api.issueRohs(params).then(({data}) => { if (data && data.code === 0) {