生成食谱接口对接
This commit is contained in:
@ -4,7 +4,8 @@ import com.stdiet.common.annotation.Log;
|
|||||||
import com.stdiet.common.core.controller.BaseController;
|
import com.stdiet.common.core.controller.BaseController;
|
||||||
import com.stdiet.common.core.domain.AjaxResult;
|
import com.stdiet.common.core.domain.AjaxResult;
|
||||||
import com.stdiet.common.enums.BusinessType;
|
import com.stdiet.common.enums.BusinessType;
|
||||||
import com.stdiet.custom.domain.SysDishes;
|
import com.stdiet.custom.domain.SysRecipes;
|
||||||
|
import com.stdiet.custom.domain.SysRecipesDailyDishes;
|
||||||
import com.stdiet.custom.service.ISysRecipesService;
|
import com.stdiet.custom.service.ISysRecipesService;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
@ -16,36 +17,66 @@ public class SysRecipesController extends BaseController {
|
|||||||
@Autowired
|
@Autowired
|
||||||
private ISysRecipesService sysRecipesService;
|
private ISysRecipesService sysRecipesService;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取食谱详情
|
||||||
|
*
|
||||||
|
* @param resipesId
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
@GetMapping(value = "/{resipesId}")
|
@GetMapping(value = "/{resipesId}")
|
||||||
public AjaxResult getInfo(@PathVariable("resipesId") Long resipesId) {
|
public AjaxResult getInfo(@PathVariable("resipesId") Long resipesId) {
|
||||||
return AjaxResult.success(sysRecipesService.selectSysRecipesByRecipesId(resipesId));
|
return AjaxResult.success(sysRecipesService.selectSysRecipesByRecipesId(resipesId));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 修改食谱菜品
|
|
||||||
*
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
@Log(title = "食谱", businessType = BusinessType.UPDATE)
|
|
||||||
@PutMapping
|
|
||||||
public AjaxResult edit(@RequestBody SysDishes sysDishes) {
|
|
||||||
return toAjax(sysRecipesService.updateDishesDetail(sysDishes));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Log(title = "食谱", businessType = BusinessType.INSERT)
|
@Log(title = "食谱", businessType = BusinessType.INSERT)
|
||||||
@PostMapping
|
@PostMapping
|
||||||
public AjaxResult add(@RequestBody SysDishes sysDishes) {
|
public AjaxResult addRecipes(@RequestBody SysRecipes sysRecipes) {
|
||||||
int rows = sysRecipesService.insertDishes(sysDishes);
|
int rows = sysRecipesService.addRecipes(sysRecipes);
|
||||||
if (rows > 0) {
|
if (rows > 0) {
|
||||||
return AjaxResult.success(sysDishes.getId());
|
return AjaxResult.success(sysRecipes.getId());
|
||||||
} else {
|
} else {
|
||||||
return AjaxResult.error();
|
return AjaxResult.error();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Log(title = "销售订单", businessType = BusinessType.DELETE)
|
/**
|
||||||
@DeleteMapping("/dishes/{cId}")
|
* 修改食谱菜品
|
||||||
public AjaxResult delete(@PathVariable Long cId) {
|
*
|
||||||
return toAjax(sysRecipesService.deleteDishes(cId));
|
* @param sysRecipesDailyDishes
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@Log(title = "食谱菜品", businessType = BusinessType.UPDATE)
|
||||||
|
@PutMapping(value = "/dishes")
|
||||||
|
public AjaxResult edit(@RequestBody SysRecipesDailyDishes sysRecipesDailyDishes) {
|
||||||
|
return toAjax(sysRecipesService.updateDishesDetail(sysRecipesDailyDishes));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 添加菜品
|
||||||
|
*
|
||||||
|
* @param sysRecipesDailyDishes
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@Log(title = "食谱菜品", businessType = BusinessType.INSERT)
|
||||||
|
@PostMapping(value = "/dishes")
|
||||||
|
public AjaxResult add(@RequestBody SysRecipesDailyDishes sysRecipesDailyDishes) {
|
||||||
|
int rows = sysRecipesService.addDishes(sysRecipesDailyDishes);
|
||||||
|
if (rows > 0) {
|
||||||
|
return AjaxResult.success(sysRecipesDailyDishes.getId());
|
||||||
|
} else {
|
||||||
|
return AjaxResult.error();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除菜品
|
||||||
|
*
|
||||||
|
* @param id
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@Log(title = "食谱菜品", businessType = BusinessType.DELETE)
|
||||||
|
@DeleteMapping("/dishes/{id}")
|
||||||
|
public AjaxResult delete(@PathVariable Long id) {
|
||||||
|
return toAjax(sysRecipesService.deleteDishes(id));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -23,10 +23,6 @@ public class SysDishes {
|
|||||||
*/
|
*/
|
||||||
private Long id;
|
private Long id;
|
||||||
|
|
||||||
private Long cId;
|
|
||||||
|
|
||||||
private Long menuId;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 菜品名称
|
* 菜品名称
|
||||||
*/
|
*/
|
||||||
@ -79,6 +75,4 @@ public class SysDishes {
|
|||||||
|
|
||||||
private List<SysDishesIngredient> igdList;
|
private List<SysDishesIngredient> igdList;
|
||||||
|
|
||||||
private JSONArray detail;
|
|
||||||
|
|
||||||
}
|
}
|
@ -1,47 +1,17 @@
|
|||||||
package com.stdiet.custom.domain;
|
package com.stdiet.custom.domain;
|
||||||
|
|
||||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
|
||||||
import java.util.Date;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@Data
|
@Data
|
||||||
public class SysRecipes {
|
public class SysRecipes {
|
||||||
private static final long serialVersionUID = 1L;
|
|
||||||
|
|
||||||
private Long id;
|
private Long id;
|
||||||
|
|
||||||
private Integer numDay;
|
private Long cusId;
|
||||||
|
|
||||||
private List<SysDishes> dishes;
|
private Long planId;
|
||||||
|
|
||||||
private Integer reviewStatus;
|
private List<SysRecipesDaily> menus;
|
||||||
|
|
||||||
/**
|
|
||||||
* 创建者
|
|
||||||
*/
|
|
||||||
private String createBy;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 创建时间
|
|
||||||
*/
|
|
||||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
|
||||||
private Date createTime;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 更新者
|
|
||||||
*/
|
|
||||||
private String updateBy;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 更新时间
|
|
||||||
*/
|
|
||||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
|
||||||
private Date updateTime;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 备注
|
|
||||||
*/
|
|
||||||
private String remark;
|
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,34 @@
|
|||||||
|
package com.stdiet.custom.domain;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.util.Date;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class SysRecipesDaily {
|
||||||
|
private Long id;
|
||||||
|
|
||||||
|
private Integer numDay;
|
||||||
|
|
||||||
|
private Date date;
|
||||||
|
|
||||||
|
private Long recipesId;
|
||||||
|
|
||||||
|
private Long cusId;
|
||||||
|
|
||||||
|
private Integer reviewStatus;
|
||||||
|
|
||||||
|
private Date createTime;
|
||||||
|
|
||||||
|
private String createBy;
|
||||||
|
|
||||||
|
private Date updateTime;
|
||||||
|
|
||||||
|
private String updateBy;
|
||||||
|
|
||||||
|
private String remark;
|
||||||
|
|
||||||
|
private List<SysRecipesDailyDishes> dishes;
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,28 @@
|
|||||||
|
package com.stdiet.custom.domain;
|
||||||
|
|
||||||
|
import com.alibaba.fastjson.JSONArray;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.util.Date;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class SysRecipesDailyDishes {
|
||||||
|
private Long id;
|
||||||
|
|
||||||
|
private Long menuId;
|
||||||
|
|
||||||
|
private String name;
|
||||||
|
|
||||||
|
private Long dishesId;
|
||||||
|
|
||||||
|
private JSONArray detail;
|
||||||
|
|
||||||
|
private String methods;
|
||||||
|
|
||||||
|
private List<SysDishesIngredient> igdList;
|
||||||
|
|
||||||
|
private String type;
|
||||||
|
|
||||||
|
private Integer isMain;
|
||||||
|
}
|
@ -1,17 +1,28 @@
|
|||||||
package com.stdiet.custom.mapper;
|
package com.stdiet.custom.mapper;
|
||||||
|
|
||||||
import com.stdiet.custom.domain.SysDishes;
|
|
||||||
import com.stdiet.custom.domain.SysRecipes;
|
import com.stdiet.custom.domain.SysRecipes;
|
||||||
|
import com.stdiet.custom.domain.SysRecipesDaily;
|
||||||
|
import com.stdiet.custom.domain.SysRecipesDailyDishes;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public interface SysRecipesMapper {
|
public interface SysRecipesMapper {
|
||||||
|
|
||||||
|
|
||||||
|
public int addRecipes(SysRecipes sysRecipes);
|
||||||
|
|
||||||
|
public int bashAddDishes(List<SysRecipesDailyDishes> dishes);
|
||||||
|
|
||||||
|
public int bashAddMenus(List<SysRecipesDaily> menus);
|
||||||
|
|
||||||
|
|
||||||
|
public int getNumDayByCusId(Long id);
|
||||||
|
|
||||||
public List<SysRecipes> selectSysRecipesByRecipesId(Long id);
|
public List<SysRecipes> selectSysRecipesByRecipesId(Long id);
|
||||||
|
|
||||||
public int updateDishesDetail(SysDishes sysDishes);
|
public int updateDishesDetail(SysRecipesDailyDishes sysRecipesDaily);
|
||||||
|
|
||||||
public int insertDishes(SysDishes sysDishes);
|
public int addDishes(SysRecipesDailyDishes sysRecipesDaily);
|
||||||
|
|
||||||
public int deleteDishes(Long cId);
|
public int deleteDishes(Long id);
|
||||||
}
|
}
|
||||||
|
@ -1,16 +1,20 @@
|
|||||||
package com.stdiet.custom.service;
|
package com.stdiet.custom.service;
|
||||||
|
|
||||||
import com.stdiet.custom.domain.SysDishes;
|
|
||||||
import com.stdiet.custom.domain.SysRecipes;
|
import com.stdiet.custom.domain.SysRecipes;
|
||||||
|
import com.stdiet.custom.domain.SysRecipesDaily;
|
||||||
|
import com.stdiet.custom.domain.SysRecipesDailyDishes;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public interface ISysRecipesService {
|
public interface ISysRecipesService {
|
||||||
|
|
||||||
|
public int addRecipes(SysRecipes sysRecipes);
|
||||||
|
|
||||||
public List<SysRecipes> selectSysRecipesByRecipesId(Long id);
|
public List<SysRecipes> selectSysRecipesByRecipesId(Long id);
|
||||||
|
|
||||||
public int updateDishesDetail(SysDishes sysDishes);
|
public int updateDishesDetail(SysRecipesDailyDishes sysRecipesDaily);
|
||||||
|
|
||||||
public int insertDishes(SysDishes sysDishes);
|
public int addDishes(SysRecipesDailyDishes sysRecipesDaily);
|
||||||
|
|
||||||
public int deleteDishes(Long cId);
|
public int deleteDishes(Long id);
|
||||||
}
|
}
|
||||||
|
@ -1,13 +1,18 @@
|
|||||||
package com.stdiet.custom.service.impl;
|
package com.stdiet.custom.service.impl;
|
||||||
|
|
||||||
import com.stdiet.custom.domain.SysDishes;
|
|
||||||
import com.stdiet.custom.domain.SysRecipes;
|
import com.stdiet.custom.domain.SysRecipes;
|
||||||
|
import com.stdiet.custom.domain.SysRecipesDaily;
|
||||||
|
import com.stdiet.custom.domain.SysRecipesDailyDishes;
|
||||||
|
import com.stdiet.custom.domain.SysRecipesPlan;
|
||||||
import com.stdiet.custom.mapper.SysRecipesMapper;
|
import com.stdiet.custom.mapper.SysRecipesMapper;
|
||||||
|
import com.stdiet.custom.mapper.SysRecipesPlanMapper;
|
||||||
import com.stdiet.custom.service.ISysRecipesService;
|
import com.stdiet.custom.service.ISysRecipesService;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Date;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@Service
|
@Service
|
||||||
@ -17,23 +22,64 @@ public class SysRecipesServiceImpl implements ISysRecipesService {
|
|||||||
@Autowired
|
@Autowired
|
||||||
private SysRecipesMapper sysRecipesMapper;
|
private SysRecipesMapper sysRecipesMapper;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private SysRecipesPlanMapper sysRecipesPlanMapper;
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int addRecipes(SysRecipes sysRecipes) {
|
||||||
|
int rows = sysRecipesMapper.addRecipes(sysRecipes);
|
||||||
|
if (rows > 0) {
|
||||||
|
int count = sysRecipesMapper.getNumDayByCusId(sysRecipes.getCusId());
|
||||||
|
List<SysRecipesDaily> menus = sysRecipes.getMenus();
|
||||||
|
List<SysRecipesDailyDishes> dishes = new ArrayList<>();
|
||||||
|
int size = menus.size();
|
||||||
|
for (int i = 0; i < size; i++) {
|
||||||
|
SysRecipesDaily tarMenu = menus.get(i);
|
||||||
|
// 计算menuId
|
||||||
|
long dailyId = sysRecipes.getId() + new Date().getTime() + i;
|
||||||
|
tarMenu.setId(dailyId);
|
||||||
|
// 插入recipiesId
|
||||||
|
tarMenu.setRecipesId(sysRecipes.getId());
|
||||||
|
// 插入numDay
|
||||||
|
tarMenu.setNumDay(count + i + 1);
|
||||||
|
for (SysRecipesDailyDishes tmpDishes : tarMenu.getDishes()) {
|
||||||
|
// 让菜品插入menuId
|
||||||
|
tmpDishes.setMenuId(dailyId);
|
||||||
|
dishes.add(tmpDishes);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// 插入每天食谱
|
||||||
|
sysRecipesMapper.bashAddMenus(menus);
|
||||||
|
// 插入每天菜品
|
||||||
|
sysRecipesMapper.bashAddDishes(dishes);
|
||||||
|
// 更新食谱计划
|
||||||
|
SysRecipesPlan sysRecipesPlan = new SysRecipesPlan();
|
||||||
|
sysRecipesPlan.setId(sysRecipes.getPlanId());
|
||||||
|
sysRecipesPlan.setRecipesId(sysRecipes.getId());
|
||||||
|
sysRecipesPlanMapper.updateSysRecipesPlan(sysRecipesPlan);
|
||||||
|
}
|
||||||
|
|
||||||
|
return rows;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<SysRecipes> selectSysRecipesByRecipesId(Long id) {
|
public List<SysRecipes> selectSysRecipesByRecipesId(Long id) {
|
||||||
return sysRecipesMapper.selectSysRecipesByRecipesId(id);
|
return sysRecipesMapper.selectSysRecipesByRecipesId(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int updateDishesDetail(SysDishes sysDishes) {
|
public int updateDishesDetail(SysRecipesDailyDishes sysRecipesDailyDishes) {
|
||||||
return sysRecipesMapper.updateDishesDetail(sysDishes);
|
return sysRecipesMapper.updateDishesDetail(sysRecipesDailyDishes);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int insertDishes(SysDishes sysDishes) {
|
public int addDishes(SysRecipesDailyDishes sysRecipesDailyDishes) {
|
||||||
return sysRecipesMapper.insertDishes(sysDishes);
|
return sysRecipesMapper.addDishes(sysRecipesDailyDishes);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int deleteDishes(Long cId) {
|
public int deleteDishes(Long id) {
|
||||||
return sysRecipesMapper.deleteDishes(cId);
|
return sysRecipesMapper.deleteDishes(id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||||
<mapper namespace="com.stdiet.custom.mapper.SysRecipesMapper">
|
<mapper namespace="com.stdiet.custom.mapper.SysRecipesMapper">
|
||||||
|
|
||||||
<resultMap type="SysRecipes" id="SysRecipesResult">
|
<resultMap type="SysRecipesDaily" id="SysRecipesResult">
|
||||||
<result property="id" column="id"/>
|
<result property="id" column="id"/>
|
||||||
<result property="numDay" column="num_day"/>
|
<result property="numDay" column="num_day"/>
|
||||||
<result property="updateBy" column="update_by"/>
|
<result property="updateBy" column="update_by"/>
|
||||||
@ -15,9 +15,10 @@
|
|||||||
<association property="dishes" column="id" select="selectDishesByMenuId"/>
|
<association property="dishes" column="id" select="selectDishesByMenuId"/>
|
||||||
</resultMap>
|
</resultMap>
|
||||||
|
|
||||||
<resultMap id="SysDishesResult" type="SysDishes">
|
<resultMap id="SysDishesResult" type="SysRecipesDailyDishes">
|
||||||
<result property="id" column="dishes_id"/>
|
<result property="dishesId" column="dishes_id"/>
|
||||||
<result property="cId" column="id" />
|
<result property="menuId" column="menu_id"/>
|
||||||
|
<result property="id" column="id" />
|
||||||
<result property="name" column="name"/>
|
<result property="name" column="name"/>
|
||||||
<result property="type" column="type"/>
|
<result property="type" column="type"/>
|
||||||
<result property="methods" column="methods"/>
|
<result property="methods" column="methods"/>
|
||||||
@ -78,26 +79,26 @@
|
|||||||
</select>
|
</select>
|
||||||
|
|
||||||
<!-- 更新菜品-->
|
<!-- 更新菜品-->
|
||||||
<update id="updateDishesDetail" parameterType="SysDishes">
|
<update id="updateDishesDetail" parameterType="SysRecipesDailyDishes">
|
||||||
update sys_customer_menu_dishes
|
update sys_customer_menu_dishes
|
||||||
<trim prefix="SET" suffixOverrides=",">
|
<trim prefix="SET" suffixOverrides=",">
|
||||||
<if test="detail != null">detail = #{detail, jdbcType=OTHER, typeHandler=com.stdiet.custom.typehandler.ArrayJsonHandler},</if>
|
<if test="detail != null">detail = #{detail, jdbcType=OTHER, typeHandler=com.stdiet.custom.typehandler.ArrayJsonHandler},</if>
|
||||||
</trim>
|
</trim>
|
||||||
where id = #{cId}
|
where id = #{id}
|
||||||
</update>
|
</update>
|
||||||
|
|
||||||
<!-- 插入菜品-->
|
<!-- 插入菜品-->
|
||||||
<insert id="insertDishes" parameterType="SysDishes" useGeneratedKeys="true" keyProperty="id">
|
<insert id="addDishes" parameterType="SysRecipesDailyDishes" useGeneratedKeys="true" keyProperty="id">
|
||||||
insert into sys_customer_menu_dishes
|
insert into sys_customer_menu_dishes
|
||||||
<trim prefix="(" suffix=")" suffixOverrides=",">
|
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||||
<if test="menuId != null">menu_id,</if>
|
<if test="menuId != null">menu_id,</if>
|
||||||
<if test="id != null">dishes_id,</if>
|
<if test="dishesId != null">dishes_id,</if>
|
||||||
<if test="type != null">type,</if>
|
<if test="type != null">type,</if>
|
||||||
<if test="detail != null">detail,</if>
|
<if test="detail != null">detail,</if>
|
||||||
</trim>
|
</trim>
|
||||||
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||||
<if test="menuId != null">#{menuId},</if>
|
<if test="menuId != null">#{menuId},</if>
|
||||||
<if test="id != null">#{id},</if>
|
<if test="dishesId != null">#{dishesId},</if>
|
||||||
<if test="type != null">#{type},</if>
|
<if test="type != null">#{type},</if>
|
||||||
<if test="detail != null">#{detail, jdbcType=OTHER, typeHandler=com.stdiet.custom.typehandler.ArrayJsonHandler},</if>
|
<if test="detail != null">#{detail, jdbcType=OTHER, typeHandler=com.stdiet.custom.typehandler.ArrayJsonHandler},</if>
|
||||||
</trim>
|
</trim>
|
||||||
@ -105,7 +106,39 @@
|
|||||||
|
|
||||||
<!-- 删除菜品-->
|
<!-- 删除菜品-->
|
||||||
<delete id="deleteDishes" parameterType="Long">
|
<delete id="deleteDishes" parameterType="Long">
|
||||||
delete from sys_customer_menu_dishes where id = #{cId}
|
delete from sys_customer_menu_dishes where id = #{id}
|
||||||
</delete>
|
</delete>
|
||||||
|
|
||||||
|
<!-- 查询已有食谱天数-->
|
||||||
|
<select id="getNumDayByCusId" parameterType="Long" resultType="Integer">
|
||||||
|
select count(*) from sys_customer_daily_menu where cus_id = #{id}
|
||||||
|
</select>
|
||||||
|
|
||||||
|
<!-- 新增食谱 -->
|
||||||
|
<insert id="addRecipes" parameterType="SysRecipes" useGeneratedKeys="true" keyProperty="id">
|
||||||
|
insert into sys_customer_menu
|
||||||
|
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||||
|
<if test="cusId != null">cus_id,</if>
|
||||||
|
</trim>
|
||||||
|
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||||
|
<if test="cusId != null">#{cusId},</if>
|
||||||
|
</trim>
|
||||||
|
</insert>
|
||||||
|
|
||||||
|
<!-- 新增每菜单 -->
|
||||||
|
<insert id="bashAddMenus">
|
||||||
|
insert into sys_customer_daily_menu (id, num_day, date, recipes_id, cus_id) values
|
||||||
|
<foreach collection="list" separator="," item="item" index="index">
|
||||||
|
(#{item.id}, #{item.numDay}, #{item.date}, #{item.recipesId}, #{item.cusId})
|
||||||
|
</foreach>
|
||||||
|
</insert>
|
||||||
|
|
||||||
|
<!-- 新增菜单对应菜品-->
|
||||||
|
<insert id="bashAddDishes" >
|
||||||
|
insert into sys_customer_menu_dishes (menu_id, type, dishes_id, detail) values
|
||||||
|
<foreach collection="list" separator="," item="item" index="index">
|
||||||
|
(#{item.menuId}, #{item.type}, #{item.dishesId}, #{item.detail, jdbcType=OTHER, typeHandler=com.stdiet.custom.typehandler.ArrayJsonHandler})
|
||||||
|
</foreach>
|
||||||
|
</insert>
|
||||||
|
|
||||||
</mapper>
|
</mapper>
|
@ -126,7 +126,7 @@
|
|||||||
|
|
||||||
<!-- 食谱计划、订单表联查 -->
|
<!-- 食谱计划、订单表联查 -->
|
||||||
<select id="selectPlanListByCondition" parameterType="SysRecipesPlan" resultMap="SysRecipesPlanResult">
|
<select id="selectPlanListByCondition" parameterType="SysRecipesPlan" resultMap="SysRecipesPlanResult">
|
||||||
SELECT srp.id,srp.order_id,sr.customer,sr.phone,su_nutritionist.nick_name nutritionist,su_nutritionist_assis.nick_name AS nutritionist_assis,sr.start_time,sr.server_end_time, srp.start_date,srp.end_date,srp.send_flag,srp.send_time
|
SELECT srp.id,srp.order_id,srp.recipes_id, sr.customer,sr.phone,su_nutritionist.nick_name nutritionist,su_nutritionist_assis.nick_name AS nutritionist_assis,sr.start_time,sr.server_end_time, srp.start_date,srp.end_date,srp.send_flag,srp.send_time
|
||||||
FROM sys_recipes_plan srp
|
FROM sys_recipes_plan srp
|
||||||
LEFT JOIN sys_order sr ON sr.order_id = srp.order_id
|
LEFT JOIN sys_order sr ON sr.order_id = srp.order_id
|
||||||
LEFT JOIN sys_user su_nutritionist ON su_nutritionist.user_id = sr.nutritionist_id AND su_nutritionist.del_flag = 0
|
LEFT JOIN sys_user su_nutritionist ON su_nutritionist.user_id = sr.nutritionist_id AND su_nutritionist.del_flag = 0
|
||||||
|
@ -1,5 +1,13 @@
|
|||||||
import request from "@/utils/request";
|
import request from "@/utils/request";
|
||||||
|
|
||||||
|
export function addRecipesApi(data) {
|
||||||
|
return request({
|
||||||
|
url: "/custom/recipes/",
|
||||||
|
method: "post",
|
||||||
|
data
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
export function getRecipesApi(id) {
|
export function getRecipesApi(id) {
|
||||||
return request({
|
return request({
|
||||||
url: "/custom/recipes/" + id,
|
url: "/custom/recipes/" + id,
|
||||||
@ -9,7 +17,7 @@ export function getRecipesApi(id) {
|
|||||||
|
|
||||||
export function updateDishesDetailApi(data) {
|
export function updateDishesDetailApi(data) {
|
||||||
return request({
|
return request({
|
||||||
url: "/custom/recipes",
|
url: "/custom/recipes/dishes",
|
||||||
method: "put",
|
method: "put",
|
||||||
data
|
data
|
||||||
});
|
});
|
||||||
@ -17,15 +25,15 @@ export function updateDishesDetailApi(data) {
|
|||||||
|
|
||||||
export function addDishesApi(data) {
|
export function addDishesApi(data) {
|
||||||
return request({
|
return request({
|
||||||
url: "/custom/recipes",
|
url: "/custom/recipes/dishes",
|
||||||
method: "post",
|
method: "post",
|
||||||
data
|
data
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
export function deleteDishesApi(cid) {
|
export function deleteDishesApi(id) {
|
||||||
return request({
|
return request({
|
||||||
url: "/custom/recipes/dishes/" + cid,
|
url: "/custom/recipes/dishes/" + id,
|
||||||
method: "delete"
|
method: "delete"
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -1,10 +1,10 @@
|
|||||||
<template>
|
<template>
|
||||||
<div :class="classname">
|
<div :class="classname">
|
||||||
<span class="title">{{ title }}:</span>
|
<span class="info_title">{{ title }}:</span>
|
||||||
<span v-if="newLine">
|
<span v-if="newLine">
|
||||||
<div v-for="value in mValue" :key="value">{{ value }}</div>
|
<div v-for="value in mValue" :key="value">{{ value }}</div>
|
||||||
</span>
|
</span>
|
||||||
<span v-else class="value">{{ mValue }}</span>
|
<span v-else class="info_value">{{ mValue }}</span>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
<script>
|
<script>
|
||||||
@ -32,19 +32,19 @@ export default {
|
|||||||
props: ["title", "value", "extraclass"],
|
props: ["title", "value", "extraclass"],
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
<style rel="stylesheet/scss" lang="scss">
|
<style lang="scss" >
|
||||||
.text_info_wrapper {
|
.text_info_wrapper {
|
||||||
display: flex;
|
display: flex;
|
||||||
margin-right: 24px;
|
margin-right: 24px;
|
||||||
min-width: 120px;
|
min-width: 120px;
|
||||||
font-size: 14px;
|
font-size: 14px;
|
||||||
|
|
||||||
.title {
|
.info_title {
|
||||||
color: #8c8c8c;
|
color: #8c8c8c;
|
||||||
width: auto;
|
width: auto;
|
||||||
}
|
}
|
||||||
|
|
||||||
.value {
|
.info_value {
|
||||||
/* color: #696969; */
|
/* color: #696969; */
|
||||||
flex: 1 1 0;
|
flex: 1 1 0;
|
||||||
}
|
}
|
||||||
|
@ -145,7 +145,7 @@ export const constantRoutes = [
|
|||||||
hidden: true,
|
hidden: true,
|
||||||
children: [
|
children: [
|
||||||
{
|
{
|
||||||
path: "build/:cusId/:planId/:recipesId",
|
path: "build",
|
||||||
component: resolve =>
|
component: resolve =>
|
||||||
require(["@/views/custom/recipesBuild"], resolve),
|
require(["@/views/custom/recipesBuild"], resolve),
|
||||||
name: "RecipiesBuild",
|
name: "RecipiesBuild",
|
||||||
|
@ -1,62 +1,51 @@
|
|||||||
import { getOrder } from "@/api/custom/order";
|
import { getOrder } from "@/api/custom/order";
|
||||||
import { getCustomerPhysicalSignsByCusId } from "@/api/custom/customer";
|
import { getCustomerPhysicalSignsByCusId } from "@/api/custom/customer";
|
||||||
import { dealHealthy } from "@/utils/healthyData";
|
import { dealHealthy } from "@/utils/healthyData";
|
||||||
import { getRecipesPlan } from "@/api/custom/recipesPlan";
|
|
||||||
import {
|
import {
|
||||||
getRecipesApi,
|
getRecipesApi,
|
||||||
updateDishesDetailApi,
|
updateDishesDetailApi,
|
||||||
addDishesApi,
|
addDishesApi,
|
||||||
deleteDishesApi
|
deleteDishesApi,
|
||||||
|
addRecipesApi
|
||||||
} from "@/api/custom/recipes";
|
} from "@/api/custom/recipes";
|
||||||
import { getDicts } from "@/api/system/dict/data";
|
import { getDicts } from "@/api/system/dict/data";
|
||||||
import produce from "immer";
|
import dayjs from "dayjs";
|
||||||
import { updateDishes } from "@/api/custom/dishes";
|
|
||||||
|
|
||||||
const oriState = {
|
const oriState = {
|
||||||
|
cusId: undefined,
|
||||||
|
planId: undefined,
|
||||||
recipesId: undefined,
|
recipesId: undefined,
|
||||||
healthyData: {},
|
healthyData: {},
|
||||||
|
healthDataLoading: false,
|
||||||
healthyDataType: 0,
|
healthyDataType: 0,
|
||||||
recipesData: [],
|
recipesData: [],
|
||||||
|
recipesDataLoading: false,
|
||||||
cusUnitOptions: [],
|
cusUnitOptions: [],
|
||||||
cusWeightOptions: [],
|
cusWeightOptions: [],
|
||||||
dishesTypeOptions: [],
|
dishesTypeOptions: [],
|
||||||
typeOptions: [],
|
typeOptions: [],
|
||||||
currentDay: -1
|
currentDay: -1,
|
||||||
|
startDate: "",
|
||||||
|
endDate: ""
|
||||||
};
|
};
|
||||||
|
|
||||||
const mutations = {
|
const mutations = {
|
||||||
setRecipiesId(state, payload) {
|
|
||||||
state.recipesId = payload.recipesId;
|
|
||||||
},
|
|
||||||
setHealtyData(state, payload) {
|
|
||||||
state.healthyDataType = payload.healthyDataType;
|
|
||||||
state.healthyData = payload.healthyData;
|
|
||||||
},
|
|
||||||
setRecipesData(state, payload) {
|
|
||||||
state.recipesData = payload.recipesData;
|
|
||||||
// console.log(payload.recipesData);
|
|
||||||
},
|
|
||||||
updateRecipesDishesDetail(state, payload) {
|
updateRecipesDishesDetail(state, payload) {
|
||||||
const tarDishes = state.recipesData[payload.num].dishes.find(
|
const tarDishes = state.recipesData[payload.num].dishes.find(
|
||||||
obj => obj.id === payload.dishesId
|
obj => obj.dishesId === payload.dishesId
|
||||||
);
|
);
|
||||||
if (tarDishes) {
|
if (tarDishes) {
|
||||||
const tarIgd = tarDishes.igdList.find(obj => obj.id === payload.igdId);
|
const tarIgd = tarDishes.igdList.find(obj => obj.id === payload.igdId);
|
||||||
if (tarIgd) {
|
if (tarIgd) {
|
||||||
payload.weight && (tarIgd.weight = payload.weight);
|
Object.keys(payload).forEach(key => {
|
||||||
payload.cusWeight && (tarIgd.cusWeight = payload.cusWeight);
|
tarIgd[key] = payload[key];
|
||||||
payload.cusUnit && (tarIgd.cusUnit = payload.cusUnit);
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
addRecipesDishes(state, payload) {
|
addRecipesDishes(state, payload) {
|
||||||
state.recipesData[payload.num].dishes.push(payload.data);
|
state.recipesData[payload.num].dishes.push(payload.data);
|
||||||
},
|
},
|
||||||
updateOptions(state, payload) {
|
|
||||||
Object.keys(payload).forEach(key => {
|
|
||||||
state[key] = payload[key];
|
|
||||||
});
|
|
||||||
},
|
|
||||||
setCurrentDay(state, payload) {
|
setCurrentDay(state, payload) {
|
||||||
state.currentDay =
|
state.currentDay =
|
||||||
payload.currentDay === state.currentDay ? -1 : payload.currentDay;
|
payload.currentDay === state.currentDay ? -1 : payload.currentDay;
|
||||||
@ -67,6 +56,15 @@ const mutations = {
|
|||||||
payload.num
|
payload.num
|
||||||
].dishes.filter(obj => obj.id !== payload.dishesId);
|
].dishes.filter(obj => obj.id !== payload.dishesId);
|
||||||
},
|
},
|
||||||
|
updateStateData(state, payload) {
|
||||||
|
Object.keys(payload).forEach(key => {
|
||||||
|
state[key] = payload[key];
|
||||||
|
});
|
||||||
|
},
|
||||||
|
setDate(state, payload) {
|
||||||
|
state.startDate = payload.startDate;
|
||||||
|
state.endDate = payload.endDate;
|
||||||
|
},
|
||||||
clean(state) {
|
clean(state) {
|
||||||
// console.log("clean");
|
// console.log("clean");
|
||||||
Object.keys(oriState).forEach(key => {
|
Object.keys(oriState).forEach(key => {
|
||||||
@ -76,109 +74,137 @@ const mutations = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const actions = {
|
const actions = {
|
||||||
async init({ commit }, payload) {
|
async init({ commit, dispatch }, payload) {
|
||||||
const orderResult = await getOrder(payload.cusId);
|
const orderResult = await getOrder(payload.cusId);
|
||||||
if (!orderResult.data.cusId) {
|
if (!orderResult.data.cusId) {
|
||||||
throw new Error("未找到用户id");
|
throw new Error("未找到用户id");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
commit("updateStateData", {
|
||||||
|
...payload,
|
||||||
|
cusId: orderResult.data.cusId
|
||||||
|
});
|
||||||
//
|
//
|
||||||
getDicts("cus_cus_unit").then(response => {
|
getDicts("cus_cus_unit").then(response => {
|
||||||
commit("updateOptions", { cusUnitOptions: response.data });
|
commit("healthDataLoading", { cusUnitOptions: response.data });
|
||||||
});
|
});
|
||||||
getDicts("cus_cus_weight").then(response => {
|
getDicts("cus_cus_weight").then(response => {
|
||||||
commit("updateOptions", { cusWeightOptions: response.data });
|
commit("healthDataLoading", { cusWeightOptions: response.data });
|
||||||
});
|
});
|
||||||
getDicts("cus_dishes_type").then(response => {
|
getDicts("cus_dishes_type").then(response => {
|
||||||
commit("updateOptions", { typeOptions: response.data });
|
commit("healthDataLoading", { typeOptions: response.data });
|
||||||
});
|
});
|
||||||
getDicts("cus_dishes_type").then(response => {
|
getDicts("cus_dishes_type").then(response => {
|
||||||
commit("updateOptions", { dishesTypeOptions: response.data });
|
commit("healthDataLoading", { dishesTypeOptions: response.data });
|
||||||
});
|
});
|
||||||
|
|
||||||
// 健康数据
|
//
|
||||||
const healthyDataResult = await getCustomerPhysicalSignsByCusId(
|
if (orderResult.data.cusId) {
|
||||||
orderResult.data.cusId
|
dispatch("getHealthyData", { cusId: orderResult.data.cusId });
|
||||||
);
|
|
||||||
if (healthyDataResult.code === 200) {
|
|
||||||
if (!healthyDataResult.data.customerHealthy) {
|
|
||||||
throw new Error("客户还没填写健康评估表");
|
|
||||||
}
|
|
||||||
commit("setHealtyData", {
|
|
||||||
healthyDataType: healthyDataResult.data.type,
|
|
||||||
healthyData: dealHealthy(healthyDataResult.data.customerHealthy)
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
throw new Error(healthyDataResult.msg);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// 食谱数据
|
// 食谱数据
|
||||||
if (payload.recipesId) {
|
if (payload.recipesId) {
|
||||||
const recipesDataResult = await getRecipesApi(payload.recipesId);
|
dispatch("getRecipesInfo", payload);
|
||||||
if (recipesDataResult.code === 200) {
|
|
||||||
commit("setRecipesData", {
|
|
||||||
recipesData: recipesDataResult.data.map(dayData => {
|
|
||||||
return {
|
|
||||||
id: dayData.id,
|
|
||||||
numDay: dayData.numDay,
|
|
||||||
dishes: dayData.dishes.reduce((arr, cur) => {
|
|
||||||
if (
|
|
||||||
cur.id > -1 &&
|
|
||||||
cur.name &&
|
|
||||||
cur.igdList.length > 0 &&
|
|
||||||
cur.type !== "0"
|
|
||||||
) {
|
|
||||||
arr.push({
|
|
||||||
id: cur.id,
|
|
||||||
cid: cur.cid,
|
|
||||||
name: cur.name,
|
|
||||||
methods: cur.methods,
|
|
||||||
type: cur.type,
|
|
||||||
isMain: cur.isMain,
|
|
||||||
igdList: cur.igdList.reduce((igdArr, igdData) => {
|
|
||||||
if (igdData.id > 0) {
|
|
||||||
const tarDetail = cur.detail.find(
|
|
||||||
obj => obj.id === igdData.id
|
|
||||||
);
|
|
||||||
igdArr.push({
|
|
||||||
id: igdData.id,
|
|
||||||
name: igdData.name,
|
|
||||||
carbonRatio: igdData.carbonRatio,
|
|
||||||
fatRatio: igdData.fatRatio,
|
|
||||||
proteinRatio: igdData.proteinRatio,
|
|
||||||
cusUnit: tarDetail
|
|
||||||
? tarDetail.cus_unit
|
|
||||||
: igdData.cusUnit,
|
|
||||||
cusWeight: tarDetail
|
|
||||||
? parseFloat(tarDetail.cus_weight)
|
|
||||||
: igdData.cusWeight,
|
|
||||||
weight: tarDetail
|
|
||||||
? parseFloat(tarDetail.weight)
|
|
||||||
: igdData.weight,
|
|
||||||
notRec: igdData.notRec,
|
|
||||||
rec: igdData.rec,
|
|
||||||
type: igdData.type
|
|
||||||
});
|
|
||||||
}
|
|
||||||
return igdArr;
|
|
||||||
}, [])
|
|
||||||
});
|
|
||||||
}
|
|
||||||
return arr;
|
|
||||||
}, [])
|
|
||||||
};
|
|
||||||
})
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
throw new Error(recipesDataResult.msg);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
async saveRecipes({ commit, state }, payload) {
|
async getHealthyData({ commit }, payload) {
|
||||||
const { recipesData } = state;
|
commit("updateStateData", { healthDataLoading: true });
|
||||||
const params = recipesData.map(menu => {
|
// 健康数据
|
||||||
return menu.dishes.map(dObj => {
|
const healthyDataResult = await getCustomerPhysicalSignsByCusId(
|
||||||
|
payload.cusId
|
||||||
|
);
|
||||||
|
let healthyData = undefined,
|
||||||
|
healthyDataType = 0;
|
||||||
|
if (healthyDataResult.code === 200) {
|
||||||
|
if (!healthyDataResult.data.customerHealthy) {
|
||||||
|
throw new Error("客户还没填写健康评估表");
|
||||||
|
}
|
||||||
|
healthyDataType = healthyDataResult.data.type;
|
||||||
|
healthyData = dealHealthy(healthyDataResult.data.customerHealthy);
|
||||||
|
} else {
|
||||||
|
throw new Error(healthyDataResult.msg);
|
||||||
|
}
|
||||||
|
commit("updateStateData", {
|
||||||
|
healthDataLoading: false,
|
||||||
|
healthyDataType,
|
||||||
|
healthyData
|
||||||
|
});
|
||||||
|
},
|
||||||
|
async getRecipesInfo({ commit }, payload) {
|
||||||
|
commit("updateStateData", {
|
||||||
|
recipesDataLoading: true
|
||||||
|
});
|
||||||
|
const recipesDataResult = await getRecipesApi(payload.recipesId);
|
||||||
|
let recipesData = undefined;
|
||||||
|
if (recipesDataResult.code === 200) {
|
||||||
|
recipesData = recipesDataResult.data.map(dayData => {
|
||||||
return {
|
return {
|
||||||
dishesId: dObj.id,
|
id: dayData.id,
|
||||||
|
numDay: dayData.numDay,
|
||||||
|
dishes: dayData.dishes.reduce((arr, cur) => {
|
||||||
|
if (
|
||||||
|
cur.dishesId > -1 &&
|
||||||
|
cur.name &&
|
||||||
|
cur.igdList.length > 0 &&
|
||||||
|
cur.type !== "0"
|
||||||
|
) {
|
||||||
|
arr.push({
|
||||||
|
id: cur.id,
|
||||||
|
dishesId: cur.dishesId,
|
||||||
|
name: cur.name,
|
||||||
|
menuId: cur.menuId,
|
||||||
|
methods: cur.methods,
|
||||||
|
type: cur.type,
|
||||||
|
isMain: cur.isMain,
|
||||||
|
igdList: cur.igdList.reduce((igdArr, igdData) => {
|
||||||
|
if (igdData.id > 0) {
|
||||||
|
const tarDetail = cur.detail.find(
|
||||||
|
obj => obj.id === igdData.id
|
||||||
|
);
|
||||||
|
igdArr.push({
|
||||||
|
id: igdData.id,
|
||||||
|
name: igdData.name,
|
||||||
|
carbonRatio: igdData.carbonRatio,
|
||||||
|
fatRatio: igdData.fatRatio,
|
||||||
|
proteinRatio: igdData.proteinRatio,
|
||||||
|
cusUnit: tarDetail ? tarDetail.cus_unit : igdData.cusUnit,
|
||||||
|
cusWeight: tarDetail
|
||||||
|
? parseFloat(tarDetail.cus_weight)
|
||||||
|
: igdData.cusWeight,
|
||||||
|
weight: tarDetail
|
||||||
|
? parseFloat(tarDetail.weight)
|
||||||
|
: igdData.weight,
|
||||||
|
notRec: igdData.notRec,
|
||||||
|
rec: igdData.rec,
|
||||||
|
type: igdData.type
|
||||||
|
});
|
||||||
|
}
|
||||||
|
return igdArr;
|
||||||
|
}, [])
|
||||||
|
});
|
||||||
|
}
|
||||||
|
return arr;
|
||||||
|
}, [])
|
||||||
|
};
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
throw new Error(recipesDataResult.msg);
|
||||||
|
}
|
||||||
|
commit("updateStateData", { recipesDataLoading: false, recipesData });
|
||||||
|
},
|
||||||
|
async saveRecipes({ commit, dispatch, state }, payload) {
|
||||||
|
const { recipesData, cusId, planId } = state;
|
||||||
|
const params = {
|
||||||
|
cusId,
|
||||||
|
planId,
|
||||||
|
menus: recipesData.map((menu, idx) => ({
|
||||||
|
date: dayjs(state.startDate)
|
||||||
|
.add(idx, "day")
|
||||||
|
.format("YYYY-MM-DD"),
|
||||||
|
cusId,
|
||||||
|
dishes: menu.dishes.map(dObj => ({
|
||||||
|
dishesId: dObj.dishesId,
|
||||||
type: dObj.type,
|
type: dObj.type,
|
||||||
detail: dObj.igdList.map(igd => ({
|
detail: dObj.igdList.map(igd => ({
|
||||||
id: igd.id,
|
id: igd.id,
|
||||||
@ -186,72 +212,90 @@ const actions = {
|
|||||||
cus_unit: igd.cusUnit,
|
cus_unit: igd.cusUnit,
|
||||||
cus_weight: igd.cusWeight
|
cus_weight: igd.cusWeight
|
||||||
}))
|
}))
|
||||||
};
|
}))
|
||||||
});
|
}))
|
||||||
});
|
};
|
||||||
console.log(params);
|
const result = await addRecipesApi(params);
|
||||||
|
if (result.code === 200) {
|
||||||
|
dispatch("getRecipesInfo", { recipesId: result.data });
|
||||||
|
}
|
||||||
|
// console.log(params);
|
||||||
},
|
},
|
||||||
async addDishes({ commit, state }, payload) {
|
async addDishes({ commit, state }, payload) {
|
||||||
const tarRecipesObj = state.recipesData[payload.num];
|
if (state.recipesId) {
|
||||||
if (tarRecipesObj && payload.data) {
|
const tarRecipesObj = state.recipesData[payload.num];
|
||||||
const { id, type, igdList } = payload.data;
|
if (tarRecipesObj && payload.data) {
|
||||||
const params = {
|
const { dishesId, type, igdList } = payload.data;
|
||||||
menuId: tarRecipesObj.id,
|
|
||||||
id: id,
|
|
||||||
type: type,
|
|
||||||
detail: igdList.map(igd => ({
|
|
||||||
id: igd.id,
|
|
||||||
weight: igd.weight,
|
|
||||||
cus_unit: igd.cusUnit,
|
|
||||||
cus_weight: igd.cusWeight
|
|
||||||
}))
|
|
||||||
};
|
|
||||||
const result = await addDishesApi(params);
|
|
||||||
if (result.code === 200) {
|
|
||||||
payload.data.cid = result.data;
|
|
||||||
commit("addRecipesDishes", payload);
|
|
||||||
}
|
|
||||||
console.log(result);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
async updateDishes({ commit, state }, payload) {
|
|
||||||
const tarDishes = state.recipesData[payload.num].dishes.find(
|
|
||||||
obj => obj.id === payload.dishesId
|
|
||||||
);
|
|
||||||
if (tarDishes) {
|
|
||||||
const mTarDishes = JSON.parse(JSON.stringify(tarDishes));
|
|
||||||
const tarIgd = mTarDishes.igdList.find(obj => obj.id === payload.igdId);
|
|
||||||
if (tarIgd) {
|
|
||||||
payload.weight && (tarIgd.weight = payload.weight);
|
|
||||||
payload.cusWeight && (tarIgd.cusWeight = payload.cusWeight);
|
|
||||||
payload.cusUnit && (tarIgd.cusUnit = payload.cusUnit);
|
|
||||||
|
|
||||||
const params = {
|
const params = {
|
||||||
cid: mTarDishes.cid,
|
type,
|
||||||
detail: mTarDishes.igdList.map(igd => ({
|
dishesId,
|
||||||
|
menuId: tarRecipesObj.id,
|
||||||
|
detail: igdList.map(igd => ({
|
||||||
id: igd.id,
|
id: igd.id,
|
||||||
weight: igd.weight,
|
weight: igd.weight,
|
||||||
cus_unit: igd.cusUnit,
|
cus_unit: igd.cusUnit,
|
||||||
cus_weight: igd.cusWeight
|
cus_weight: igd.cusWeight
|
||||||
}))
|
}))
|
||||||
};
|
};
|
||||||
const result = await updateDishesDetailApi(params);
|
const result = await addDishesApi(params);
|
||||||
if (result.code === 200) {
|
if (result.code === 200) {
|
||||||
commit("updateRecipesDishesDetail", payload);
|
payload.menuId = tarRecipesObj.id;
|
||||||
|
// 更新id
|
||||||
|
payload.data.id = result.data;
|
||||||
|
commit("addRecipesDishes", payload);
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
commit("addRecipesDishes", payload);
|
||||||
|
}
|
||||||
|
// console.log(result);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
async updateDishes({ commit, state }, payload) {
|
||||||
|
if (state.recipesId) {
|
||||||
|
const tarDishes = state.recipesData[payload.num].dishes.find(
|
||||||
|
obj => obj.dishesId === payload.dishesId
|
||||||
|
);
|
||||||
|
if (tarDishes) {
|
||||||
|
const mTarDishes = JSON.parse(JSON.stringify(tarDishes));
|
||||||
|
const tarIgd = mTarDishes.igdList.find(obj => obj.id === payload.igdId);
|
||||||
|
if (tarIgd) {
|
||||||
|
payload.weight && (tarIgd.weight = payload.weight);
|
||||||
|
payload.cusWeight && (tarIgd.cusWeight = payload.cusWeight);
|
||||||
|
payload.cusUnit && (tarIgd.cusUnit = payload.cusUnit);
|
||||||
|
|
||||||
|
const params = {
|
||||||
|
id: mTarDishes.id,
|
||||||
|
detail: mTarDishes.igdList.map(igd => ({
|
||||||
|
id: igd.id,
|
||||||
|
weight: igd.weight,
|
||||||
|
cus_unit: igd.cusUnit,
|
||||||
|
cus_weight: igd.cusWeight
|
||||||
|
}))
|
||||||
|
};
|
||||||
|
const result = await updateDishesDetailApi(params);
|
||||||
|
if (result.code === 200) {
|
||||||
|
commit("updateRecipesDishesDetail", payload);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
commit("updateRecipesDishesDetail", payload);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
async deleteDishes({ commit, state }, payload) {
|
async deleteDishes({ commit, state }, payload) {
|
||||||
const tarDishes = state.recipesData[payload.num].dishes.find(
|
if (state.recipesId) {
|
||||||
obj => obj.id === payload.dishesId
|
const tarDishes = state.recipesData[payload.num].dishes.find(
|
||||||
);
|
obj => obj.id === payload.id
|
||||||
if (tarDishes) {
|
);
|
||||||
const result = await deleteDishesApi(tarDishes.cid);
|
if (tarDishes) {
|
||||||
if (result.code === 200) {
|
const result = await deleteDishesApi(tarDishes.id);
|
||||||
commit("deleteSomeDayDishes", payload);
|
if (result.code === 200) {
|
||||||
|
commit("deleteSomeDayDishes", payload);
|
||||||
|
}
|
||||||
|
// console.log(params);
|
||||||
}
|
}
|
||||||
// console.log(params);
|
} else {
|
||||||
|
commit("deleteSomeDayDishes", payload);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
async deleteMenu({ commit }, payload) {}
|
async deleteMenu({ commit }, payload) {}
|
||||||
@ -259,6 +303,9 @@ const actions = {
|
|||||||
|
|
||||||
const getters = {
|
const getters = {
|
||||||
analyseData: state => {
|
analyseData: state => {
|
||||||
|
if (!state.recipesData.length) {
|
||||||
|
return [];
|
||||||
|
}
|
||||||
const datas =
|
const datas =
|
||||||
state.currentDay > -1
|
state.currentDay > -1
|
||||||
? [state.recipesData[state.currentDay]]
|
? [state.recipesData[state.currentDay]]
|
||||||
|
@ -4,8 +4,12 @@
|
|||||||
:style="`height: ${collapse ? 30 : 200}px`"
|
:style="`height: ${collapse ? 30 : 200}px`"
|
||||||
>
|
>
|
||||||
<div class="header">
|
<div class="header">
|
||||||
<el-button size="mini" type="primary" @click="handleOnSave"
|
<el-button
|
||||||
>保存</el-button
|
v-if="!recipesId"
|
||||||
|
size="mini"
|
||||||
|
type="primary"
|
||||||
|
@click="handleOnSave"
|
||||||
|
>生成食谱</el-button
|
||||||
>
|
>
|
||||||
<el-button size="mini" type="text" @click="handleCollapseClick">{{
|
<el-button size="mini" type="text" @click="handleCollapseClick">{{
|
||||||
`${collapse ? "展开分析" : "收起分析"}`
|
`${collapse ? "展开分析" : "收起分析"}`
|
||||||
@ -21,7 +25,12 @@
|
|||||||
height="170px"
|
height="170px"
|
||||||
width="500px"
|
width="500px"
|
||||||
/>
|
/>
|
||||||
<PieChart v-else :data="data" height="170px" width="500px" />
|
<PieChart
|
||||||
|
v-if="data.length === 1"
|
||||||
|
:data="data"
|
||||||
|
height="170px"
|
||||||
|
width="500px"
|
||||||
|
/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
@ -29,7 +38,7 @@
|
|||||||
import BarChart from "./BarChart";
|
import BarChart from "./BarChart";
|
||||||
import PieChart from "./PieChart";
|
import PieChart from "./PieChart";
|
||||||
import { createNamespacedHelpers } from "vuex";
|
import { createNamespacedHelpers } from "vuex";
|
||||||
const { mapActions } = createNamespacedHelpers("recipes");
|
const { mapActions, mapState } = createNamespacedHelpers("recipes");
|
||||||
export default {
|
export default {
|
||||||
name: "RecipesAspectCom",
|
name: "RecipesAspectCom",
|
||||||
components: {
|
components: {
|
||||||
@ -43,7 +52,9 @@ export default {
|
|||||||
// console.log(this.data);
|
// console.log(this.data);
|
||||||
},
|
},
|
||||||
props: ["collapse", "data"],
|
props: ["collapse", "data"],
|
||||||
computed: {},
|
computed: {
|
||||||
|
...mapState(["recipesId"]),
|
||||||
|
},
|
||||||
methods: {
|
methods: {
|
||||||
handleCollapseClick() {
|
handleCollapseClick() {
|
||||||
this.$emit("update:collapse", !this.collapse);
|
this.$emit("update:collapse", !this.collapse);
|
||||||
|
@ -70,8 +70,8 @@ export default {
|
|||||||
name: "",
|
name: "",
|
||||||
type: "",
|
type: "",
|
||||||
igdList: [],
|
igdList: [],
|
||||||
recTags:[],
|
recTags: [],
|
||||||
notRecTags: []
|
notRecTags: [],
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
@ -123,8 +123,27 @@ export default {
|
|||||||
handleOnConfirmClick() {
|
handleOnConfirmClick() {
|
||||||
this.visible = false;
|
this.visible = false;
|
||||||
this.active = 0;
|
this.active = 0;
|
||||||
this.$emit("onConfirm", this.selDishes);
|
|
||||||
// console.log(this.selDishes);
|
const {
|
||||||
|
id,
|
||||||
|
methods,
|
||||||
|
name,
|
||||||
|
notRecTags,
|
||||||
|
recTags,
|
||||||
|
type,
|
||||||
|
igdList,
|
||||||
|
} = this.selDishes;
|
||||||
|
this.$emit("onConfirm", {
|
||||||
|
id: -1,
|
||||||
|
dishesId: id,
|
||||||
|
methods,
|
||||||
|
name,
|
||||||
|
notRecTags,
|
||||||
|
recTags,
|
||||||
|
type,
|
||||||
|
igdList,
|
||||||
|
});
|
||||||
|
console.log(this.selDishes);
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
@ -161,7 +161,7 @@ export default {
|
|||||||
const mData = this.data.dishes
|
const mData = this.data.dishes
|
||||||
.sort((a, b) => a.type - b.type)
|
.sort((a, b) => a.type - b.type)
|
||||||
.reduce((arr, cur, idx) => {
|
.reduce((arr, cur, idx) => {
|
||||||
if (cur.id > 0 && cur.type !== "0") {
|
if (cur.dishesId > 0 && cur.type !== "0") {
|
||||||
cur.igdList.forEach((igd) => {
|
cur.igdList.forEach((igd) => {
|
||||||
let lastTypeHit = false,
|
let lastTypeHit = false,
|
||||||
lastNameHit = false;
|
lastNameHit = false;
|
||||||
@ -194,6 +194,8 @@ export default {
|
|||||||
|
|
||||||
arr.push({
|
arr.push({
|
||||||
id: cur.id,
|
id: cur.id,
|
||||||
|
dishesId: cur.dishesId,
|
||||||
|
menuId: cur.menuId,
|
||||||
name: cur.name,
|
name: cur.name,
|
||||||
type: cur.type,
|
type: cur.type,
|
||||||
isMain: cur.isMain,
|
isMain: cur.isMain,
|
||||||
@ -272,21 +274,22 @@ export default {
|
|||||||
},
|
},
|
||||||
handleOnDelete(data) {
|
handleOnDelete(data) {
|
||||||
// console.log(data);
|
// console.log(data);
|
||||||
this.deleteDishes({ num: this.num - 1, dishesId: data.id });
|
this.deleteDishes({ num: this.num - 1, id: data.id });
|
||||||
},
|
},
|
||||||
handleOnWeightChange(data, weight) {
|
handleOnWeightChange(data, weight) {
|
||||||
// console.log({ data, weight });
|
console.log({ data, weight });
|
||||||
this.updateDishes({
|
this.updateDishes({
|
||||||
num: this.num - 1,
|
num: this.num - 1,
|
||||||
dishesId: data.id,
|
dishesId: data.dishesId,
|
||||||
igdId: data.igdId,
|
igdId: data.igdId,
|
||||||
weight,
|
weight,
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
handleOnCustomUnitChange(data, { cusWeight, cusUnit }) {
|
handleOnCustomUnitChange(data, { cusWeight, cusUnit }) {
|
||||||
|
console.log({ data, cusWeight, cusUnit });
|
||||||
this.updateDishes({
|
this.updateDishes({
|
||||||
num: this.num - 1,
|
num: this.num - 1,
|
||||||
dishesId: data.id,
|
dishesId: data.dishesId,
|
||||||
igdId: data.igdId,
|
igdId: data.igdId,
|
||||||
cusWeight,
|
cusWeight,
|
||||||
cusUnit,
|
cusUnit,
|
||||||
|
@ -24,6 +24,11 @@ export default {
|
|||||||
RecipesCom,
|
RecipesCom,
|
||||||
RecipesAspectCom,
|
RecipesAspectCom,
|
||||||
},
|
},
|
||||||
|
computed: {
|
||||||
|
mCollapse() {
|
||||||
|
return analyseData.length ? this.collapse : false;
|
||||||
|
},
|
||||||
|
},
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
collapse: false,
|
collapse: false,
|
||||||
|
22
stdiet-ui/src/views/custom/recipesBuild/RecommondView.vue
Normal file
22
stdiet-ui/src/views/custom/recipesBuild/RecommondView.vue
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
|
||||||
|
<template>
|
||||||
|
<el-button @click="handleOnClick">推荐</el-button>
|
||||||
|
</template>
|
||||||
|
<script>
|
||||||
|
import { createNamespacedHelpers } from "vuex";
|
||||||
|
const {
|
||||||
|
mapActions,
|
||||||
|
mapState,
|
||||||
|
mapMutations,
|
||||||
|
mapGetters,
|
||||||
|
} = createNamespacedHelpers("recipes");
|
||||||
|
export default {
|
||||||
|
name: "RecommondView",
|
||||||
|
methods: {
|
||||||
|
handleOnClick() {
|
||||||
|
this.getRecipesInfo({ recipesId: 73 });
|
||||||
|
},
|
||||||
|
...mapActions(["getRecipesInfo"]),
|
||||||
|
},
|
||||||
|
};
|
||||||
|
</script>
|
@ -1,13 +1,15 @@
|
|||||||
<template>
|
<template>
|
||||||
<div class="recipes_build_wrapper">
|
<div class="recipes_build_wrapper">
|
||||||
<div class="left">
|
<div class="left" v-loading="recipesDataLoading">
|
||||||
<RecipesView
|
<RecipesView
|
||||||
|
v-if="!!recipesData.length"
|
||||||
:data="recipesData"
|
:data="recipesData"
|
||||||
:name="healthyData.name"
|
:name="healthyData.name"
|
||||||
:analyseData="analyseData"
|
:analyseData="analyseData"
|
||||||
/>
|
/>
|
||||||
|
<RecommondView v-else />
|
||||||
</div>
|
</div>
|
||||||
<div class="right">
|
<div class="right" v-loading="healthDataLoading">
|
||||||
<HealthyView :data="healthyData" v-if="healthyDataType === 0" />
|
<HealthyView :data="healthyData" v-if="healthyDataType === 0" />
|
||||||
<BodySignView :data="healthyData" v-else />
|
<BodySignView :data="healthyData" v-else />
|
||||||
</div>
|
</div>
|
||||||
@ -25,6 +27,7 @@ const {
|
|||||||
import HealthyView from "./HealthyView";
|
import HealthyView from "./HealthyView";
|
||||||
import BodySignView from "./BodySignView";
|
import BodySignView from "./BodySignView";
|
||||||
import RecipesView from "./RecipesView/index";
|
import RecipesView from "./RecipesView/index";
|
||||||
|
import RecommondView from "./RecommondView";
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: "BuildRecipies",
|
name: "BuildRecipies",
|
||||||
@ -32,12 +35,15 @@ export default {
|
|||||||
return {};
|
return {};
|
||||||
},
|
},
|
||||||
mounted() {
|
mounted() {
|
||||||
//
|
const { cusId, planId, startDate, endDate, recipesId } = this.$route.query;
|
||||||
// console.log({
|
|
||||||
// cusId: this.cusId,
|
this.init({
|
||||||
// recipesId: this.recipesId,
|
cusId,
|
||||||
// });
|
planId,
|
||||||
this.init({ cusId: this.cusId, recipesId: this.recipesId }).catch((err) => {
|
startDate,
|
||||||
|
endDate,
|
||||||
|
recipesId,
|
||||||
|
}).catch((err) => {
|
||||||
this.$message.error(err.message);
|
this.$message.error(err.message);
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
@ -49,10 +55,17 @@ export default {
|
|||||||
HealthyView,
|
HealthyView,
|
||||||
BodySignView,
|
BodySignView,
|
||||||
RecipesView,
|
RecipesView,
|
||||||
|
RecommondView,
|
||||||
},
|
},
|
||||||
props: ["planId", "cusId", "recipesId"],
|
// props: ["cusId", "planId", "recipesId", "startDate", "endDate"],
|
||||||
computed: {
|
computed: {
|
||||||
...mapState(["healthyData", "healthyDataType", "recipesData"]),
|
...mapState([
|
||||||
|
"healthyData",
|
||||||
|
"healthyDataType",
|
||||||
|
"recipesData",
|
||||||
|
"recipesDataLoading",
|
||||||
|
"healthDataLoading",
|
||||||
|
]),
|
||||||
...mapGetters(["analyseData"]),
|
...mapGetters(["analyseData"]),
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
|
@ -170,14 +170,14 @@
|
|||||||
<el-button
|
<el-button
|
||||||
size="mini"
|
size="mini"
|
||||||
type="text"
|
type="text"
|
||||||
icon="el-icon-edit"
|
icon="el-icon-view"
|
||||||
@click="
|
@click="
|
||||||
allRecipesPlanQueryParam.orderId = scope.row.orderId;
|
allRecipesPlanQueryParam.orderId = scope.row.orderId;
|
||||||
getAllPlanByOrderId();
|
getAllPlanByOrderId();
|
||||||
"
|
"
|
||||||
>查看完整计划
|
>查看完整计划
|
||||||
</el-button>
|
</el-button>
|
||||||
<el-button
|
<!-- <el-button
|
||||||
size="mini"
|
size="mini"
|
||||||
type="text"
|
type="text"
|
||||||
icon="el-icon-edit"
|
icon="el-icon-edit"
|
||||||
@ -192,13 +192,15 @@
|
|||||||
@click="getCustomerSign(scope.row)"
|
@click="getCustomerSign(scope.row)"
|
||||||
v-hasPermi="['custom:customer:query']"
|
v-hasPermi="['custom:customer:query']"
|
||||||
>查看体征
|
>查看体征
|
||||||
</el-button>
|
</el-button> -->
|
||||||
<el-button
|
<el-button
|
||||||
size="mini"
|
size="mini"
|
||||||
type="text"
|
type="text"
|
||||||
icon="el-icon-edit"
|
:icon="`${
|
||||||
|
scope.row.recipesId ? 'el-icon-edit' : 'el-icon-edit-outline'
|
||||||
|
}`"
|
||||||
@click="handleBuild(scope.row)"
|
@click="handleBuild(scope.row)"
|
||||||
>{{ `${scope.row.recipes_id ? "编辑" : "制作"}食谱` }}</el-button
|
>{{ `${scope.row.recipesId ? "编辑" : "制作"}食谱` }}</el-button
|
||||||
>
|
>
|
||||||
</template>
|
</template>
|
||||||
</el-table-column>
|
</el-table-column>
|
||||||
@ -604,20 +606,26 @@ export default {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
handleBuild(data) {
|
handleBuild(data) {
|
||||||
|
// console.log(data);
|
||||||
|
const { startDate, endDate, id, orderId, recipesId } = data;
|
||||||
|
|
||||||
// const params = { id: data.id, cusId: data.orderId };
|
// const params = { id: data.id, cusId: data.orderId };
|
||||||
let path = `/recipes/build/${data.orderId}/${data.id}`;
|
// const path = `/recipes/build/${orderId}/${id}/${recipesId || 0}`;
|
||||||
if (data.recipes_id) {
|
|
||||||
// params.recipesId = data.recipes_id;
|
|
||||||
path += `/${data.recipes_id}`;
|
|
||||||
}
|
|
||||||
// test
|
|
||||||
// params.recipesId = "61";
|
|
||||||
path += '/73';
|
|
||||||
// this.$router.push({
|
// this.$router.push({
|
||||||
// name: "build",
|
// name: "build",
|
||||||
// params,
|
// params,
|
||||||
// });
|
// });
|
||||||
this.$router.push(path);
|
const queryParam = {
|
||||||
|
planId: id,
|
||||||
|
cusId: orderId,
|
||||||
|
};
|
||||||
|
if (!recipesId) {
|
||||||
|
queryParam.startDate = startDate;
|
||||||
|
queryParam.endDate = endDate;
|
||||||
|
} else {
|
||||||
|
queryParam.recipesId = recipesId;
|
||||||
|
}
|
||||||
|
this.$router.push({ path: "/recipes/build", query: queryParam });
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
Reference in New Issue
Block a user