完成食材管理页面

This commit is contained in:
huangdeliang 2020-12-23 20:44:23 +08:00
parent 347ff618d0
commit fa5264b908
12 changed files with 979 additions and 172 deletions

View File

@ -82,7 +82,7 @@ spring:
druid: druid:
# 主库数据源 # 主库数据源
master: master:
url: jdbc:mysql://47.115.23.82:3306/stdiet?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8 url: jdbc:mysql://47.115.23.82:3306/stdiet_test?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8
password: Ttj4fAHU password: Ttj4fAHU
username: root username: root
slave: slave:

View File

@ -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.SysPhysicalSigns;
import com.stdiet.custom.service.ISysPhysicalSignsService;
import com.stdiet.common.utils.poi.ExcelUtil;
import com.stdiet.common.core.page.TableDataInfo;
/**
* 体征Controller
*
* @author wonder
* @date 2020-12-23
*/
@RestController
@RequestMapping("/custom/physicalSigns")
public class SysPhysicalSignsController extends BaseController
{
@Autowired
private ISysPhysicalSignsService sysPhysicalSignsService;
/**
* 查询体征列表
*/
@PreAuthorize("@ss.hasPermi('custom:physicalSigns:list')")
@GetMapping("/list")
public TableDataInfo list(SysPhysicalSigns sysPhysicalSigns)
{
startPage();
List<SysPhysicalSigns> list = sysPhysicalSignsService.selectSysPhysicalSignsList(sysPhysicalSigns);
return getDataTable(list);
}
/**
* 导出体征列表
*/
@PreAuthorize("@ss.hasPermi('custom:physicalSigns:export')")
@Log(title = "体征", businessType = BusinessType.EXPORT)
@GetMapping("/export")
public AjaxResult export(SysPhysicalSigns sysPhysicalSigns)
{
List<SysPhysicalSigns> list = sysPhysicalSignsService.selectSysPhysicalSignsList(sysPhysicalSigns);
ExcelUtil<SysPhysicalSigns> util = new ExcelUtil<SysPhysicalSigns>(SysPhysicalSigns.class);
return util.exportExcel(list, "physicalSigns");
}
/**
* 获取体征详细信息
*/
@PreAuthorize("@ss.hasPermi('custom:physicalSigns:query')")
@GetMapping(value = "/{id}")
public AjaxResult getInfo(@PathVariable("id") Long id)
{
return AjaxResult.success(sysPhysicalSignsService.selectSysPhysicalSignsById(id));
}
/**
* 新增体征
*/
@PreAuthorize("@ss.hasPermi('custom:physicalSigns:add')")
@Log(title = "体征", businessType = BusinessType.INSERT)
@PostMapping
public AjaxResult add(@RequestBody SysPhysicalSigns sysPhysicalSigns)
{
return toAjax(sysPhysicalSignsService.insertSysPhysicalSigns(sysPhysicalSigns));
}
/**
* 修改体征
*/
@PreAuthorize("@ss.hasPermi('custom:physicalSigns:edit')")
@Log(title = "体征", businessType = BusinessType.UPDATE)
@PutMapping
public AjaxResult edit(@RequestBody SysPhysicalSigns sysPhysicalSigns)
{
return toAjax(sysPhysicalSignsService.updateSysPhysicalSigns(sysPhysicalSigns));
}
/**
* 删除体征
*/
@PreAuthorize("@ss.hasPermi('custom:physicalSigns:remove')")
@Log(title = "体征", businessType = BusinessType.DELETE)
@DeleteMapping("/{ids}")
public AjaxResult remove(@PathVariable Long[] ids)
{
return toAjax(sysPhysicalSignsService.deleteSysPhysicalSignsByIds(ids));
}
}

View File

@ -1,10 +1,11 @@
package com.stdiet.custom.domain; package com.stdiet.custom.domain;
import java.math.BigDecimal;
import org.apache.commons.lang3.builder.ToStringBuilder;
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 org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import java.math.BigDecimal;
/** /**
* 食材对象 sys_ingredient * 食材对象 sys_ingredient
@ -12,56 +13,79 @@ import com.stdiet.common.core.domain.BaseEntity;
* @author wonder * @author wonder
* @date 2020-12-15 * @date 2020-12-15
*/ */
public class SysIngredient extends BaseEntity public class SysIngredient extends BaseEntity {
{
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
/** id */ /**
* id
*/
private Long id; private Long id;
/** 食材名称 */ /**
* 食材名称
*/
@Excel(name = "食材名称") @Excel(name = "食材名称")
private String name; private String name;
/** 食材类别 */ /**
* 食材类别
*/
@Excel(name = "食材类别") @Excel(name = "食材类别")
private String type; private String type;
/** 推荐分量估算 */ /**
* 推荐分量估算
*/
@Excel(name = "推荐分量估算") @Excel(name = "推荐分量估算")
private Long recEstimation; private Long recEstimation;
/** 推荐分量估算单位id */ /**
* 推荐分量估算单位id
*/
@Excel(name = "推荐分量估算单位id") @Excel(name = "推荐分量估算单位id")
private Long recEstUnit; private Long recEstUnit;
/** 推荐分量 */ /**
* 推荐分量
*/
@Excel(name = "推荐分量") @Excel(name = "推荐分量")
private Long recPortion; private Long recPortion;
/** 蛋白质比例 */ /**
* 蛋白质比例
*/
@Excel(name = "蛋白质比例") @Excel(name = "蛋白质比例")
private BigDecimal proteinRatio; private BigDecimal proteinRatio;
/** 脂肪比例 */ /**
* 脂肪比例
*/
@Excel(name = "脂肪比例") @Excel(name = "脂肪比例")
private BigDecimal fatRatio; private BigDecimal fatRatio;
/** 碳水比例 */ /**
* 碳水比例
*/
@Excel(name = "碳水比例") @Excel(name = "碳水比例")
private BigDecimal carbonRatio; private BigDecimal carbonRatio;
/** 地域 */ /**
* 地域
*/
@Excel(name = "地域") @Excel(name = "地域")
private String area; private String area;
/** 忌口 */ /**
@Excel(name = "忌口") * 忌口
*/
@Excel(name = "忌口人群")
private String notRec; private String notRec;
/** 推荐 */ /**
@Excel(name = "推荐") * 推荐
private String recommend; */
@Excel(name = "推荐人群")
private String rec;
private Long[] recIds; private Long[] recIds;
@ -75,143 +99,122 @@ public class SysIngredient extends BaseEntity
return notRecIds; return notRecIds;
} }
public void setNotRecIds(Long[] notRecIds) { public Long getId() {
this.notRecIds = notRecIds; return id;
} }
public void setRedIds(Long[] recIds) { public void setId(Long id) {
this.recIds = recIds;
}
public void setId(Long id)
{
this.id = id; this.id = id;
} }
public Long getId() public String getName() {
{ return name;
return id;
} }
public void setName(String name)
{ public void setName(String name) {
this.name = name; this.name = name;
} }
public String getName() public String getType() {
{ return type;
return name;
} }
public void setType(String type)
{ public void setType(String type) {
this.type = type; this.type = type;
} }
public String getType() public Long getRecEstimation() {
{ return recEstimation;
return type;
} }
public void setRecEstimation(Long recEstimation)
{ public void setRecEstimation(Long recEstimation) {
this.recEstimation = recEstimation; this.recEstimation = recEstimation;
} }
public Long getRecEstimation() public Long getRecEstUnit() {
{ return recEstUnit;
return recEstimation;
} }
public void setRecEstUnit(Long recEstUnit)
{ public void setRecEstUnit(Long recEstUnit) {
this.recEstUnit = recEstUnit; this.recEstUnit = recEstUnit;
} }
public Long getRecEstUnit() public Long getRecPortion() {
{ return recPortion;
return recEstUnit;
} }
public void setRecPortion(Long recPortion)
{ public void setRecPortion(Long recPortion) {
this.recPortion = recPortion; this.recPortion = recPortion;
} }
public Long getRecPortion() public BigDecimal getProteinRatio() {
{ return proteinRatio;
return recPortion;
} }
public void setProteinRatio(BigDecimal proteinRatio)
{ public void setProteinRatio(BigDecimal proteinRatio) {
this.proteinRatio = proteinRatio; this.proteinRatio = proteinRatio;
} }
public BigDecimal getProteinRatio() public BigDecimal getFatRatio() {
{ return fatRatio;
return proteinRatio;
} }
public void setFatRatio(BigDecimal fatRatio)
{ public void setFatRatio(BigDecimal fatRatio) {
this.fatRatio = fatRatio; this.fatRatio = fatRatio;
} }
public BigDecimal getFatRatio() public BigDecimal getCarbonRatio() {
{ return carbonRatio;
return fatRatio;
} }
public void setCarbonRatio(BigDecimal carbonRatio)
{ public void setCarbonRatio(BigDecimal carbonRatio) {
this.carbonRatio = carbonRatio; this.carbonRatio = carbonRatio;
} }
public BigDecimal getCarbonRatio() public String getArea() {
{ return area;
return carbonRatio;
} }
public void setArea(String area)
{ public void setArea(String area) {
this.area = area; this.area = area;
} }
public String getArea() public String getNotRec() {
{ return notRec;
return area;
} }
public void setNotRec(String notRec)
{ public void setNotRec(String notRec) {
this.notRec = notRec; this.notRec = notRec;
} }
public String getNotRec() public String getRec() {
{ return rec;
return notRec;
}
public void setRecommend(String recommend)
{
this.recommend = recommend;
} }
public String getRecommend() public void setRec(String rec) {
{ this.rec = rec;
return recommend;
} }
@Override @Override
public String toString() { public String toString() {
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE)
.append("id", getId()) .append("id", getId())
.append("name", getName()) .append("name", getName())
.append("type", getType()) .append("type", getType())
.append("recEstimation", getRecEstimation()) .append("recEstimation", getRecEstimation())
.append("recEstUnit", getRecEstUnit()) .append("recEstUnit", getRecEstUnit())
.append("recPortion", getRecPortion()) .append("recPortion", getRecPortion())
.append("proteinRatio", getProteinRatio()) .append("proteinRatio", getProteinRatio())
.append("fatRatio", getFatRatio()) .append("fatRatio", getFatRatio())
.append("carbonRatio", getCarbonRatio()) .append("carbonRatio", getCarbonRatio())
.append("remark", getRemark()) .append("remark", getRemark())
.append("area", getArea()) .append("area", getArea())
.append("notRec", getNotRec()) .append("notRec", getNotRec())
.append("recommend", getRecommend()) .append("recommend", getRec())
.append("createBy", getCreateBy()) .append("createBy", getCreateBy())
.append("createTime", getCreateTime()) .append("createTime", getCreateTime())
.append("updateBy", getUpdateBy()) .append("updateBy", getUpdateBy())
.append("updateTime", getUpdateTime()) .append("updateTime", getUpdateTime())
.toString(); .toString();
} }
} }

View File

@ -0,0 +1,66 @@
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_physical_signs
*
* @author wonder
* @date 2020-12-23
*/
public class SysPhysicalSigns extends BaseEntity
{
private static final long serialVersionUID = 1L;
/** id */
private Long id;
/** 体征名称 */
@Excel(name = "体征名称")
private String name;
/** 体征类别 */
@Excel(name = "体征类别")
private Long typeId;
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 setTypeId(Long typeId)
{
this.typeId = typeId;
}
public Long getTypeId()
{
return typeId;
}
@Override
public String toString() {
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
.append("id", getId())
.append("name", getName())
.append("typeId", getTypeId())
.append("remark", getRemark())
.toString();
}
}

View File

@ -0,0 +1,61 @@
package com.stdiet.custom.mapper;
import java.util.List;
import com.stdiet.custom.domain.SysPhysicalSigns;
/**
* 体征Mapper接口
*
* @author wonder
* @date 2020-12-23
*/
public interface SysPhysicalSignsMapper
{
/**
* 查询体征
*
* @param id 体征ID
* @return 体征
*/
public SysPhysicalSigns selectSysPhysicalSignsById(Long id);
/**
* 查询体征列表
*
* @param sysPhysicalSigns 体征
* @return 体征集合
*/
public List<SysPhysicalSigns> selectSysPhysicalSignsList(SysPhysicalSigns sysPhysicalSigns);
/**
* 新增体征
*
* @param sysPhysicalSigns 体征
* @return 结果
*/
public int insertSysPhysicalSigns(SysPhysicalSigns sysPhysicalSigns);
/**
* 修改体征
*
* @param sysPhysicalSigns 体征
* @return 结果
*/
public int updateSysPhysicalSigns(SysPhysicalSigns sysPhysicalSigns);
/**
* 删除体征
*
* @param id 体征ID
* @return 结果
*/
public int deleteSysPhysicalSignsById(Long id);
/**
* 批量删除体征
*
* @param ids 需要删除的数据ID
* @return 结果
*/
public int deleteSysPhysicalSignsByIds(Long[] ids);
}

View File

@ -0,0 +1,61 @@
package com.stdiet.custom.service;
import java.util.List;
import com.stdiet.custom.domain.SysPhysicalSigns;
/**
* 体征Service接口
*
* @author wonder
* @date 2020-12-23
*/
public interface ISysPhysicalSignsService
{
/**
* 查询体征
*
* @param id 体征ID
* @return 体征
*/
public SysPhysicalSigns selectSysPhysicalSignsById(Long id);
/**
* 查询体征列表
*
* @param sysPhysicalSigns 体征
* @return 体征集合
*/
public List<SysPhysicalSigns> selectSysPhysicalSignsList(SysPhysicalSigns sysPhysicalSigns);
/**
* 新增体征
*
* @param sysPhysicalSigns 体征
* @return 结果
*/
public int insertSysPhysicalSigns(SysPhysicalSigns sysPhysicalSigns);
/**
* 修改体征
*
* @param sysPhysicalSigns 体征
* @return 结果
*/
public int updateSysPhysicalSigns(SysPhysicalSigns sysPhysicalSigns);
/**
* 批量删除体征
*
* @param ids 需要删除的体征ID
* @return 结果
*/
public int deleteSysPhysicalSignsByIds(Long[] ids);
/**
* 删除体征信息
*
* @param id 体征ID
* @return 结果
*/
public int deleteSysPhysicalSignsById(Long id);
}

View File

@ -0,0 +1,93 @@
package com.stdiet.custom.service.impl;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.stdiet.custom.mapper.SysPhysicalSignsMapper;
import com.stdiet.custom.domain.SysPhysicalSigns;
import com.stdiet.custom.service.ISysPhysicalSignsService;
/**
* 体征Service业务层处理
*
* @author wonder
* @date 2020-12-23
*/
@Service
public class SysPhysicalSignsServiceImpl implements ISysPhysicalSignsService
{
@Autowired
private SysPhysicalSignsMapper sysPhysicalSignsMapper;
/**
* 查询体征
*
* @param id 体征ID
* @return 体征
*/
@Override
public SysPhysicalSigns selectSysPhysicalSignsById(Long id)
{
return sysPhysicalSignsMapper.selectSysPhysicalSignsById(id);
}
/**
* 查询体征列表
*
* @param sysPhysicalSigns 体征
* @return 体征
*/
@Override
public List<SysPhysicalSigns> selectSysPhysicalSignsList(SysPhysicalSigns sysPhysicalSigns)
{
return sysPhysicalSignsMapper.selectSysPhysicalSignsList(sysPhysicalSigns);
}
/**
* 新增体征
*
* @param sysPhysicalSigns 体征
* @return 结果
*/
@Override
public int insertSysPhysicalSigns(SysPhysicalSigns sysPhysicalSigns)
{
return sysPhysicalSignsMapper.insertSysPhysicalSigns(sysPhysicalSigns);
}
/**
* 修改体征
*
* @param sysPhysicalSigns 体征
* @return 结果
*/
@Override
public int updateSysPhysicalSigns(SysPhysicalSigns sysPhysicalSigns)
{
return sysPhysicalSignsMapper.updateSysPhysicalSigns(sysPhysicalSigns);
}
/**
* 批量删除体征
*
* @param ids 需要删除的体征ID
* @return 结果
*/
@Override
public int deleteSysPhysicalSignsByIds(Long[] ids)
{
return sysPhysicalSignsMapper.deleteSysPhysicalSignsByIds(ids);
}
/**
* 删除体征信息
*
* @param id 体征ID
* @return 结果
*/
@Override
public int deleteSysPhysicalSignsById(Long id)
{
return sysPhysicalSignsMapper.deleteSysPhysicalSignsById(id);
}
}

View File

@ -17,10 +17,27 @@
<result property="createTime" column="create_time" /> <result property="createTime" column="create_time" />
<result property="updateBy" column="update_by" /> <result property="updateBy" column="update_by" />
<result property="updateTime" column="update_time" /> <result property="updateTime" column="update_time" />
<result property="rec" column="rec" />
<result property="notRec" column="not_rec" />
</resultMap> </resultMap>
<sql id="selectSysIngredientVo"> <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 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(
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)
</sql> </sql>
<select id="selectSysIngredientList" parameterType="SysIngredient" resultMap="SysIngredientResult"> <select id="selectSysIngredientList" parameterType="SysIngredient" resultMap="SysIngredientResult">
@ -68,14 +85,14 @@
</insert> </insert>
<insert id="batchIngredientRec" > <insert id="batchIngredientRec" >
insert into sys_ingredient_rec(ingredient_id, rec_id) values insert into sys_ingredient_rec(ingredient_id, physical_signs_id) values
<foreach collection="list" separator="," item="item" index="index"> <foreach collection="list" separator="," item="item" index="index">
(#{item.ingredientId},#{item.recommandId}) (#{item.ingredientId},#{item.recommandId})
</foreach> </foreach>
</insert> </insert>
<insert id="batchIngredientNotRec" > <insert id="batchIngredientNotRec" >
insert into sys_ingredient_not_rec(ingredient_id, not_rec_id) values insert into sys_ingredient_not_rec(ingredient_id, physical_signs_id) values
<foreach collection="list" separator="," item="item" index="index"> <foreach collection="list" separator="," item="item" index="index">
(#{item.ingredientId},#{item.notRecommandId}) (#{item.ingredientId},#{item.notRecommandId})
</foreach> </foreach>

View File

@ -0,0 +1,66 @@
<?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.SysPhysicalSignsMapper">
<resultMap type="SysPhysicalSigns" id="SysPhysicalSignsResult">
<result property="id" column="id" />
<result property="name" column="name" />
<result property="typeId" column="type_id" />
<result property="remark" column="remark" />
</resultMap>
<sql id="selectSysPhysicalSignsVo">
select id, name, type_id, remark from sys_physical_signs
</sql>
<select id="selectSysPhysicalSignsList" parameterType="SysPhysicalSigns" resultMap="SysPhysicalSignsResult">
<include refid="selectSysPhysicalSignsVo"/>
<where>
<if test="name != null and name != ''"> and name like concat('%', #{name}, '%')</if>
<if test="typeId != null "> and type_id = #{typeId}</if>
</where>
</select>
<select id="selectSysPhysicalSignsById" parameterType="Long" resultMap="SysPhysicalSignsResult">
<include refid="selectSysPhysicalSignsVo"/>
where id = #{id}
</select>
<insert id="insertSysPhysicalSigns" parameterType="SysPhysicalSigns" useGeneratedKeys="true" keyProperty="id">
insert into sys_physical_signs
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="name != null">name,</if>
<if test="typeId != null">type_id,</if>
<if test="remark != null">remark,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="name != null">#{name},</if>
<if test="typeId != null">#{typeId},</if>
<if test="remark != null">#{remark},</if>
</trim>
</insert>
<update id="updateSysPhysicalSigns" parameterType="SysPhysicalSigns">
update sys_physical_signs
<trim prefix="SET" suffixOverrides=",">
<if test="name != null">name = #{name},</if>
<if test="typeId != null">type_id = #{typeId},</if>
<if test="remark != null">remark = #{remark},</if>
</trim>
where id = #{id}
</update>
<delete id="deleteSysPhysicalSignsById" parameterType="Long">
delete from sys_physical_signs where id = #{id}
</delete>
<delete id="deleteSysPhysicalSignsByIds" parameterType="String">
delete from sys_physical_signs where id in
<foreach item="id" collection="array" open="(" separator="," close=")">
#{id}
</foreach>
</delete>
</mapper>

View File

@ -0,0 +1,53 @@
import request from '@/utils/request'
// 查询体征列表
export function listPhysicalSigns(query) {
return request({
url: '/custom/physicalSigns/list',
method: 'get',
params: query
})
}
// 查询体征详细
export function getPhysicalSigns(id) {
return request({
url: '/custom/physicalSigns/' + id,
method: 'get'
})
}
// 新增体征
export function addPhysicalSigns(data) {
return request({
url: '/custom/physicalSigns',
method: 'post',
data: data
})
}
// 修改体征
export function updatePhysicalSigns(data) {
return request({
url: '/custom/physicalSigns',
method: 'put',
data: data
})
}
// 删除体征
export function delPhysicalSigns(id) {
return request({
url: '/custom/physicalSigns/' + id,
method: 'delete'
})
}
// 导出体征
export function exportPhysicalSigns(query) {
return request({
url: '/custom/physicalSigns/export',
method: 'get',
params: query
})
}

View File

@ -47,28 +47,28 @@
>新增 >新增
</el-button> </el-button>
</el-col> </el-col>
<!-- <el-col :span="1.5">--> <!-- <el-col :span="1.5">-->
<!-- <el-button--> <!-- <el-button-->
<!-- type="success"--> <!-- type="success"-->
<!-- icon="el-icon-edit"--> <!-- icon="el-icon-edit"-->
<!-- size="mini"--> <!-- size="mini"-->
<!-- :disabled="single"--> <!-- :disabled="single"-->
<!-- @click="handleUpdate"--> <!-- @click="handleUpdate"-->
<!-- v-hasPermi="['custom:ingredient:edit']"--> <!-- v-hasPermi="['custom:ingredient:edit']"-->
<!-- >修改--> <!-- >修改-->
<!-- </el-button>--> <!-- </el-button>-->
<!-- </el-col>--> <!-- </el-col>-->
<!-- <el-col :span="1.5">--> <!-- <el-col :span="1.5">-->
<!-- <el-button--> <!-- <el-button-->
<!-- type="danger"--> <!-- type="danger"-->
<!-- icon="el-icon-delete"--> <!-- icon="el-icon-delete"-->
<!-- size="mini"--> <!-- size="mini"-->
<!-- :disabled="multiple"--> <!-- :disabled="multiple"-->
<!-- @click="handleDelete"--> <!-- @click="handleDelete"-->
<!-- v-hasPermi="['custom:ingredient:remove']"--> <!-- v-hasPermi="['custom:ingredient:remove']"-->
<!-- >删除--> <!-- >删除-->
<!-- </el-button>--> <!-- </el-button>-->
<!-- </el-col>--> <!-- </el-col>-->
<el-col :span="1.5"> <el-col :span="1.5">
<el-button <el-button
type="warning" type="warning"
@ -91,8 +91,8 @@
<el-table-column label="脂肪比例(100g)" align="center" prop="fatRatio"/> <el-table-column label="脂肪比例(100g)" align="center" prop="fatRatio"/>
<el-table-column label="碳水比例(100g)" align="center" prop="carbonRatio"/> <el-table-column label="碳水比例(100g)" align="center" prop="carbonRatio"/>
<el-table-column label="地域" align="center" prop="area" :formatter="areaFormat"/> <el-table-column label="地域" align="center" prop="area" :formatter="areaFormat"/>
<el-table-column label="忌口人群" align="center" prop="notRecIds" :formatter="notRecFormat"/> <el-table-column label="忌口人群" align="center" prop="notRec"/>
<el-table-column label="推荐人群" align="center" prop="recIds" :formatter="recommendFormat"/> <el-table-column label="推荐人群" align="center" prop="rec"/>
<el-table-column label="备注" align="center" prop="remark"/> <el-table-column label="备注" align="center" prop="remark"/>
<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">
@ -177,26 +177,26 @@
</el-col> </el-col>
<el-col :span="24"> <el-col :span="24">
<el-form-item label="忌口人群" label-width="90px"> <el-form-item label="忌口人群" label-width="90px">
<el-checkbox-group v-model="form.notRecIds"> <el-select v-model="form.notRecIds" multiple placeholder="请选择体征">
<el-checkbox <el-option
v-for="dict in notRecOptions" v-for="dict in physicalSignsOptions"
:key="dict.dictValue" :key="dict.dictValue"
:label="dict.dictValue"> :label="dict.dictLabel"
{{dict.dictLabel}} :value="dict.dictValue">
</el-checkbox> </el-option>
</el-checkbox-group> </el-select>
</el-form-item> </el-form-item>
</el-col> </el-col>
<el-col :span="24"> <el-col :span="24">
<el-form-item label="推荐人群" label-width="90px"> <el-form-item label="推荐人群" label-width="90px">
<el-checkbox-group v-model="form.recIds"> <el-select v-model="form.recIds" multiple placeholder="请选择体征">
<el-checkbox <el-option
v-for="dict in recommendOptions" v-for="dict in physicalSignsOptions"
:key="dict.dictValue" :key="dict.dictValue"
:label="dict.dictValue"> :label="dict.dictLabel"
{{dict.dictLabel}} :value="dict.dictValue">
</el-checkbox> </el-option>
</el-checkbox-group> </el-select>
</el-form-item> </el-form-item>
</el-col> </el-col>
<el-col :span="24"> <el-col :span="24">
@ -224,6 +224,8 @@
updateIngredient updateIngredient
} from "@/api/custom/ingredient"; } from "@/api/custom/ingredient";
import {listPhysicalSigns} from "@/api/custom/physicalSigns";
export default { export default {
name: "Ingredient", name: "Ingredient",
data() { data() {
@ -250,10 +252,8 @@
typeOptions: [], typeOptions: [],
// //
areaOptions: [], areaOptions: [],
// //
notRecOptions: [], physicalSignsOptions: [],
//
recommendOptions: [],
// //
queryParams: { queryParams: {
pageNum: 1, pageNum: 1,
@ -278,12 +278,12 @@
this.getDicts("cus_area").then(response => { this.getDicts("cus_area").then(response => {
this.areaOptions = response.data; this.areaOptions = response.data;
}); });
this.getDicts("cus_not_rec_group").then(response => { listPhysicalSigns().then(response => {
this.notRecOptions = response.data; this.physicalSignsOptions = response.rows.map(obj => ({
}); dictLabel: obj.name,
this.getDicts("cus_rec_group").then(response => { dictValue: obj.id
this.recommendOptions = response.data; }))
}); })
}, },
methods: { methods: {
/** 查询食材列表 */ /** 查询食材列表 */
@ -303,14 +303,6 @@
areaFormat(row, column) { areaFormat(row, column) {
return this.selectDictLabel(this.areaOptions, row.area); return this.selectDictLabel(this.areaOptions, row.area);
}, },
//
notRecFormat(row, column) {
return this.selectDictLabels(this.notRecOptions, row.notRecIds.join(','));
},
//
recommendFormat(row, column) {
return this.selectDictLabels(this.recommendOptions, row.recIds.join(','));
},
// //
cancel() { cancel() {
this.open = false; this.open = false;
@ -364,8 +356,8 @@
const id = row.id || this.ids const id = row.id || this.ids
getIngredient(id).then(response => { getIngredient(id).then(response => {
this.form = response.data; this.form = response.data;
// this.form.notRecIds = this.form.notRecIds.split(","); this.form.notRecIds = this.form.rec ? this.form.rec.split(',').map(label => this.physicalSignsOptions.find(pObj => pObj.dictLabel === label).dictValue) : [];
// this.form.recIds = this.form.recIds.split(","); this.form.recIds = this.form.notRec ? this.form.notRec.split(',').map(label => this.physicalSignsOptions.find(pObj => pObj.dictLabel === label).dictValue) : [];
this.open = true; this.open = true;
this.title = "修改食材"; this.title = "修改食材";
}); });
@ -374,8 +366,6 @@
submitForm() { submitForm() {
this.$refs["form"].validate(valid => { this.$refs["form"].validate(valid => {
if (valid) { if (valid) {
// this.form.notRecIds = this.form.notRecIds.join(",");
// this.form.recIds = this.form.recIds.join(",");
if (this.form.id != null) { if (this.form.id != null) {
updateIngredient(this.form).then(response => { updateIngredient(this.form).then(response => {
if (response.code === 200) { if (response.code === 200) {

View File

@ -0,0 +1,294 @@
<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="typeId">
<el-select v-model="queryParams.typeId" placeholder="请选择体征类别" clearable size="small">
<el-option
v-for="dict in typeIdOptions"
: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:physicalSigns:add']"
>新增</el-button>
</el-col>
<!-- <el-col :span="1.5">-->
<!-- <el-button-->
<!-- type="success"-->
<!-- icon="el-icon-edit"-->
<!-- size="mini"-->
<!-- :disabled="single"-->
<!-- @click="handleUpdate"-->
<!-- v-hasPermi="['custom:physicalSigns:edit']"-->
<!-- >修改</el-button>-->
<!-- </el-col>-->
<!-- <el-col :span="1.5">-->
<!-- <el-button-->
<!-- type="danger"-->
<!-- icon="el-icon-delete"-->
<!-- size="mini"-->
<!-- :disabled="multiple"-->
<!-- @click="handleDelete"-->
<!-- v-hasPermi="['custom:physicalSigns:remove']"-->
<!-- >删除</el-button>-->
<!-- </el-col>-->
<el-col :span="1.5">
<el-button
type="warning"
icon="el-icon-download"
size="mini"
@click="handleExport"
v-hasPermi="['custom:physicalSigns:export']"
>导出</el-button>
</el-col>
<right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
</el-row>
<el-table v-loading="loading" :data="physicalSignsList" @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="typeId" :formatter="typeIdFormat" />
<el-table-column label="备注" align="center" prop="remark" />
<el-table-column label="操作" align="center" class-name="small-padding fixed-width">
<template slot-scope="scope">
<el-button
size="mini"
type="text"
icon="el-icon-edit"
@click="handleUpdate(scope.row)"
v-hasPermi="['custom:physicalSigns:edit']"
>修改</el-button>
<el-button
size="mini"
type="text"
icon="el-icon-delete"
@click="handleDelete(scope.row)"
v-hasPermi="['custom:physicalSigns: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="500px" append-to-body>
<el-form ref="form" :model="form" :rules="rules" label-width="80px">
<el-form-item label="体征名称" prop="name">
<el-input v-model="form.name" placeholder="请输入体征名称" />
</el-form-item>
<el-form-item label="体征类别" prop="typeId">
<el-select v-model="form.typeId" placeholder="请选择体征类别">
<el-option
v-for="dict in typeIdOptions"
:key="dict.dictValue"
:label="dict.dictLabel"
:value="parseInt(dict.dictValue)"
></el-option>
</el-select>
</el-form-item>
<el-form-item label="备注" prop="remark">
<el-input v-model="form.remark" 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 { listPhysicalSigns, getPhysicalSigns, delPhysicalSigns, addPhysicalSigns, updatePhysicalSigns, exportPhysicalSigns } from "@/api/custom/physicalSigns";
export default {
name: "PhysicalSigns",
data() {
return {
//
loading: true,
//
ids: [],
//
single: true,
//
multiple: true,
//
showSearch: true,
//
total: 0,
//
physicalSignsList: [],
//
title: "",
//
open: false,
//
typeIdOptions: [],
//
queryParams: {
pageNum: 1,
pageSize: 10,
name: null,
typeId: null,
},
//
form: {},
//
rules: {
}
};
},
created() {
this.getList();
this.getDicts("cus_signs_type").then(response => {
this.typeIdOptions = response.data;
});
},
methods: {
/** 查询体征列表 */
getList() {
this.loading = true;
listPhysicalSigns(this.queryParams).then(response => {
this.physicalSignsList = response.rows;
this.total = response.total;
this.loading = false;
});
},
//
typeIdFormat(row, column) {
return this.selectDictLabel(this.typeIdOptions, row.typeId);
},
//
cancel() {
this.open = false;
this.reset();
},
//
reset() {
this.form = {
id: null,
name: null,
typeId: null,
remark: null
};
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
getPhysicalSigns(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) {
updatePhysicalSigns(this.form).then(response => {
if (response.code === 200) {
this.msgSuccess("修改成功");
this.open = false;
this.getList();
}
});
} else {
addPhysicalSigns(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 delPhysicalSigns(ids);
}).then(() => {
this.getList();
this.msgSuccess("删除成功");
}).catch(function() {});
},
/** 导出按钮操作 */
handleExport() {
const queryParams = this.queryParams;
this.$confirm('是否确认导出所有体征数据项?', "警告", {
confirmButtonText: "确定",
cancelButtonText: "取消",
type: "warning"
}).then(function() {
return exportPhysicalSigns(queryParams);
}).then(response => {
this.download(response.msg);
}).catch(function() {});
}
}
};
</script>