refactor(测试跟踪): 功能用例保存问题优化

This commit is contained in:
song-cc-rock 2023-03-02 15:23:51 +08:00 committed by fit2-zhao
parent 51ff04fef3
commit ce66e06bd1
6 changed files with 99 additions and 44 deletions

View File

@ -2,7 +2,6 @@
<div class="edit-container"> <div class="edit-container">
<div <div
class="content" class="content"
v-custom-click-outside="preSave"
@mouseleave="mouseLeaveEvent" @mouseleave="mouseLeaveEvent"
> >
<div class="edit" v-show="edit"> <div class="edit" v-show="edit">

View File

@ -6,7 +6,7 @@
<div class="edit-header-container"> <div class="edit-header-container">
<div class="header-content-row"> <div class="header-content-row">
<div :class="'case-name'"> <div :class="'case-name'">
{{ !editable ? form.name : $t('test_track.case.create_case') }} {{ !editable ? form.name : editableState ? $t('test_track.case.edit_case') : $t('test_track.case.create_case') }}
</div> </div>
<div class="case-edit" v-if="!editable"> <div class="case-edit" v-if="!editable">
<div class="case-level" v-if="!isPublicShow"> <div class="case-level" v-if="!isPublicShow">
@ -95,24 +95,13 @@
<div class="label-row">{{ $t("case.followed") }}</div> <div class="label-row">{{ $t("case.followed") }}</div>
</div> </div>
<div <div
class="add-public-row head-opt" class="follow-row head-opt" v-if="!isPublicShow"
v-if="!isPublicShow && !casePublic" @click="toEdit"
@click="addPublic"
> >
<div class="icon-row"> <div class="icon-row">
<img src="/assets/module/figma/icon_add-folder_outlined.svg" alt="" /> <img src="/assets/module/figma/icon_edit_outlined.svg" alt="" />
</div> </div>
<div class="label-row">{{ $t("case.add_to_public_case") }}</div> <div class="label-row">{{ $t("commons.edit") }}</div>
</div>
<div
class="add-public-row head-opt"
v-if="!isPublicShow && casePublic"
@click="removePublic"
>
<div class="icon-row">
<img src="/assets/module/figma/icon_yes_outlined.svg" alt="" />
</div>
<div class="label-row">{{ $t("case.added_to_public_case") }}</div>
</div> </div>
<div class="more-row head-opt" v-if="!isPublicShow"> <div class="more-row head-opt" v-if="!isPublicShow">
<div class="icon-row"> <div class="icon-row">
@ -126,6 +115,27 @@
:visible-arrow="false" :visible-arrow="false"
> >
<div class="opt-row"> <div class="opt-row">
<div
class="add-public-row sub-opt-row"
v-if="!casePublic"
@click="addPublic"
>
<div class="icon">
<img src="/assets/module/figma/icon_add-folder_outlined.svg" alt="" />
</div>
<div class="title">{{ $t("case.add_to_public_case") }}</div>
</div>
<div
class="add-public-row sub-opt-row"
v-if="!isPublicShow && casePublic"
@click="removePublic"
>
<div class="icon">
<img src="/assets/module/figma/icon_yes_outlined.svg" alt="" />
</div>
<div class="title">{{ $t("case.added_to_public_case") }}</div>
</div>
<div class="split"></div>
<div class="copy-row sub-opt-row" @click="copyRow"> <div class="copy-row sub-opt-row" @click="copyRow">
<div class="icon"> <div class="icon">
<i class="el-icon-copy-document"></i> <i class="el-icon-copy-document"></i>
@ -191,6 +201,7 @@
<div v-loading="loading" class="edit-content-container" :class="{'editable-edit-content-container' : editable}"> <div v-loading="loading" class="edit-content-container" :class="{'editable-edit-content-container' : editable}">
<case-edit-info-component <case-edit-info-component
:editable="editable" :editable="editable"
:editable-state="editableState"
:richTextDefaultOpen="richTextDefaultOpen" :richTextDefaultOpen="richTextDefaultOpen"
:formLabelWidth="formLabelWidth" :formLabelWidth="formLabelWidth"
:read-only="readOnly" :read-only="readOnly"
@ -219,7 +230,7 @@
:form="form" :form="form"
:is-form-alive="isFormAlive" :is-form-alive="isFormAlive"
:isloading="loading" :isloading="loading"
:read-only="readOnly" :read-only="readOnly || !editable"
:public-enable="isPublicShow" :public-enable="isPublicShow"
:show-input-tag="showInputTag" :show-input-tag="showInputTag"
:tree-nodes="treeNodes" :tree-nodes="treeNodes"
@ -253,7 +264,7 @@
<!-- 保存并新建 --> <!-- 保存并新建 -->
<div class="save-create-row"> <div class="save-create-row">
<el-button <el-button
v-if="showAddBtn" v-if="showAddBtn && !editableState"
v-prevent-re-click v-prevent-re-click
size="small" size="small"
:disabled="readOnly || loading" :disabled="readOnly || loading"
@ -263,7 +274,7 @@
</div> </div>
<!-- 保存并添加到公共用例库 --> <!-- 保存并添加到公共用例库 -->
<div <div
v-if="showPublic" v-if="showPublic && !editableState"
class="save-add-pub-row"> class="save-add-pub-row">
<el-button size="small" <el-button size="small"
v-prevent-re-click v-prevent-re-click
@ -272,6 +283,16 @@
{{ $t("test_track.case.save_add_public") }} {{ $t("test_track.case.save_add_public") }}
</el-button> </el-button>
</div> </div>
<!-- 取消 -->
<div class="cancel-row">
<el-button
v-if="editableState"
size="small"
:disabled="readOnly || loading"
@click="handleCommand(4)">
{{ $t("commons.cancel") }}
</el-button>
</div>
</template> </template>
</div> </div>
</div> </div>
@ -549,7 +570,8 @@ export default {
// 3 // 3
saveType: 1, saveType: 1,
projectId: null, projectId: null,
createVersionId: null createVersionId: null,
editableState: false
}; };
}, },
props: { props: {
@ -603,7 +625,7 @@ export default {
return !this.caseId || this.isCopy; return !this.caseId || this.isCopy;
}, },
editable() { editable() {
return this.isAdd; return this.isAdd || this.editableState;
}, },
isCopy() { isCopy() {
return this.editType == 'copy'; return this.editType == 'copy';
@ -919,6 +941,10 @@ export default {
this.saveType = e; this.saveType = e;
if (e === 3) { if (e === 3) {
this.casePublic = true; this.casePublic = true;
} else if (e === 4) {
this.editableState = false;
this.loadTestCase();
return;
} }
this.saveCase(); this.saveCase();
}, },
@ -1174,6 +1200,10 @@ export default {
this.loading = true; this.loading = true;
this.$request(option) this.$request(option)
.then((response) => { .then((response) => {
if (this.editableState) {
this.editableState = false;
this.$refs.otherInfo.caseActiveName = 'detail';
}
response = response.data; response = response.data;
// //
this.currentTestCaseInfo.isCopy = false; this.currentTestCaseInfo.isCopy = false;
@ -1428,6 +1458,9 @@ export default {
}); });
} }
}, },
toEdit() {
this.editableState = true;
},
setSpecialPropForCompare: function (that) { setSpecialPropForCompare: function (that) {
that.newData.tags = JSON.parse(that.newData.tags || "{}"); that.newData.tags = JSON.parse(that.newData.tags || "{}");
that.newData.steps = JSON.parse(that.newData.steps || "{}"); that.newData.steps = JSON.parse(that.newData.steps || "{}");
@ -2234,4 +2267,25 @@ export default {
height: 80px; height: 80px;
min-width: 120px !important; min-width: 120px !important;
} }
.case-step-item-popover .sub-opt-row .icon img {
width: 14px;
height: 14px;
}
.case-step-item-popover .add-public-row .icon {
color: #646a73;
margin-top: 3px;
}
.case-step-item-popover .add-public-row .title {
color: #1f2329;
margin-right: 10px;
}
.case-step-item-popover .add-public-row:hover {
background-color: rgba(31, 35, 41, 0.1);
}
.case-step-item-popover .split {
width: 140px;
}
</style> </style>

View File

@ -173,8 +173,8 @@
content: isCustomNum ? form.customNum : form.num, content: isCustomNum ? form.customNum : form.num,
contentType: 'INPUT', contentType: 'INPUT',
}" }"
:readonlyHoverEvent="isCustomNum" :readonlyHoverEvent="isCustomNum && !readOnly"
:content-click-event="isCustomNum" :content-click-event="isCustomNum && !readOnly"
:model="form" :model="form"
:rules="rules" :rules="rules"
> >

View File

@ -192,7 +192,7 @@
</div> </div>
<!-- 附件 --> <!-- 附件 -->
<div class="attachment-row"> <div class="attachment-row" v-if="!editableState">
<div class="attachment-name case-title-wrap"> <div class="attachment-name case-title-wrap">
<div class="name title-wrap">{{ $t("case.attachment") }}</div> <div class="name title-wrap">{{ $t("case.attachment") }}</div>
</div> </div>
@ -206,7 +206,7 @@
:type="type" :type="type"
:isCopy="isCopy" :isCopy="isCopy"
:copyCaseId="copyCaseId" :copyCaseId="copyCaseId"
:readOnly="readOnly" :readOnly="readOnly && editable"
:projectId="projectId" :projectId="projectId"
:isClickAttachmentTab="isClickAttachmentTab" :isClickAttachmentTab="isClickAttachmentTab"
:isDelete="!isTestPlan" :isDelete="!isTestPlan"
@ -266,16 +266,29 @@ export default {
projectId: String, projectId: String,
copyCaseId: String, copyCaseId: String,
isCopy: Boolean, isCopy: Boolean,
editableState: Boolean
}, },
methods: { methods: {
getUploadFiles() { getUploadFiles() {
return this.$refs.attachmentComp.uploadFiles; if (this.$refs.attachmentComp) {
return this.$refs.attachmentComp.uploadFiles;
} else {
return [];
}
}, },
getRelateFiles() { getRelateFiles() {
return this.$refs.attachmentComp.relateFiles; if (this.$refs.attachmentComp) {
return this.$refs.attachmentComp.relateFiles;
} else {
return [];
}
}, },
getUnRelateFiles() { getUnRelateFiles() {
return this.$refs.attachmentComp.unRelateFiles; if (this.$refs.attachmentComp) {
return this.$refs.attachmentComp.unRelateFiles;
} else {
return [];
}
}, },
textBlur(options, refName) { textBlur(options, refName) {
if (!this.editable && options.autoSave) { if (!this.editable && options.autoSave) {

View File

@ -13,7 +13,7 @@
<case-detail-component <case-detail-component
:type="type" :type="type"
:case-id="caseId" :case-id="caseId"
:read-only="readOnly" :read-only="readOnly || !editable"
:project-id="projectId" :project-id="projectId"
:is-copy="isCopy" :is-copy="isCopy"
:copy-case-id="copyCaseId" :copy-case-id="copyCaseId"
@ -157,6 +157,7 @@
:isClickAttachmentTab="isClickAttachmentTab" :isClickAttachmentTab="isClickAttachmentTab"
:isTestPlan="isTestPlan" :isTestPlan="isTestPlan"
:editable="editable" :editable="editable"
:editable-state="editableState"
:form="form" :form="form"
:richTextDefaultOpen="richTextDefaultOpen" :richTextDefaultOpen="richTextDefaultOpen"
:formLabelWidth="formLabelWidth" :formLabelWidth="formLabelWidth"
@ -212,6 +213,8 @@ export default {
"comments", "comments",
"isClickAttachmentTab", "isClickAttachmentTab",
"defaultOpen", "defaultOpen",
"edit",
"editableState"
], ],
data() { data() {
return { return {

View File

@ -32,7 +32,6 @@
:rows="defaultRows" :rows="defaultRows"
:placeholder="$t('commons.input_content')" :placeholder="$t('commons.input_content')"
@input="resizeTextarea(scope)" @input="resizeTextarea(scope)"
@blur="onInputBlur"
/> />
</template> </template>
</el-table-column> </el-table-column>
@ -52,7 +51,6 @@
:disabled="readOnly" :disabled="readOnly"
:placeholder="$t('commons.input_content')" :placeholder="$t('commons.input_content')"
@input="resizeTextarea(scope)" @input="resizeTextarea(scope)"
@blur="onInputBlur"
/> />
</template> </template>
</el-table-column> </el-table-column>
@ -222,13 +220,6 @@ export default {
} }
}); });
this.form.steps.splice(index + 1, 0, step); this.form.steps.splice(index + 1, 0, step);
if (data.desc && data.result) {
clearTimeout(this.TIMER);
this.TIMER = setTimeout(() => {
this.$emit("saveCase");
this.saveCase();
}, 500);
}
}, },
handleDeleteStep(index, data) { handleDeleteStep(index, data) {
if (this.readOnly) { if (this.readOnly) {
@ -243,11 +234,6 @@ export default {
step.num--; step.num--;
} }
}); });
clearTimeout(this.TIMER);
this.TIMER = setTimeout(() => {
this.$emit("saveCase");
this.saveCase();
}, 500);
}, },
// //
resizeTextarea(scope) { resizeTextarea(scope) {