菜品添加、查询优化

This commit is contained in:
xiezhijun 2021-03-11 18:31:34 +08:00
parent 9946667f88
commit 2b571aca92
5 changed files with 107 additions and 16 deletions

View File

@ -47,6 +47,8 @@
<where> <where>
<if test="name != null and name != ''"> and name like concat('%', #{name}, '%')</if> <if test="name != null and name != ''"> and name like concat('%', #{name}, '%')</if>
<if test="type != null and type != ''"> and FIND_IN_SET(#{type}, type)</if> <if test="type != null and type != ''"> and FIND_IN_SET(#{type}, type)</if>
<if test="bigClass != null"> and big_class = #{bigClass}</if>
<if test="smallClass != null"> and small_class = #{smallClass}</if>
<if test="reviewStatus != null and type != ''"> and review_status = #{reviewStatus}</if> <if test="reviewStatus != null and type != ''"> and review_status = #{reviewStatus}</if>
<if test="isMain != null and type != ''"> and is_main = #{isMain}</if> <if test="isMain != null and type != ''"> and is_main = #{isMain}</if>
</where> </where>

View File

@ -33,7 +33,9 @@ const oriState = {
templateInfo: undefined, templateInfo: undefined,
copyData: undefined, copyData: undefined,
canCopyMenuTypes: [], canCopyMenuTypes: [],
fontSize: parseInt(localStorage.getItem("fontSize")) || 12 fontSize: parseInt(localStorage.getItem("fontSize")) || 12,
dishBigClassOptions:[],
dishSmallClassOptions:[],
}; };
const mutations = { const mutations = {
@ -138,6 +140,12 @@ const actions = {
getDicts("cus_dishes_type").then(response => { getDicts("cus_dishes_type").then(response => {
commit("updateStateData", { typeOptions: response.data }); commit("updateStateData", { typeOptions: response.data });
}); });
getDicts("dish_class_big").then((response) => {
commit("updateStateData", { dishBigClassOptions: response.data });
});
getDicts("dish_class_small").then((response) => {
commit("updateStateData", { dishSmallClassOptions: response.data });
});
return new Promise((res, rej) => { return new Promise((res, rej) => {
// 健康数据 // 健康数据
@ -454,6 +462,27 @@ const actions = {
}; };
const getters = { const getters = {
dishClassOptions: state => {
const dishClass = [];
state.dishBigClassOptions.forEach((item, index) => {
dishClass.push({
'value': parseInt(item.dictValue),
'label': item.dictLabel,
'children': []
});
if(index == state.dishBigClassOptions.length - 1){
state.dishSmallClassOptions.forEach((smallClass, i) => {
if(smallClass.remark){
dishClass[parseInt(smallClass.remark-1)].children.push({
'value': parseInt(smallClass.dictValue),
'label': smallClass.dictLabel
});
}
});
}
});
return dishClass;
},
analyseData: state => { analyseData: state => {
if (!state.recipesData.length) { if (!state.recipesData.length) {
return []; return [];
@ -504,7 +533,18 @@ const getters = {
state.typeOptions.reduce((obj, cur) => { state.typeOptions.reduce((obj, cur) => {
obj[cur.dictValue] = cur.dictLabel; obj[cur.dictValue] = cur.dictLabel;
return obj; return obj;
}, {}) }, {}),
dishBigClassDict: state =>
state.dishBigClassOptions.reduce((obj, cur) => {
obj[cur.dictValue] = cur.dictLabel;
return obj;
}, {}),
dishSmallClassDict: state =>
state.dishSmallClassOptions.reduce((obj, cur) => {
obj[cur.dictValue] = cur.dictLabel;
return obj;
}, {}),
}; };
export default { export default {

View File

@ -16,6 +16,17 @@
@keyup.enter.native="handleQuery" @keyup.enter.native="handleQuery"
/> />
</el-form-item> </el-form-item>
<el-form-item label="菜品种类" prop="dishClass">
<el-cascader
v-model="dishClassQueryParam"
:options="dishClassOptions"
:props="{ expandTrigger: 'hover' }"
:show-all-levels="true"
filterable
clearable
placeholder="请选择菜品种类"
></el-cascader>
</el-form-item>
<el-form-item label="菜品类型" prop="type"> <el-form-item label="菜品类型" prop="type">
<el-select <el-select
v-model="queryParams.type" v-model="queryParams.type"
@ -187,7 +198,7 @@
v-model="form.dishClass" v-model="form.dishClass"
:options="dishClassOptions" :options="dishClassOptions"
:props="{ expandTrigger: 'hover' }" :props="{ expandTrigger: 'hover' }"
placeholder="请输入菜品种类" placeholder="请选择菜品种类"
></el-cascader> ></el-cascader>
</el-form-item> </el-form-item>
</el-col> </el-col>
@ -453,15 +464,6 @@ export default {
// //
cusWeightOptions: [], cusWeightOptions: [],
dishClassOptions: [], dishClassOptions: [],
/*
* {
value: 'zhinan',
label: '指南',
children: [{
value: 'shejiyuanze',
label: '设计原则'
}]
}*/
dishClassBigOptions:[], dishClassBigOptions:[],
dishClassSmallOptions:[], dishClassSmallOptions:[],
// //
@ -470,11 +472,15 @@ export default {
pageSize: 10, pageSize: 10,
name: null, name: null,
type: null, type: null,
bigClass: null,
smallClass: null
}, },
// //
form: {}, form: {},
// //
rules: {}, rules: {},
//
dishClassQueryParam:[]
}; };
}, },
created() { created() {
@ -506,6 +512,11 @@ export default {
/** 查询菜品列表 */ /** 查询菜品列表 */
getList() { getList() {
this.loading = true; this.loading = true;
if(this.dishClassQueryParam != null && this.dishClassQueryParam.length > 0){
this.queryParams.smallClass = this.dishClassQueryParam[1];
}else{
this.queryParams.smallClass = null;
}
listDishes(this.queryParams).then((response) => { listDishes(this.queryParams).then((response) => {
this.dishesList = response.rows.map((d) => { this.dishesList = response.rows.map((d) => {
const recTags = [], const recTags = [],
@ -621,6 +632,7 @@ export default {
/** 重置按钮操作 */ /** 重置按钮操作 */
resetQuery() { resetQuery() {
this.resetForm("queryForm"); this.resetForm("queryForm");
this.dishClassQueryParam = [];
this.handleQuery(); this.handleQuery();
}, },
// //

View File

@ -71,7 +71,7 @@
size="mini" size="mini"
type="primary" type="primary"
@click="handleOnSave" @click="handleOnSave"
>生成食谱</el-button >生成食谱2</el-button
> >
</span> </span>
</div> </div>

View File

@ -15,6 +15,17 @@
@keyup.enter.native="handleQuery" @keyup.enter.native="handleQuery"
/> />
</el-form-item> </el-form-item>
<el-form-item label="菜品种类" prop="dishClass">
<el-cascader
filterable
clearable
v-model="dishClassQueryParam"
:options="dishClassOptions"
:props="{ expandTrigger: 'hover' }"
:show-all-levels="true"
placeholder="请选择菜品种类"
></el-cascader>
</el-form-item>
<el-form-item label="菜品类型" prop="type"> <el-form-item label="菜品类型" prop="type">
<el-select <el-select
:disabled="lockType" :disabled="lockType"
@ -54,6 +65,11 @@
@current-change="handleCurrentChange" @current-change="handleCurrentChange"
> >
<el-table-column label="菜品名称" align="center" prop="name" /> <el-table-column label="菜品名称" align="center" prop="name" />
<el-table-column label="菜品种类" align="center" prop="bigClass">
<template slot-scope="scope">
<AutoHideMessage :data="dishClassFormat(scope.row)" :maxLength="10"></AutoHideMessage>
</template>
</el-table-column>
<el-table-column label="菜品类型" align="center" prop="type"> <el-table-column label="菜品类型" align="center" prop="type">
<template slot-scope="scope"> <template slot-scope="scope">
<AutoHideInfo :data="typeFormat(scope.row)" /> <AutoHideInfo :data="typeFormat(scope.row)" />
@ -90,9 +106,10 @@
</template> </template>
<script> <script>
import AutoHideInfo from "@/components/AutoHideInfo"; import AutoHideInfo from "@/components/AutoHideInfo";
import AutoHideMessage from "@/components/AutoHideMessage";
import { listDishes } from "@/api/custom/dishes"; import { listDishes } from "@/api/custom/dishes";
import { createNamespacedHelpers } from "vuex"; import { createNamespacedHelpers } from "vuex";
const { mapState } = createNamespacedHelpers("recipes"); const { mapState,mapGetters } = createNamespacedHelpers("recipes");
export default { export default {
name: "SelectDishes", name: "SelectDishes",
props: [], props: [],
@ -107,15 +124,20 @@ export default {
pageSize: 10, pageSize: 10,
name: null, name: null,
type: null, type: null,
smallClass: null,
bigClass: null,
reviewStatus: "yes", reviewStatus: "yes",
}, },
//
dishClassQueryParam:[]
}; };
}, },
components: { components: {
AutoHideInfo, AutoHideInfo,AutoHideMessage
}, },
computed: { computed: {
...mapState(["typeOptions"]), ...mapState(["typeOptions","dishBigClassOptions","dishSmallClassOptions"]),
...mapGetters(["dishClassOptions"]),
}, },
methods: { methods: {
getList({ type }) { getList({ type }) {
@ -124,6 +146,11 @@ export default {
this.lockType = true; this.lockType = true;
this.queryParams.type = type; this.queryParams.type = type;
} }
if(this.dishClassQueryParam != null && this.dishClassQueryParam.length > 0){
this.queryParams.smallClass = this.dishClassQueryParam[1];
}else{
this.queryParams.smallClass = null;
}
this.loading = true; this.loading = true;
listDishes(this.queryParams).then((result) => { listDishes(this.queryParams).then((result) => {
this.dishesList = result.rows.map((d) => { this.dishesList = result.rows.map((d) => {
@ -175,6 +202,7 @@ export default {
}, },
resetQuery() { resetQuery() {
this.resetForm("queryForm"); this.resetForm("queryForm");
this.dishClassQueryParam = [];
this.handleQuery(); this.handleQuery();
}, },
typeFormat(row, column) { typeFormat(row, column) {
@ -184,6 +212,15 @@ export default {
.split(",") .split(",")
.map((type) => this.selectDictLabel(this.typeOptions, type)); .map((type) => this.selectDictLabel(this.typeOptions, type));
}, },
//
dishClassFormat(row){
if(row.bigClass > 0 && row.smallClass > 0){
let bigClassName = this.selectDictLabel(this.dishBigClassOptions, row.bigClass);
let smallClassName = this.selectDictLabel(this.dishSmallClassOptions, row.smallClass);
return bigClassName+"/"+smallClassName;
}
return "";
},
}, },
}; };
</script> </script>