!340 模板检索语句修改,新增编辑时加上关键词

Merge pull request !340 from 德仔/xzj
This commit is contained in:
德仔 2021-07-31 11:06:01 +00:00 committed by Gitee
commit dcae5727f8
5 changed files with 160 additions and 17 deletions

View File

@ -1,6 +1,7 @@
package com.stdiet.custom.domain; package com.stdiet.custom.domain;
import com.fasterxml.jackson.annotation.JsonFormat; import com.fasterxml.jackson.annotation.JsonFormat;
import com.stdiet.common.annotation.Excel;
import lombok.Data; import lombok.Data;
import java.util.Date; import java.util.Date;
@ -21,6 +22,9 @@ public class SysRecipesTemplate {
Long planId; Long planId;
/** 关键词,使用 , 隔开 */
private String keyWord;
String remark; String remark;
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")

View File

@ -10,6 +10,7 @@
<result property="planId" column="plan_id"/> <result property="planId" column="plan_id"/>
<result property="nutritionistId" column="nutritionist_id"/> <result property="nutritionistId" column="nutritionist_id"/>
<result property="nutriAssisId" column="nutri_assis_id"/> <result property="nutriAssisId" column="nutri_assis_id"/>
<result property="keyWord" column="key_word" />
<result property="remark" column="remark"/> <result property="remark" column="remark"/>
<result property="createTime" column="create_time"/> <result property="createTime" column="create_time"/>
<result property="createBy" column="create_by"/> <result property="createBy" column="create_by"/>
@ -23,7 +24,7 @@
</resultMap> </resultMap>
<select id="selectRecipesTemplateListByCondition" parameterType="SysRecipesTemplate" resultMap="SysRecipesTemplateResult"> <select id="selectRecipesTemplateListByCondition" parameterType="SysRecipesTemplate" resultMap="SysRecipesTemplateResult">
select srt.id, srt.name, srt.nutritionist_id, srt.nutri_assis_id, srt.remark, srt.update_time, select srt.id, srt.name, srt.nutritionist_id, srt.nutri_assis_id, srt.key_word, srt.remark, srt.update_time,
srt.create_time, srt.update_by, srt.create_by, srt.plan_id, srp.recipes_id, srp.review_status, srt.create_time, srt.update_by, srt.create_by, srt.plan_id, srp.recipes_id, srp.review_status,
su_nutritionist.nick_name as nutritionist, su_nutritionist_assis.nick_name as nutritionist_assis su_nutritionist.nick_name as nutritionist, su_nutritionist_assis.nick_name as nutritionist_assis
from sys_recipes_template srt from sys_recipes_template srt
@ -31,19 +32,31 @@
left join sys_user su_nutritionist on su_nutritionist.user_id = srt.nutritionist_id and su_nutritionist.del_flag = 0 left join sys_user su_nutritionist on su_nutritionist.user_id = srt.nutritionist_id and su_nutritionist.del_flag = 0
left join sys_user su_nutritionist_assis on su_nutritionist_assis.user_id = srt.nutri_assis_id and su_nutritionist_assis.del_flag = 0 left join sys_user su_nutritionist_assis on su_nutritionist_assis.user_id = srt.nutri_assis_id and su_nutritionist_assis.del_flag = 0
where srt.del_flag = 0 where srt.del_flag = 0
<if test="keys != null">and <if test="keys != null and keys.length > 0">and
<foreach collection="keys" item="key" separator="and" open="(" close=")"> <foreach collection="keys" item="key" separator="and" open="(" close=")">
(
srt.name like concat('%', #{key}, '%') or srt.remark like concat('%', #{key}, '%') srt.name like concat('%', #{key}, '%') or srt.remark like concat('%', #{key}, '%')
or FIND_IN_SET(#{key}, srt.key_word)
)
</foreach> </foreach>
</if> </if>
<if test="nutriAssisId != null ">and srt.nutri_assis_id = #{nutriAssisId}</if> <if test="nutriAssisId != null ">and srt.nutri_assis_id = #{nutriAssisId}</if>
<if test="nutritionistId != null ">and srt.nutritionist_id = #{nutritionistId}</if> <if test="nutritionistId != null ">and srt.nutritionist_id = #{nutritionistId}</if>
<if test="reviewStatus != null ">and srp.review_status = #{reviewStatus}</if> <if test="reviewStatus != null ">and srp.review_status = #{reviewStatus}</if>
order by srt.id desc order by
<if test="keys != null and keys.length > 0">
FIND_IN_SET(srt.id, (
SELECT group_concat(t.id Separator ',') from sys_recipes_template t WHERE
<foreach collection="keys" item="key" separator="and" open="(" close=")">
FIND_IN_SET(#{key}, srt.key_word)
</foreach>
)) desc,
</if>
srt.id desc
</select> </select>
<select id="getRecipesTemplateById" parameterType="Long" resultType="SysRecipesTemplate"> <select id="getRecipesTemplateById" parameterType="Long" resultType="SysRecipesTemplate">
select srt.id, srt.name, srt.nutritionist_id as nutritionistId, srt.nutri_assis_id as nutriAssisId, srt.remark, srt.update_time as updateTime, select srt.id, srt.name, srt.nutritionist_id as nutritionistId, srt.nutri_assis_id as nutriAssisId, srt.key_word, srt.remark, srt.update_time as updateTime,
srt.create_time as createTime, srt.update_by as updateBy, srt.create_by as createBy, srt.plan_id as planId, srt.create_time as createTime, srt.update_by as updateBy, srt.create_by as createBy, srt.plan_id as planId,
su_nutritionist.nick_name as nutritionist, su_nutritionist_assis.nick_name as nutriAssis su_nutritionist.nick_name as nutritionist, su_nutritionist_assis.nick_name as nutriAssis
from sys_recipes_template srt from sys_recipes_template srt
@ -59,6 +72,7 @@
<if test="planId != null">plan_id,</if> <if test="planId != null">plan_id,</if>
<if test="nutriAssisId != null">nutri_assis_id,</if> <if test="nutriAssisId != null">nutri_assis_id,</if>
<if test="nutritionistId != null">nutritionist_id,</if> <if test="nutritionistId != null">nutritionist_id,</if>
<if test="keyWord != null">key_word,</if>
<if test="createTime != null">create_time,</if> <if test="createTime != null">create_time,</if>
<if test="createBy != null">create_by,</if> <if test="createBy != null">create_by,</if>
<if test="updateTime != null">update_time,</if> <if test="updateTime != null">update_time,</if>
@ -70,6 +84,7 @@
<if test="planId != null">#{planId},</if> <if test="planId != null">#{planId},</if>
<if test="nutriAssisId != null">#{nutriAssisId},</if> <if test="nutriAssisId != null">#{nutriAssisId},</if>
<if test="nutritionistId != null">#{nutritionistId},</if> <if test="nutritionistId != null">#{nutritionistId},</if>
<if test="keyWord != null">#{keyWord},</if>
<if test="createTime != null">#{createTime},</if> <if test="createTime != null">#{createTime},</if>
<if test="createBy != null">#{createBy},</if> <if test="createBy != null">#{createBy},</if>
<if test="updateTime != null">#{updateTime},</if> <if test="updateTime != null">#{updateTime},</if>
@ -84,6 +99,7 @@
<if test="name != null">name = #{name},</if> <if test="name != null">name = #{name},</if>
<if test="nutriAssisId != null">nutri_assis_id = #{nutriAssisId},</if> <if test="nutriAssisId != null">nutri_assis_id = #{nutriAssisId},</if>
<if test="nutritionistId != null">nutritionist_id = #{nutritionistId},</if> <if test="nutritionistId != null">nutritionist_id = #{nutritionistId},</if>
<if test="keyWord != null">key_word = #{keyWord},</if>
<if test="createTime != null">create_time = #{createTime},</if> <if test="createTime != null">create_time = #{createTime},</if>
<if test="createBy != null">create_by = #{createBy},</if> <if test="createBy != null">create_by = #{createBy},</if>
<if test="updateTime != null">update_time = #{updateTime},</if> <if test="updateTime != null">update_time = #{updateTime},</if>

View File

@ -29,6 +29,27 @@
></el-option> ></el-option>
</el-select> </el-select>
</el-form-item> </el-form-item>
<el-form-item label="关键词" prop="keyWordArray" label-width="100px">
<el-select
v-model="form.keyWordArray"
multiple
filterable
clearable
allow-create
default-first-option
placeholder="请创建模板关键词,用于模板检索,按回车创建"
style="width:100%"
>
<el-option
v-for="dict in keyOptions"
:key="dict.dictValue"
:label="dict.dictLabel"
:value="dict.dictValue"
>
</el-option>
</el-select>
</el-form-item>
<el-form-item label="备注" prop="remark" label-width="100px"> <el-form-item label="备注" prop="remark" label-width="100px">
<el-input <el-input
v-model="form.remark" v-model="form.remark"
@ -58,6 +79,8 @@ export default {
nutriAssisId: null, nutriAssisId: null,
nutritionistId: null, nutritionistId: null,
remark: null, remark: null,
keyWordArray: null,
keyWord: null
}, },
// //
rules: { rules: {
@ -70,6 +93,16 @@ export default {
], ],
}, },
visible: false, visible: false,
keyOptions:[
{
dictLabel: "1-7",
dictValue: "1-7"
},
{
dictLabel: "高血压",
dictValue: "高血压"
}
]
}; };
}, },
computed: { computed: {
@ -87,6 +120,7 @@ export default {
this.reset(); this.reset();
if (data) { if (data) {
this.title = "修改模板"; this.title = "修改模板";
data.keyWordArray = (data.keyWord != null && data.keyWord != "") ? data.keyWord.split(",") : null;
this.form = data; this.form = data;
} else { } else {
this.title = "创建模板"; this.title = "创建模板";
@ -94,7 +128,9 @@ export default {
}, },
submitForm() { submitForm() {
this.$refs["form"].validate((valid) => { this.$refs["form"].validate((valid) => {
if (valid) { if (valid && this.checkFormat(this.form.keyWordArray)) {
this.form.keyWord = (this.form.keyWordArray != null && this.form.keyWordArray.length > 0) ? this.form.keyWordArray.join(",") : null;
this.form.keyWord = this.form.keyWord.replace("",",");
this.$emit("onConfirm", this.form); this.$emit("onConfirm", this.form);
this.visible = false; this.visible = false;
} }
@ -108,12 +144,30 @@ export default {
nutriAssisId: null, nutriAssisId: null,
nutritionistId: null, nutritionistId: null,
remark: null, remark: null,
keyWordArray: null,
keyWord: null
}; };
this.resetForm("form"); this.resetForm("form");
}, },
cancel() { cancel() {
this.visible = false; this.visible = false;
}, },
checkFormat(keyWordArray){
let flag = true;
let msg = "";
if(keyWordArray != null && keyWordArray.length > 0){
keyWordArray.forEach((item,index) => {
if(item.indexOf(",") != -1 || item.indexOf("") != -1 || item.indexOf(" ") != -1){
msg = "关键词中不能含有逗号和空格";
flag = false;
}
});
}
if(!flag){
this.msgError(msg);
}
return flag;
}
}, },
}; };
</script> </script>

View File

@ -8,11 +8,22 @@
<!-- 筛选 --> <!-- 筛选 -->
<el-form :model="queryParams" ref="queryForm" :inline="true"> <el-form :model="queryParams" ref="queryForm" :inline="true">
<el-form-item label="搜索内容" prop="name"> <el-form-item label="搜索内容" prop="name">
<el-input <el-select
v-model="queryParams.name" v-model="queryParams.keys"
placeholder="请输入模板名称或备注" multiple
filterable
allow-create
clearable
default-first-option
@keyup.enter.native="handleQuery" @keyup.enter.native="handleQuery"
/> placeholder="请输入或选择关键字">
<!--<el-option
v-for="item in options"
:key="item.value"
:label="item.label"
:value="item.value">
</el-option>-->
</el-select>
</el-form-item> </el-form-item>
<el-form-item label="营养师" prop="nutritionistId"> <el-form-item label="营养师" prop="nutritionistId">
<el-select <el-select
@ -67,7 +78,16 @@
<el-table-column label="模板名称" align="center" prop="name" /> <el-table-column label="模板名称" align="center" prop="name" />
<el-table-column label="营养师" align="center" prop="nutritionist" /> <el-table-column label="营养师" align="center" prop="nutritionist" />
<el-table-column label="营养师助理" align="center" prop="nutriAssis" /> <el-table-column label="营养师助理" align="center" prop="nutriAssis" />
<el-table-column label="备注" prop="remark" align="center" /> <el-table-column label="关键词" align="center" prop="keyWord">
<template slot-scope="scope">
<AutoHideMessage :data="scope.row.keyWord" :maxLength="20"></AutoHideMessage>
</template>
</el-table-column>
<el-table-column label="备注" prop="remark" align="center" >
<template slot-scope="scope">
<AutoHideMessage :data="scope.row.remark" :maxLength="20"></AutoHideMessage>
</template>
</el-table-column>
</el-table> </el-table>
<pagination <pagination
@ -83,6 +103,7 @@
<script> <script>
import { listRecipesTemplate } from "@/api/custom/recipesTemplate"; import { listRecipesTemplate } from "@/api/custom/recipesTemplate";
import { mapState } from "vuex"; import { mapState } from "vuex";
import AutoHideMessage from "@/components/AutoHideMessage";
export default { export default {
name: "TemplateView", name: "TemplateView",
data() { data() {
@ -97,9 +118,13 @@ export default {
pageNum: 1, pageNum: 1,
pageSize: 10, pageSize: 10,
reviewStatus: 2, reviewStatus: 2,
keys: null
}, },
}; };
}, },
components:{
AutoHideMessage
},
props: ["view"], props: ["view"],
computed: { computed: {
...mapState({ ...mapState({
@ -119,6 +144,7 @@ export default {
/** 重置按钮操作 */ /** 重置按钮操作 */
resetQuery() { resetQuery() {
this.resetForm("queryForm"); this.resetForm("queryForm");
this.queryParams.keys = null;
this.handleQuery(); this.handleQuery();
}, },
handleOnBackClick() { handleOnBackClick() {
@ -132,7 +158,7 @@ export default {
getList() { getList() {
this.loading = true; this.loading = true;
const params = JSON.parse(JSON.stringify(this.queryParams)); const params = JSON.parse(JSON.stringify(this.queryParams));
params.keys = (params.name || "").split(" "); //params.keys = (params.name || "").split(" ");
listRecipesTemplate(params).then((res) => { listRecipesTemplate(params).then((res) => {
if (res.code === 200) { if (res.code === 200) {
this.dataList = res.rows; this.dataList = res.rows;

View File

@ -7,11 +7,28 @@
v-show="showSearch" v-show="showSearch"
> >
<el-form-item label="搜索内容" prop="name"> <el-form-item label="搜索内容" prop="name">
<el-input <!--<el-input
clearable
v-model="queryParams.name" v-model="queryParams.name"
placeholder="请输入模板名称或备注" placeholder="请输入模板名称或备注"
@keyup.enter.native="handleQuery" @keyup.enter.native="handleQuery"
/> />-->
<el-select
v-model="queryParams.keys"
multiple
filterable
allow-create
clearable
default-first-option
@keyup.enter.native="handleQuery"
placeholder="请输入或选择关键字">
<!--<el-option
v-for="item in options"
:key="item.value"
:label="item.label"
:value="item.value">
</el-option>-->
</el-select>
</el-form-item> </el-form-item>
<el-form-item label="营养师" prop="nutritionistId"> <el-form-item label="营养师" prop="nutritionistId">
<el-select <el-select
@ -116,13 +133,30 @@
prop="nutriAssisId" prop="nutriAssisId"
:formatter="nutriAssisIdFormat" :formatter="nutriAssisIdFormat"
/> />
<el-table-column
label="关键词"
align="center"
width="200"
prop="kwyWordArray"
>
<!--<template slot-scope="scope">
<AutoHideInfo :data="scope.row.keyWordArray" :line="2"> </AutoHideInfo>
</template>-->
<template slot-scope="scope">
<AutoHideMessage :data="scope.row.keyWord" :maxLength="20"></AutoHideMessage>
</template>
</el-table-column>
<el-table-column label="备注" prop="remark" align="center" >
<template slot-scope="scope">
<AutoHideMessage :data="scope.row.remark" :maxLength="20"></AutoHideMessage>
</template>
</el-table-column>
<el-table-column <el-table-column
label="创建时间" label="创建时间"
align="center" align="center"
width="180" width="180"
prop="createTime" prop="createTime"
/> />
<el-table-column label="备注" prop="remark" align="center" />
<el-table-column <el-table-column
label="操作" label="操作"
align="center" align="center"
@ -181,6 +215,8 @@ import {
deleteRecipesTemplate, deleteRecipesTemplate,
} from "@/api/custom/recipesTemplate"; } from "@/api/custom/recipesTemplate";
import TemplateDialog from "@/components/TemplateDialog"; import TemplateDialog from "@/components/TemplateDialog";
import AutoHideInfo from "@/components/AutoHideInfo";
import AutoHideMessage from "@/components/AutoHideMessage";
import { mapGetters, mapState } from "vuex"; import { mapGetters, mapState } from "vuex";
export default { export default {
@ -210,6 +246,7 @@ export default {
nutritionistId: null, nutritionistId: null,
nutriAssisId: null, nutriAssisId: null,
reviewStatus: null, reviewStatus: null,
keys: null
}, },
open: false, open: false,
title: "", title: "",
@ -231,6 +268,8 @@ export default {
}, },
components: { components: {
TemplateDialog, TemplateDialog,
AutoHideInfo,
AutoHideMessage
// "order-dialog": OrderDetail, // "order-dialog": OrderDetail,
// body_sign_dialog: BodySignDetail, // body_sign_dialog: BodySignDetail,
}, },
@ -270,8 +309,11 @@ export default {
getList() { getList() {
this.loading = true; this.loading = true;
const params = JSON.parse(JSON.stringify(this.queryParams)); const params = JSON.parse(JSON.stringify(this.queryParams));
params.keys = params.name ? params.name.split(" ") : null; //params.keys = params.name ? params.name.split(" ") : null;
listRecipesTemplate(params).then((response) => { listRecipesTemplate(params).then((response) => {
response.rows.forEach((item,index) => {
item.keyWordArray = (item.keyWord != null && item.keyWord != "") ? item.keyWord.split(",") : [];
});
this.recipesTemplateList = response.rows; this.recipesTemplateList = response.rows;
this.total = response.total; this.total = response.total;
this.loading = false; this.loading = false;
@ -289,6 +331,7 @@ export default {
/** 重置按钮操作 */ /** 重置按钮操作 */
resetQuery() { resetQuery() {
this.resetForm("queryForm"); this.resetForm("queryForm");
this.queryParams.keys = null;
this.handleQuery(); this.handleQuery();
}, },
getReviewStatusName(status) { getReviewStatusName(status) {