新增食材管理
This commit is contained in:
parent
27bf41b006
commit
d1786f5327
@ -63,6 +63,26 @@ public class SysIngredient extends BaseEntity
|
||||
@Excel(name = "推荐")
|
||||
private String recommend;
|
||||
|
||||
private Long[] recIds;
|
||||
|
||||
private Long[] notRecIds;
|
||||
|
||||
public Long[] getRecIds() {
|
||||
return recIds;
|
||||
}
|
||||
|
||||
public Long[] getNotRecIds() {
|
||||
return notRecIds;
|
||||
}
|
||||
|
||||
public void setNotRecIds(Long[] notRecIds) {
|
||||
this.notRecIds = notRecIds;
|
||||
}
|
||||
|
||||
public void setRedIds(Long[] recIds) {
|
||||
this.recIds = recIds;
|
||||
}
|
||||
|
||||
public void setId(Long id)
|
||||
{
|
||||
this.id = id;
|
||||
|
@ -0,0 +1,30 @@
|
||||
package com.stdiet.custom.domain;
|
||||
|
||||
public class SysIngredientNotRec {
|
||||
private Long ingredientId;
|
||||
private Long notRecommandId;
|
||||
|
||||
public Long getIngredientId() {
|
||||
return ingredientId;
|
||||
}
|
||||
|
||||
public void setIngredientId(Long ingredientId) {
|
||||
this.ingredientId = ingredientId;
|
||||
}
|
||||
|
||||
public Long getRecommandId() {
|
||||
return notRecommandId;
|
||||
}
|
||||
|
||||
public void setRecommandId(Long recommandId) {
|
||||
this.notRecommandId = recommandId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "SysIngredientRec{" +
|
||||
"ingredientId=" + ingredientId +
|
||||
", notRecommandId=" + notRecommandId +
|
||||
'}';
|
||||
}
|
||||
}
|
@ -0,0 +1,30 @@
|
||||
package com.stdiet.custom.domain;
|
||||
|
||||
public class SysIngredientRec {
|
||||
private Long ingredientId;
|
||||
private Long recommandId;
|
||||
|
||||
public Long getIngredientId() {
|
||||
return ingredientId;
|
||||
}
|
||||
|
||||
public void setIngredientId(Long ingredientId) {
|
||||
this.ingredientId = ingredientId;
|
||||
}
|
||||
|
||||
public Long getRecommandId() {
|
||||
return recommandId;
|
||||
}
|
||||
|
||||
public void setRecommandId(Long recommandId) {
|
||||
this.recommandId = recommandId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "SysIngredientRec{" +
|
||||
"ingredientId=" + ingredientId +
|
||||
", recommandId=" + recommandId +
|
||||
'}';
|
||||
}
|
||||
}
|
@ -2,6 +2,8 @@ package com.stdiet.custom.mapper;
|
||||
|
||||
import java.util.List;
|
||||
import com.stdiet.custom.domain.SysIngredient;
|
||||
import com.stdiet.custom.domain.SysIngredientNotRec;
|
||||
import com.stdiet.custom.domain.SysIngredientRec;
|
||||
|
||||
/**
|
||||
* 食材Mapper接口
|
||||
@ -58,4 +60,12 @@ public interface SysIngredientMapper
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteSysIngredientByIds(Long[] ids);
|
||||
|
||||
public int batchIngredientRec(List<SysIngredientRec> ingredientRecList);
|
||||
|
||||
public int batchIngredientNotRec(List<SysIngredientNotRec> ingredientNotRecList);
|
||||
|
||||
public int deleteIngredentRecByIngredientId(Long recId);
|
||||
|
||||
public int deleteIngredentNotRecByIngredientId(Long notRecId);
|
||||
}
|
@ -1,12 +1,17 @@
|
||||
package com.stdiet.custom.service.impl;
|
||||
|
||||
import java.util.List;
|
||||
import com.stdiet.common.utils.DateUtils;
|
||||
import com.stdiet.common.utils.StringUtils;
|
||||
import com.stdiet.custom.domain.SysIngredient;
|
||||
import com.stdiet.custom.domain.SysIngredientNotRec;
|
||||
import com.stdiet.custom.domain.SysIngredientRec;
|
||||
import com.stdiet.custom.mapper.SysIngredientMapper;
|
||||
import com.stdiet.custom.service.ISysIngredientService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import com.stdiet.custom.mapper.SysIngredientMapper;
|
||||
import com.stdiet.custom.domain.SysIngredient;
|
||||
import com.stdiet.custom.service.ISysIngredientService;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 食材Service业务层处理
|
||||
@ -15,8 +20,7 @@ import com.stdiet.custom.service.ISysIngredientService;
|
||||
* @date 2020-12-15
|
||||
*/
|
||||
@Service
|
||||
public class SysIngredientServiceImpl implements ISysIngredientService
|
||||
{
|
||||
public class SysIngredientServiceImpl implements ISysIngredientService {
|
||||
@Autowired
|
||||
private SysIngredientMapper sysIngredientMapper;
|
||||
|
||||
@ -27,8 +31,7 @@ public class SysIngredientServiceImpl implements ISysIngredientService
|
||||
* @return 食材
|
||||
*/
|
||||
@Override
|
||||
public SysIngredient selectSysIngredientById(Long id)
|
||||
{
|
||||
public SysIngredient selectSysIngredientById(Long id) {
|
||||
return sysIngredientMapper.selectSysIngredientById(id);
|
||||
}
|
||||
|
||||
@ -39,8 +42,7 @@ public class SysIngredientServiceImpl implements ISysIngredientService
|
||||
* @return 食材
|
||||
*/
|
||||
@Override
|
||||
public List<SysIngredient> selectSysIngredientList(SysIngredient sysIngredient)
|
||||
{
|
||||
public List<SysIngredient> selectSysIngredientList(SysIngredient sysIngredient) {
|
||||
return sysIngredientMapper.selectSysIngredientList(sysIngredient);
|
||||
}
|
||||
|
||||
@ -51,10 +53,54 @@ public class SysIngredientServiceImpl implements ISysIngredientService
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int insertSysIngredient(SysIngredient sysIngredient)
|
||||
{
|
||||
public int insertSysIngredient(SysIngredient sysIngredient) {
|
||||
sysIngredient.setCreateTime(DateUtils.getNowDate());
|
||||
return sysIngredientMapper.insertSysIngredient(sysIngredient);
|
||||
int rows = sysIngredientMapper.insertSysIngredient(sysIngredient);
|
||||
//
|
||||
insertRecommand(sysIngredient);
|
||||
//
|
||||
insertNotRecommand(sysIngredient);
|
||||
return rows;
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增推荐标签
|
||||
* @param ingredient
|
||||
*/
|
||||
public void insertRecommand(SysIngredient ingredient) {
|
||||
Long[] recIds = ingredient.getRecIds();
|
||||
if(StringUtils.isNotNull(recIds)) {
|
||||
List<SysIngredientRec> list = new ArrayList<SysIngredientRec>();
|
||||
for(Long recId: recIds) {
|
||||
SysIngredientRec rec = new SysIngredientRec();
|
||||
rec.setIngredientId(ingredient.getId());
|
||||
rec.setRecommandId(recId);
|
||||
list.add(rec);
|
||||
}
|
||||
if(list.size() > 0) {
|
||||
sysIngredientMapper.batchIngredientRec(list);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增不推荐标签
|
||||
* @param ingredient
|
||||
*/
|
||||
public void insertNotRecommand(SysIngredient ingredient) {
|
||||
Long[] notRecIds = ingredient.getNotRecIds();
|
||||
if(StringUtils.isNotNull(notRecIds)) {
|
||||
List<SysIngredientNotRec> list = new ArrayList<SysIngredientNotRec>();
|
||||
for(Long recId: notRecIds) {
|
||||
SysIngredientNotRec notRec = new SysIngredientNotRec();
|
||||
notRec.setIngredientId(ingredient.getId());
|
||||
notRec.setRecommandId(recId);
|
||||
list.add(notRec);
|
||||
}
|
||||
if(list.size() > 0) {
|
||||
sysIngredientMapper.batchIngredientNotRec(list);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@ -64,9 +110,13 @@ public class SysIngredientServiceImpl implements ISysIngredientService
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int updateSysIngredient(SysIngredient sysIngredient)
|
||||
{
|
||||
public int updateSysIngredient(SysIngredient sysIngredient) {
|
||||
sysIngredient.setUpdateTime(DateUtils.getNowDate());
|
||||
Long ingredientId = sysIngredient.getId();
|
||||
sysIngredientMapper.deleteIngredentNotRecByIngredientId(ingredientId);
|
||||
insertNotRecommand(sysIngredient);
|
||||
sysIngredientMapper.deleteIngredentRecByIngredientId(ingredientId);
|
||||
insertRecommand(sysIngredient);
|
||||
return sysIngredientMapper.updateSysIngredient(sysIngredient);
|
||||
}
|
||||
|
||||
@ -77,8 +127,7 @@ public class SysIngredientServiceImpl implements ISysIngredientService
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int deleteSysIngredientByIds(Long[] ids)
|
||||
{
|
||||
public int deleteSysIngredientByIds(Long[] ids) {
|
||||
return sysIngredientMapper.deleteSysIngredientByIds(ids);
|
||||
}
|
||||
|
||||
@ -89,8 +138,9 @@ public class SysIngredientServiceImpl implements ISysIngredientService
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int deleteSysIngredientById(Long id)
|
||||
{
|
||||
public int deleteSysIngredientById(Long id) {
|
||||
sysIngredientMapper.deleteIngredentRecByIngredientId(id);
|
||||
sysIngredientMapper.deleteIngredentNotRecByIngredientId(id);
|
||||
return sysIngredientMapper.deleteSysIngredientById(id);
|
||||
}
|
||||
}
|
@ -8,16 +8,11 @@
|
||||
<result property="id" column="id" />
|
||||
<result property="name" column="name" />
|
||||
<result property="type" column="type" />
|
||||
<result property="recEstimation" column="rec_estimation" />
|
||||
<result property="recEstUnit" column="rec_est_unit" />
|
||||
<result property="recPortion" column="rec_portion" />
|
||||
<result property="proteinRatio" column="protein_ratio" />
|
||||
<result property="fatRatio" column="fat_ratio" />
|
||||
<result property="carbonRatio" column="carbon_ratio" />
|
||||
<result property="remark" column="remark" />
|
||||
<result property="area" column="area" />
|
||||
<result property="notRec" column="not_rec" />
|
||||
<result property="recommend" column="recommend" />
|
||||
<result property="remark" column="remark" />
|
||||
<result property="createBy" column="create_by" />
|
||||
<result property="createTime" column="create_time" />
|
||||
<result property="updateBy" column="update_by" />
|
||||
@ -25,7 +20,7 @@
|
||||
</resultMap>
|
||||
|
||||
<sql id="selectSysIngredientVo">
|
||||
select id, name, type, rec_estimation, rec_est_unit, rec_portion, protein_ratio, fat_ratio, carbon_ratio, remark, area, not_rec, recommend, create_by, create_time, update_by, update_time from sys_ingredient
|
||||
select id, name, type, protein_ratio, fat_ratio, carbon_ratio, area, remark, create_by, create_time, update_by, update_time from sys_ingredient
|
||||
</sql>
|
||||
|
||||
<select id="selectSysIngredientList" parameterType="SysIngredient" resultMap="SysIngredientResult">
|
||||
@ -34,8 +29,6 @@
|
||||
<if test="name != null and name != ''"> and name like concat('%', #{name}, '%')</if>
|
||||
<if test="type != null and type != ''"> and type = #{type}</if>
|
||||
<if test="area != null and area != ''"> and area = #{area}</if>
|
||||
<if test="notRec != null and notRec != ''"> and not_rec like concat('%', #{notRec}, '%')</if>
|
||||
<if test="recommend != null and recommend != ''"> and recommend like concat('%', #{recommend}, '%')</if>
|
||||
</where>
|
||||
</select>
|
||||
|
||||
@ -49,16 +42,11 @@
|
||||
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||
<if test="name != null">name,</if>
|
||||
<if test="type != null">type,</if>
|
||||
<if test="recEstimation != null">rec_estimation,</if>
|
||||
<if test="recEstUnit != null">rec_est_unit,</if>
|
||||
<if test="recPortion != null">rec_portion,</if>
|
||||
<if test="proteinRatio != null">protein_ratio,</if>
|
||||
<if test="fatRatio != null">fat_ratio,</if>
|
||||
<if test="carbonRatio != null">carbon_ratio,</if>
|
||||
<if test="remark != null">remark,</if>
|
||||
<if test="area != null">area,</if>
|
||||
<if test="notRec != null">not_rec,</if>
|
||||
<if test="recommend != null">recommend,</if>
|
||||
<if test="remark != null">remark,</if>
|
||||
<if test="createBy != null">create_by,</if>
|
||||
<if test="createTime != null">create_time,</if>
|
||||
<if test="updateBy != null">update_by,</if>
|
||||
@ -67,16 +55,11 @@
|
||||
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||
<if test="name != null">#{name},</if>
|
||||
<if test="type != null">#{type},</if>
|
||||
<if test="recEstimation != null">#{recEstimation},</if>
|
||||
<if test="recEstUnit != null">#{recEstUnit},</if>
|
||||
<if test="recPortion != null">#{recPortion},</if>
|
||||
<if test="proteinRatio != null">#{proteinRatio},</if>
|
||||
<if test="fatRatio != null">#{fatRatio},</if>
|
||||
<if test="carbonRatio != null">#{carbonRatio},</if>
|
||||
<if test="remark != null">#{remark},</if>
|
||||
<if test="area != null">#{area},</if>
|
||||
<if test="notRec != null">#{notRec},</if>
|
||||
<if test="recommend != null">#{recommend},</if>
|
||||
<if test="remark != null">#{remark},</if>
|
||||
<if test="createBy != null">#{createBy},</if>
|
||||
<if test="createTime != null">#{createTime},</if>
|
||||
<if test="updateBy != null">#{updateBy},</if>
|
||||
@ -84,21 +67,38 @@
|
||||
</trim>
|
||||
</insert>
|
||||
|
||||
<insert id="batchIngredientRec" >
|
||||
insert into sys_ingredient_rec(ingredient_id, rec_id) values
|
||||
<foreach collection="list" separator="," item="item" index="index">
|
||||
(#{item.ingredientId},#{item.recommandId})
|
||||
</foreach>
|
||||
</insert>
|
||||
|
||||
<insert id="batchIngredientNotRec" >
|
||||
insert into sys_ingredient_not_rec(ingredient_id, not_rec_id) values
|
||||
<foreach collection="list" separator="," item="item" index="index">
|
||||
(#{item.ingredientId},#{item.notRecommandId})
|
||||
</foreach>
|
||||
</insert>
|
||||
|
||||
<delete id="deleteIngredentRecByIngredientId" parameterType="Long">
|
||||
delete from sys_ingredient_rec where ingredient_id=#{ingredientId}
|
||||
</delete>
|
||||
|
||||
<delete id="deleteIngredentNotRecByIngredientId" parameterType="Long">
|
||||
delete from sys_ingredient_not_rec where ingredient_id=#{ingredientId}
|
||||
</delete>
|
||||
|
||||
<update id="updateSysIngredient" parameterType="SysIngredient">
|
||||
update sys_ingredient
|
||||
<trim prefix="SET" suffixOverrides=",">
|
||||
<if test="name != null">name = #{name},</if>
|
||||
<if test="type != null">type = #{type},</if>
|
||||
<if test="recEstimation != null">rec_estimation = #{recEstimation},</if>
|
||||
<if test="recEstUnit != null">rec_est_unit = #{recEstUnit},</if>
|
||||
<if test="recPortion != null">rec_portion = #{recPortion},</if>
|
||||
<if test="proteinRatio != null">protein_ratio = #{proteinRatio},</if>
|
||||
<if test="fatRatio != null">fat_ratio = #{fatRatio},</if>
|
||||
<if test="carbonRatio != null">carbon_ratio = #{carbonRatio},</if>
|
||||
<if test="remark != null">remark = #{remark},</if>
|
||||
<if test="area != null">area = #{area},</if>
|
||||
<if test="notRec != null">not_rec = #{notRec},</if>
|
||||
<if test="recommend != null">recommend = #{recommend},</if>
|
||||
<if test="remark != null">remark = #{remark},</if>
|
||||
<if test="createBy != null">create_by = #{createBy},</if>
|
||||
<if test="createTime != null">create_time = #{createTime},</if>
|
||||
<if test="updateBy != null">update_by = #{updateBy},</if>
|
||||
|
@ -44,28 +44,31 @@
|
||||
size="mini"
|
||||
@click="handleAdd"
|
||||
v-hasPermi="['custom:ingredient:add']"
|
||||
>新增</el-button>
|
||||
</el-col>
|
||||
<el-col :span="1.5">
|
||||
<el-button
|
||||
type="success"
|
||||
icon="el-icon-edit"
|
||||
size="mini"
|
||||
:disabled="single"
|
||||
@click="handleUpdate"
|
||||
v-hasPermi="['custom:ingredient:edit']"
|
||||
>修改</el-button>
|
||||
</el-col>
|
||||
<el-col :span="1.5">
|
||||
<el-button
|
||||
type="danger"
|
||||
icon="el-icon-delete"
|
||||
size="mini"
|
||||
:disabled="multiple"
|
||||
@click="handleDelete"
|
||||
v-hasPermi="['custom:ingredient:remove']"
|
||||
>删除</el-button>
|
||||
>新增
|
||||
</el-button>
|
||||
</el-col>
|
||||
<!-- <el-col :span="1.5">-->
|
||||
<!-- <el-button-->
|
||||
<!-- type="success"-->
|
||||
<!-- icon="el-icon-edit"-->
|
||||
<!-- size="mini"-->
|
||||
<!-- :disabled="single"-->
|
||||
<!-- @click="handleUpdate"-->
|
||||
<!-- v-hasPermi="['custom:ingredient:edit']"-->
|
||||
<!-- >修改-->
|
||||
<!-- </el-button>-->
|
||||
<!-- </el-col>-->
|
||||
<!-- <el-col :span="1.5">-->
|
||||
<!-- <el-button-->
|
||||
<!-- type="danger"-->
|
||||
<!-- icon="el-icon-delete"-->
|
||||
<!-- size="mini"-->
|
||||
<!-- :disabled="multiple"-->
|
||||
<!-- @click="handleDelete"-->
|
||||
<!-- v-hasPermi="['custom:ingredient:remove']"-->
|
||||
<!-- >删除-->
|
||||
<!-- </el-button>-->
|
||||
<!-- </el-col>-->
|
||||
<el-col :span="1.5">
|
||||
<el-button
|
||||
type="warning"
|
||||
@ -73,26 +76,24 @@
|
||||
size="mini"
|
||||
@click="handleExport"
|
||||
v-hasPermi="['custom:ingredient:export']"
|
||||
>导出</el-button>
|
||||
>导出
|
||||
</el-button>
|
||||
</el-col>
|
||||
<right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
|
||||
</el-row>
|
||||
|
||||
<el-table v-loading="loading" :data="ingredientList" @selection-change="handleSelectionChange">
|
||||
<el-table-column type="selection" width="55" align="center" />
|
||||
<el-table-column label="id" align="center" prop="id" />
|
||||
<el-table-column label="食材名称" align="center" prop="name" />
|
||||
<el-table-column label="食材类别" align="center" prop="type" :formatter="typeFormat" />
|
||||
<el-table-column label="推荐分量" align="center" prop="recEstimation" />
|
||||
<el-table-column label="推荐分量单位" align="center" prop="recEstUnit" :formatter="recEstUnitFormat" />
|
||||
<el-table-column label="推荐分量" align="center" prop="recPortion" />
|
||||
<el-table-column label="蛋白质比例" align="center" prop="proteinRatio" />
|
||||
<el-table-column label="脂肪比例" align="center" prop="fatRatio" />
|
||||
<el-table-column label="碳水比例" align="center" prop="carbonRatio" />
|
||||
<el-table-column label="地域" align="center" prop="area" :formatter="areaFormat" />
|
||||
<el-table-column label="忌口人群" align="center" prop="notRec" :formatter="notRecFormat" />
|
||||
<el-table-column label="推荐人群" align="center" prop="recommend" :formatter="recommendFormat" />
|
||||
<el-table-column label="备注" align="center" prop="remark" />
|
||||
<!-- <el-table-column type="selection" width="55" align="center" />-->
|
||||
<!-- <el-table-column label="id" align="center" prop="id" />-->
|
||||
<el-table-column label="食材名称" align="center" prop="name"/>
|
||||
<el-table-column label="食材类别" align="center" prop="type" :formatter="typeFormat"/>
|
||||
<el-table-column label="蛋白质比例(100g)" align="center" prop="proteinRatio"/>
|
||||
<el-table-column label="脂肪比例(100g)" align="center" prop="fatRatio"/>
|
||||
<el-table-column label="碳水比例(100g)" align="center" prop="carbonRatio"/>
|
||||
<el-table-column label="地域" align="center" prop="area" :formatter="areaFormat"/>
|
||||
<el-table-column label="忌口人群" align="center" prop="notRecIds" :formatter="notRecFormat"/>
|
||||
<el-table-column label="推荐人群" align="center" prop="recIds" :formatter="recommendFormat"/>
|
||||
<el-table-column label="备注" align="center" prop="remark"/>
|
||||
<el-table-column label="操作" align="center" class-name="small-padding fixed-width">
|
||||
<template slot-scope="scope">
|
||||
<el-button
|
||||
@ -101,14 +102,16 @@
|
||||
icon="el-icon-edit"
|
||||
@click="handleUpdate(scope.row)"
|
||||
v-hasPermi="['custom:ingredient:edit']"
|
||||
>修改</el-button>
|
||||
>修改
|
||||
</el-button>
|
||||
<el-button
|
||||
size="mini"
|
||||
type="text"
|
||||
icon="el-icon-delete"
|
||||
@click="handleDelete(scope.row)"
|
||||
v-hasPermi="['custom:ingredient:remove']"
|
||||
>删除</el-button>
|
||||
>删除
|
||||
</el-button>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
@ -122,80 +125,87 @@
|
||||
/>
|
||||
|
||||
<!-- 添加或修改食材对话框 -->
|
||||
<el-dialog :title="title" :visible.sync="open" width="500px" append-to-body>
|
||||
<el-form ref="form" :model="form" :rules="rules" label-width="80px">
|
||||
<el-form-item label="食材名称" prop="name">
|
||||
<el-input v-model="form.name" placeholder="请输入食材名称" />
|
||||
</el-form-item>
|
||||
<el-form-item label="食材类别" prop="type">
|
||||
<el-select v-model="form.type" placeholder="请选择食材类别">
|
||||
<el-option
|
||||
v-for="dict in typeOptions"
|
||||
:key="dict.dictValue"
|
||||
:label="dict.dictLabel"
|
||||
:value="dict.dictValue"
|
||||
></el-option>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="推荐分量" prop="recEstimation">
|
||||
<el-input v-model="form.recEstimation" placeholder="请输入推荐分量" />
|
||||
</el-form-item>
|
||||
<el-form-item label="推荐分量单位" prop="recEstUnit">
|
||||
<el-select v-model="form.recEstUnit" placeholder="请选择推荐分量单位">
|
||||
<el-option
|
||||
v-for="dict in recEstUnitOptions"
|
||||
:key="dict.dictValue"
|
||||
:label="dict.dictLabel"
|
||||
:value="parseInt(dict.dictValue)"
|
||||
></el-option>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="推荐分量" prop="recPortion">
|
||||
<el-input v-model="form.recPortion" placeholder="请输入推荐分量" />
|
||||
</el-form-item>
|
||||
<el-form-item label="蛋白质比例" prop="proteinRatio">
|
||||
<el-input v-model="form.proteinRatio" placeholder="请输入蛋白质比例" />
|
||||
</el-form-item>
|
||||
<el-form-item label="脂肪比例" prop="fatRatio">
|
||||
<el-input v-model="form.fatRatio" placeholder="请输入脂肪比例" />
|
||||
</el-form-item>
|
||||
<el-form-item label="碳水比例" prop="carbonRatio">
|
||||
<el-input v-model="form.carbonRatio" placeholder="请输入碳水比例" />
|
||||
</el-form-item>
|
||||
<el-form-item label="地域" prop="area">
|
||||
<el-select v-model="form.area" placeholder="请选择地域">
|
||||
<el-option
|
||||
v-for="dict in areaOptions"
|
||||
:key="dict.dictValue"
|
||||
:label="dict.dictLabel"
|
||||
:value="dict.dictValue"
|
||||
></el-option>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="忌口人群">
|
||||
<el-checkbox-group v-model="form.notRec">
|
||||
<el-checkbox
|
||||
v-for="dict in notRecOptions"
|
||||
:key="dict.dictValue"
|
||||
:label="dict.dictValue">
|
||||
{{dict.dictLabel}}
|
||||
</el-checkbox>
|
||||
</el-checkbox-group>
|
||||
</el-form-item>
|
||||
<el-form-item label="推荐人群">
|
||||
<el-checkbox-group v-model="form.recommend">
|
||||
<el-checkbox
|
||||
v-for="dict in recommendOptions"
|
||||
:key="dict.dictValue"
|
||||
:label="dict.dictValue">
|
||||
{{dict.dictLabel}}
|
||||
</el-checkbox>
|
||||
</el-checkbox-group>
|
||||
</el-form-item>
|
||||
<el-form-item label="备注" prop="remark">
|
||||
<el-input v-model="form.remark" type="textarea" placeholder="请输入内容" />
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
<el-dialog :title="title" :visible.sync="open" width="620px" append-to-body>
|
||||
<el-row :gutter="15">
|
||||
<el-form ref="form" :model="form" :rules="rules" label-width="80px">
|
||||
<el-col :span="12">
|
||||
<el-form-item label="食材名称" prop="name" label-width="90px">
|
||||
<el-input v-model="form.name" placeholder="请输入食材名称"/>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="12">
|
||||
<el-form-item label="蛋白质比例" prop="proteinRatio" label-width="90px">
|
||||
<el-input v-model="form.proteinRatio" placeholder="请输入蛋白质比例" style="width: 150px"/>
|
||||
/100g
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="12">
|
||||
<el-form-item label="脂肪比例" prop="fatRatio" label-width="90px">
|
||||
<el-input v-model="form.fatRatio" placeholder="请输入脂肪比例" style="width: 150px"/>
|
||||
/100g
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="12">
|
||||
<el-form-item label="碳水比例" prop="carbonRatio" label-width="90px">
|
||||
<el-input v-model="form.carbonRatio" placeholder="请输入碳水比例" style="width: 150px"/>
|
||||
/100g
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="12">
|
||||
<el-form-item label="食材类别" prop="type" label-width="90px">
|
||||
<el-select v-model="form.type" placeholder="请选择食材类别">
|
||||
<el-option
|
||||
v-for="dict in typeOptions"
|
||||
:key="dict.dictValue"
|
||||
:label="dict.dictLabel"
|
||||
:value="dict.dictValue"
|
||||
></el-option>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="12">
|
||||
<el-form-item label="地域" prop="area" label-width="90px">
|
||||
<el-select v-model="form.area" placeholder="请选择地域">
|
||||
<el-option
|
||||
v-for="dict in areaOptions"
|
||||
:key="dict.dictValue"
|
||||
:label="dict.dictLabel"
|
||||
:value="dict.dictValue"
|
||||
></el-option>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="24">
|
||||
<el-form-item label="忌口人群" label-width="90px">
|
||||
<el-checkbox-group v-model="form.notRecIds">
|
||||
<el-checkbox
|
||||
v-for="dict in notRecOptions"
|
||||
:key="dict.dictValue"
|
||||
:label="dict.dictValue">
|
||||
{{dict.dictLabel}}
|
||||
</el-checkbox>
|
||||
</el-checkbox-group>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="24">
|
||||
<el-form-item label="推荐人群" label-width="90px">
|
||||
<el-checkbox-group v-model="form.recIds">
|
||||
<el-checkbox
|
||||
v-for="dict in recommendOptions"
|
||||
:key="dict.dictValue"
|
||||
:label="dict.dictValue">
|
||||
{{dict.dictLabel}}
|
||||
</el-checkbox>
|
||||
</el-checkbox-group>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="24">
|
||||
<el-form-item label="备注" prop="remark" label-width="90px">
|
||||
<el-input v-model="form.remark" type="textarea" placeholder="请输入内容"/>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
</el-form>
|
||||
</el-row>
|
||||
<div slot="footer" class="dialog-footer">
|
||||
<el-button type="primary" @click="submitForm">确 定</el-button>
|
||||
<el-button @click="cancel">取 消</el-button>
|
||||
@ -205,7 +215,14 @@
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { listIngredient, getIngredient, delIngredient, addIngredient, updateIngredient, exportIngredient } from "@/api/custom/ingredient";
|
||||
import {
|
||||
addIngredient,
|
||||
delIngredient,
|
||||
exportIngredient,
|
||||
getIngredient,
|
||||
listIngredient,
|
||||
updateIngredient
|
||||
} from "@/api/custom/ingredient";
|
||||
|
||||
export default {
|
||||
name: "Ingredient",
|
||||
@ -231,8 +248,6 @@
|
||||
open: false,
|
||||
// 食材类别字典
|
||||
typeOptions: [],
|
||||
// 推荐分量单位字典
|
||||
recEstUnitOptions: [],
|
||||
// 地域字典
|
||||
areaOptions: [],
|
||||
// 忌口人群字典
|
||||
@ -246,14 +261,13 @@
|
||||
name: null,
|
||||
type: null,
|
||||
area: null,
|
||||
notRec: null,
|
||||
recommend: null,
|
||||
notRecIds: null,
|
||||
recIds: null,
|
||||
},
|
||||
// 表单参数
|
||||
form: {},
|
||||
// 表单校验
|
||||
rules: {
|
||||
}
|
||||
rules: {}
|
||||
};
|
||||
},
|
||||
created() {
|
||||
@ -261,9 +275,6 @@
|
||||
this.getDicts("cus_ing_type").then(response => {
|
||||
this.typeOptions = response.data;
|
||||
});
|
||||
this.getDicts("cus_cus_unit").then(response => {
|
||||
this.recEstUnitOptions = response.data;
|
||||
});
|
||||
this.getDicts("cus_area").then(response => {
|
||||
this.areaOptions = response.data;
|
||||
});
|
||||
@ -288,21 +299,17 @@
|
||||
typeFormat(row, column) {
|
||||
return this.selectDictLabel(this.typeOptions, row.type);
|
||||
},
|
||||
// 推荐分量单位字典翻译
|
||||
recEstUnitFormat(row, column) {
|
||||
return this.selectDictLabel(this.recEstUnitOptions, row.recEstUnit);
|
||||
},
|
||||
// 地域字典翻译
|
||||
areaFormat(row, column) {
|
||||
return this.selectDictLabel(this.areaOptions, row.area);
|
||||
},
|
||||
// 忌口人群字典翻译
|
||||
notRecFormat(row, column) {
|
||||
return this.selectDictLabels(this.notRecOptions, row.notRec);
|
||||
return this.selectDictLabels(this.notRecOptions, row.notRecIds.join(','));
|
||||
},
|
||||
// 推荐人群字典翻译
|
||||
recommendFormat(row, column) {
|
||||
return this.selectDictLabels(this.recommendOptions, row.recommend);
|
||||
return this.selectDictLabels(this.recommendOptions, row.recIds.join(','));
|
||||
},
|
||||
// 取消按钮
|
||||
cancel() {
|
||||
@ -315,15 +322,12 @@
|
||||
id: null,
|
||||
name: null,
|
||||
type: null,
|
||||
recEstimation: null,
|
||||
recEstUnit: null,
|
||||
recPortion: null,
|
||||
proteinRatio: null,
|
||||
fatRatio: null,
|
||||
carbonRatio: null,
|
||||
area: null,
|
||||
notRec: [],
|
||||
recommend: [],
|
||||
notRecIds: [],
|
||||
recIds: [],
|
||||
remark: null,
|
||||
createBy: null,
|
||||
createTime: null,
|
||||
@ -345,7 +349,7 @@
|
||||
// 多选框选中数据
|
||||
handleSelectionChange(selection) {
|
||||
this.ids = selection.map(item => item.id)
|
||||
this.single = selection.length!==1
|
||||
this.single = selection.length !== 1
|
||||
this.multiple = !selection.length
|
||||
},
|
||||
/** 新增按钮操作 */
|
||||
@ -360,8 +364,8 @@
|
||||
const id = row.id || this.ids
|
||||
getIngredient(id).then(response => {
|
||||
this.form = response.data;
|
||||
this.form.notRec = this.form.notRec.split(",");
|
||||
this.form.recommend = this.form.recommend.split(",");
|
||||
// this.form.notRecIds = this.form.notRecIds.split(",");
|
||||
// this.form.recIds = this.form.recIds.split(",");
|
||||
this.open = true;
|
||||
this.title = "修改食材";
|
||||
});
|
||||
@ -370,8 +374,8 @@
|
||||
submitForm() {
|
||||
this.$refs["form"].validate(valid => {
|
||||
if (valid) {
|
||||
this.form.notRec = this.form.notRec.join(",");
|
||||
this.form.recommend = this.form.recommend.join(",");
|
||||
// this.form.notRecIds = this.form.notRecIds.join(",");
|
||||
// this.form.recIds = this.form.recIds.join(",");
|
||||
if (this.form.id != null) {
|
||||
updateIngredient(this.form).then(response => {
|
||||
if (response.code === 200) {
|
||||
@ -399,12 +403,13 @@
|
||||
confirmButtonText: "确定",
|
||||
cancelButtonText: "取消",
|
||||
type: "warning"
|
||||
}).then(function() {
|
||||
}).then(function () {
|
||||
return delIngredient(ids);
|
||||
}).then(() => {
|
||||
this.getList();
|
||||
this.msgSuccess("删除成功");
|
||||
}).catch(function() {});
|
||||
}).catch(function () {
|
||||
});
|
||||
},
|
||||
/** 导出按钮操作 */
|
||||
handleExport() {
|
||||
@ -413,11 +418,12 @@
|
||||
confirmButtonText: "确定",
|
||||
cancelButtonText: "取消",
|
||||
type: "warning"
|
||||
}).then(function() {
|
||||
}).then(function () {
|
||||
return exportIngredient(queryParams);
|
||||
}).then(response => {
|
||||
this.download(response.msg);
|
||||
}).catch(function() {});
|
||||
}).catch(function () {
|
||||
});
|
||||
}
|
||||
}
|
||||
};
|
||||
|
Loading…
x
Reference in New Issue
Block a user