fix(高级查询): 修复高级查询执行查询操作后不能保留查询条件的bug

This commit is contained in:
q4speed 2020-07-22 17:52:23 +08:00
parent 0fa304a409
commit 473cbe8274
15 changed files with 96 additions and 128 deletions

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -98,15 +98,13 @@
},
methods: {
search(combine) {
// combine
let condition = combine ? {combine: combine} : this.condition;
search() {
if (this.testId !== 'all') {
condition.testId = this.testId;
this.condition.testId = this.testId;
}
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;
this.total = data.itemCount;
this.tableData = data.listObject;

View File

@ -105,15 +105,13 @@
create() {
this.$router.push('/api/test/create');
},
search(combine) {
// combine
let condition = combine ? {combine: combine} : this.condition;
search() {
if (this.projectId !== 'all') {
condition.projectId = this.projectId;
this.condition.projectId = this.projectId;
}
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;
this.total = data.itemCount;
this.tableData = data.listObject;

View File

@ -14,7 +14,7 @@
</span>
<span>
<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>
</el-row>
</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.visible = false;
},
@ -80,6 +85,9 @@
component.value = source[index].value;
}
})
this.condition.combine = undefined;
this.$emit('update:condition', this.condition);
this.$emit('search');
},
open() {
this.visible = true;

View File

@ -126,12 +126,11 @@
}
},
methods: {
initTableData(combine) {
let condition = combine ? {combine: combine} : this.condition;
initTableData() {
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;
this.total = data.itemCount;
this.tableData = data.listObject;

View File

@ -143,13 +143,12 @@
this.initTableData();
},
methods: {
initTableData(combine) {
let condition = combine ? {combine: combine} : this.condition;
initTableData() {
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;
this.total = data.itemCount;
this.tableData = data.listObject;

View File

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

View File

@ -167,18 +167,16 @@
this.initTableData();
},
methods: {
initTableData(combine) {
// combine
let condition = combine ? {combine: combine} : this.condition;
initTableData() {
if (this.planId) {
// param.planId = this.planId;
condition.planId = this.planId;
this.condition.planId = this.planId;
}
if (this.selectNodeIds && this.selectNodeIds.length > 0) {
// 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;
this.total = data.itemCount;
this.tableData = data.listObject;

View File

@ -152,19 +152,17 @@
this.$emit('refresh');
});
},
getCaseNames(combine) {
getCaseNames() {
let param = {};
// combine
let condition = combine ? {combine: combine} : this.condition;
if (this.planId) {
// param.planId = this.planId;
condition.planId = this.planId;
this.condition.planId = this.planId;
}
if (this.selectNodeIds && this.selectNodeIds.length > 0) {
// 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.forEach(item => {
item.checked = false;