This commit is contained in:
chenjianxing 2020-07-23 07:36:59 +08:00
commit b877e03e5c
15 changed files with 96 additions and 128 deletions

View File

@ -53,7 +53,7 @@
</sql> </sql>
<sql id="combine"> <sql id="combine">
<if test="${condition}.name != null"> <if test='${condition}.name != null and (${name} == null or ${name} == "")'>
and api_test.name and api_test.name
<include refid="condition"> <include refid="condition">
<property name="object" value="${condition}.name"/> <property name="object" value="${condition}.name"/>
@ -97,20 +97,16 @@
left join project on api_test.project_id = project.id left join project on api_test.project_id = project.id
left join user on api_test.user_id = user.id left join user on api_test.user_id = user.id
<where> <where>
<choose> <if test="request.combine != null">
<!--高级--> <include refid="combine">
<when test="request.combine != null"> <property name="condition" value="request.combine"/>
<include refid="combine"> <property name="name" value="request.name"/>
<property name="condition" value="request.combine"/> </include>
</include> </if>
</when>
<!--普通--> <if test="request.name != null">
<otherwise> and api_test.name like CONCAT('%', #{request.name},'%')
<if test="request.name != null"> </if>
and api_test.name like CONCAT('%', #{request.name},'%')
</if>
</otherwise>
</choose>
<if test="request.workspaceId != null"> <if test="request.workspaceId != null">
AND project.workspace_id = #{request.workspaceId} AND project.workspace_id = #{request.workspaceId}
</if> </if>

View File

@ -14,7 +14,7 @@
</sql> </sql>
<sql id="combine"> <sql id="combine">
<if test="${condition}.name != null"> <if test='${condition}.name != null and (${name} == null or ${name} == "")'>
and r.name and r.name
<include refid="condition"> <include refid="condition">
<property name="object" value="${condition}.name"/> <property name="object" value="${condition}.name"/>
@ -66,20 +66,16 @@
LEFT JOIN project ON project.id = t.project_id LEFT JOIN project ON project.id = t.project_id
LEFT JOIN user ON user.id = r.user_id LEFT JOIN user ON user.id = r.user_id
<where> <where>
<choose> <if test="request.combine != null">
<!--高级--> <include refid="combine">
<when test="request.combine != null"> <property name="condition" value="request.combine"/>
<include refid="combine"> <property name="name" value="request.name"/>
<property name="condition" value="request.combine"/> </include>
</include> </if>
</when>
<!--普通--> <if test="request.name != null">
<otherwise> and r.name like CONCAT('%', #{request.name},'%')
<if test="request.name != null"> </if>
and r.name like CONCAT('%', #{request.name},'%')
</if>
</otherwise>
</choose>
<if test="request.projectId != null"> <if test="request.projectId != null">
AND project.id = #{request.projectId} AND project.id = #{request.projectId}
</if> </if>

View File

@ -13,7 +13,7 @@
</sql> </sql>
<sql id="combine"> <sql id="combine">
<if test="${condition}.name != null"> <if test='${condition}.name != null and (${name} == null or ${name} == "")'>
and load_test.name and load_test.name
<include refid="condition"> <include refid="condition">
<property name="object" value="${condition}.name"/> <property name="object" value="${condition}.name"/>
@ -57,20 +57,15 @@
left join project on load_test.project_id = project.id left join project on load_test.project_id = project.id
left join user on load_test.user_id = user.id left join user on load_test.user_id = user.id
<where> <where>
<choose> <if test="request.combine != null">
<!--高级--> <include refid="combine">
<when test="request.combine != null"> <property name="condition" value="request.combine"/>
<include refid="combine"> <property name="name" value="request.name"/>
<property name="condition" value="request.combine"/> </include>
</include> </if>
</when> <if test="request.name != null">
<!--普通--> and load_test.name like CONCAT('%', #{request.name},'%')
<otherwise> </if>
<if test="request.name != null">
and load_test.name like CONCAT('%', #{request.name},'%')
</if>
</otherwise>
</choose>
<if test="request.workspaceId != null"> <if test="request.workspaceId != null">
AND project.workspace_id = #{request.workspaceId} AND project.workspace_id = #{request.workspaceId}
</if> </if>

View File

@ -20,7 +20,7 @@
</sql> </sql>
<sql id="combine"> <sql id="combine">
<if test="${condition}.name != null"> <if test='${condition}.name != null and (${name} == null or ${name} == "")'>
and ltr.name and ltr.name
<include refid="condition"> <include refid="condition">
<property name="object" value="${condition}.name"/> <property name="object" value="${condition}.name"/>
@ -75,20 +75,15 @@
JOIN project on project.id = lt.project_id JOIN project on project.id = lt.project_id
</if> </if>
<where> <where>
<choose> <if test="reportRequest.combine != null">
<!--高级--> <include refid="combine">
<when test="reportRequest.combine != null"> <property name="condition" value="reportRequest.combine"/>
<include refid="combine"> <property name="name" value="reportRequest.name"/>
<property name="condition" value="reportRequest.combine"/> </include>
</include> </if>
</when> <if test="reportRequest.name != null">
<!--普通--> AND ltr.name like CONCAT('%', #{reportRequest.name},'%')
<otherwise> </if>
<if test="reportRequest.name != null">
AND ltr.name like CONCAT('%', #{reportRequest.name},'%')
</if>
</otherwise>
</choose>
<if test="reportRequest.workspaceId != null"> <if test="reportRequest.workspaceId != null">
AND workspace_id = #{reportRequest.workspaceId,jdbcType=VARCHAR} AND workspace_id = #{reportRequest.workspaceId,jdbcType=VARCHAR}
</if> </if>

View File

@ -47,7 +47,7 @@
</sql> </sql>
<sql id="combine"> <sql id="combine">
<if test="${condition}.name != null"> <if test='${condition}.name != null and (${name} == null or ${name} == "")'>
and test_case.name and test_case.name
<include refid="condition"> <include refid="condition">
<property name="object" value="${condition}.name"/> <property name="object" value="${condition}.name"/>
@ -102,20 +102,15 @@
select test_case.id, test_case.name, test_case.priority, test_case.type select test_case.id, test_case.name, test_case.priority, test_case.type
from test_case from test_case
<where> <where>
<choose> <if test="request.combine != null">
<!--高级--> <include refid="combine">
<when test="request.combine != null"> <property name="condition" value="request.combine"/>
<include refid="combine"> <property name="name" value="request.name"/>
<property name="condition" value="request.combine"/> </include>
</include> </if>
</when> <if test="request.name != null">
<!--普通--> and test_case.name like CONCAT('%', #{request.name},'%')
<otherwise> </if>
<if test="request.name != null">
and test_case.name like CONCAT('%', #{request.name},'%')
</if>
</otherwise>
</choose>
<if test="request.projectId != null"> <if test="request.projectId != null">
AND test_case.project_id = #{request.projectId} AND test_case.project_id = #{request.projectId}
</if> </if>

View File

@ -51,7 +51,7 @@
</sql> </sql>
<sql id="combine"> <sql id="combine">
<if test="${condition}.name != null"> <if test='${condition}.name != null and (${name} == null or ${name} == "")'>
and test_plan.name and test_plan.name
<include refid="condition"> <include refid="condition">
<property name="object" value="${condition}.name"/> <property name="object" value="${condition}.name"/>
@ -100,20 +100,15 @@
from test_plan from test_plan
left join project on test_plan.project_id = project.id left join project on test_plan.project_id = project.id
<where> <where>
<choose> <if test="request.combine != null">
<!--高级--> <include refid="combine">
<when test="request.combine != null"> <property name="condition" value="request.combine"/>
<include refid="combine"> <property name="name" value="request.name"/>
<property name="condition" value="request.combine"/> </include>
</include> </if>
</when> <if test="request.name != null">
<!--普通--> and test_plan.name like CONCAT('%', #{request.name},'%')
<otherwise> </if>
<if test="request.name != null">
and test_plan.name like CONCAT('%', #{request.name},'%')
</if>
</otherwise>
</choose>
<if test="request.workspaceId != null"> <if test="request.workspaceId != null">
AND project.workspace_id = #{request.workspaceId} AND project.workspace_id = #{request.workspaceId}
</if> </if>

View File

@ -98,15 +98,13 @@
}, },
methods: { methods: {
search(combine) { search() {
// combine
let condition = combine ? {combine: combine} : this.condition;
if (this.testId !== 'all') { if (this.testId !== 'all') {
condition.testId = this.testId; this.condition.testId = this.testId;
} }
let url = "/api/report/list/" + this.currentPage + "/" + this.pageSize; let url = "/api/report/list/" + this.currentPage + "/" + this.pageSize;
this.result = this.$post(url, condition, response => { this.result = this.$post(url, this.condition, response => {
let data = response.data; let data = response.data;
this.total = data.itemCount; this.total = data.itemCount;
this.tableData = data.listObject; this.tableData = data.listObject;

View File

@ -105,15 +105,13 @@
create() { create() {
this.$router.push('/api/test/create'); this.$router.push('/api/test/create');
}, },
search(combine) { search() {
// combine
let condition = combine ? {combine: combine} : this.condition;
if (this.projectId !== 'all') { if (this.projectId !== 'all') {
condition.projectId = this.projectId; this.condition.projectId = this.projectId;
} }
let url = "/api/list/" + this.currentPage + "/" + this.pageSize; let url = "/api/list/" + this.currentPage + "/" + this.pageSize;
this.result = this.$post(url, condition, response => { this.result = this.$post(url, this.condition, response => {
let data = response.data; let data = response.data;
this.total = data.itemCount; this.total = data.itemCount;
this.tableData = data.listObject; this.tableData = data.listObject;

View File

@ -14,7 +14,7 @@
</span> </span>
<span> <span>
<ms-table-search-bar :condition.sync="condition" @change="search" class="search-bar"/> <ms-table-search-bar :condition.sync="condition" @change="search" class="search-bar"/>
<ms-table-adv-search-bar :condition="condition" @search="search" v-if="isCombine"/> <ms-table-adv-search-bar :condition.sync="condition" @search="search" v-if="isCombine"/>
</span> </span>
</el-row> </el-row>
</div> </div>

View File

@ -66,6 +66,11 @@
} }
}); });
// name
if (this.condition.name) this.condition.name = undefined;
//
this.condition.combine = condition;
this.$emit('update:condition', this.condition);
this.$emit('search', condition); this.$emit('search', condition);
this.visible = false; this.visible = false;
}, },
@ -80,6 +85,9 @@
component.value = source[index].value; component.value = source[index].value;
} }
}) })
this.condition.combine = undefined;
this.$emit('update:condition', this.condition);
this.$emit('search');
}, },
open() { open() {
this.visible = true; this.visible = true;

View File

@ -126,12 +126,11 @@
} }
}, },
methods: { methods: {
initTableData(combine) { initTableData() {
let condition = combine ? {combine: combine} : this.condition;
if (this.testId !== 'all') { if (this.testId !== 'all') {
condition.testId = this.testId; this.condition.testId = this.testId;
} }
this.result = this.$post(this.buildPagePath(this.queryPath), condition, response => { this.result = this.$post(this.buildPagePath(this.queryPath), this.condition, response => {
let data = response.data; let data = response.data;
this.total = data.itemCount; this.total = data.itemCount;
this.tableData = data.listObject; this.tableData = data.listObject;

View File

@ -143,13 +143,12 @@
this.initTableData(); this.initTableData();
}, },
methods: { methods: {
initTableData(combine) { initTableData() {
let condition = combine ? {combine: combine} : this.condition;
if (this.projectId !== 'all') { if (this.projectId !== 'all') {
condition.projectId = this.projectId; this.condition.projectId = this.projectId;
} }
this.result = this.$post(this.buildPagePath(this.queryPath), condition, response => { this.result = this.$post(this.buildPagePath(this.queryPath), this.condition, response => {
let data = response.data; let data = response.data;
this.total = data.itemCount; this.total = data.itemCount;
this.tableData = data.listObject; this.tableData = data.listObject;

View File

@ -196,20 +196,18 @@
} }
}, },
methods: { methods: {
initTableData(combine) { initTableData() {
// combine
let condition = combine ? {combine: combine} : this.condition;
if (this.planId) { if (this.planId) {
// param.planId = this.planId; // param.planId = this.planId;
condition.planId = this.planId; this.condition.planId = this.planId;
} }
if (this.selectNodeIds && this.selectNodeIds.length > 0) { if (this.selectNodeIds && this.selectNodeIds.length > 0) {
// param.nodeIds = this.selectNodeIds; // param.nodeIds = this.selectNodeIds;
condition.nodeIds = this.selectNodeIds; this.condition.nodeIds = this.selectNodeIds;
} }
if (this.currentProject) { if (this.currentProject) {
condition.projectId = this.currentProject.id; this.condition.projectId = this.currentProject.id;
this.result = this.$post(this.buildPagePath('/test/case/list'), condition, response => { this.result = this.$post(this.buildPagePath('/test/case/list'), this.condition, response => {
let data = response.data; let data = response.data;
this.total = data.itemCount; this.total = data.itemCount;
this.tableData = data.listObject; this.tableData = data.listObject;

View File

@ -167,18 +167,16 @@
this.initTableData(); this.initTableData();
}, },
methods: { methods: {
initTableData(combine) { initTableData() {
// combine
let condition = combine ? {combine: combine} : this.condition;
if (this.planId) { if (this.planId) {
// param.planId = this.planId; // param.planId = this.planId;
condition.planId = this.planId; this.condition.planId = this.planId;
} }
if (this.selectNodeIds && this.selectNodeIds.length > 0) { if (this.selectNodeIds && this.selectNodeIds.length > 0) {
// param.nodeIds = this.selectNodeIds; // param.nodeIds = this.selectNodeIds;
condition.nodeIds = this.selectNodeIds; this.condition.nodeIds = this.selectNodeIds;
} }
this.result = this.$post(this.buildPagePath(this.queryPath), condition, response => { this.result = this.$post(this.buildPagePath(this.queryPath), this.condition, response => {
let data = response.data; let data = response.data;
this.total = data.itemCount; this.total = data.itemCount;
this.tableData = data.listObject; this.tableData = data.listObject;

View File

@ -152,19 +152,17 @@
this.$emit('refresh'); this.$emit('refresh');
}); });
}, },
getCaseNames(combine) { getCaseNames() {
let param = {}; let param = {};
// combine
let condition = combine ? {combine: combine} : this.condition;
if (this.planId) { if (this.planId) {
// param.planId = this.planId; // param.planId = this.planId;
condition.planId = this.planId; this.condition.planId = this.planId;
} }
if (this.selectNodeIds && this.selectNodeIds.length > 0) { if (this.selectNodeIds && this.selectNodeIds.length > 0) {
// param.nodeIds = this.selectNodeIds; // param.nodeIds = this.selectNodeIds;
condition.nodeIds = this.selectNodeIds; this.condition.nodeIds = this.selectNodeIds;
} }
this.result = this.$post('/test/case/name', condition, response => { this.result = this.$post('/test/case/name', this.condition, response => {
this.testCases = response.data; this.testCases = response.data;
this.testCases.forEach(item => { this.testCases.forEach(item => {
item.checked = false; item.checked = false;