feat(测试跟踪): 测试用例批量编辑

This commit is contained in:
shiziyuan9527 2020-08-04 19:01:36 +08:00
parent 5fb0fc59b7
commit fdc9b1c2fe
3 changed files with 81 additions and 13 deletions

View File

@ -10,7 +10,7 @@
> >
<el-form :model="form" label-position="right" label-width="150px" size="medium" ref="form" :rules="rules"> <el-form :model="form" label-position="right" label-width="150px" size="medium" ref="form" :rules="rules">
<el-form-item :label="$t('test_track.case.batch_update', [size])" prop="type"> <el-form-item :label="$t('test_track.case.batch_update', [size])" prop="type">
<el-select v-model="form.type" style="width: 80%"> <el-select v-model="form.type" style="width: 80%" @change="changeType">
<el-option label="用例等级" value="priority"/> <el-option label="用例等级" value="priority"/>
<el-option label="类型" value="type"/> <el-option label="类型" value="type"/>
<el-option label="测试方式" value="method"/> <el-option label="测试方式" value="method"/>
@ -18,9 +18,13 @@
</el-select> </el-select>
</el-form-item> </el-form-item>
<el-form-item label="更新后属性值为" prop="value"> <el-form-item label="更新后属性值为" prop="value">
<el-select v-model="form.value" style="width: 80%"> <el-select v-model="form.value" style="width: 80%" :filterable="filterable">
<el-option label="值1" value="value1"/> <el-option v-for="(option, index) in options" :key="index" :value="option.id" :label="option.name">
<el-option label="值2" value="value2"/> <!-- <div v-if="option.email">-->
<!-- <span style="float: left">{{ option.name }}</span>-->
<!-- <span style="float: right;color: #8492a6;">{{ option.email }}</span>-->
<!-- </div>-->
</el-option>
</el-select> </el-select>
</el-form-item> </el-form-item>
</el-form> </el-form>
@ -35,12 +39,16 @@
<script> <script>
import MsDialogFooter from "../../../common/components/MsDialogFooter"; import MsDialogFooter from "../../../common/components/MsDialogFooter";
import {WORKSPACE_ID} from "../../../../../common/js/constants";
export default { export default {
name: "BatchEdit", name: "BatchEdit",
components: { components: {
MsDialogFooter MsDialogFooter
}, },
created() {
this.getMaintainerOptions();
},
data() { data() {
return { return {
dialogVisible: false, dialogVisible: false,
@ -50,13 +58,32 @@
type: {required: true, message: "请选择属性", trigger: ['blur','change']}, type: {required: true, message: "请选择属性", trigger: ['blur','change']},
value: {required: true, message: "请选择属性对应的值", trigger: ['blur','change']} value: {required: true, message: "请选择属性对应的值", trigger: ['blur','change']}
}, },
options: [],
priorities: [
{name: 'P0', id: 'P0'},
{name: 'P1', id: 'P1'},
{name: 'P2', id: 'P2'},
{name: 'P3', id: 'P3'}
],
types: [
{name: this.$t('commons.functional'), id: 'functional'},
{name: this.$t('commons.performance'), id: 'performance'},
{name: this.$t('commons.api'), id: 'api'}
],
methods: [
{name: this.$t('test_track.case.manual'), id: 'manual'},
{name: this.$t('test_track.case.auto'), id: 'auto'}
],
maintainers: [],
filterable: false,
} }
}, },
methods: { methods: {
submit(form) { submit(form) {
this.$refs[form].validate((valid) => { this.$refs[form].validate((valid) => {
if (valid) { if (valid) {
this.$emit("submit", this.form); this.$emit("batchEdit", this.form);
this.dialogVisible = false;
} else { } else {
return false; return false;
} }
@ -68,6 +95,33 @@
}, },
handleClose() { handleClose() {
this.form = {}; this.form = {};
},
changeType(val) {
this.$set(this.form, "value", "");
this.filterable = val === "maintainer";
switch (val) {
case "priority":
this.options = this.priorities;
break;
case "type":
this.options = this.types;
break;
case "method":
this.options = this.methods;
break;
case "maintainer":
this.options = this.maintainers;
break;
default:
this.options = [];
}
},
getMaintainerOptions() {
let workspaceId = localStorage.getItem(WORKSPACE_ID);
this.$post('/user/ws/member/tester/list', {workspaceId: workspaceId}, response => {
this.maintainers = response.data;
});
} }
} }
} }

View File

@ -56,7 +56,7 @@
.show-more-btn-title { .show-more-btn-title {
color: #696969; color: #696969;
background-color: #C0C0C0; background-color: #e2e2e2;
padding: 5px; padding: 5px;
} }

View File

@ -120,7 +120,7 @@
</el-card> </el-card>
<batch-edit ref="batchEdit"/> <batch-edit ref="batchEdit" @batchEdit="batchEdit"/>
</div> </div>
</template> </template>
@ -333,17 +333,19 @@
this.$set(row, "showMore", false); this.$set(row, "showMore", false);
this.selectRows.delete(row); this.selectRows.delete(row);
} else { } else {
this.$set(row, "showMore", true);
this.selectRows.add(row); this.selectRows.add(row);
} }
// todo let arr = Array.from(this.selectRows);
if (this.selectRows.size > 1) {
Array.from(this.selectRows).forEach(row => { // 1
if (this.selectRows.size === 1) {
this.$set(arr[0], "showMore", false);
} else if (this.selectRows.size === 2) {
arr.forEach(row => {
this.$set(row, "showMore", true); this.$set(row, "showMore", true);
}) })
} else if (this.selectRows.size === 1) {
let arr = Array.from(this.selectRows);
this.$set(arr[0], "showMore", false);
} }
}, },
importTestCase() { importTestCase() {
@ -391,6 +393,18 @@
this.exportTestCase(); this.exportTestCase();
} }
}, },
batchEdit(form) {
let ids = Array.from(this.selectRows).map(row => row.id);
let param = {};
param[form.type] = form.value;
param.ids = ids;
// todo
//
this.$post('/test/case/batch/edit' , param, () => {
this.$success(this.$t('commons.save_success'));
this.refresh();
});
},
filter(filters) { filter(filters) {
_filter(filters, this.condition); _filter(filters, this.condition);
this.initTableData(); this.initTableData();