Merge branch 'master' of https://gitee.com/darlk/ShengTangManage into xzj
This commit is contained in:
commit
3df32e4e1e
@ -1,24 +1,23 @@
|
|||||||
package com.stdiet.web.controller.custom;
|
package com.stdiet.web.controller.custom;
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
import org.springframework.security.access.prepost.PreAuthorize;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
import org.springframework.web.bind.annotation.GetMapping;
|
|
||||||
import org.springframework.web.bind.annotation.PostMapping;
|
|
||||||
import org.springframework.web.bind.annotation.PutMapping;
|
|
||||||
import org.springframework.web.bind.annotation.DeleteMapping;
|
|
||||||
import org.springframework.web.bind.annotation.PathVariable;
|
|
||||||
import org.springframework.web.bind.annotation.RequestBody;
|
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
|
||||||
import com.stdiet.common.annotation.Log;
|
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.custom.domain.SysDishes;
|
|
||||||
import com.stdiet.custom.service.ISysDishesService;
|
|
||||||
import com.stdiet.common.utils.poi.ExcelUtil;
|
|
||||||
import com.stdiet.common.core.page.TableDataInfo;
|
import com.stdiet.common.core.page.TableDataInfo;
|
||||||
|
import com.stdiet.common.enums.BusinessType;
|
||||||
|
import com.stdiet.common.utils.StringUtils;
|
||||||
|
import com.stdiet.common.utils.poi.ExcelUtil;
|
||||||
|
import com.stdiet.custom.domain.SysDishes;
|
||||||
|
import com.stdiet.custom.domain.SysDishesIngredient;
|
||||||
|
import com.stdiet.custom.domain.SysIngredient;
|
||||||
|
import com.stdiet.custom.service.ISysDishesService;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.security.access.prepost.PreAuthorize;
|
||||||
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
|
import java.lang.reflect.Array;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 菜品Controller
|
* 菜品Controller
|
||||||
@ -28,8 +27,7 @@ import com.stdiet.common.core.page.TableDataInfo;
|
|||||||
*/
|
*/
|
||||||
@RestController
|
@RestController
|
||||||
@RequestMapping("/custom/dishes")
|
@RequestMapping("/custom/dishes")
|
||||||
public class SysDishesController extends BaseController
|
public class SysDishesController extends BaseController {
|
||||||
{
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private ISysDishesService sysDishesService;
|
private ISysDishesService sysDishesService;
|
||||||
|
|
||||||
@ -38,10 +36,17 @@ public class SysDishesController extends BaseController
|
|||||||
*/
|
*/
|
||||||
@PreAuthorize("@ss.hasPermi('custom:dishes:list')")
|
@PreAuthorize("@ss.hasPermi('custom:dishes:list')")
|
||||||
@GetMapping("/list")
|
@GetMapping("/list")
|
||||||
public TableDataInfo list(SysDishes sysDishes)
|
public TableDataInfo list(SysDishes sysDishes) {
|
||||||
{
|
|
||||||
startPage();
|
startPage();
|
||||||
List<SysDishes> list = sysDishesService.selectSysDishesList(sysDishes);
|
List<SysDishes> list = sysDishesService.selectSysDishesList(sysDishes);
|
||||||
|
for (SysDishes dishes : list) {
|
||||||
|
List<SysDishesIngredient> ingredients = sysDishesService.selectSysIngreditentsById(dishes.getId());
|
||||||
|
if (StringUtils.isNull(ingredients)) {
|
||||||
|
dishes.setIgdList(new ArrayList<>());
|
||||||
|
} else {
|
||||||
|
dishes.setIgdList(ingredients);
|
||||||
|
}
|
||||||
|
}
|
||||||
return getDataTable(list);
|
return getDataTable(list);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -51,8 +56,7 @@ public class SysDishesController extends BaseController
|
|||||||
@PreAuthorize("@ss.hasPermi('custom:dishes:export')")
|
@PreAuthorize("@ss.hasPermi('custom:dishes:export')")
|
||||||
@Log(title = "菜品", businessType = BusinessType.EXPORT)
|
@Log(title = "菜品", businessType = BusinessType.EXPORT)
|
||||||
@GetMapping("/export")
|
@GetMapping("/export")
|
||||||
public AjaxResult export(SysDishes sysDishes)
|
public AjaxResult export(SysDishes sysDishes) {
|
||||||
{
|
|
||||||
List<SysDishes> list = sysDishesService.selectSysDishesList(sysDishes);
|
List<SysDishes> list = sysDishesService.selectSysDishesList(sysDishes);
|
||||||
ExcelUtil<SysDishes> util = new ExcelUtil<SysDishes>(SysDishes.class);
|
ExcelUtil<SysDishes> util = new ExcelUtil<SysDishes>(SysDishes.class);
|
||||||
return util.exportExcel(list, "dishes");
|
return util.exportExcel(list, "dishes");
|
||||||
@ -63,8 +67,7 @@ public class SysDishesController extends BaseController
|
|||||||
*/
|
*/
|
||||||
@PreAuthorize("@ss.hasPermi('custom:dishes:query')")
|
@PreAuthorize("@ss.hasPermi('custom:dishes:query')")
|
||||||
@GetMapping(value = "/{id}")
|
@GetMapping(value = "/{id}")
|
||||||
public AjaxResult getInfo(@PathVariable("id") Long id)
|
public AjaxResult getInfo(@PathVariable("id") Long id) {
|
||||||
{
|
|
||||||
return AjaxResult.success(sysDishesService.selectSysDishesById(id));
|
return AjaxResult.success(sysDishesService.selectSysDishesById(id));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -74,8 +77,7 @@ public class SysDishesController extends BaseController
|
|||||||
@PreAuthorize("@ss.hasPermi('custom:dishes:add')")
|
@PreAuthorize("@ss.hasPermi('custom:dishes:add')")
|
||||||
@Log(title = "菜品", businessType = BusinessType.INSERT)
|
@Log(title = "菜品", businessType = BusinessType.INSERT)
|
||||||
@PostMapping
|
@PostMapping
|
||||||
public AjaxResult add(@RequestBody SysDishes sysDishes)
|
public AjaxResult add(@RequestBody SysDishes sysDishes) {
|
||||||
{
|
|
||||||
return toAjax(sysDishesService.insertSysDishes(sysDishes));
|
return toAjax(sysDishesService.insertSysDishes(sysDishes));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -85,8 +87,7 @@ public class SysDishesController extends BaseController
|
|||||||
@PreAuthorize("@ss.hasPermi('custom:dishes:edit')")
|
@PreAuthorize("@ss.hasPermi('custom:dishes:edit')")
|
||||||
@Log(title = "菜品", businessType = BusinessType.UPDATE)
|
@Log(title = "菜品", businessType = BusinessType.UPDATE)
|
||||||
@PutMapping
|
@PutMapping
|
||||||
public AjaxResult edit(@RequestBody SysDishes sysDishes)
|
public AjaxResult edit(@RequestBody SysDishes sysDishes) {
|
||||||
{
|
|
||||||
return toAjax(sysDishesService.updateSysDishes(sysDishes));
|
return toAjax(sysDishesService.updateSysDishes(sysDishes));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -95,9 +96,8 @@ public class SysDishesController extends BaseController
|
|||||||
*/
|
*/
|
||||||
@PreAuthorize("@ss.hasPermi('custom:dishes:remove')")
|
@PreAuthorize("@ss.hasPermi('custom:dishes:remove')")
|
||||||
@Log(title = "菜品", businessType = BusinessType.DELETE)
|
@Log(title = "菜品", businessType = BusinessType.DELETE)
|
||||||
@DeleteMapping("/{ids}")
|
@DeleteMapping("/{ids}")
|
||||||
public AjaxResult remove(@PathVariable Long[] ids)
|
public AjaxResult remove(@PathVariable Long[] ids) {
|
||||||
{
|
|
||||||
return toAjax(sysDishesService.deleteSysDishesByIds(ids));
|
return toAjax(sysDishesService.deleteSysDishesByIds(ids));
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -45,6 +45,14 @@ public class SysIngredientController extends BaseController
|
|||||||
return getDataTable(list);
|
return getDataTable(list);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@PreAuthorize("@ss.hasPermi('custom:ingredient:list')")
|
||||||
|
@PostMapping("/listAll")
|
||||||
|
public TableDataInfo listAll(@RequestBody SysIngredient sysIngredient)
|
||||||
|
{
|
||||||
|
List<SysIngredient> list = sysIngredientService.selectSysIngredientList(sysIngredient);
|
||||||
|
return getDataTable(list);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 导出食材列表
|
* 导出食材列表
|
||||||
*/
|
*/
|
||||||
|
@ -5,6 +5,8 @@ import org.apache.commons.lang3.builder.ToStringStyle;
|
|||||||
import com.stdiet.common.annotation.Excel;
|
import com.stdiet.common.annotation.Excel;
|
||||||
import com.stdiet.common.core.domain.BaseEntity;
|
import com.stdiet.common.core.domain.BaseEntity;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 菜品对象 sys_dishes
|
* 菜品对象 sys_dishes
|
||||||
*
|
*
|
||||||
@ -30,6 +32,8 @@ public class SysDishes extends BaseEntity
|
|||||||
@Excel(name = "做法")
|
@Excel(name = "做法")
|
||||||
private String methods;
|
private String methods;
|
||||||
|
|
||||||
|
private List<SysDishesIngredient> igdList;
|
||||||
|
|
||||||
public void setId(Long id)
|
public void setId(Long id)
|
||||||
{
|
{
|
||||||
this.id = id;
|
this.id = id;
|
||||||
@ -67,6 +71,14 @@ public class SysDishes extends BaseEntity
|
|||||||
return methods;
|
return methods;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setIgdList(List<SysDishesIngredient> ingredientList) {
|
||||||
|
this.igdList = ingredientList;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<SysDishesIngredient> getIgdList() {
|
||||||
|
return igdList;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
|
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
|
||||||
|
@ -0,0 +1,76 @@
|
|||||||
|
package com.stdiet.custom.domain;
|
||||||
|
|
||||||
|
import org.apache.commons.lang3.builder.ToStringBuilder;
|
||||||
|
import org.apache.commons.lang3.builder.ToStringStyle;
|
||||||
|
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 菜品对象 sys_dishes
|
||||||
|
*
|
||||||
|
* @author wonder
|
||||||
|
* @date 2020-12-28
|
||||||
|
*/
|
||||||
|
public class SysDishesIngredient extends SysIngredient {
|
||||||
|
|
||||||
|
private Long ingredientId;
|
||||||
|
|
||||||
|
private Long dishesId;
|
||||||
|
|
||||||
|
private Long cusUnit;
|
||||||
|
|
||||||
|
private BigDecimal cusWeight;
|
||||||
|
|
||||||
|
private BigDecimal weight;
|
||||||
|
|
||||||
|
public Long getIngredientId() {
|
||||||
|
return ingredientId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setIngredientId(Long ingredientId) {
|
||||||
|
this.ingredientId = ingredientId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Long getDishesId() {
|
||||||
|
return dishesId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDishesId(Long dishesId) {
|
||||||
|
this.dishesId = dishesId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public BigDecimal getWeight() {
|
||||||
|
return weight;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setWeight(BigDecimal weight) {
|
||||||
|
this.weight = weight;
|
||||||
|
}
|
||||||
|
|
||||||
|
public BigDecimal getCusWeight() {
|
||||||
|
return cusWeight;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCusWeight(BigDecimal cusWeight) {
|
||||||
|
this.cusWeight = cusWeight;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Long getCusUnit() {
|
||||||
|
return cusUnit;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCusUnit(Long cusUnit) {
|
||||||
|
this.cusUnit = cusUnit;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE)
|
||||||
|
.append("ingredientId", getIngredientId())
|
||||||
|
.append("dishesId", getDishesId())
|
||||||
|
.append("weight", getWeight())
|
||||||
|
.append("cusWeight", getCusWeight())
|
||||||
|
.append("cusUnit", getCusUnit())
|
||||||
|
.toString();
|
||||||
|
}
|
||||||
|
}
|
@ -33,24 +33,6 @@ public class SysIngredient extends BaseEntity {
|
|||||||
@Excel(name = "食材类别")
|
@Excel(name = "食材类别")
|
||||||
private String type;
|
private String type;
|
||||||
|
|
||||||
/**
|
|
||||||
* 推荐分量估算
|
|
||||||
*/
|
|
||||||
@Excel(name = "推荐分量估算")
|
|
||||||
private Long recEstimation;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 推荐分量估算单位id
|
|
||||||
*/
|
|
||||||
@Excel(name = "推荐分量估算单位id")
|
|
||||||
private Long recEstUnit;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 推荐分量
|
|
||||||
*/
|
|
||||||
@Excel(name = "推荐分量")
|
|
||||||
private Long recPortion;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 蛋白质比例
|
* 蛋白质比例
|
||||||
*/
|
*/
|
||||||
@ -123,30 +105,6 @@ public class SysIngredient extends BaseEntity {
|
|||||||
this.type = type;
|
this.type = type;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Long getRecEstimation() {
|
|
||||||
return recEstimation;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setRecEstimation(Long recEstimation) {
|
|
||||||
this.recEstimation = recEstimation;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Long getRecEstUnit() {
|
|
||||||
return recEstUnit;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setRecEstUnit(Long recEstUnit) {
|
|
||||||
this.recEstUnit = recEstUnit;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Long getRecPortion() {
|
|
||||||
return recPortion;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setRecPortion(Long recPortion) {
|
|
||||||
this.recPortion = recPortion;
|
|
||||||
}
|
|
||||||
|
|
||||||
public BigDecimal getProteinRatio() {
|
public BigDecimal getProteinRatio() {
|
||||||
return proteinRatio;
|
return proteinRatio;
|
||||||
}
|
}
|
||||||
@ -201,9 +159,6 @@ public class SysIngredient extends BaseEntity {
|
|||||||
.append("id", getId())
|
.append("id", getId())
|
||||||
.append("name", getName())
|
.append("name", getName())
|
||||||
.append("type", getType())
|
.append("type", getType())
|
||||||
.append("recEstimation", getRecEstimation())
|
|
||||||
.append("recEstUnit", getRecEstUnit())
|
|
||||||
.append("recPortion", getRecPortion())
|
|
||||||
.append("proteinRatio", getProteinRatio())
|
.append("proteinRatio", getProteinRatio())
|
||||||
.append("fatRatio", getFatRatio())
|
.append("fatRatio", getFatRatio())
|
||||||
.append("carbonRatio", getCarbonRatio())
|
.append("carbonRatio", getCarbonRatio())
|
||||||
|
@ -1,7 +1,11 @@
|
|||||||
package com.stdiet.custom.mapper;
|
package com.stdiet.custom.mapper;
|
||||||
|
|
||||||
|
import java.lang.reflect.Array;
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import com.stdiet.custom.domain.SysDishes;
|
import com.stdiet.custom.domain.SysDishes;
|
||||||
|
import com.stdiet.custom.domain.SysDishesIngredient;
|
||||||
|
import com.stdiet.custom.domain.SysIngredient;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 菜品Mapper接口
|
* 菜品Mapper接口
|
||||||
@ -19,6 +23,8 @@ public interface SysDishesMapper
|
|||||||
*/
|
*/
|
||||||
public SysDishes selectSysDishesById(Long id);
|
public SysDishes selectSysDishesById(Long id);
|
||||||
|
|
||||||
|
public ArrayList<SysDishesIngredient> selectSysIngreditentsById(Long id);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询菜品列表
|
* 查询菜品列表
|
||||||
*
|
*
|
||||||
@ -58,4 +64,10 @@ public interface SysDishesMapper
|
|||||||
* @return 结果
|
* @return 结果
|
||||||
*/
|
*/
|
||||||
public int deleteSysDishesByIds(Long[] ids);
|
public int deleteSysDishesByIds(Long[] ids);
|
||||||
|
|
||||||
|
public int deleteIngredientById(Long id);
|
||||||
|
|
||||||
|
public int deleteIngredientByIds(Long[] ids);
|
||||||
|
|
||||||
|
public int bashInsertDishesIngredent(List<SysDishesIngredient> sysDishesIngredients);
|
||||||
}
|
}
|
@ -68,4 +68,8 @@ public interface SysIngredientMapper
|
|||||||
public int deleteIngredentRecByIngredientId(Long recId);
|
public int deleteIngredentRecByIngredientId(Long recId);
|
||||||
|
|
||||||
public int deleteIngredentNotRecByIngredientId(Long notRecId);
|
public int deleteIngredentNotRecByIngredientId(Long notRecId);
|
||||||
|
|
||||||
|
public int deleteIngredentRecByIngredientIds(Long[] id);
|
||||||
|
|
||||||
|
public int deleteIngredentNotRecByIngredientIds(Long[] id);
|
||||||
}
|
}
|
@ -2,6 +2,8 @@ package com.stdiet.custom.service;
|
|||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import com.stdiet.custom.domain.SysDishes;
|
import com.stdiet.custom.domain.SysDishes;
|
||||||
|
import com.stdiet.custom.domain.SysDishesIngredient;
|
||||||
|
import com.stdiet.custom.domain.SysIngredient;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 菜品Service接口
|
* 菜品Service接口
|
||||||
@ -19,6 +21,8 @@ public interface ISysDishesService
|
|||||||
*/
|
*/
|
||||||
public SysDishes selectSysDishesById(Long id);
|
public SysDishes selectSysDishesById(Long id);
|
||||||
|
|
||||||
|
public List<SysDishesIngredient> selectSysIngreditentsById(Long id);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询菜品列表
|
* 查询菜品列表
|
||||||
*
|
*
|
||||||
|
@ -1,12 +1,16 @@
|
|||||||
package com.stdiet.custom.service.impl;
|
package com.stdiet.custom.service.impl;
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
import com.stdiet.common.utils.DateUtils;
|
import com.stdiet.common.utils.DateUtils;
|
||||||
|
import com.stdiet.common.utils.StringUtils;
|
||||||
|
import com.stdiet.custom.domain.SysDishes;
|
||||||
|
import com.stdiet.custom.domain.SysDishesIngredient;
|
||||||
|
import com.stdiet.custom.mapper.SysDishesMapper;
|
||||||
|
import com.stdiet.custom.service.ISysDishesService;
|
||||||
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 com.stdiet.custom.mapper.SysDishesMapper;
|
|
||||||
import com.stdiet.custom.domain.SysDishes;
|
import java.util.ArrayList;
|
||||||
import com.stdiet.custom.service.ISysDishesService;
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 菜品Service业务层处理
|
* 菜品Service业务层处理
|
||||||
@ -15,8 +19,7 @@ import com.stdiet.custom.service.ISysDishesService;
|
|||||||
* @date 2020-12-28
|
* @date 2020-12-28
|
||||||
*/
|
*/
|
||||||
@Service
|
@Service
|
||||||
public class SysDishesServiceImpl implements ISysDishesService
|
public class SysDishesServiceImpl implements ISysDishesService {
|
||||||
{
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private SysDishesMapper sysDishesMapper;
|
private SysDishesMapper sysDishesMapper;
|
||||||
|
|
||||||
@ -27,9 +30,23 @@ public class SysDishesServiceImpl implements ISysDishesService
|
|||||||
* @return 菜品
|
* @return 菜品
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public SysDishes selectSysDishesById(Long id)
|
public SysDishes selectSysDishesById(Long id) {
|
||||||
{
|
SysDishes dishes = sysDishesMapper.selectSysDishesById(id);
|
||||||
return sysDishesMapper.selectSysDishesById(id);
|
if (StringUtils.isNotNull(dishes)) {
|
||||||
|
List<SysDishesIngredient> ingredientArray = selectSysIngreditentsById(id);
|
||||||
|
if (StringUtils.isNull(ingredientArray)) {
|
||||||
|
dishes.setIgdList(new ArrayList<>());
|
||||||
|
} else {
|
||||||
|
dishes.setIgdList(ingredientArray);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
return dishes;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<SysDishesIngredient> selectSysIngreditentsById(Long id) {
|
||||||
|
return sysDishesMapper.selectSysIngreditentsById(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -39,8 +56,7 @@ public class SysDishesServiceImpl implements ISysDishesService
|
|||||||
* @return 菜品
|
* @return 菜品
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public List<SysDishes> selectSysDishesList(SysDishes sysDishes)
|
public List<SysDishes> selectSysDishesList(SysDishes sysDishes) {
|
||||||
{
|
|
||||||
return sysDishesMapper.selectSysDishesList(sysDishes);
|
return sysDishesMapper.selectSysDishesList(sysDishes);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -51,10 +67,23 @@ public class SysDishesServiceImpl implements ISysDishesService
|
|||||||
* @return 结果
|
* @return 结果
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public int insertSysDishes(SysDishes sysDishes)
|
public int insertSysDishes(SysDishes sysDishes) {
|
||||||
{
|
|
||||||
sysDishes.setCreateTime(DateUtils.getNowDate());
|
sysDishes.setCreateTime(DateUtils.getNowDate());
|
||||||
return sysDishesMapper.insertSysDishes(sysDishes);
|
int rows = sysDishesMapper.insertSysDishes(sysDishes);
|
||||||
|
//
|
||||||
|
insertDishesIngredient(sysDishes);
|
||||||
|
return rows;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void insertDishesIngredient(SysDishes sysDishes) {
|
||||||
|
if (StringUtils.isNotNull(sysDishes.getIgdList())) {
|
||||||
|
List<SysDishesIngredient> list = sysDishes.getIgdList();
|
||||||
|
for (SysDishesIngredient dishesIngredient : list) {
|
||||||
|
dishesIngredient.setDishesId(sysDishes.getId());
|
||||||
|
dishesIngredient.setIngredientId(dishesIngredient.getId());
|
||||||
|
}
|
||||||
|
sysDishesMapper.bashInsertDishesIngredent(list);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -64,9 +93,11 @@ public class SysDishesServiceImpl implements ISysDishesService
|
|||||||
* @return 结果
|
* @return 结果
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public int updateSysDishes(SysDishes sysDishes)
|
public int updateSysDishes(SysDishes sysDishes) {
|
||||||
{
|
|
||||||
sysDishes.setUpdateTime(DateUtils.getNowDate());
|
sysDishes.setUpdateTime(DateUtils.getNowDate());
|
||||||
|
Long dishesId = sysDishes.getId();
|
||||||
|
sysDishesMapper.deleteIngredientById(dishesId);
|
||||||
|
insertDishesIngredient(sysDishes);
|
||||||
return sysDishesMapper.updateSysDishes(sysDishes);
|
return sysDishesMapper.updateSysDishes(sysDishes);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -77,8 +108,8 @@ public class SysDishesServiceImpl implements ISysDishesService
|
|||||||
* @return 结果
|
* @return 结果
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public int deleteSysDishesByIds(Long[] ids)
|
public int deleteSysDishesByIds(Long[] ids) {
|
||||||
{
|
sysDishesMapper.deleteIngredientByIds(ids);
|
||||||
return sysDishesMapper.deleteSysDishesByIds(ids);
|
return sysDishesMapper.deleteSysDishesByIds(ids);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -89,8 +120,8 @@ public class SysDishesServiceImpl implements ISysDishesService
|
|||||||
* @return 结果
|
* @return 结果
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public int deleteSysDishesById(Long id)
|
public int deleteSysDishesById(Long id) {
|
||||||
{
|
sysDishesMapper.deleteIngredientById(id);
|
||||||
return sysDishesMapper.deleteSysDishesById(id);
|
return sysDishesMapper.deleteSysDishesById(id);
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -128,6 +128,8 @@ public class SysIngredientServiceImpl implements ISysIngredientService {
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public int deleteSysIngredientByIds(Long[] ids) {
|
public int deleteSysIngredientByIds(Long[] ids) {
|
||||||
|
sysIngredientMapper.deleteIngredentRecByIngredientIds(ids);
|
||||||
|
sysIngredientMapper.deleteIngredentNotRecByIngredientIds(ids);
|
||||||
return sysIngredientMapper.deleteSysIngredientByIds(ids);
|
return sysIngredientMapper.deleteSysIngredientByIds(ids);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -15,6 +15,21 @@
|
|||||||
<result property="updateTime" column="update_time" />
|
<result property="updateTime" column="update_time" />
|
||||||
</resultMap>
|
</resultMap>
|
||||||
|
|
||||||
|
<resultMap type="SysDishesIngredient" id="SysDishesIngredientResult">
|
||||||
|
<result property="id" column="id" />
|
||||||
|
<result property="name" column="name" />
|
||||||
|
<result property="type" column="type" />
|
||||||
|
<result property="proteinRatio" column="protein_ratio" />
|
||||||
|
<result property="fatRatio" column="fat_ratio" />
|
||||||
|
<result property="carbonRatio" column="carbon_ratio" />
|
||||||
|
<result property="area" column="area" />
|
||||||
|
<result property="rec" column="rec" />
|
||||||
|
<result property="notRec" column="not_rec" />
|
||||||
|
<result property="cusWeight" column="cus_weight" />
|
||||||
|
<result property="cusUnit" column="cus_unit" />
|
||||||
|
<result property="weight" column="weight" />
|
||||||
|
</resultMap>
|
||||||
|
|
||||||
<sql id="selectSysDishesVo">
|
<sql id="selectSysDishesVo">
|
||||||
select id, name, type, methods, create_by, create_time, update_by, update_time from sys_dishes
|
select id, name, type, methods, create_by, create_time, update_by, update_time from sys_dishes
|
||||||
</sql>
|
</sql>
|
||||||
@ -27,6 +42,38 @@
|
|||||||
</where>
|
</where>
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
|
<sql id="selectSysIngreditentsByIdVo">
|
||||||
|
SELECT * FROM(
|
||||||
|
SELECT ingredient_id AS id, ingredient_weight AS weight, cus_weight, cus_unit
|
||||||
|
FROM sys_dishes_ingredient
|
||||||
|
WHERE dishes_id = #{id}
|
||||||
|
) dishes
|
||||||
|
LEFT JOIN (
|
||||||
|
SELECT id, name, type, protein_ratio, fat_ratio, carbon_ratio, area, not_rec, rec
|
||||||
|
FROM sys_ingredient igd
|
||||||
|
LEFT JOIN (
|
||||||
|
SELECT ingredient_id as id, GROUP_CONCAT(name SEPARATOR ',') not_rec FROM(
|
||||||
|
SELECT physical_signs_id as id, ingredient_id
|
||||||
|
FROM sys_ingredient_not_rec
|
||||||
|
) notRec JOIN sys_physical_signs phy USING(id)
|
||||||
|
GROUP BY id
|
||||||
|
) notRecT USING(id)
|
||||||
|
LEFT JOIN (
|
||||||
|
SELECT ingredient_id as id, GROUP_CONCAT(name SEPARATOR ',') rec FROM(
|
||||||
|
SELECT physical_signs_id as id, ingredient_id
|
||||||
|
FROM sys_ingredient_rec
|
||||||
|
) rec JOIN sys_physical_signs phy USING(id)
|
||||||
|
GROUP BY id
|
||||||
|
) recT USING(id)
|
||||||
|
) ing USING(id)
|
||||||
|
</sql>
|
||||||
|
|
||||||
|
<select id="selectSysIngreditentsById" parameterType="Long" resultMap="SysDishesIngredientResult">
|
||||||
|
<include refid="selectSysIngreditentsByIdVo" >
|
||||||
|
<property name="id" value="#{id}"/>
|
||||||
|
</include>
|
||||||
|
</select>
|
||||||
|
|
||||||
<select id="selectSysDishesById" parameterType="Long" resultMap="SysDishesResult">
|
<select id="selectSysDishesById" parameterType="Long" resultMap="SysDishesResult">
|
||||||
<include refid="selectSysDishesVo"/>
|
<include refid="selectSysDishesVo"/>
|
||||||
where id = #{id}
|
where id = #{id}
|
||||||
@ -79,4 +126,22 @@
|
|||||||
</foreach>
|
</foreach>
|
||||||
</delete>
|
</delete>
|
||||||
|
|
||||||
|
<delete id="deleteIngredientById" parameterType="Long">
|
||||||
|
delete from sys_dishes_ingredient where dishes_id = #{id}
|
||||||
|
</delete>
|
||||||
|
|
||||||
|
<delete id="deleteIngredientByIds" parameterType="String">
|
||||||
|
delete from sys_dishes_ingredient where dishes_id in
|
||||||
|
<foreach item="id" collection="array" open="(" separator="," close=")">
|
||||||
|
#{id}
|
||||||
|
</foreach>
|
||||||
|
</delete>
|
||||||
|
|
||||||
|
<insert id="bashInsertDishesIngredent">
|
||||||
|
insert into sys_dishes_ingredient(dishes_id, ingredient_id, ingredient_weight, cus_unit, cus_weight) values
|
||||||
|
<foreach collection="list" separator="," item="item" index="index">
|
||||||
|
(#{item.dishesId}, #{item.ingredientId}, #{item.weight}, #{item.cusUnit}, #{item.cusWeight})
|
||||||
|
</foreach>
|
||||||
|
</insert>
|
||||||
|
|
||||||
</mapper>
|
</mapper>
|
@ -159,6 +159,20 @@
|
|||||||
delete from sys_ingredient_not_rec where ingredient_id=#{ingredientId}
|
delete from sys_ingredient_not_rec where ingredient_id=#{ingredientId}
|
||||||
</delete>
|
</delete>
|
||||||
|
|
||||||
|
<delete id="deleteIngredentRecByIngredientIds" parameterType="Long">
|
||||||
|
delete from sys_ingredient_rec where ingredient_id in
|
||||||
|
<foreach item="id" collection="array" open="(" separator="," close=")">
|
||||||
|
#{id}
|
||||||
|
</foreach>
|
||||||
|
</delete>
|
||||||
|
|
||||||
|
<delete id="deleteIngredentNotRecByIngredientIds" parameterType="String">
|
||||||
|
delete from sys_ingredient_not_rec where ingredient_id in
|
||||||
|
<foreach item="id" collection="array" open="(" separator="," close=")">
|
||||||
|
#{id}
|
||||||
|
</foreach>
|
||||||
|
</delete>
|
||||||
|
|
||||||
<update id="updateSysIngredient" parameterType="SysIngredient">
|
<update id="updateSysIngredient" parameterType="SysIngredient">
|
||||||
update sys_ingredient
|
update sys_ingredient
|
||||||
<trim prefix="SET" suffixOverrides=",">
|
<trim prefix="SET" suffixOverrides=",">
|
||||||
|
@ -14,6 +14,19 @@ export function listIngredient(query) {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function listAllIngredient(query) {
|
||||||
|
const {recIds, notRecIds} = query;
|
||||||
|
return request({
|
||||||
|
url: '/custom/ingredient/listAll',
|
||||||
|
method: 'post',
|
||||||
|
data: {
|
||||||
|
...query,
|
||||||
|
recIds: recIds && recIds.length ? recIds : null,
|
||||||
|
notRecIds: notRecIds && notRecIds.length ? notRecIds : null,
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
// 查询食材详细
|
// 查询食材详细
|
||||||
export function getIngredient(id) {
|
export function getIngredient(id) {
|
||||||
return request({
|
return request({
|
||||||
|
@ -11,7 +11,7 @@
|
|||||||
/>
|
/>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item label="菜品类型" prop="type">
|
<el-form-item label="菜品类型" prop="type">
|
||||||
<el-select v-model="queryParams.type" placeholder="请选择菜品类型" clearable size="small">
|
<el-select v-model="queryParams.type" multiple placeholder="请选择菜品类型" clearable size="small">
|
||||||
<el-option
|
<el-option
|
||||||
v-for="dict in typeOptions"
|
v-for="dict in typeOptions"
|
||||||
:key="dict.dictValue"
|
:key="dict.dictValue"
|
||||||
@ -34,7 +34,8 @@
|
|||||||
size="mini"
|
size="mini"
|
||||||
@click="handleAdd"
|
@click="handleAdd"
|
||||||
v-hasPermi="['custom:dishes:add']"
|
v-hasPermi="['custom:dishes:add']"
|
||||||
>新增</el-button>
|
>新增
|
||||||
|
</el-button>
|
||||||
</el-col>
|
</el-col>
|
||||||
<el-col :span="1.5">
|
<el-col :span="1.5">
|
||||||
<el-button
|
<el-button
|
||||||
@ -43,17 +44,42 @@
|
|||||||
size="mini"
|
size="mini"
|
||||||
@click="handleExport"
|
@click="handleExport"
|
||||||
v-hasPermi="['custom:dishes:export']"
|
v-hasPermi="['custom:dishes:export']"
|
||||||
>导出</el-button>
|
>导出
|
||||||
|
</el-button>
|
||||||
</el-col>
|
</el-col>
|
||||||
<right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
|
<right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
|
||||||
</el-row>
|
</el-row>
|
||||||
|
|
||||||
<el-table v-loading="loading" :data="dishesList" @selection-change="handleSelectionChange">
|
<el-table v-loading="loading" :data="dishesList" @selection-change="handleSelectionChange">
|
||||||
<!-- <el-table-column type="selection" width="55" align="center" />-->
|
<!-- <el-table-column type="selection" width="55" align="center" />-->
|
||||||
<!-- <el-table-column label="id" align="center" prop="id" />-->
|
<!-- <el-table-column label="id" align="center" prop="id" />-->
|
||||||
<el-table-column label="菜品名称" align="center" prop="name" />
|
<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="type" :formatter="typeFormat"/>
|
||||||
<el-table-column label="做法" align="center" prop="methods" />
|
<el-table-column label="包含食材" align="center">
|
||||||
|
<template slot-scope="scope">
|
||||||
|
<div v-for="igd in scope.row.igdList"
|
||||||
|
:key="igd.id">
|
||||||
|
{{igd.name}}
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
<el-table-column label="推荐人群" align="center">
|
||||||
|
<template slot-scope="scope">
|
||||||
|
<div v-for="tag in scope.row.recTags"
|
||||||
|
:key="tag">
|
||||||
|
{{tag}}
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
<el-table-column label="忌口人群" align="center">
|
||||||
|
<template slot-scope="scope">
|
||||||
|
<div v-for="tag in scope.row.notRecTags"
|
||||||
|
:key="tag">
|
||||||
|
{{tag}}
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
<el-table-column label="做法" align="center" prop="methods"/>
|
||||||
<el-table-column label="操作" align="center" class-name="small-padding fixed-width">
|
<el-table-column label="操作" align="center" class-name="small-padding fixed-width">
|
||||||
<template slot-scope="scope">
|
<template slot-scope="scope">
|
||||||
<el-button
|
<el-button
|
||||||
@ -62,14 +88,16 @@
|
|||||||
icon="el-icon-edit"
|
icon="el-icon-edit"
|
||||||
@click="handleUpdate(scope.row)"
|
@click="handleUpdate(scope.row)"
|
||||||
v-hasPermi="['custom:dishes:edit']"
|
v-hasPermi="['custom:dishes:edit']"
|
||||||
>修改</el-button>
|
>修改
|
||||||
|
</el-button>
|
||||||
<el-button
|
<el-button
|
||||||
size="mini"
|
size="mini"
|
||||||
type="text"
|
type="text"
|
||||||
icon="el-icon-delete"
|
icon="el-icon-delete"
|
||||||
@click="handleDelete(scope.row)"
|
@click="handleDelete(scope.row)"
|
||||||
v-hasPermi="['custom:dishes:remove']"
|
v-hasPermi="['custom:dishes:remove']"
|
||||||
>删除</el-button>
|
>删除
|
||||||
|
</el-button>
|
||||||
</template>
|
</template>
|
||||||
</el-table-column>
|
</el-table-column>
|
||||||
</el-table>
|
</el-table>
|
||||||
@ -83,59 +111,150 @@
|
|||||||
/>
|
/>
|
||||||
|
|
||||||
<!-- 添加或修改菜品对话框 -->
|
<!-- 添加或修改菜品对话框 -->
|
||||||
<el-dialog :title="title" :visible.sync="open" width="720px" append-to-body>
|
<el-drawer :title="title" :visible.sync="open" size="50%">
|
||||||
<el-form ref="form" :model="form" :rules="rules" label-width="80px">
|
<div class="drawer_content">
|
||||||
<el-form-item label="菜品名称" prop="name">
|
<el-form ref="form" :model="form" :rules="rules" label-width="80px">
|
||||||
<el-input v-model="form.name" placeholder="请输入菜品名称" />
|
<el-form-item label="菜品名称" prop="name">
|
||||||
</el-form-item>
|
<el-input v-model="form.name" placeholder="请输入菜品名称"/>
|
||||||
<el-form-item label="菜品类型" prop="type">
|
</el-form-item>
|
||||||
<el-select v-model="form.type" placeholder="请选择菜品类型">
|
<el-form-item label="菜品类型" prop="type">
|
||||||
<el-option
|
<el-select v-model="form.type" placeholder="请选择菜品类型">
|
||||||
v-for="dict in typeOptions"
|
<el-option
|
||||||
:key="dict.dictValue"
|
v-for="dict in typeOptions"
|
||||||
:label="dict.dictLabel"
|
:key="dict.dictValue"
|
||||||
:value="dict.dictValue"
|
:label="dict.dictLabel"
|
||||||
></el-option>
|
:value="dict.dictValue"
|
||||||
</el-select>
|
></el-option>
|
||||||
</el-form-item>
|
</el-select>
|
||||||
<el-form-item label="食材" prop="ingIds">
|
</el-form-item>
|
||||||
<el-transfer
|
<el-form-item label="食材" prop="ingIds">
|
||||||
style="text-align: left; display: inline-block"
|
<el-transfer
|
||||||
v-model="form.ingIds"
|
style="text-align: left; display: inline-block"
|
||||||
filterable
|
v-model="selIngIds"
|
||||||
:render-content="renderFunc"
|
size="mini"
|
||||||
:titles="['备选', '已选']"
|
filterable
|
||||||
:button-texts="['', '']"
|
:titles="['备选', '已选']"
|
||||||
:format="{
|
:button-texts="['', '']"
|
||||||
|
:format="{
|
||||||
noChecked: '${total}',
|
noChecked: '${total}',
|
||||||
hasChecked: '${checked}/${total}',
|
hasChecked: '${checked}/${total}',
|
||||||
}"
|
}"
|
||||||
@change="handleChange"
|
@change="handleChange"
|
||||||
:data="data"
|
:data="ingDataList"
|
||||||
>
|
>
|
||||||
<el-select class="transfer-footer" slot="left-footer" size="small"
|
<el-select
|
||||||
v-model="ingType"
|
class="transfer-footer"
|
||||||
v-for="dict in ingTypeOptions"
|
slot="left-footer"
|
||||||
:key="dict.dictValue"
|
size="small"
|
||||||
:label="dict.dictLabel"
|
filterable
|
||||||
:value="dict.dictValue"/>
|
v-model="ingType"
|
||||||
<div class="transfer-footer" slot="right-footer" size="small" />
|
@change="handleOnTypeChange">
|
||||||
</el-transfer>
|
<el-option
|
||||||
</el-form-item>
|
v-for="dict in ingTypeOptions"
|
||||||
<el-form-item label="做法" prop="methods">
|
:key="dict.dictValue"
|
||||||
<el-input v-model="form.methods" type="textarea" placeholder="请输入内容" />
|
:label="dict.dictLabel"
|
||||||
</el-form-item>
|
:value="dict.dictValue"/>
|
||||||
</el-form>
|
</el-select>
|
||||||
<div slot="footer" class="dialog-footer">
|
<div class="transfer-footer" slot="right-footer" size="small"/>
|
||||||
<el-button type="primary" @click="submitForm">确 定</el-button>
|
</el-transfer>
|
||||||
<el-button @click="cancel">取 消</el-button>
|
</el-form-item>
|
||||||
|
<el-form-item label="分量" prop="weight">
|
||||||
|
<el-table
|
||||||
|
:data="selTableData"
|
||||||
|
border
|
||||||
|
show-summary
|
||||||
|
size="mini"
|
||||||
|
:summary-method="getSummaries"
|
||||||
|
style="width: 100%">
|
||||||
|
<el-table-column
|
||||||
|
prop="name"
|
||||||
|
label="食材">
|
||||||
|
</el-table-column>
|
||||||
|
<el-table-column label="通俗计量">
|
||||||
|
<template slot-scope="scope">
|
||||||
|
<span class="cus-unit">
|
||||||
|
<el-input-number
|
||||||
|
v-model="scope.row.cusWeight"
|
||||||
|
size="small"
|
||||||
|
controls-position="right"
|
||||||
|
step="0.5"
|
||||||
|
:min="0.5"/>
|
||||||
|
<el-select
|
||||||
|
size="small"
|
||||||
|
v-model="scope.row.cusUnit"
|
||||||
|
>
|
||||||
|
<el-option
|
||||||
|
v-for="dict in cusUnitOptions"
|
||||||
|
:key="dict.dictValue"
|
||||||
|
:label="dict.dictLabel"
|
||||||
|
:value="parseInt(dict.dictValue)"
|
||||||
|
/>
|
||||||
|
</el-select>
|
||||||
|
</span>
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
<el-table-column
|
||||||
|
prop="weight"
|
||||||
|
label="重量(g)">
|
||||||
|
<template slot-scope="scope">
|
||||||
|
<el-input-number
|
||||||
|
class="weight"
|
||||||
|
v-model="scope.row.weight"
|
||||||
|
size="mini"
|
||||||
|
controls-position="right"
|
||||||
|
@change="handleInputChange"
|
||||||
|
:min="0"
|
||||||
|
step="50"/>
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
<el-table-column
|
||||||
|
prop="proteinRatio"
|
||||||
|
label="P/100g">
|
||||||
|
</el-table-column>
|
||||||
|
<el-table-column
|
||||||
|
prop="fatRatio"
|
||||||
|
label="F/100g">
|
||||||
|
</el-table-column>
|
||||||
|
<el-table-column
|
||||||
|
prop="carbonRatio"
|
||||||
|
label="C/100g">
|
||||||
|
</el-table-column>
|
||||||
|
</el-table>
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="推荐人群">
|
||||||
|
<el-tag
|
||||||
|
style="margin-right: 4px"
|
||||||
|
v-for="rec in selRec"
|
||||||
|
:key="rec"
|
||||||
|
type="success">
|
||||||
|
{{rec}}
|
||||||
|
</el-tag>
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="忌口人群">
|
||||||
|
<el-tag
|
||||||
|
style="margin-right: 4px"
|
||||||
|
v-for="notRec in selNotRec"
|
||||||
|
:key="notRec"
|
||||||
|
type="danger">
|
||||||
|
{{notRec}}
|
||||||
|
</el-tag>
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="做法" prop="methods">
|
||||||
|
<el-input v-model="form.methods" type="textarea" placeholder="请输入内容" rows="4"/>
|
||||||
|
</el-form-item>
|
||||||
|
</el-form>
|
||||||
|
<div slot="footer" class="dialog-footer">
|
||||||
|
<el-button type="primary" @click="submitForm">确 定</el-button>
|
||||||
|
<el-button @click="cancel">取 消</el-button>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</el-dialog>
|
</el-drawer>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import { listDishes, getDishes, delDishes, addDishes, updateDishes, exportDishes } from "@/api/custom/dishes";
|
import {addDishes, delDishes, exportDishes, getDishes, listDishes, updateDishes} from "@/api/custom/dishes";
|
||||||
|
import {listAllIngredient} from "@/api/custom/ingredient";
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: "Dishes",
|
name: "Dishes",
|
||||||
@ -159,11 +278,27 @@
|
|||||||
title: "",
|
title: "",
|
||||||
// 是否显示弹出层
|
// 是否显示弹出层
|
||||||
open: false,
|
open: false,
|
||||||
ingType: 1,
|
ingType: '1',
|
||||||
// 食材类别字典
|
// 食材类别字典
|
||||||
ingTypeOptions: [],
|
ingTypeOptions: [],
|
||||||
|
// 远程数据缓存,预防新增的食材找不到
|
||||||
|
oriDataList: [],
|
||||||
|
// 备选食材列表
|
||||||
|
ingDataList: [],
|
||||||
|
// 选中的食材列表
|
||||||
|
selIngList: [],
|
||||||
|
//
|
||||||
|
selRec: [],
|
||||||
|
//
|
||||||
|
selNotRec: [],
|
||||||
|
// 选中的食材id
|
||||||
|
selIngIds: [],
|
||||||
|
// 选中的食材分量列表
|
||||||
|
selTableData: [],
|
||||||
// 菜品类别字典
|
// 菜品类别字典
|
||||||
typeOptions: [],
|
typeOptions: [],
|
||||||
|
// 通俗单位
|
||||||
|
cusUnitOptions: [],
|
||||||
// 查询参数
|
// 查询参数
|
||||||
queryParams: {
|
queryParams: {
|
||||||
pageNum: 1,
|
pageNum: 1,
|
||||||
@ -174,8 +309,7 @@
|
|||||||
// 表单参数
|
// 表单参数
|
||||||
form: {},
|
form: {},
|
||||||
// 表单校验
|
// 表单校验
|
||||||
rules: {
|
rules: {}
|
||||||
}
|
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
created() {
|
created() {
|
||||||
@ -186,13 +320,40 @@
|
|||||||
this.getDicts("cus_ing_type").then(response => {
|
this.getDicts("cus_ing_type").then(response => {
|
||||||
this.ingTypeOptions = response.data;
|
this.ingTypeOptions = response.data;
|
||||||
});
|
});
|
||||||
|
this.getDicts("cus_cus_unit").then(response => {
|
||||||
|
this.cusUnitOptions = response.data;
|
||||||
|
});
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
/** 查询菜品列表 */
|
/** 查询菜品列表 */
|
||||||
getList() {
|
getList() {
|
||||||
this.loading = true;
|
this.loading = true;
|
||||||
listDishes(this.queryParams).then(response => {
|
listDishes(this.queryParams).then(response => {
|
||||||
this.dishesList = response.rows;
|
this.dishesList = response.rows.map(d => {
|
||||||
|
const recTags = [], notRecTags = [];
|
||||||
|
d.igdList.forEach(igd => {
|
||||||
|
if (igd.rec) {
|
||||||
|
igd.rec.split(',').forEach(rec => {
|
||||||
|
if (!recTags.includes(rec)) {
|
||||||
|
recTags.push(rec)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
if (igd.notRec) {
|
||||||
|
igd.notRec.split(',').forEach(notRec => {
|
||||||
|
if (!notRecTags.includes(notRec)) {
|
||||||
|
notRecTags.push(notRec)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
})
|
||||||
|
return {
|
||||||
|
...d,
|
||||||
|
recTags,
|
||||||
|
notRecTags
|
||||||
|
}
|
||||||
|
});
|
||||||
|
console.log(this.dishesList)
|
||||||
this.total = response.total;
|
this.total = response.total;
|
||||||
this.loading = false;
|
this.loading = false;
|
||||||
});
|
});
|
||||||
@ -201,6 +362,9 @@
|
|||||||
typeFormat(row, column) {
|
typeFormat(row, column) {
|
||||||
return this.selectDictLabel(this.typeOptions, row.type);
|
return this.selectDictLabel(this.typeOptions, row.type);
|
||||||
},
|
},
|
||||||
|
cusUnitFormat(row, column) {
|
||||||
|
return this.selectDictLabel(this.cusUnitOptions, row.type);
|
||||||
|
},
|
||||||
// 取消按钮
|
// 取消按钮
|
||||||
cancel() {
|
cancel() {
|
||||||
this.open = false;
|
this.open = false;
|
||||||
@ -217,8 +381,15 @@
|
|||||||
createTime: null,
|
createTime: null,
|
||||||
updateBy: null,
|
updateBy: null,
|
||||||
updateTime: null,
|
updateTime: null,
|
||||||
ingIds: []
|
igdList: []
|
||||||
};
|
};
|
||||||
|
this.selIngIds = [];
|
||||||
|
this.selIngList = [];
|
||||||
|
this.selTableData = [];
|
||||||
|
this.oriDataList = [];
|
||||||
|
this.selRec = [];
|
||||||
|
this.selNotRec = [];
|
||||||
|
this.ingType = '1';
|
||||||
this.resetForm("form");
|
this.resetForm("form");
|
||||||
},
|
},
|
||||||
/** 搜索按钮操作 */
|
/** 搜索按钮操作 */
|
||||||
@ -234,14 +405,21 @@
|
|||||||
// 多选框选中数据
|
// 多选框选中数据
|
||||||
handleSelectionChange(selection) {
|
handleSelectionChange(selection) {
|
||||||
this.ids = selection.map(item => item.id)
|
this.ids = selection.map(item => item.id)
|
||||||
this.single = selection.length!==1
|
this.single = selection.length !== 1
|
||||||
this.multiple = !selection.length
|
this.multiple = !selection.length
|
||||||
},
|
},
|
||||||
/** 新增按钮操作 */
|
/** 新增按钮操作 */
|
||||||
handleAdd() {
|
handleAdd() {
|
||||||
this.reset();
|
this.reset();
|
||||||
this.open = true;
|
listAllIngredient({type: this.ingType}).then(response => {
|
||||||
this.title = "添加菜品";
|
this.open = true;
|
||||||
|
this.title = "添加菜品";
|
||||||
|
this.oriDataList = response.rows;
|
||||||
|
this.ingDataList = this.oriDataList.map(obj => ({
|
||||||
|
key: obj.id,
|
||||||
|
label: obj.name
|
||||||
|
}))
|
||||||
|
})
|
||||||
},
|
},
|
||||||
/** 修改按钮操作 */
|
/** 修改按钮操作 */
|
||||||
handleUpdate(row) {
|
handleUpdate(row) {
|
||||||
@ -249,14 +427,49 @@
|
|||||||
const id = row.id || this.ids
|
const id = row.id || this.ids
|
||||||
getDishes(id).then(response => {
|
getDishes(id).then(response => {
|
||||||
this.form = response.data;
|
this.form = response.data;
|
||||||
this.open = true;
|
this.form.igdList.forEach(obj => {
|
||||||
this.title = "修改菜品";
|
this.selIngIds.push(obj.id);
|
||||||
|
this.selIngList.push({
|
||||||
|
key: obj.id,
|
||||||
|
label: obj.name
|
||||||
|
});
|
||||||
|
this.selTableData.push(obj)
|
||||||
|
if (obj.rec) {
|
||||||
|
obj.rec.split(',').forEach(rec => {
|
||||||
|
if (!this.selRec.includes(rec)) {
|
||||||
|
this.selRec.push(rec)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
if (obj.notRec) {
|
||||||
|
obj.notRec.split(',').forEach(notRec => {
|
||||||
|
if (!this.selNotRec.includes(notRec)) {
|
||||||
|
this.selNotRec.push(notRec)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
})
|
||||||
|
listAllIngredient({type: this.ingType}).then(res => {
|
||||||
|
this.open = true;
|
||||||
|
this.title = "修改菜品";
|
||||||
|
this.oriDataList = res.rows;
|
||||||
|
this.ingDataList = this.oriDataList.reduce((arr, cur) => {
|
||||||
|
if (!arr.some(({key}) => key === cur.id)) {
|
||||||
|
arr.push({
|
||||||
|
key: cur.id,
|
||||||
|
label: cur.name
|
||||||
|
});
|
||||||
|
}
|
||||||
|
return arr;
|
||||||
|
}, this.selIngList.slice());
|
||||||
|
})
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
/** 提交按钮 */
|
/** 提交按钮 */
|
||||||
submitForm() {
|
submitForm() {
|
||||||
this.$refs["form"].validate(valid => {
|
this.$refs["form"].validate(valid => {
|
||||||
if (valid) {
|
if (valid) {
|
||||||
|
this.form.igdList = this.selTableData;
|
||||||
if (this.form.id != null) {
|
if (this.form.id != null) {
|
||||||
updateDishes(this.form).then(response => {
|
updateDishes(this.form).then(response => {
|
||||||
if (response.code === 200) {
|
if (response.code === 200) {
|
||||||
@ -284,12 +497,13 @@
|
|||||||
confirmButtonText: "确定",
|
confirmButtonText: "确定",
|
||||||
cancelButtonText: "取消",
|
cancelButtonText: "取消",
|
||||||
type: "warning"
|
type: "warning"
|
||||||
}).then(function() {
|
}).then(function () {
|
||||||
return delDishes(ids);
|
return delDishes(ids);
|
||||||
}).then(() => {
|
}).then(() => {
|
||||||
this.getList();
|
this.getList();
|
||||||
this.msgSuccess("删除成功");
|
this.msgSuccess("删除成功");
|
||||||
}).catch(function() {});
|
}).catch(function () {
|
||||||
|
});
|
||||||
},
|
},
|
||||||
/** 导出按钮操作 */
|
/** 导出按钮操作 */
|
||||||
handleExport() {
|
handleExport() {
|
||||||
@ -298,20 +512,153 @@
|
|||||||
confirmButtonText: "确定",
|
confirmButtonText: "确定",
|
||||||
cancelButtonText: "取消",
|
cancelButtonText: "取消",
|
||||||
type: "warning"
|
type: "warning"
|
||||||
}).then(function() {
|
}).then(function () {
|
||||||
return exportDishes(queryParams);
|
return exportDishes(queryParams);
|
||||||
}).then(response => {
|
}).then(response => {
|
||||||
this.download(response.msg);
|
this.download(response.msg);
|
||||||
}).catch(function() {});
|
}).catch(function () {
|
||||||
|
});
|
||||||
},
|
},
|
||||||
renderFunc(h, option) {
|
handleChange(value, direction, movedKeys) {
|
||||||
if (this.form.ingIds.includes(option.key)) {
|
// console.log({oriIgdList: this.oriDataList, selIgdList: this.form.igdList});
|
||||||
return <span>
|
const newTableData = [];
|
||||||
{option.key} - {option.label}
|
this.selRec = [];
|
||||||
</span>
|
this.selNotRec = [];
|
||||||
}
|
this.selIngList = value.map(id => {
|
||||||
return <span>{option.label}</span>;
|
// 搜索table中的数据
|
||||||
|
let tmpTableObj = this.selTableData.find(obj => obj.id === id);
|
||||||
|
if (tmpTableObj) {
|
||||||
|
newTableData.push(tmpTableObj);
|
||||||
|
} else {
|
||||||
|
// 搜索请求的缓存数据
|
||||||
|
tmpTableObj = this.oriDataList.find(obj => obj.id === id);
|
||||||
|
if (tmpTableObj) {
|
||||||
|
newTableData.push({...tmpTableObj, weight: 100, cusWeight: 1, cusUnit: 1})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (tmpTableObj) {
|
||||||
|
if (tmpTableObj.rec) {
|
||||||
|
tmpTableObj.rec.split(',').forEach(rec => {
|
||||||
|
if (!this.selRec.includes(rec)) {
|
||||||
|
this.selRec.push(rec)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
if (tmpTableObj.notRec) {
|
||||||
|
tmpTableObj.notRec.split(',').forEach(notRec => {
|
||||||
|
if (!this.selNotRec.includes(notRec)) {
|
||||||
|
this.selNotRec.push(notRec)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
const tarObj = this.ingDataList.find(({key}) => key === id);
|
||||||
|
return tarObj
|
||||||
|
});
|
||||||
|
this.selTableData = newTableData;
|
||||||
},
|
},
|
||||||
|
handleOnTypeChange(value) {
|
||||||
|
listAllIngredient({type: value}).then(res => {
|
||||||
|
this.oriDataList = res.rows;
|
||||||
|
this.ingDataList = this.oriDataList.reduce((arr, cur) => {
|
||||||
|
if (!arr.some(({key}) => key === cur.id)) {
|
||||||
|
arr.push({
|
||||||
|
key: cur.id,
|
||||||
|
label: cur.name
|
||||||
|
});
|
||||||
|
}
|
||||||
|
return arr;
|
||||||
|
}, this.selIngList.slice());
|
||||||
|
})
|
||||||
|
},
|
||||||
|
handleInputChange(val) {
|
||||||
|
console.log({val, table: this.selTableData})
|
||||||
|
},
|
||||||
|
getSummaries(param) {
|
||||||
|
const {columns, data} = param;
|
||||||
|
return columns.reduce((arr, cur, idx) => {
|
||||||
|
if (idx > 1) {
|
||||||
|
arr[idx] = data.reduce((acc, dAcc) => {
|
||||||
|
if (idx === 2) {
|
||||||
|
return acc + parseFloat(dAcc.weight);
|
||||||
|
}
|
||||||
|
return acc + dAcc[cur.property] * dAcc.weight / 100;
|
||||||
|
}, 0);
|
||||||
|
}
|
||||||
|
return arr;
|
||||||
|
}, ['合计'])
|
||||||
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
<style>
|
||||||
|
.el-transfer-panel__filter {
|
||||||
|
margin: 2px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.cus-unit {
|
||||||
|
display: inline-flex;
|
||||||
|
}
|
||||||
|
|
||||||
|
.cus-unit .el-input-number--small {
|
||||||
|
width: 38px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.cus-unit .el-input-number .el-input-number__decrease {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.cus-unit .el-input-number .el-input-number__increase {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.cus-unit .el-input-number .el-input {
|
||||||
|
width: 38px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.cus-unit .el-input-number .el-input .el-input__inner {
|
||||||
|
padding: 0;
|
||||||
|
border-radius: 0;
|
||||||
|
border: unset;
|
||||||
|
border-bottom: 1px solid #DCDFE6;
|
||||||
|
}
|
||||||
|
|
||||||
|
.cus-unit .el-select .el-input__suffix {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.cus-unit .el-select .el-input__inner {
|
||||||
|
padding: 0 4px;
|
||||||
|
border: unset;
|
||||||
|
}
|
||||||
|
|
||||||
|
.weight {
|
||||||
|
width: 70px
|
||||||
|
}
|
||||||
|
|
||||||
|
.weight .el-input .el-input__inner {
|
||||||
|
padding: 0 32px 0 4px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.drawer_content {
|
||||||
|
height: 100%;
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
}
|
||||||
|
|
||||||
|
.drawer_content .el-form {
|
||||||
|
/*height: calc(100% - 45px);*/
|
||||||
|
flex: 1 1 0;
|
||||||
|
padding: 12px;
|
||||||
|
overflow: auto;
|
||||||
|
}
|
||||||
|
|
||||||
|
.drawer_content > div {
|
||||||
|
flex: 0 0 45px;
|
||||||
|
display: inline-flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: flex-end;
|
||||||
|
padding: 0 12px;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user