校验 项目和前端项目配置 是否存在

This commit is contained in:
joylink_cuiweidong 2022-09-29 16:50:22 +08:00
parent e29fdb0cb3
commit c2c746406e
3 changed files with 52 additions and 17 deletions

View File

@ -125,3 +125,21 @@ export function getAllFrontProjectConfigByLogin(markKey) {
method: 'get'
});
}
/** 检查项目code */
export function checkBackProjectExist(params) {
return request({
url: `/api/project/check/code`,
method: 'get',
params
});
}
/** 检查项目markKey */
export function checkFrontProjectExist(params) {
return request({
url: `/api/project/check/markKey`,
method: 'get',
params
});
}

View File

@ -22,7 +22,7 @@
</el-dialog>
</template>
<script>
import { updateFrontProjectConfig, saveFrontProjectConfig} from '@/api/projectConfig';
import { updateFrontProjectConfig, saveFrontProjectConfig, checkFrontProjectExist} from '@/api/projectConfig';
export default {
name:'AddProjectConfig',
data() {
@ -96,15 +96,24 @@ export default {
});
} else {
delete data.id;
//
saveFrontProjectConfig(data).then(resp => {
this.$message.success('创建前端配置成功!');
this.handleClose();
this.$emit('reloadTable');
}).catch(error => {
this.$message.error(error.message);
this.loading = false;
// markKey
checkFrontProjectExist({markKey:data.markKey}).then(res=>{
if (!res.data) {
//
saveFrontProjectConfig(data).then(resp => {
this.$message.success('创建前端配置成功!');
this.handleClose();
this.$emit('reloadTable');
}).catch(error => {
this.$message.error(error.message);
this.loading = false;
});
} else {
this.$message.success('此前端配置已存在,请修改配置编码');
}
});
}
}
});

View File

@ -21,7 +21,7 @@
</el-dialog>
</template>
<script>
import { saveBackProjectConfig, updateBackProjectConfig} from '@/api/projectConfig';
import { saveBackProjectConfig, updateBackProjectConfig, checkBackProjectExist} from '@/api/projectConfig';
export default {
name: 'AddProject',
data() {
@ -100,14 +100,22 @@ export default {
});
} else {
delete data.id;
saveBackProjectConfig(data).then(resp => {
this.$message.success('创建项目成功!');
this.handleClose();
this.$emit('reloadTable');
}).catch(error => {
this.$message.error(error.message);
this.loading = false;
// code
checkBackProjectExist({code:data.code}).then(res=>{
if (!res.data) {
saveBackProjectConfig(data).then(resp => {
this.$message.success('创建项目成功!');
this.handleClose();
this.$emit('reloadTable');
}).catch(error => {
this.$message.error(error.message);
this.loading = false;
});
} else {
this.$message.success('此项目已存在,请修改项目编码');
}
});
}
}
});