fix(测试跟踪): 自定义字段成员选项,如果用户被删除则不显示

--bug=1024451 --user=陈建星 【测试跟踪】用例评审-关联跨项目用例-责任人未显示 https://www.tapd.cn/55049933/s/1352654
This commit is contained in:
chenjianxing 2023-03-20 15:15:50 +08:00 committed by jianxing
parent 4c510484f5
commit 6813bd5508
4 changed files with 88 additions and 45 deletions

View File

@ -108,10 +108,10 @@
v-model="data[prop]"
:placeholder="$t('commons.default')">
<el-option
v-for="(item) in memberOptions"
:key="item.id"
:label="item.name + (item.email ? ' (' + item.email + ')' : '')"
:value="item.id">
v-for="(item) in data.options ? data.options : []"
:key="item.value"
:label="item.text + (item.email ? ' (' + item.email + ')' : '')"
:value="item.value">
</el-option>
</el-select>
@ -169,48 +169,14 @@ export default {
],
data() {
return {
memberOptions: [],
originOptions: null,
loading: false
};
},
mounted() {
if (['select', 'multipleSelect', 'checkbox', 'radio'].indexOf(this.data.type) > -1 && this.data.options) {
let values = this.data[this.prop];
if (['multipleSelect', 'checkbox'].indexOf(this.data.type) > -1) {
if (values && values instanceof Array) {
for (let i = values.length - 1; i >= 0; i--) {
if (!this.data.options.find(item => item.value === values[i])) {
//
values.splice(i, 1);
}
}
} else {
//
this.data[this.prop] = [];
}
} else {
if (!this.data.options.find(item => item.value === values)) {
//
this.data[this.prop] = '';
}
}
}
this.clearDeletedOption();
this.setFormData();
if (['member', 'multipleMember'].indexOf(this.data.type) < 0) {
return;
}
if (this.projectId) {
getProjectMemberById(this.projectId)
.then((r) => {
this.handleMemberOptions(r.data);
});
} else {
getProjectMemberOption()
.then((r) => {
this.handleMemberOptions(r.data);
});
}
this.getMemberOptions();
},
watch: {
form() {
@ -218,10 +184,65 @@ export default {
}
},
methods: {
clearDeletedOption() {
//
if (['select', 'multipleSelect', 'checkbox', 'radio'].indexOf(this.data.type) > -1 && this.data.options) {
if (['multipleSelect', 'checkbox'].indexOf(this.data.type) > -1) {
this.clearDeletedMultipleOption();
} else {
this.clearDeletedSingleOption();
}
}
},
clearDeletedMultipleOption() {
let values = this.data[this.prop];
if (values && values instanceof Array) {
for (let i = values.length - 1; i >= 0; i--) {
if (!this.data.options.find(item => item.value === values[i])) {
//
values.splice(i, 1);
}
}
} else {
//
this.data[this.prop] = [];
}
},
clearDeletedSingleOption() {
if (!this.data.options.find(item => item.value === this.data[this.prop])) {
//
this.data[this.prop] = '';
}
},
getMemberOptions() {
if (['member', 'multipleMember'].indexOf(this.data.type) < 0) {
return;
}
if (this.projectId) {
getProjectMemberById(this.projectId)
.then((r) => {
this.handleMemberOptions(r.data);
});
} else {
getProjectMemberOption()
.then((r) => {
this.handleMemberOptions(r.data);
});
}
},
handleMemberOptions(data) {
this.memberOptions = data;
this.data.options = data;
this.data.options.forEach(item => {
item.value = item.id;
item.text = item.name;
});
if (this.data.name === '责任人' && this.data.system && this.isTemplateEdit) {
this.memberOptions.unshift({id: 'CURRENT_USER', name: '创建人', email: ''});
this.data.options.unshift({id: 'CURRENT_USER', name: '创建人', email: ''});
}
if ('multipleMember' === this.data.type) {
this.clearDeletedMultipleOption();
} else {
this.clearDeletedSingleOption();
}
},
clickPane(){

View File

@ -108,7 +108,6 @@ export function getTagToolTips(tags) {
}
}
export function parseColumnTag(tags) {
if (tags.length > 1) {
let parseTags = [];
@ -119,3 +118,16 @@ export function parseColumnTag(tags) {
return tags;
}
}
export function resetCaseSystemField(customFields, testCase) {
// 用例等级等字段以表中对应字段为准
customFields.forEach((field) => {
if (field.name === "用例等级") {
field.defaultValue = testCase.priority;
} else if (field.name === "责任人") {
field.defaultValue = testCase.maintainer;
} else if (field.name === "用例状态") {
field.defaultValue = testCase.status;
}
});
}

View File

@ -117,6 +117,7 @@
:prop="item.name"
>
<custom-filed-component
v-if="!loading"
:disabled="true"
:data="item"
:form="{}"
@ -248,7 +249,7 @@ import {
import { testPlanEditStatus } from "@/api/remote/plan/test-plan";
import { getTestTemplate } from "@/api/custom-field-template";
import { checkProjectPermission } from "@/api/testCase";
import {openCaseEdit} from "@/business/case/test-case";
import {openCaseEdit, resetCaseSystemField} from "@/business/case/test-case";
export default {
name: "FunctionalTestCaseEdit",
@ -521,8 +522,12 @@ export default {
// ,使
this.testCase.actualResult = this.testCaseTemplate.actualResult;
}
this.resetSystemField();
});
},
resetSystemField() {
resetCaseSystemField(this.testCaseTemplate.customFields, this.testCase);
},
openTestCaseEdit(testCase, tableData) {
checkProjectPermission(testCase.projectId).then((r) => {
this.hasProjectPermission = r.data;

View File

@ -42,7 +42,7 @@
<el-form-item :label="item.system ? $t(systemNameMap[item.name]) : item.name"
:prop="item.name"
:label-width="formLabelWidth">
<custom-filed-component :disabled="true" :data="item" :form="{}" prop="defaultValue"/>
<custom-filed-component v-if="!loading" :disabled="true" :data="item" :form="{}" prop="defaultValue"/>
</el-form-item>
</el-col>
</el-row>
@ -131,6 +131,7 @@ import {
import TestReviewTestCaseEditOperationBar from "@/business/review/view/components/TestReviewTestCaseEditOperationBar";
import TestReviewTestCaseEditHeaderBar from "@/business/review/view/components/TestReviewTestCaseEditHeaderBar";
import CommentHistory from "@/business/review/view/components/commnet/CommentHistory";
import {resetCaseSystemField} from "@/business/case/test-case";
export default {
name: "TestReviewTestCaseEdit",
@ -266,6 +267,9 @@ export default {
this.$refs.comment.getComments();
}
},
resetSystemField() {
resetCaseSystemField(this.testCaseTemplate.customFields, this.testCase);
},
refreshTestCaseStatus(status) {
this.testCase.reviewStatus = status;
this.updateTestCases(this.testCase);
@ -356,6 +360,7 @@ export default {
// ,使
this.testCase.actualResult = this.testCaseTemplate.actualResult;
}
this.resetSystemField();
});
},
setTitleWith() {