暂存
This commit is contained in:
parent
fa5264b908
commit
eeaa3d36e9
@ -83,7 +83,7 @@ spring:
|
||||
# 主库数据源
|
||||
master:
|
||||
url: jdbc:mysql://localhost:3306/stdiet_test?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8
|
||||
password: Ttj4fAHU
|
||||
password: S6QAUjVMFwWe
|
||||
username: root
|
||||
slave:
|
||||
# 从数据源开关/默认关闭
|
||||
|
@ -83,7 +83,7 @@ spring:
|
||||
# 主库数据源
|
||||
master:
|
||||
url: jdbc:mysql://47.115.23.82:3306/stdiet_test?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8
|
||||
password: Ttj4fAHU
|
||||
password: S6QAUjVMFwWe
|
||||
username: root
|
||||
slave:
|
||||
# 从数据源开关/默认关闭
|
||||
|
@ -83,7 +83,7 @@ spring:
|
||||
# 主库数据源
|
||||
master:
|
||||
url: jdbc:mysql://localhost:3306/stdiet?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8
|
||||
password: Ttj4fAHU
|
||||
password: S6QAUjVMFwWe
|
||||
username: root
|
||||
slave:
|
||||
# 从数据源开关/默认关闭
|
||||
|
@ -0,0 +1,103 @@
|
||||
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.core.controller.BaseController;
|
||||
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;
|
||||
|
||||
/**
|
||||
* 菜品Controller
|
||||
*
|
||||
* @author wonder
|
||||
* @date 2020-12-28
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/custom/dishes")
|
||||
public class SysDishesController extends BaseController
|
||||
{
|
||||
@Autowired
|
||||
private ISysDishesService sysDishesService;
|
||||
|
||||
/**
|
||||
* 查询菜品列表
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('custom:dishes:list')")
|
||||
@GetMapping("/list")
|
||||
public TableDataInfo list(SysDishes sysDishes)
|
||||
{
|
||||
startPage();
|
||||
List<SysDishes> list = sysDishesService.selectSysDishesList(sysDishes);
|
||||
return getDataTable(list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 导出菜品列表
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('custom:dishes:export')")
|
||||
@Log(title = "菜品", businessType = BusinessType.EXPORT)
|
||||
@GetMapping("/export")
|
||||
public AjaxResult export(SysDishes sysDishes)
|
||||
{
|
||||
List<SysDishes> list = sysDishesService.selectSysDishesList(sysDishes);
|
||||
ExcelUtil<SysDishes> util = new ExcelUtil<SysDishes>(SysDishes.class);
|
||||
return util.exportExcel(list, "dishes");
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取菜品详细信息
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('custom:dishes:query')")
|
||||
@GetMapping(value = "/{id}")
|
||||
public AjaxResult getInfo(@PathVariable("id") Long id)
|
||||
{
|
||||
return AjaxResult.success(sysDishesService.selectSysDishesById(id));
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增菜品
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('custom:dishes:add')")
|
||||
@Log(title = "菜品", businessType = BusinessType.INSERT)
|
||||
@PostMapping
|
||||
public AjaxResult add(@RequestBody SysDishes sysDishes)
|
||||
{
|
||||
return toAjax(sysDishesService.insertSysDishes(sysDishes));
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改菜品
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('custom:dishes:edit')")
|
||||
@Log(title = "菜品", businessType = BusinessType.UPDATE)
|
||||
@PutMapping
|
||||
public AjaxResult edit(@RequestBody SysDishes sysDishes)
|
||||
{
|
||||
return toAjax(sysDishesService.updateSysDishes(sysDishes));
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除菜品
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('custom:dishes:remove')")
|
||||
@Log(title = "菜品", businessType = BusinessType.DELETE)
|
||||
@DeleteMapping("/{ids}")
|
||||
public AjaxResult remove(@PathVariable Long[] ids)
|
||||
{
|
||||
return toAjax(sysDishesService.deleteSysDishesByIds(ids));
|
||||
}
|
||||
}
|
@ -37,8 +37,8 @@ public class SysIngredientController extends BaseController
|
||||
* 查询食材列表
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('custom:ingredient:list')")
|
||||
@GetMapping("/list")
|
||||
public TableDataInfo list(SysIngredient sysIngredient)
|
||||
@PostMapping("/list")
|
||||
public TableDataInfo list(@RequestBody SysIngredient sysIngredient)
|
||||
{
|
||||
startPage();
|
||||
List<SysIngredient> list = sysIngredientService.selectSysIngredientList(sysIngredient);
|
||||
|
@ -0,0 +1,83 @@
|
||||
package com.stdiet.custom.domain;
|
||||
|
||||
import org.apache.commons.lang3.builder.ToStringBuilder;
|
||||
import org.apache.commons.lang3.builder.ToStringStyle;
|
||||
import com.stdiet.common.annotation.Excel;
|
||||
import com.stdiet.common.core.domain.BaseEntity;
|
||||
|
||||
/**
|
||||
* 菜品对象 sys_dishes
|
||||
*
|
||||
* @author wonder
|
||||
* @date 2020-12-28
|
||||
*/
|
||||
public class SysDishes extends BaseEntity
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/** id */
|
||||
private Long id;
|
||||
|
||||
/** 菜品名称 */
|
||||
@Excel(name = "菜品名称")
|
||||
private String name;
|
||||
|
||||
/** 菜品类型 */
|
||||
@Excel(name = "菜品类型")
|
||||
private String type;
|
||||
|
||||
/** 做法 */
|
||||
@Excel(name = "做法")
|
||||
private String methods;
|
||||
|
||||
public void setId(Long id)
|
||||
{
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public Long getId()
|
||||
{
|
||||
return id;
|
||||
}
|
||||
public void setName(String name)
|
||||
{
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getName()
|
||||
{
|
||||
return name;
|
||||
}
|
||||
public void setType(String type)
|
||||
{
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public String getType()
|
||||
{
|
||||
return type;
|
||||
}
|
||||
public void setMethods(String methods)
|
||||
{
|
||||
this.methods = methods;
|
||||
}
|
||||
|
||||
public String getMethods()
|
||||
{
|
||||
return methods;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
|
||||
.append("id", getId())
|
||||
.append("name", getName())
|
||||
.append("type", getType())
|
||||
.append("methods", getMethods())
|
||||
.append("createBy", getCreateBy())
|
||||
.append("createTime", getCreateTime())
|
||||
.append("updateBy", getUpdateBy())
|
||||
.append("updateTime", getUpdateTime())
|
||||
.toString();
|
||||
}
|
||||
}
|
@ -0,0 +1,61 @@
|
||||
package com.stdiet.custom.mapper;
|
||||
|
||||
import java.util.List;
|
||||
import com.stdiet.custom.domain.SysDishes;
|
||||
|
||||
/**
|
||||
* 菜品Mapper接口
|
||||
*
|
||||
* @author wonder
|
||||
* @date 2020-12-28
|
||||
*/
|
||||
public interface SysDishesMapper
|
||||
{
|
||||
/**
|
||||
* 查询菜品
|
||||
*
|
||||
* @param id 菜品ID
|
||||
* @return 菜品
|
||||
*/
|
||||
public SysDishes selectSysDishesById(Long id);
|
||||
|
||||
/**
|
||||
* 查询菜品列表
|
||||
*
|
||||
* @param sysDishes 菜品
|
||||
* @return 菜品集合
|
||||
*/
|
||||
public List<SysDishes> selectSysDishesList(SysDishes sysDishes);
|
||||
|
||||
/**
|
||||
* 新增菜品
|
||||
*
|
||||
* @param sysDishes 菜品
|
||||
* @return 结果
|
||||
*/
|
||||
public int insertSysDishes(SysDishes sysDishes);
|
||||
|
||||
/**
|
||||
* 修改菜品
|
||||
*
|
||||
* @param sysDishes 菜品
|
||||
* @return 结果
|
||||
*/
|
||||
public int updateSysDishes(SysDishes sysDishes);
|
||||
|
||||
/**
|
||||
* 删除菜品
|
||||
*
|
||||
* @param id 菜品ID
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteSysDishesById(Long id);
|
||||
|
||||
/**
|
||||
* 批量删除菜品
|
||||
*
|
||||
* @param ids 需要删除的数据ID
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteSysDishesByIds(Long[] ids);
|
||||
}
|
@ -0,0 +1,61 @@
|
||||
package com.stdiet.custom.service;
|
||||
|
||||
import java.util.List;
|
||||
import com.stdiet.custom.domain.SysDishes;
|
||||
|
||||
/**
|
||||
* 菜品Service接口
|
||||
*
|
||||
* @author wonder
|
||||
* @date 2020-12-28
|
||||
*/
|
||||
public interface ISysDishesService
|
||||
{
|
||||
/**
|
||||
* 查询菜品
|
||||
*
|
||||
* @param id 菜品ID
|
||||
* @return 菜品
|
||||
*/
|
||||
public SysDishes selectSysDishesById(Long id);
|
||||
|
||||
/**
|
||||
* 查询菜品列表
|
||||
*
|
||||
* @param sysDishes 菜品
|
||||
* @return 菜品集合
|
||||
*/
|
||||
public List<SysDishes> selectSysDishesList(SysDishes sysDishes);
|
||||
|
||||
/**
|
||||
* 新增菜品
|
||||
*
|
||||
* @param sysDishes 菜品
|
||||
* @return 结果
|
||||
*/
|
||||
public int insertSysDishes(SysDishes sysDishes);
|
||||
|
||||
/**
|
||||
* 修改菜品
|
||||
*
|
||||
* @param sysDishes 菜品
|
||||
* @return 结果
|
||||
*/
|
||||
public int updateSysDishes(SysDishes sysDishes);
|
||||
|
||||
/**
|
||||
* 批量删除菜品
|
||||
*
|
||||
* @param ids 需要删除的菜品ID
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteSysDishesByIds(Long[] ids);
|
||||
|
||||
/**
|
||||
* 删除菜品信息
|
||||
*
|
||||
* @param id 菜品ID
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteSysDishesById(Long id);
|
||||
}
|
@ -0,0 +1,96 @@
|
||||
package com.stdiet.custom.service.impl;
|
||||
|
||||
import java.util.List;
|
||||
import com.stdiet.common.utils.DateUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import com.stdiet.custom.mapper.SysDishesMapper;
|
||||
import com.stdiet.custom.domain.SysDishes;
|
||||
import com.stdiet.custom.service.ISysDishesService;
|
||||
|
||||
/**
|
||||
* 菜品Service业务层处理
|
||||
*
|
||||
* @author wonder
|
||||
* @date 2020-12-28
|
||||
*/
|
||||
@Service
|
||||
public class SysDishesServiceImpl implements ISysDishesService
|
||||
{
|
||||
@Autowired
|
||||
private SysDishesMapper sysDishesMapper;
|
||||
|
||||
/**
|
||||
* 查询菜品
|
||||
*
|
||||
* @param id 菜品ID
|
||||
* @return 菜品
|
||||
*/
|
||||
@Override
|
||||
public SysDishes selectSysDishesById(Long id)
|
||||
{
|
||||
return sysDishesMapper.selectSysDishesById(id);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询菜品列表
|
||||
*
|
||||
* @param sysDishes 菜品
|
||||
* @return 菜品
|
||||
*/
|
||||
@Override
|
||||
public List<SysDishes> selectSysDishesList(SysDishes sysDishes)
|
||||
{
|
||||
return sysDishesMapper.selectSysDishesList(sysDishes);
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增菜品
|
||||
*
|
||||
* @param sysDishes 菜品
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int insertSysDishes(SysDishes sysDishes)
|
||||
{
|
||||
sysDishes.setCreateTime(DateUtils.getNowDate());
|
||||
return sysDishesMapper.insertSysDishes(sysDishes);
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改菜品
|
||||
*
|
||||
* @param sysDishes 菜品
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int updateSysDishes(SysDishes sysDishes)
|
||||
{
|
||||
sysDishes.setUpdateTime(DateUtils.getNowDate());
|
||||
return sysDishesMapper.updateSysDishes(sysDishes);
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量删除菜品
|
||||
*
|
||||
* @param ids 需要删除的菜品ID
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int deleteSysDishesByIds(Long[] ids)
|
||||
{
|
||||
return sysDishesMapper.deleteSysDishesByIds(ids);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除菜品信息
|
||||
*
|
||||
* @param id 菜品ID
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int deleteSysDishesById(Long id)
|
||||
{
|
||||
return sysDishesMapper.deleteSysDishesById(id);
|
||||
}
|
||||
}
|
@ -0,0 +1,82 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<!DOCTYPE mapper
|
||||
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.stdiet.custom.mapper.SysDishesMapper">
|
||||
|
||||
<resultMap type="SysDishes" id="SysDishesResult">
|
||||
<result property="id" column="id" />
|
||||
<result property="name" column="name" />
|
||||
<result property="type" column="type" />
|
||||
<result property="methods" column="methods" />
|
||||
<result property="createBy" column="create_by" />
|
||||
<result property="createTime" column="create_time" />
|
||||
<result property="updateBy" column="update_by" />
|
||||
<result property="updateTime" column="update_time" />
|
||||
</resultMap>
|
||||
|
||||
<sql id="selectSysDishesVo">
|
||||
select id, name, type, methods, create_by, create_time, update_by, update_time from sys_dishes
|
||||
</sql>
|
||||
|
||||
<select id="selectSysDishesList" parameterType="SysDishes" resultMap="SysDishesResult">
|
||||
<include refid="selectSysDishesVo"/>
|
||||
<where>
|
||||
<if test="name != null and name != ''"> and name like concat('%', #{name}, '%')</if>
|
||||
<if test="type != null and type != ''"> and type = #{type}</if>
|
||||
</where>
|
||||
</select>
|
||||
|
||||
<select id="selectSysDishesById" parameterType="Long" resultMap="SysDishesResult">
|
||||
<include refid="selectSysDishesVo"/>
|
||||
where id = #{id}
|
||||
</select>
|
||||
|
||||
<insert id="insertSysDishes" parameterType="SysDishes" useGeneratedKeys="true" keyProperty="id">
|
||||
insert into sys_dishes
|
||||
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||
<if test="name != null">name,</if>
|
||||
<if test="type != null">type,</if>
|
||||
<if test="methods != null">methods,</if>
|
||||
<if test="createBy != null">create_by,</if>
|
||||
<if test="createTime != null">create_time,</if>
|
||||
<if test="updateBy != null">update_by,</if>
|
||||
<if test="updateTime != null">update_time,</if>
|
||||
</trim>
|
||||
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||
<if test="name != null">#{name},</if>
|
||||
<if test="type != null">#{type},</if>
|
||||
<if test="methods != null">#{methods},</if>
|
||||
<if test="createBy != null">#{createBy},</if>
|
||||
<if test="createTime != null">#{createTime},</if>
|
||||
<if test="updateBy != null">#{updateBy},</if>
|
||||
<if test="updateTime != null">#{updateTime},</if>
|
||||
</trim>
|
||||
</insert>
|
||||
|
||||
<update id="updateSysDishes" parameterType="SysDishes">
|
||||
update sys_dishes
|
||||
<trim prefix="SET" suffixOverrides=",">
|
||||
<if test="name != null">name = #{name},</if>
|
||||
<if test="type != null">type = #{type},</if>
|
||||
<if test="methods != null">methods = #{methods},</if>
|
||||
<if test="createBy != null">create_by = #{createBy},</if>
|
||||
<if test="createTime != null">create_time = #{createTime},</if>
|
||||
<if test="updateBy != null">update_by = #{updateBy},</if>
|
||||
<if test="updateTime != null">update_time = #{updateTime},</if>
|
||||
</trim>
|
||||
where id = #{id}
|
||||
</update>
|
||||
|
||||
<delete id="deleteSysDishesById" parameterType="Long">
|
||||
delete from sys_dishes where id = #{id}
|
||||
</delete>
|
||||
|
||||
<delete id="deleteSysDishesByIds" parameterType="String">
|
||||
delete from sys_dishes where id in
|
||||
<foreach item="id" collection="array" open="(" separator="," close=")">
|
||||
#{id}
|
||||
</foreach>
|
||||
</delete>
|
||||
|
||||
</mapper>
|
@ -22,7 +22,6 @@
|
||||
</resultMap>
|
||||
|
||||
<sql id="selectSysIngredientVo">
|
||||
-- select id, name, type, protein_ratio, fat_ratio, carbon_ratio, area, remark, create_by, create_time, update_by, update_time from sys_ingredient
|
||||
SELECT * FROM sys_ingredient igd
|
||||
LEFT JOIN (
|
||||
SELECT ingredient_id as id, GROUP_CONCAT(name SEPARATOR ',') not_rec FROM(
|
||||
@ -36,12 +35,66 @@
|
||||
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)
|
||||
GROUP BY id
|
||||
) recT USING(id)
|
||||
</sql>
|
||||
|
||||
<sql id="selectSysIngredientByPhyVo">
|
||||
SELECT * FROM sys_ingredient igd
|
||||
RIGHT JOIN(
|
||||
SELECT * FROM(
|
||||
SELECT DISTINCT(ingredient_id) as id FROM sys_ingredient_rec
|
||||
<where>
|
||||
<if test="recIds != null">
|
||||
physical_signs_id in
|
||||
<foreach collection="recIds" item="item" index="index" open="(" separator="," close=")">
|
||||
#{item}
|
||||
</foreach>
|
||||
</if>
|
||||
</where>
|
||||
) recId
|
||||
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
|
||||
) recM USING(id)
|
||||
INNER JOIN (
|
||||
SELECT * FROM(
|
||||
SELECT DISTINCT(ingredient_id) as id FROM sys_ingredient_not_rec
|
||||
<where>
|
||||
<if test="notRecIds != null">
|
||||
physical_signs_id in
|
||||
<foreach collection="notRecIds" item="item" index="index" open="(" separator="," close=")">
|
||||
#{item}
|
||||
</foreach>
|
||||
</if>
|
||||
</where>
|
||||
) notRecId
|
||||
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
|
||||
) notRecM USING(id)
|
||||
) notRecT USING(id)
|
||||
) recT USING(id)
|
||||
</sql>
|
||||
|
||||
<select id="selectSysIngredientList" parameterType="SysIngredient" resultMap="SysIngredientResult">
|
||||
<choose>
|
||||
<when test="recIds == null and notRecIds == null">
|
||||
<include refid="selectSysIngredientVo"/>
|
||||
</when>
|
||||
<otherwise>
|
||||
<include refid="selectSysIngredientByPhyVo">
|
||||
<property name="recIds" value="#{recIds}"/>
|
||||
<property name="notRecIds" value="#{notRecIds}"/>
|
||||
</include>
|
||||
</otherwise>
|
||||
</choose>
|
||||
<where>
|
||||
<if test="name != null and name != ''"> and name like concat('%', #{name}, '%')</if>
|
||||
<if test="type != null and type != ''"> and type = #{type}</if>
|
||||
|
53
stdiet-ui/src/api/custom/dishes.js
Normal file
53
stdiet-ui/src/api/custom/dishes.js
Normal file
@ -0,0 +1,53 @@
|
||||
import request from '@/utils/request'
|
||||
|
||||
// 查询菜品列表
|
||||
export function listDishes(query) {
|
||||
return request({
|
||||
url: '/custom/dishes/list',
|
||||
method: 'get',
|
||||
params: query
|
||||
})
|
||||
}
|
||||
|
||||
// 查询菜品详细
|
||||
export function getDishes(id) {
|
||||
return request({
|
||||
url: '/custom/dishes/' + id,
|
||||
method: 'get'
|
||||
})
|
||||
}
|
||||
|
||||
// 新增菜品
|
||||
export function addDishes(data) {
|
||||
return request({
|
||||
url: '/custom/dishes',
|
||||
method: 'post',
|
||||
data: data
|
||||
})
|
||||
}
|
||||
|
||||
// 修改菜品
|
||||
export function updateDishes(data) {
|
||||
return request({
|
||||
url: '/custom/dishes',
|
||||
method: 'put',
|
||||
data: data
|
||||
})
|
||||
}
|
||||
|
||||
// 删除菜品
|
||||
export function delDishes(id) {
|
||||
return request({
|
||||
url: '/custom/dishes/' + id,
|
||||
method: 'delete'
|
||||
})
|
||||
}
|
||||
|
||||
// 导出菜品
|
||||
export function exportDishes(query) {
|
||||
return request({
|
||||
url: '/custom/dishes/export',
|
||||
method: 'get',
|
||||
params: query
|
||||
})
|
||||
}
|
@ -2,10 +2,15 @@ import request from '@/utils/request'
|
||||
|
||||
// 查询食材列表
|
||||
export function listIngredient(query) {
|
||||
const {recIds, notRecIds} = query;
|
||||
return request({
|
||||
url: '/custom/ingredient/list',
|
||||
method: 'get',
|
||||
params: query
|
||||
method: 'post',
|
||||
data: {
|
||||
...query,
|
||||
recIds: recIds && recIds.length ? recIds : null,
|
||||
notRecIds: notRecIds && notRecIds.length ? notRecIds : null,
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
|
317
stdiet-ui/src/views/custom/dishes/index.vue
Normal file
317
stdiet-ui/src/views/custom/dishes/index.vue
Normal file
@ -0,0 +1,317 @@
|
||||
<template>
|
||||
<div class="app-container">
|
||||
<el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="68px">
|
||||
<el-form-item label="菜品名称" prop="name">
|
||||
<el-input
|
||||
v-model="queryParams.name"
|
||||
placeholder="请输入菜品名称"
|
||||
clearable
|
||||
size="small"
|
||||
@keyup.enter.native="handleQuery"
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item label="菜品类型" prop="type">
|
||||
<el-select v-model="queryParams.type" placeholder="请选择菜品类型" clearable size="small">
|
||||
<el-option
|
||||
v-for="dict in typeOptions"
|
||||
:key="dict.dictValue"
|
||||
:label="dict.dictLabel"
|
||||
:value="dict.dictValue"
|
||||
/>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item>
|
||||
<el-button type="cyan" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
|
||||
<el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
|
||||
<el-row :gutter="10" class="mb8">
|
||||
<el-col :span="1.5">
|
||||
<el-button
|
||||
type="primary"
|
||||
icon="el-icon-plus"
|
||||
size="mini"
|
||||
@click="handleAdd"
|
||||
v-hasPermi="['custom:dishes:add']"
|
||||
>新增</el-button>
|
||||
</el-col>
|
||||
<el-col :span="1.5">
|
||||
<el-button
|
||||
type="warning"
|
||||
icon="el-icon-download"
|
||||
size="mini"
|
||||
@click="handleExport"
|
||||
v-hasPermi="['custom:dishes:export']"
|
||||
>导出</el-button>
|
||||
</el-col>
|
||||
<right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
|
||||
</el-row>
|
||||
|
||||
<el-table v-loading="loading" :data="dishesList" @selection-change="handleSelectionChange">
|
||||
<!-- <el-table-column type="selection" width="55" align="center" />-->
|
||||
<!-- <el-table-column label="id" align="center" prop="id" />-->
|
||||
<el-table-column label="菜品名称" align="center" prop="name" />
|
||||
<el-table-column label="菜品类型" align="center" prop="type" :formatter="typeFormat" />
|
||||
<el-table-column label="做法" align="center" prop="methods" />
|
||||
<el-table-column label="操作" align="center" class-name="small-padding fixed-width">
|
||||
<template slot-scope="scope">
|
||||
<el-button
|
||||
size="mini"
|
||||
type="text"
|
||||
icon="el-icon-edit"
|
||||
@click="handleUpdate(scope.row)"
|
||||
v-hasPermi="['custom:dishes:edit']"
|
||||
>修改</el-button>
|
||||
<el-button
|
||||
size="mini"
|
||||
type="text"
|
||||
icon="el-icon-delete"
|
||||
@click="handleDelete(scope.row)"
|
||||
v-hasPermi="['custom:dishes:remove']"
|
||||
>删除</el-button>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
|
||||
<pagination
|
||||
v-show="total>0"
|
||||
:total="total"
|
||||
:page.sync="queryParams.pageNum"
|
||||
:limit.sync="queryParams.pageSize"
|
||||
@pagination="getList"
|
||||
/>
|
||||
|
||||
<!-- 添加或修改菜品对话框 -->
|
||||
<el-dialog :title="title" :visible.sync="open" width="720px" append-to-body>
|
||||
<el-form ref="form" :model="form" :rules="rules" label-width="80px">
|
||||
<el-form-item label="菜品名称" prop="name">
|
||||
<el-input v-model="form.name" placeholder="请输入菜品名称" />
|
||||
</el-form-item>
|
||||
<el-form-item label="菜品类型" prop="type">
|
||||
<el-select v-model="form.type" placeholder="请选择菜品类型">
|
||||
<el-option
|
||||
v-for="dict in typeOptions"
|
||||
:key="dict.dictValue"
|
||||
:label="dict.dictLabel"
|
||||
:value="dict.dictValue"
|
||||
></el-option>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="食材" prop="ingIds">
|
||||
<el-transfer
|
||||
style="text-align: left; display: inline-block"
|
||||
v-model="form.ingIds"
|
||||
filterable
|
||||
:render-content="renderFunc"
|
||||
:titles="['备选', '已选']"
|
||||
:button-texts="['', '']"
|
||||
:format="{
|
||||
noChecked: '${total}',
|
||||
hasChecked: '${checked}/${total}',
|
||||
}"
|
||||
@change="handleChange"
|
||||
:data="data"
|
||||
>
|
||||
<el-select class="transfer-footer" slot="left-footer" size="small"
|
||||
v-model="ingType"
|
||||
v-for="dict in ingTypeOptions"
|
||||
:key="dict.dictValue"
|
||||
:label="dict.dictLabel"
|
||||
:value="dict.dictValue"/>
|
||||
<div class="transfer-footer" slot="right-footer" size="small" />
|
||||
</el-transfer>
|
||||
</el-form-item>
|
||||
<el-form-item label="做法" prop="methods">
|
||||
<el-input v-model="form.methods" type="textarea" placeholder="请输入内容" />
|
||||
</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>
|
||||
</el-dialog>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { listDishes, getDishes, delDishes, addDishes, updateDishes, exportDishes } from "@/api/custom/dishes";
|
||||
|
||||
export default {
|
||||
name: "Dishes",
|
||||
data() {
|
||||
return {
|
||||
// 遮罩层
|
||||
loading: true,
|
||||
// 选中数组
|
||||
ids: [],
|
||||
// 非单个禁用
|
||||
single: true,
|
||||
// 非多个禁用
|
||||
multiple: true,
|
||||
// 显示搜索条件
|
||||
showSearch: true,
|
||||
// 总条数
|
||||
total: 0,
|
||||
// 菜品表格数据
|
||||
dishesList: [],
|
||||
// 弹出层标题
|
||||
title: "",
|
||||
// 是否显示弹出层
|
||||
open: false,
|
||||
ingType: 1,
|
||||
// 食材类别字典
|
||||
ingTypeOptions: [],
|
||||
// 菜品类别字典
|
||||
typeOptions: [],
|
||||
// 查询参数
|
||||
queryParams: {
|
||||
pageNum: 1,
|
||||
pageSize: 10,
|
||||
name: null,
|
||||
type: null,
|
||||
},
|
||||
// 表单参数
|
||||
form: {},
|
||||
// 表单校验
|
||||
rules: {
|
||||
}
|
||||
};
|
||||
},
|
||||
created() {
|
||||
this.getList();
|
||||
this.getDicts("cus_dishes_type").then(response => {
|
||||
this.typeOptions = response.data;
|
||||
});
|
||||
this.getDicts("cus_ing_type").then(response => {
|
||||
this.ingTypeOptions = response.data;
|
||||
});
|
||||
},
|
||||
methods: {
|
||||
/** 查询菜品列表 */
|
||||
getList() {
|
||||
this.loading = true;
|
||||
listDishes(this.queryParams).then(response => {
|
||||
this.dishesList = response.rows;
|
||||
this.total = response.total;
|
||||
this.loading = false;
|
||||
});
|
||||
},
|
||||
// 菜品类型字典翻译
|
||||
typeFormat(row, column) {
|
||||
return this.selectDictLabel(this.typeOptions, row.type);
|
||||
},
|
||||
// 取消按钮
|
||||
cancel() {
|
||||
this.open = false;
|
||||
this.reset();
|
||||
},
|
||||
// 表单重置
|
||||
reset() {
|
||||
this.form = {
|
||||
id: null,
|
||||
name: null,
|
||||
type: null,
|
||||
methods: null,
|
||||
createBy: null,
|
||||
createTime: null,
|
||||
updateBy: null,
|
||||
updateTime: null,
|
||||
ingIds: []
|
||||
};
|
||||
this.resetForm("form");
|
||||
},
|
||||
/** 搜索按钮操作 */
|
||||
handleQuery() {
|
||||
this.queryParams.pageNum = 1;
|
||||
this.getList();
|
||||
},
|
||||
/** 重置按钮操作 */
|
||||
resetQuery() {
|
||||
this.resetForm("queryForm");
|
||||
this.handleQuery();
|
||||
},
|
||||
// 多选框选中数据
|
||||
handleSelectionChange(selection) {
|
||||
this.ids = selection.map(item => item.id)
|
||||
this.single = selection.length!==1
|
||||
this.multiple = !selection.length
|
||||
},
|
||||
/** 新增按钮操作 */
|
||||
handleAdd() {
|
||||
this.reset();
|
||||
this.open = true;
|
||||
this.title = "添加菜品";
|
||||
},
|
||||
/** 修改按钮操作 */
|
||||
handleUpdate(row) {
|
||||
this.reset();
|
||||
const id = row.id || this.ids
|
||||
getDishes(id).then(response => {
|
||||
this.form = response.data;
|
||||
this.open = true;
|
||||
this.title = "修改菜品";
|
||||
});
|
||||
},
|
||||
/** 提交按钮 */
|
||||
submitForm() {
|
||||
this.$refs["form"].validate(valid => {
|
||||
if (valid) {
|
||||
if (this.form.id != null) {
|
||||
updateDishes(this.form).then(response => {
|
||||
if (response.code === 200) {
|
||||
this.msgSuccess("修改成功");
|
||||
this.open = false;
|
||||
this.getList();
|
||||
}
|
||||
});
|
||||
} else {
|
||||
addDishes(this.form).then(response => {
|
||||
if (response.code === 200) {
|
||||
this.msgSuccess("新增成功");
|
||||
this.open = false;
|
||||
this.getList();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
},
|
||||
/** 删除按钮操作 */
|
||||
handleDelete(row) {
|
||||
const ids = row.id || this.ids;
|
||||
this.$confirm('是否确认删除菜品编号为"' + ids + '"的数据项?', "警告", {
|
||||
confirmButtonText: "确定",
|
||||
cancelButtonText: "取消",
|
||||
type: "warning"
|
||||
}).then(function() {
|
||||
return delDishes(ids);
|
||||
}).then(() => {
|
||||
this.getList();
|
||||
this.msgSuccess("删除成功");
|
||||
}).catch(function() {});
|
||||
},
|
||||
/** 导出按钮操作 */
|
||||
handleExport() {
|
||||
const queryParams = this.queryParams;
|
||||
this.$confirm('是否确认导出所有菜品数据项?', "警告", {
|
||||
confirmButtonText: "确定",
|
||||
cancelButtonText: "取消",
|
||||
type: "warning"
|
||||
}).then(function() {
|
||||
return exportDishes(queryParams);
|
||||
}).then(response => {
|
||||
this.download(response.msg);
|
||||
}).catch(function() {});
|
||||
},
|
||||
renderFunc(h, option) {
|
||||
if (this.form.ingIds.includes(option.key)) {
|
||||
return <span>
|
||||
{option.key} - {option.label}
|
||||
</span>
|
||||
}
|
||||
return <span>{option.label}</span>;
|
||||
},
|
||||
}
|
||||
};
|
||||
</script>
|
@ -30,6 +30,26 @@
|
||||
/>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="忌口人群" prop="notRecIds">
|
||||
<el-select v-model="queryParams.notRecIds" multiple placeholder="请选择体征">
|
||||
<el-option
|
||||
v-for="dict in physicalSignsOptions"
|
||||
:key="dict.dictValue"
|
||||
:label="dict.dictLabel"
|
||||
:value="dict.dictValue">
|
||||
</el-option>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="推荐人群" prop="recIds">
|
||||
<el-select v-model="queryParams.recIds" multiple placeholder="请选择体征">
|
||||
<el-option
|
||||
v-for="dict in physicalSignsOptions"
|
||||
:key="dict.dictValue"
|
||||
:label="dict.dictLabel"
|
||||
:value="dict.dictValue">
|
||||
</el-option>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item>
|
||||
<el-button type="cyan" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
|
||||
<el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
|
||||
|
Loading…
x
Reference in New Issue
Block a user