commit
415e7f3859
running/pdf
stdiet-admin/src/main/java/com/stdiet/web/controller/custom
stdiet-custom/src/main
stdiet-ui/src/views/custom/dishes
Binary file not shown.
@ -90,6 +90,10 @@ public class SysDishesController extends BaseController {
|
||||
@Log(title = "菜品", businessType = BusinessType.INSERT)
|
||||
@PostMapping
|
||||
public AjaxResult add(@RequestBody SysDishes sysDishes) {
|
||||
if(sysDishes.getDishClass() != null && sysDishes.getDishClass().length == 2){
|
||||
sysDishes.setBigClass(sysDishes.getDishClass()[0]);
|
||||
sysDishes.setSmallClass(sysDishes.getDishClass()[1]);
|
||||
}
|
||||
return toAjax(sysDishesService.insertSysDishes(sysDishes));
|
||||
}
|
||||
|
||||
@ -100,6 +104,10 @@ public class SysDishesController extends BaseController {
|
||||
@Log(title = "菜品", businessType = BusinessType.UPDATE)
|
||||
@PutMapping
|
||||
public AjaxResult edit(@RequestBody SysDishes sysDishes) {
|
||||
if(sysDishes.getDishClass() != null && sysDishes.getDishClass().length == 2){
|
||||
sysDishes.setBigClass(sysDishes.getDishClass()[0]);
|
||||
sysDishes.setSmallClass(sysDishes.getDishClass()[1]);
|
||||
}
|
||||
return toAjax(sysDishesService.updateSysDishes(sysDishes));
|
||||
}
|
||||
|
||||
|
@ -29,6 +29,19 @@ public class SysDishes {
|
||||
@Excel(name = "菜品名称")
|
||||
private String name;
|
||||
|
||||
/** 大类 */
|
||||
@Excel(name = "大类")
|
||||
private Integer bigClass;
|
||||
|
||||
@Excel(name = "大类")
|
||||
private String bigClassName;
|
||||
|
||||
/** 小类 */
|
||||
private Integer smallClass;
|
||||
|
||||
@Excel(name = "小类")
|
||||
private String smallClassName;
|
||||
|
||||
/**
|
||||
* 菜品类型
|
||||
*/
|
||||
@ -72,7 +85,8 @@ public class SysDishes {
|
||||
*/
|
||||
private String remark;
|
||||
|
||||
|
||||
private List<SysDishesIngredient> igdList;
|
||||
|
||||
private Integer[] dishClass;
|
||||
|
||||
}
|
@ -7,6 +7,8 @@
|
||||
<resultMap type="SysDishes" id="SysDishesResult">
|
||||
<result property="id" column="id" />
|
||||
<result property="name" column="name" />
|
||||
<result property="bigClass" column="big_class" />
|
||||
<result property="smallClass" column="small_class" />
|
||||
<result property="type" column="type" />
|
||||
<result property="isMain" column="is_main" />
|
||||
<result property="methods" column="methods" />
|
||||
@ -15,6 +17,10 @@
|
||||
<result property="createTime" column="create_time" />
|
||||
<result property="updateBy" column="update_by" />
|
||||
<result property="updateTime" column="update_time" />
|
||||
|
||||
<!-- 非持久化字段 -->
|
||||
<result property="bigClassName" column="bigClassName" />
|
||||
<result property="smallClassName" column="smallClassName" />
|
||||
</resultMap>
|
||||
|
||||
<resultMap type="SysDishesIngredient" id="SysDishesIngredientResult">
|
||||
@ -33,7 +39,7 @@
|
||||
</resultMap>
|
||||
|
||||
<sql id="selectSysDishesVo">
|
||||
select id, name, type, is_main, methods, create_by, create_time, update_by, update_time, review_status from sys_dishes
|
||||
select id, name, big_class, small_class, type, is_main, methods, create_by, create_time, update_by, update_time, review_status from sys_dishes
|
||||
</sql>
|
||||
|
||||
<select id="selectSysDishesList" parameterType="SysDishes" resultMap="SysDishesResult">
|
||||
@ -88,6 +94,8 @@
|
||||
insert into sys_dishes
|
||||
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||
<if test="name != null">name,</if>
|
||||
<if test="bigClass != null">big_class,</if>
|
||||
<if test="smallClass != null">small_class,</if>
|
||||
<if test="type != null">type,</if>
|
||||
<if test="isMain != null">is_main,</if>
|
||||
<if test="methods != null">methods,</if>
|
||||
@ -99,6 +107,8 @@
|
||||
</trim>
|
||||
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||
<if test="name != null">#{name},</if>
|
||||
<if test="bigClass != null">#{bigClass},</if>
|
||||
<if test="smallClass != null">#{smallClass},</if>
|
||||
<if test="type != null">#{type},</if>
|
||||
<if test="isMain != null">#{isMain},</if>
|
||||
<if test="methods != null">#{methods},</if>
|
||||
@ -114,6 +124,8 @@
|
||||
update sys_dishes
|
||||
<trim prefix="SET" suffixOverrides=",">
|
||||
<if test="name != null">name = #{name},</if>
|
||||
<if test="bigClass != null">big_class = #{bigClass},</if>
|
||||
<if test="smallClass != null">small_class = #{smallClass},</if>
|
||||
<if test="type != null">type = #{type},</if>
|
||||
<if test="isMain != null">is_main = #{isMain},</if>
|
||||
<if test="methods != null">methods = #{methods},</if>
|
||||
|
@ -100,7 +100,13 @@
|
||||
</el-tag>
|
||||
</template>
|
||||
</el-table-column>
|
||||
|
||||
<el-table-column label="菜品名称" align="center" prop="name" />
|
||||
<el-table-column label="菜品种类" align="center" prop="bigClass" >
|
||||
<template slot-scope="scope">
|
||||
{{dishClassFormat(scope.row)}}
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="菜品类型" align="center" prop="type">
|
||||
<template slot-scope="scope">
|
||||
<autohideinfo :data="typeFormat(scope.row)" />
|
||||
@ -174,7 +180,18 @@
|
||||
<el-input v-model="form.name" placeholder="请输入菜品名称" />
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="12">
|
||||
<el-col :span="8">
|
||||
<el-form-item label="菜品种类" prop="dishClass">
|
||||
<el-cascader
|
||||
filterable
|
||||
v-model="form.dishClass"
|
||||
:options="dishClassOptions"
|
||||
:props="{ expandTrigger: 'hover' }"
|
||||
placeholder="请输入菜品种类"
|
||||
></el-cascader>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="8">
|
||||
<el-form-item label="菜品类型" prop="type">
|
||||
<el-select
|
||||
v-model="form.type"
|
||||
@ -190,7 +207,7 @@
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="12">
|
||||
<el-col :span="8">
|
||||
<el-form-item label="是否主食" prop="isMain">
|
||||
<el-radio-group v-model="form.isMain">
|
||||
<el-radio :label="0">是</el-radio>
|
||||
@ -435,6 +452,18 @@ export default {
|
||||
cusUnitOptions: [],
|
||||
//
|
||||
cusWeightOptions: [],
|
||||
dishClassOptions: [],
|
||||
/*
|
||||
* {
|
||||
value: 'zhinan',
|
||||
label: '指南',
|
||||
children: [{
|
||||
value: 'shejiyuanze',
|
||||
label: '设计原则'
|
||||
}]
|
||||
}*/
|
||||
dishClassBigOptions:[],
|
||||
dishClassSmallOptions:[],
|
||||
// 查询参数
|
||||
queryParams: {
|
||||
pageNum: 1,
|
||||
@ -465,6 +494,13 @@ export default {
|
||||
this.getDicts("cus_review_status").then((response) => {
|
||||
this.reviewStatusOptions = response.data;
|
||||
});
|
||||
this.getDicts("dish_class_big").then((response) => {
|
||||
this.dishClassBigOptions = response.data;
|
||||
this.getDicts("dish_class_small").then((res) => {
|
||||
this.dishClassSmallOptions = res.data;
|
||||
this.dealDishClassBigAndSmall();
|
||||
});
|
||||
});
|
||||
},
|
||||
methods: {
|
||||
/** 查询菜品列表 */
|
||||
@ -501,6 +537,26 @@ export default {
|
||||
this.loading = false;
|
||||
});
|
||||
},
|
||||
//处理菜品大类小类的关系
|
||||
dealDishClassBigAndSmall(){
|
||||
this.dishClassBigOptions.forEach((item, index) => {
|
||||
this.dishClassOptions.push({
|
||||
'value': parseInt(item.dictValue),
|
||||
'label': item.dictLabel,
|
||||
'children': []
|
||||
});
|
||||
if(index == this.dishClassBigOptions.length - 1){
|
||||
this.dishClassSmallOptions.forEach((smallClass, i) => {
|
||||
if(smallClass.remark){
|
||||
this.dishClassOptions[parseInt(smallClass.remark-1)].children.push({
|
||||
'value': parseInt(smallClass.dictValue),
|
||||
'label': smallClass.dictLabel
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
},
|
||||
// 菜品类型字典翻译
|
||||
typeFormat(row, column) {
|
||||
return !row.type
|
||||
@ -519,6 +575,15 @@ export default {
|
||||
reviewStatusFormat(row, column) {
|
||||
return this.selectDictLabel(this.reviewStatusOptions, row.area);
|
||||
},
|
||||
//菜品种类翻译
|
||||
dishClassFormat(row){
|
||||
if(row.bigClass > 0 && row.smallClass > 0){
|
||||
let bigClassName = this.selectDictLabel(this.dishClassBigOptions, row.bigClass);
|
||||
let smallClassName = this.selectDictLabel(this.dishClassSmallOptions, row.smallClass);
|
||||
return bigClassName+"/"+smallClassName;
|
||||
}
|
||||
return "";
|
||||
},
|
||||
// 取消按钮
|
||||
cancel() {
|
||||
this.open = false;
|
||||
@ -530,6 +595,7 @@ export default {
|
||||
id: null,
|
||||
name: null,
|
||||
type: [],
|
||||
dishClass:[],
|
||||
methods: null,
|
||||
createBy: null,
|
||||
createTime: null,
|
||||
@ -582,6 +648,7 @@ export default {
|
||||
const id = row.id || this.ids;
|
||||
getDishes(id).then((response) => {
|
||||
this.form = response.data;
|
||||
this.form.dishClass = [this.form.bigClass, this.form.smallClass];
|
||||
this.form.type = this.form.type ? this.form.type.split(",") : null;
|
||||
this.form.igdList.forEach((obj) => {
|
||||
this.selIngIds.push(obj.id);
|
||||
|
Loading…
x
Reference in New Issue
Block a user