refactor: 复制功能用例其他信息弹出框优化

This commit is contained in:
zhangdahai112 2022-01-21 17:36:21 +08:00 committed by jianxing
parent dfe0c8d2ec
commit 50a36fac7f
2 changed files with 53 additions and 38 deletions

View File

@ -154,6 +154,8 @@
:tree-nodes="treeNodes"></test-case-version-diff> :tree-nodes="treeNodes"></test-case-version-diff>
</el-dialog> </el-dialog>
<version-create-other-info-select @confirmOtherInfo="confirmOtherInfo" ref="selectPropDialog"></version-create-other-info-select>
</div> </div>
</el-card> </el-card>
@ -723,21 +725,11 @@ export default {
this.dialogFormVisible = false; this.dialogFormVisible = false;
}, },
saveCase(callback) { saveCase(callback) {
let isValidate = true; if (this.validateForm()) {
this.$refs['caseFrom'].validate((valid) => {
if (!valid) {
isValidate = false;
return false;
}
});
this.$refs['customFieldForm'].validate((valid) => {
if (!valid) {
isValidate = false;
return false;
}
});
if (isValidate) {
this._saveCase(callback); this._saveCase(callback);
}else{
this.$refs.versionHistory.loading = false;
this.$refs.selectPropDialog.close();
} }
}, },
_saveCase(callback) { _saveCase(callback) {
@ -968,7 +960,6 @@ export default {
this.currentProjectId = getCurrentProjectID(); this.currentProjectId = getCurrentProjectID();
} }
this.versionData = response.data; this.versionData = response.data;
this.$refs.versionHistory.cancelOtherInfo();
this.$refs.versionHistory.loading = false; this.$refs.versionHistory.loading = false;
}); });
}, },
@ -1012,15 +1003,35 @@ export default {
}); });
} }
}, },
validateForm() {
let isValidate = true;
this.$refs['caseFrom'].validate((valid) => {
if (!valid) {
isValidate = false;
return false;
}
});
this.$refs['customFieldForm'].validate((valid) => {
if (!valid) {
isValidate = false;
return false;
}
});
return isValidate;
},
async create(row) { async create(row) {
// if (this.validateForm()) {
this.form.versionId = row.id; //
let hasOtherInfo = await this.hasOtherInfo(); this.form.versionId = row.id;
if (hasOtherInfo) { let hasOtherInfo = await this.hasOtherInfo();
this.$refs.versionHistory.loading = false; if (hasOtherInfo) {
this.$refs.versionHistory.showOtherInfo(); this.$refs.versionHistory.loading = false;
this.$refs.selectPropDialog.open();
} else {
this.saveCase();
}
} else { } else {
this.saveCase(); this.$refs.versionHistory.loading = false;
} }
}, },
del(row) { del(row) {

View File

@ -1,13 +1,12 @@
<template> <template>
<div> <!--创建新版本选择其他信息对话框-->
<el-dialog
:title="$t('commons.sync_other_info')"
:visible.sync="visible"
:show-close="false"
width="30%"
>
<el-form ref="form" :model="form" label-width="10px" label-position="left"> <el-form ref="form" :model="form" label-width="10px" label-position="left">
<el-row>
<el-col :span="24">
<el-form-item>
<span>{{ $t('test_track.case.sync_to_new_version') }}</span>
</el-form-item>
</el-col>
</el-row>
<el-row> <el-row>
<el-col :span="6"> <el-col :span="6">
<el-form-item> <el-form-item>
@ -42,14 +41,12 @@
</el-form-item> </el-form-item>
</el-col> </el-col>
</el-row> </el-row>
<el-row>
<el-form-item style="float:right">
<el-button size="small" @click="$emit('cancelOtherInfo')">{{ $t('commons.cancel') }}</el-button>
<el-button type="primary" size="small" @click="confirmOtherInfo">{{ $t('commons.confirm') }}</el-button>
</el-form-item>
</el-row>
</el-form> </el-form>
</div> <span slot="footer" class="dialog-footer">
<el-button @click="visible = false;">{{ $t('commons.cancel') }}</el-button>
<el-button type="primary" @click="confirmOtherInfo">{{ $t('commons.confirm') }}</el-button>
</span>
</el-dialog>
</template> </template>
<script> <script>
@ -58,6 +55,7 @@ export default {
name: "VersionCreateOtherInfoSelect", name: "VersionCreateOtherInfoSelect",
data() { data() {
return { return {
visible: false,
form: { form: {
remark: false, remark: false,
relateTest: false, relateTest: false,
@ -66,11 +64,17 @@ export default {
archive: false, archive: false,
dependency: false, dependency: false,
} }
}; };
}, },
methods: { methods: {
open() {
this.visible = true;
},
close() {
this.visible = false;
},
confirmOtherInfo() { confirmOtherInfo() {
this.visible = false;
this.$emit("confirmOtherInfo", this.form); this.$emit("confirmOtherInfo", this.form);
} }
} }