修复业务模块bug

This commit is contained in:
2026-08-14 14:19:12 +08:00
parent 6bc9981ffc
commit 574b1a52f4
8 changed files with 1035 additions and 254 deletions
+61 -3
View File
@@ -730,6 +730,33 @@ export default {
this.form.projectIds = project ? String(project.id) : '';
this.form.projectNames = project ? project.projectName : '';
},
checkEnabledProjectConfig(projectId, excludeId = '') {
if (!projectId) return Promise.resolve(false);
return api
.getList(1, 100, {
projectIds: String(projectId),
status: 1,
})
.then(res => {
const data = res?.data?.data || {};
const records = Array.isArray(data) ? data : data.records || [];
return records.some(item => {
const projectIds = String(item.projectIds || '')
.split(/[,]/)
.map(value => value.trim())
.filter(Boolean);
return (
String(item.id || '') !== String(excludeId || '') &&
Number(item.status) === 1 &&
projectIds.includes(String(projectId))
);
});
});
},
checkEnabledProjectBeforeSubmit(row) {
if (row.id || !row.projectIds) return Promise.resolve(false);
return this.checkEnabledProjectConfig(row.projectIds);
},
handleFinishDaysInput(value) {
this.form.defaultFinishDays = String(value || '')
.replace(/\D/g, '')
@@ -895,7 +922,14 @@ export default {
this.stopSubmitLoading(loading);
return;
}
this.confirmDuplicateVoucher()
this.checkEnabledProjectBeforeSubmit(submitRow)
.then(exists => {
if (exists) {
this.$message.warning('该项目已有启用状态的过程配置,不能重复添加');
throw { code: 'enabled-project-config' };
}
})
.then(() => this.confirmDuplicateVoucher())
.then(() => api.submit(submitRow))
.then(() => {
this.onLoad(this.page);
@@ -903,7 +937,11 @@ export default {
done();
})
.catch(error => {
if (error !== 'cancel' && error !== 'close') {
if (
error !== 'cancel' &&
error !== 'close' &&
error?.code !== 'enabled-project-config'
) {
window.console.log(error);
}
this.stopSubmitLoading(loading);
@@ -1089,8 +1127,28 @@ export default {
cancelButtonText: '取消',
type: 'warning',
})
.then(() => api[action](row.id))
.then(() => {
if (action !== 'enable') return true;
return this.checkEnabledProjectConfig(row.projectIds, row.id)
.then(exists => {
if (exists) {
this.$message.warning('该项目已有其他启用状态的过程配置,不能重复启用');
return false;
}
return true;
})
.catch(error => {
window.console.log(error);
this.$message.error('检查项目过程配置失败,暂不能启用');
return false;
});
})
.then(canProceed => {
if (!canProceed) return null;
return api[action](row.id);
})
.then(result => {
if (!result) return;
this.$message.success(`${actionName}成功`);
this.onLoad(this.page, this.query);
});