feat: 自定义表头

This commit is contained in:
wenyann 2021-02-08 17:22:27 +08:00
parent 67a420e78e
commit 21b6481b8b
11 changed files with 498 additions and 480 deletions

View File

@ -27,8 +27,7 @@
</when> </when>
<when test="criterion.listValue"> <when test="criterion.listValue">
and ${criterion.condition} and ${criterion.condition}
<foreach close=")" collection="criterion.value" item="listItem" open="(" <foreach close=")" collection="criterion.value" item="listItem" open="(" separator=",">
separator=",">
#{listItem} #{listItem}
</foreach> </foreach>
</when> </when>
@ -57,8 +56,7 @@
</when> </when>
<when test="criterion.listValue"> <when test="criterion.listValue">
and ${criterion.condition} and ${criterion.condition}
<foreach close=")" collection="criterion.value" item="listItem" open="(" <foreach close=")" collection="criterion.value" item="listItem" open="(" separator=",">
separator=",">
#{listItem} #{listItem}
</foreach> </foreach>
</when> </when>

View File

@ -1,8 +1,10 @@
package io.metersphere.controller; package io.metersphere.controller;
import io.metersphere.base.domain.SystemParameter; import io.metersphere.base.domain.SystemParameter;
import io.metersphere.base.domain.UserHeader;
import io.metersphere.commons.constants.ParamConstants; import io.metersphere.commons.constants.ParamConstants;
import io.metersphere.commons.constants.RoleConstants; import io.metersphere.commons.constants.RoleConstants;
import io.metersphere.controller.request.HeaderRequest;
import io.metersphere.dto.BaseSystemConfigDTO; import io.metersphere.dto.BaseSystemConfigDTO;
import io.metersphere.ldap.domain.LdapInfo; import io.metersphere.ldap.domain.LdapInfo;
import io.metersphere.notice.domain.MailInfo; import io.metersphere.notice.domain.MailInfo;
@ -67,4 +69,13 @@ public class SystemParameterController {
return SystemParameterService.getLdapInfo(ParamConstants.Classify.LDAP.getValue()); return SystemParameterService.getLdapInfo(ParamConstants.Classify.LDAP.getValue());
} }
@PostMapping("save/header")
public void saveHeader(@RequestBody UserHeader userHeader) {
SystemParameterService.saveHeader(userHeader);
}
@PostMapping("/header/info")
public UserHeader getHeaderInfo(@RequestBody HeaderRequest headerRequest) {
return SystemParameterService.queryUserHeader(headerRequest);
}
} }

View File

@ -0,0 +1,11 @@
package io.metersphere.controller.request;
import lombok.Getter;
import lombok.Setter;
@Getter
@Setter
public class HeaderRequest {
private String userId;
private String type;
}

View File

@ -2,12 +2,16 @@ package io.metersphere.service;
import io.metersphere.base.domain.SystemParameter; import io.metersphere.base.domain.SystemParameter;
import io.metersphere.base.domain.SystemParameterExample; import io.metersphere.base.domain.SystemParameterExample;
import io.metersphere.base.domain.UserHeader;
import io.metersphere.base.domain.UserHeaderExample;
import io.metersphere.base.mapper.SystemParameterMapper; import io.metersphere.base.mapper.SystemParameterMapper;
import io.metersphere.base.mapper.UserHeaderMapper;
import io.metersphere.base.mapper.ext.ExtSystemParameterMapper; import io.metersphere.base.mapper.ext.ExtSystemParameterMapper;
import io.metersphere.commons.constants.ParamConstants; import io.metersphere.commons.constants.ParamConstants;
import io.metersphere.commons.exception.MSException; import io.metersphere.commons.exception.MSException;
import io.metersphere.commons.utils.EncryptUtils; import io.metersphere.commons.utils.EncryptUtils;
import io.metersphere.commons.utils.LogUtil; import io.metersphere.commons.utils.LogUtil;
import io.metersphere.controller.request.HeaderRequest;
import io.metersphere.dto.BaseSystemConfigDTO; import io.metersphere.dto.BaseSystemConfigDTO;
import io.metersphere.i18n.Translator; import io.metersphere.i18n.Translator;
import io.metersphere.ldap.domain.LdapInfo; import io.metersphere.ldap.domain.LdapInfo;
@ -29,7 +33,8 @@ import java.util.*;
@Service @Service
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
public class SystemParameterService { public class SystemParameterService {
@Resource
private UserHeaderMapper userHeaderMapper;
@Resource @Resource
private SystemParameterMapper systemParameterMapper; private SystemParameterMapper systemParameterMapper;
@Resource @Resource
@ -233,4 +238,16 @@ public class SystemParameterService {
example.clear(); example.clear();
}); });
} }
//保存表头
public void saveHeader(UserHeader userHeader) {
userHeader.setId(UUID.randomUUID().toString());
userHeaderMapper.insert(userHeader);
}
public UserHeader queryUserHeader(HeaderRequest headerRequest) {
UserHeaderExample example = new UserHeaderExample();
example.createCriteria().andUserIdEqualTo(headerRequest.getUserId()).andTypeEqualTo(headerRequest.getType());
return userHeaderMapper.selectByExample(example).get(0);
}
} }

View File

@ -0,0 +1,10 @@
create table user_header
(
id varchar(50) not null,
user_id varchar(50) null,
props varchar(1000) null,
type varchar(150) null,
constraint user_header_pk
primary key (id)
) ENGINE = InnoDB
DEFAULT CHARSET = utf8mb4

View File

@ -66,6 +66,7 @@
<table tableName="auth_source"/> <table tableName="auth_source"/>
<table tableName="swagger_url_project"/> <table tableName="swagger_url_project"/>
<table tableName="user_header"/>
<!--<table tableName="test_plan_api_scenario"/>--> <!--<table tableName="test_plan_api_scenario"/>-->
<!--<table tableName="test_plan"/>--> <!--<table tableName="test_plan"/>-->
<!--<table tableName="api_scenario_report"/>--> <!--<table tableName="api_scenario_report"/>-->

View File

@ -0,0 +1,64 @@
<template>
<el-dialog title="表头显示字段" :visible.sync="dialogTableVisible" :append-to-body="true">
<template>
<el-transfer
:titles="['待选字段', '已选字段']"
v-model="value"
:props="{
key: 'prop',
label: 'label'
}"
:data="optionalField"
></el-transfer>
</template>
<template v-slot:footer>
<ms-dialog-footer
@cancel="close"
@confirm="saveHeader"
/>
</template>
</el-dialog>
</template>
<script>
import MsDialogFooter from "@/business/components/common/components/MsDialogFooter";
import {getCurrentUser} from "@/common/js/utils";
import {TEST_CASE_LIST} from "@/common/js/constants";
export default {
name: "HeaderCustom",
components: {MsDialogFooter},
data() {
return {
dialogTableVisible: false,
optionalField: [],
value: [],
fieldSelected:[]
}
},
methods: {
open(items) {
console.log(items)
this.dialogTableVisible = true
this.optionalField = items
},
saveHeader() {
let param={
userId:getCurrentUser().id,
type:TEST_CASE_LIST,
props:JSON.stringify(this.value)
}
this.$post("/system/save/header",param,response=>{
this.$success(this.$t("commons.save_success"));
this.dialogTableVisible = false
})
},
close() {
}
}
}
</script>
<style scoped>
</style>

View File

@ -0,0 +1,15 @@
import i18n from '../../../../i18n/i18n'
//自定义默认表头
export const Track_Test_Case=[
{prop: 'num', label: i18n.t('commons.id')},
{prop: 'name', label: i18n.t('commons.name')},
{prop: 'priority', label: i18n.t('test_track.case.priority')},
{prop: 'type', label: i18n.t('test_track.case.type')},
{prop: 'method', label: i18n.t('test_track.case.method')},
{prop: 'reviewStatus', label:i18n.t('test_track.case.status')},
{prop: 'tags', label: i18n.t('commons.tag')},
{prop: 'nodePath', label: i18n.t('test_track.case.module')},
{prop: 'updateTime', label: i18n.t('commons.update_time')},
{prop: 'operating', label: i18n.t('commons.operating')},
]

View File

@ -1,136 +0,0 @@
<template>
<el-dialog
title="表头显示字段"
:visible.sync="centerDialogVisible"
width="50%"
>
<el-divider style="margin-top: 0;margin-right: 10px"></el-divider>
<el-form :inline="true" :model="headerItem" class="demo-form-inline" type="selection">
<el-row :gutter="20">
<el-col :span="10">
<label>可选择字段可选择字段:{{ this.headerItem.optionalField.length }}</label>
<div class="grid-content bg-purple" style="margin-top: 25px">
<el-form-item>
<el-card class="box-card">
<div v-for="item in headerItem.optionalField" :key="item.prop" class="text item"
@click="selectItem(item)">
<input type="checkbox"/>
<label>{{ item.name }}</label>
</div>
</el-card>
</el-form-item>
</div>
</el-col>
<el-col :span="4">
<div class="grid-content bg-purple" style="margin-top: 160px">
<el-form-item>
<el-button size="medium" round @click="addItem">添加</el-button>
<!-- <i class="el-icon-arrow-right" @click="addItem"></i>-->
</el-form-item>
<el-form-item>
<el-button size="medium" round>移除</el-button>
<!-- <i class="el-icon-arrow-right" @click="addItem"></i>-->
</el-form-item>
</div>
</el-col>
<el-col :span="10">
<label>已选择字段</label>
<div class="grid-content bg-purple" style="margin-top: 25px">
<el-form-item>
<el-card class="box-card">
<div v-for="item in headerItem.fieldSelected" :key="item.prop" class="text item"
@click="moveItem(item)">
<el-checkbox v-model="checked1">{{ item.name }}</el-checkbox>
</div>
</el-card>
</el-form-item>
</div>
</el-col>
</el-row>
<el-form-item>
<el-button type="primary" style="margin-right: 0" @click="save('headerItem')">保存</el-button>
</el-form-item>
</el-form>
</el-dialog>
</template>
<script>
export default {
name: "CustomHeader",
data() {
return {
centerDialogVisible: false,
headerItem: {
optionalField: [
{prop: 'name', name: '名称'},
{prop: 'name', name: '名称'},
{prop: 'name', name: '名称'},
{prop: 'name', name: '名称'},
{prop: 'name', name: '名称'},
{prop: 'name', name: '名称'},
{prop: 'name', name: '名称'},
{prop: 'name', name: '名称'},
],
fieldSelected: []
},
selectItems: [],
checked1: false
};
},
methods: {
open() {
this.centerDialogVisible = true
},
selectItem(item) {
this.checked1 = !this.checked1
this.selectItems.push(item)
},
//
moveItem(item) {
this.headerItem.fieldSelected.remove(item)
},
//
addItem() {
console.log(this.selectItems)
this.headerItem.fieldSelected = this.selectItems
console.log(this.headerItem.fieldSelected)
},
save(headerItem) {
}
}
}
</script>
<style scoped>
.text {
font-size: 14px;
}
.item {
margin-bottom: 18px;
}
.clearfix:before,
.clearfix:after {
display: table;
content: "";
}
.clearfix:after {
clear: both
}
.box-card {
width: 250px;
height: 400px;
overflow: auto;
}
</style>

View File

@ -34,7 +34,6 @@
row-key="id" row-key="id"
class="test-content adjust-table ms-select-all-fixed" class="test-content adjust-table ms-select-all-fixed"
ref="table" @row-click="handleEdit"> ref="table" @row-click="handleEdit">
<el-table-column <el-table-column
width="50" width="50"
type="selection"/> type="selection"/>
@ -50,16 +49,22 @@
<show-more-btn :is-show="scope.row.showMore" :buttons="buttons" :size="selectDataCounts"/> <show-more-btn :is-show="scope.row.showMore" :buttons="buttons" :size="selectDataCounts"/>
</template> </template>
</el-table-column> </el-table-column>
<template v-for="(item, index) in tableLabel">
<el-table-column <el-table-column
v-if="item.prop == 'num'"
prop="num" prop="num"
sortable="custom" sortable="custom"
:label="$t('commons.id')" :label="$t('commons.id')"
:key="index"
show-overflow-tooltip> show-overflow-tooltip>
</el-table-column> </el-table-column>
<el-table-column <el-table-column
v-if="item.prop == 'name'"
prop="name" prop="name"
:label="$t('commons.name')" :label="$t('commons.name')"
show-overflow-tooltip show-overflow-tooltip
:key="index"
> >
<template v-slot:default="scope"> <template v-slot:default="scope">
<!--<div @mouseover="showDetail(scope.row)"> <!--<div @mouseover="showDetail(scope.row)">
@ -76,43 +81,51 @@
</template> </template>
</el-table-column> </el-table-column>
<el-table-column <el-table-column
v-if="item.prop == 'priority'"
prop="priority" prop="priority"
:filters="priorityFilters" :filters="priorityFilters"
column-key="priority" column-key="priority"
min-width="100px" min-width="100px"
:label="$t('test_track.case.priority')" :label="$t('test_track.case.priority')"
show-overflow-tooltip> show-overflow-tooltip
:key="index">
<template v-slot:default="scope"> <template v-slot:default="scope">
<priority-table-item :value="scope.row.priority"/> <priority-table-item :value="scope.row.priority"/>
</template> </template>
</el-table-column> </el-table-column>
<el-table-column <el-table-column
v-if="item.prop == 'type'"
prop="type" prop="type"
:filters="typeFilters" :filters="typeFilters"
column-key="type" column-key="type"
:label="$t('test_track.case.type')" :label="$t('test_track.case.type')"
show-overflow-tooltip> show-overflow-tooltip
:key="index">
<template v-slot:default="scope"> <template v-slot:default="scope">
<type-table-item :value="scope.row.type"/> <type-table-item :value="scope.row.type"/>
</template> </template>
</el-table-column> </el-table-column>
<el-table-column <el-table-column
v-if="item.prop=='method'"
prop="method" prop="method"
column-key="method" column-key="method"
:filters="methodFilters" :filters="methodFilters"
min-width="100px" min-width="100px"
:label="$t('test_track.case.method')" :label="$t('test_track.case.method')"
show-overflow-tooltip> show-overflow-tooltip
:key="index">
<template v-slot:default="scope"> <template v-slot:default="scope">
<method-table-item :value="scope.row.method"/> <method-table-item :value="scope.row.method"/>
</template> </template>
</el-table-column> </el-table-column>
<el-table-column <el-table-column
v-if="item.prop=='status'"
:filters="statusFilters" :filters="statusFilters"
column-key="status" column-key="status"
min-width="100px" min-width="100px"
:label="$t('test_track.case.status')"> :label="$t('test_track.case.status')"
:key="index">
<template v-slot:default="scope"> <template v-slot:default="scope">
<span class="el-dropdown-link"> <span class="el-dropdown-link">
<review-status :value="scope.row.reviewStatus"/> <review-status :value="scope.row.reviewStatus"/>
@ -120,7 +133,7 @@
</template> </template>
</el-table-column> </el-table-column>
<el-table-column prop="tags" :label="$t('commons.tag')"> <el-table-column v-if="item.prop=='tags'" prop="tags" :label="$t('commons.tag')" :key="index">
<template v-slot:default="scope"> <template v-slot:default="scope">
<div v-for="(itemName,index) in scope.row.tags" :key="index"> <div v-for="(itemName,index) in scope.row.tags" :key="index">
<ms-tag type="success" effect="plain" :content="itemName"/> <ms-tag type="success" effect="plain" :content="itemName"/>
@ -129,25 +142,27 @@
</el-table-column> </el-table-column>
<el-table-column <el-table-column
v-if="item.prop=='nodePath'"
prop="nodePath" prop="nodePath"
:label="$t('test_track.case.module')" :label="$t('test_track.case.module')"
min-width="150px" min-width="150px"
show-overflow-tooltip> show-overflow-tooltip
:key="index">
</el-table-column> </el-table-column>
<el-table-column <el-table-column
v-if="item.prop=='updateTime'"
prop="updateTime" prop="updateTime"
sortable="custom" sortable="custom"
:label="$t('commons.update_time')" :label="$t('commons.update_time')"
min-width="150px" min-width="150px"
show-overflow-tooltip> show-overflow-tooltip
:key="index">
<template v-slot:default="scope"> <template v-slot:default="scope">
<span>{{ scope.row.updateTime | timestampFormatDate }}</span> <span>{{ scope.row.updateTime | timestampFormatDate }}</span>
</template> </template>
</el-table-column> </el-table-column>
<el-table-column fixed="right" <el-table-column v-if="item.prop=='operating'" fixed="right" min-width="150" :key="index">
:label="$t('commons.operating')" min-width="150">
<el-table-column fixed="right" min-width="150">
<template slot="header"> <template slot="header">
<span>{{ $t('commons.operating') }} <span>{{ $t('commons.operating') }}
<i class='el-icon-setting' style="color:#7834c1; margin-left:10px" @click="customHeader"> </i> <i class='el-icon-setting' style="color:#7834c1; margin-left:10px" @click="customHeader"> </i>
@ -164,12 +179,11 @@
</ms-table-operator> </ms-table-operator>
</template> </template>
</el-table-column> </el-table-column>
</template>
</el-table> <header-custom ref="headerCustom"></header-custom>
<custom-header ref="customHeader"/>
<ms-table-pagination :change="initTableData" :current-page.sync="currentPage" :page-size.sync="pageSize" <ms-table-pagination :change="initTableData" :current-page.sync="currentPage" :page-size.sync="pageSize"
:total="total"/> :total="total"/>
</el-table>
</el-card> </el-card>
<batch-edit ref="batchEdit" @batchEdit="batchEdit" <batch-edit ref="batchEdit" @batchEdit="batchEdit"
@ -198,12 +212,12 @@ import MsTableButton from "../../../common/components/MsTableButton";
import {TEST_CASE_CONFIGS} from "../../../common/components/search/search-components"; import {TEST_CASE_CONFIGS} from "../../../common/components/search/search-components";
import ShowMoreBtn from "./ShowMoreBtn"; import ShowMoreBtn from "./ShowMoreBtn";
import BatchEdit from "./BatchEdit"; import BatchEdit from "./BatchEdit";
import {WORKSPACE_ID} from "@/common/js/constants"; import {TEST_CASE_LIST, WORKSPACE_ID} from "@/common/js/constants";
import {LIST_CHANGE, TrackEvent} from "@/business/components/common/head/ListEvent"; import {LIST_CHANGE, TrackEvent} from "@/business/components/common/head/ListEvent";
import StatusTableItem from "@/business/components/track/common/tableItems/planview/StatusTableItem"; import StatusTableItem from "@/business/components/track/common/tableItems/planview/StatusTableItem";
import TestCaseDetail from "./TestCaseDetail"; import TestCaseDetail from "./TestCaseDetail";
import ReviewStatus from "@/business/components/track/case/components/ReviewStatus"; import ReviewStatus from "@/business/components/track/case/components/ReviewStatus";
import {getCurrentProjectID} from "../../../../../common/js/utils"; import {getCurrentProjectID, getCurrentUser} from "../../../../../common/js/utils";
import MsTag from "@/business/components/common/components/MsTag"; import MsTag from "@/business/components/common/components/MsTag";
import { import {
_filter, _filter,
@ -215,12 +229,13 @@ import {
toggleAllSelection toggleAllSelection
} from "@/common/js/tableUtils"; } from "@/common/js/tableUtils";
import BatchMove from "./BatchMove"; import BatchMove from "./BatchMove";
import CustomHeader from "@/business/components/track/case/components/CustomHeader"; import {Track_Test_Case} from "@/business/components/common/model/JsonData";
import HeaderCustom from "@/business/components/common/head/HeaderCustom";
export default { export default {
name: "TestCaseList", name: "TestCaseList",
components: { components: {
CustomHeader, HeaderCustom,
BatchMove, BatchMove,
MsTableHeaderSelectPopover, MsTableHeaderSelectPopover,
MsTableButton, MsTableButton,
@ -244,11 +259,8 @@ export default {
}, },
data() { data() {
return { return {
cols: [{label: "id", prop: "num"}, //
{label: "名称", prop: "name"}, tableLabel:Track_Test_Case,
{label: "级别", prop: "priority"},
{label: "类型", prop: "type"},
{label: "测试方式", prop: "method"}],
result: {}, result: {},
deletePath: "/test/case/delete", deletePath: "/test/case/delete",
condition: { condition: {
@ -347,10 +359,9 @@ export default {
}, },
methods: { methods: {
customHeader() { customHeader() {
this.$refs.customHeader.open() this.$refs.headerCustom.open(this.tableLabel)
}, },
initTableData() { initTableData() {
this.projectId = getCurrentProjectID(); this.projectId = getCurrentProjectID();
this.condition.planId = ""; this.condition.planId = "";
this.condition.nodeIds = []; this.condition.nodeIds = [];
@ -365,8 +376,23 @@ export default {
// param.nodeIds = this.selectNodeIds; // param.nodeIds = this.selectNodeIds;
this.condition.nodeIds = this.selectNodeIds; this.condition.nodeIds = this.selectNodeIds;
} }
this.getLabel()
this.getData(); this.getData();
}, },
getLabel(){
let param={}
param.userId=getCurrentUser().id;
param.type=TEST_CASE_LIST
this.result=this.$post('/system/header/info',param,response=>{
console.log(response.data)
/*if(response.data){
this.tableLabel=response.data.props
}else{
this.tableLabel=Track_Test_Case
}*/
})
},
getData() { getData() {
if (this.projectId) { if (this.projectId) {
this.condition.projectId = this.projectId; this.condition.projectId = this.projectId;

View File

@ -1,3 +1,4 @@
export const TEST_CASE_LIST='test_case_list'
export const TokenKey = 'Admin-Token'; export const TokenKey = 'Admin-Token';
export const LicenseKey = 'License'; export const LicenseKey = 'License';
export const DEFAULT_LANGUAGE = 'default_language'; export const DEFAULT_LANGUAGE = 'default_language';