refactor: 优化列表删除时的提示

This commit is contained in:
CaptainB 2022-01-26 15:14:57 +08:00 committed by 刘瑞斌
parent f92c67fe84
commit 6f4d99323f
4 changed files with 62 additions and 49 deletions

View File

@ -563,6 +563,7 @@ export default {
envGroupId: "", envGroupId: "",
apiscenariofilters: {}, apiscenariofilters: {},
runRequest: {}, runRequest: {},
versionEnable: false,
}; };
}, },
created() { created() {
@ -843,6 +844,7 @@ export default {
} }
if (hasLicense()) { if (hasLicense()) {
this.$get('/project/version/enable/' + projectId, response => { this.$get('/project/version/enable/' + projectId, response => {
this.versionEnable = response.data;
if (!response.data) { if (!response.data) {
this.fields = this.fields.filter(f => f.id !== 'versionId'); this.fields = this.fields.filter(f => f.id !== 'versionId');
} }
@ -1147,20 +1149,22 @@ export default {
} }
} }
// //
if (hasLicense()) { this.$get('/api/automation/versions/' + row.id, response => {
// if (hasLicense() && this.versionEnable && response.data.length > 1) {
this.$refs.apiDeleteConfirm.open(row, alertMsg); //
} else { this.$refs.apiDeleteConfirm.open(row, alertMsg);
this.$alert(alertMsg, '', { } else {
confirmButtonText: this.$t('commons.confirm'), this.$alert(alertMsg, '', {
cancelButtonText: this.$t('commons.cancel'), confirmButtonText: this.$t('commons.confirm'),
callback: (action) => { cancelButtonText: this.$t('commons.cancel'),
if (action === 'confirm') { callback: (action) => {
this._handleDelete(row, false); if (action === 'confirm') {
this._handleDelete(row, false);
}
} }
} });
}); }
} });
}); });
} }
}, },

View File

@ -430,6 +430,7 @@ export default {
environmentId: undefined, environmentId: undefined,
selectDataCounts: 0, selectDataCounts: 0,
projectName: "", projectName: "",
versionEnable: false,
}; };
}, },
props: { props: {
@ -814,19 +815,22 @@ export default {
}); });
return; return;
} }
if (hasLicense()) { // api
// this.$get('/api/definition/versions/' + api.id, response => {
this.$refs.apiDeleteConfirm.open(api, this.$t('api_test.definition.request.delete_confirm')); if (hasLicense() && this.versionEnable && response.data.length > 1) {
} else { //
this.$alert(this.$t('api_test.definition.request.delete_confirm') + ' ' + api.name + " ", '', { this.$refs.apiDeleteConfirm.open(api, this.$t('api_test.definition.request.delete_confirm'));
confirmButtonText: this.$t('commons.confirm'), } else {
callback: (action) => { this.$alert(this.$t('api_test.definition.request.delete_confirm') + ' ' + api.name + " ", '', {
if (action === 'confirm') { confirmButtonText: this.$t('commons.confirm'),
this._handleDelete(api, false); callback: (action) => {
if (action === 'confirm') {
this._handleDelete(api, false);
}
} }
} });
}); }
} });
}, },
_handleDelete(api, deleteCurrentVersion) { _handleDelete(api, deleteCurrentVersion) {
// //
@ -927,6 +931,7 @@ export default {
} }
if (hasLicense()) { if (hasLicense()) {
this.$get('/project/version/enable/' + this.projectId, response => { this.$get('/project/version/enable/' + this.projectId, response => {
this.versionEnable = response.data;
if (!response.data) { if (!response.data) {
this.fields = this.fields.filter(f => f.id !== 'versionId'); this.fields = this.fields.filter(f => f.id !== 'versionId');
} }

View File

@ -256,19 +256,21 @@ export default {
}); });
}, },
handleDelete(test) { handleDelete(test) {
if (hasLicense()) { this.$get('/performance/versions/' + test.id, response => {
// if (hasLicense() && this.versionEnable && response.data.length > 1) {
this.$refs.apiDeleteConfirm.open(test, this.$t('load_test.delete_confirm')); //
} else { this.$refs.apiDeleteConfirm.open(test, this.$t('load_test.delete_confirm'));
this.$alert(this.$t('load_test.delete_confirm') + test.name + "", '', { } else {
confirmButtonText: this.$t('commons.confirm'), this.$alert(this.$t('load_test.delete_confirm') + test.name + "", '', {
callback: (action) => { confirmButtonText: this.$t('commons.confirm'),
if (action === 'confirm') { callback: (action) => {
this._handleDelete(test, false); if (action === 'confirm') {
this._handleDelete(test, false);
}
} }
} });
}); }
} });
}, },
_handleDelete(test, deleteCurrentVersion) { _handleDelete(test, deleteCurrentVersion) {
if (deleteCurrentVersion) { if (deleteCurrentVersion) {

View File

@ -897,19 +897,21 @@ export default {
}); });
}, },
handleDeleteToGc(testCase) { handleDeleteToGc(testCase) {
if (hasLicense()) { this.$get('/test/case/versions/' + testCase.id, response => {
// if (hasLicense() && this.versionEnable && response.data.length > 1) {
this.$refs.apiDeleteConfirm.open(testCase, this.$t('test_track.case.delete_confirm')); //
} else { this.$refs.apiDeleteConfirm.open(testCase, this.$t('test_track.case.delete_confirm'));
this.$alert(this.$t('test_track.case.delete_confirm') + '\'' + testCase.name + '\'' + "", '', { } else {
confirmButtonText: this.$t('commons.confirm'), this.$alert(this.$t('test_track.case.delete_confirm') + '\'' + testCase.name + '\'' + "", '', {
callback: (action) => { confirmButtonText: this.$t('commons.confirm'),
if (action === 'confirm') { callback: (action) => {
this._handleDeleteVersion(testCase, false); if (action === 'confirm') {
this._handleDeleteVersion(testCase, false);
}
} }
} });
}); }
} });
}, },
batchReduction() { batchReduction() {
let param = buildBatchParam(this, this.$refs.table.selectIds); let param = buildBatchParam(this, this.$refs.table.selectIds);