食材添加信息
This commit is contained in:
parent
03eb2508b6
commit
1b5a4f3777
@ -17,11 +17,11 @@ public class SysIngredentFile {
|
|||||||
|
|
||||||
Integer delFlag;
|
Integer delFlag;
|
||||||
|
|
||||||
Long createBy;
|
String createBy;
|
||||||
|
|
||||||
Date createTime;
|
Date createTime;
|
||||||
|
|
||||||
Long updateBy;
|
String updateBy;
|
||||||
|
|
||||||
Date updateTime;
|
Date updateTime;
|
||||||
}
|
}
|
||||||
|
@ -6,6 +6,7 @@ import lombok.Data;
|
|||||||
|
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 食材对象 sys_ingredient
|
* 食材对象 sys_ingredient
|
||||||
@ -110,4 +111,6 @@ public class SysIngredient {
|
|||||||
*/
|
*/
|
||||||
private String info;
|
private String info;
|
||||||
|
|
||||||
|
private List<SysIngredentFile> imgList;
|
||||||
|
|
||||||
}
|
}
|
@ -83,5 +83,5 @@ public interface SysIngredientMapper
|
|||||||
*/
|
*/
|
||||||
public SysIngredient selectSysIngredientByName(@Param("name") String name);
|
public SysIngredient selectSysIngredientByName(@Param("name") String name);
|
||||||
|
|
||||||
int batchInsertIngredientImage(List<SysIngredentFile> ingredentFiles);
|
int batchInsertIngredientImage(List<SysIngredentFile> list);
|
||||||
}
|
}
|
@ -1,7 +1,9 @@
|
|||||||
package com.stdiet.custom.service.impl;
|
package com.stdiet.custom.service.impl;
|
||||||
|
|
||||||
import com.stdiet.common.utils.DateUtils;
|
import com.stdiet.common.utils.DateUtils;
|
||||||
|
import com.stdiet.common.utils.SecurityUtils;
|
||||||
import com.stdiet.common.utils.StringUtils;
|
import com.stdiet.common.utils.StringUtils;
|
||||||
|
import com.stdiet.custom.domain.SysIngredentFile;
|
||||||
import com.stdiet.custom.domain.SysIngredient;
|
import com.stdiet.custom.domain.SysIngredient;
|
||||||
import com.stdiet.custom.domain.SysIngredientNotRec;
|
import com.stdiet.custom.domain.SysIngredientNotRec;
|
||||||
import com.stdiet.custom.domain.SysIngredientRec;
|
import com.stdiet.custom.domain.SysIngredientRec;
|
||||||
@ -61,13 +63,21 @@ public class SysIngredientServiceImpl implements ISysIngredientService {
|
|||||||
//
|
//
|
||||||
insertNotRecommand(sysIngredient);
|
insertNotRecommand(sysIngredient);
|
||||||
//
|
//
|
||||||
|
if (StringUtils.isNotNull(sysIngredient.getImgList())) {
|
||||||
|
List<SysIngredentFile> fileList = sysIngredient.getImgList();
|
||||||
|
for (SysIngredentFile file : fileList) {
|
||||||
|
file.setId(sysIngredient.getId());
|
||||||
|
file.setCreateBy(SecurityUtils.getUsername());
|
||||||
|
file.setCreateTime(DateUtils.getNowDate());
|
||||||
|
}
|
||||||
|
sysIngredientMapper.batchInsertIngredientImage(fileList);
|
||||||
|
}
|
||||||
return rows;
|
return rows;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 新增推荐标签
|
* 新增推荐标签
|
||||||
|
*
|
||||||
* @param ingredient
|
* @param ingredient
|
||||||
*/
|
*/
|
||||||
public void insertRecommand(SysIngredient ingredient) {
|
public void insertRecommand(SysIngredient ingredient) {
|
||||||
@ -88,6 +98,7 @@ public class SysIngredientServiceImpl implements ISysIngredientService {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 新增不推荐标签
|
* 新增不推荐标签
|
||||||
|
*
|
||||||
* @param ingredient
|
* @param ingredient
|
||||||
*/
|
*/
|
||||||
public void insertNotRecommand(SysIngredient ingredient) {
|
public void insertNotRecommand(SysIngredient ingredient) {
|
||||||
@ -151,6 +162,7 @@ public class SysIngredientServiceImpl implements ISysIngredientService {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 根据食材名称查询食材信息
|
* 根据食材名称查询食材信息
|
||||||
|
*
|
||||||
* @param name
|
* @param name
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
|
@ -21,7 +21,7 @@
|
|||||||
<result property="notRec" column="not_rec"/>
|
<result property="notRec" column="not_rec"/>
|
||||||
<result property="reviewStatus" column="review_status"/>
|
<result property="reviewStatus" column="review_status"/>
|
||||||
<result property="info" column="info"/>
|
<result property="info" column="info"/>
|
||||||
<association property="imgFiles" column="id" select="selectIngredentFileById"/>
|
<association property="imgList" column="id" select="selectIngredentFileById"/>
|
||||||
</resultMap>
|
</resultMap>
|
||||||
|
|
||||||
<sql id="selectSysIngredientVo">
|
<sql id="selectSysIngredientVo">
|
||||||
@ -126,6 +126,7 @@
|
|||||||
<if test="updateBy != null">update_by,</if>
|
<if test="updateBy != null">update_by,</if>
|
||||||
<if test="updateTime != null">update_time,</if>
|
<if test="updateTime != null">update_time,</if>
|
||||||
<if test="reviewStatus != null">review_status,</if>
|
<if test="reviewStatus != null">review_status,</if>
|
||||||
|
<if test="info != null">info,</if>
|
||||||
</trim>
|
</trim>
|
||||||
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||||
<if test="name != null">#{name},</if>
|
<if test="name != null">#{name},</if>
|
||||||
@ -140,6 +141,7 @@
|
|||||||
<if test="updateBy != null">#{updateBy},</if>
|
<if test="updateBy != null">#{updateBy},</if>
|
||||||
<if test="updateTime != null">#{updateTime},</if>
|
<if test="updateTime != null">#{updateTime},</if>
|
||||||
<if test="reviewStatus != null">#{reviewStatus},</if>
|
<if test="reviewStatus != null">#{reviewStatus},</if>
|
||||||
|
<if test="info != null">#{info},</if>
|
||||||
</trim>
|
</trim>
|
||||||
</insert>
|
</insert>
|
||||||
|
|
||||||
@ -194,6 +196,7 @@
|
|||||||
<if test="updateBy != null">update_by = #{updateBy},</if>
|
<if test="updateBy != null">update_by = #{updateBy},</if>
|
||||||
<if test="updateTime != null">update_time = #{updateTime},</if>
|
<if test="updateTime != null">update_time = #{updateTime},</if>
|
||||||
<if test="reviewStatus != null">review_status = #{reviewStatus},</if>
|
<if test="reviewStatus != null">review_status = #{reviewStatus},</if>
|
||||||
|
<if test="info != null">info = #{info},</if>
|
||||||
</trim>
|
</trim>
|
||||||
where id = #{id}
|
where id = #{id}
|
||||||
</update>
|
</update>
|
||||||
|
60
stdiet-ui/src/components/FileUpload/index.vue
Normal file
60
stdiet-ui/src/components/FileUpload/index.vue
Normal file
@ -0,0 +1,60 @@
|
|||||||
|
<template>
|
||||||
|
<el-upload
|
||||||
|
ref="ElUpload"
|
||||||
|
v-bind="$props"
|
||||||
|
>
|
||||||
|
<slot></slot>
|
||||||
|
</el-upload>
|
||||||
|
</template>
|
||||||
|
<script>
|
||||||
|
export default {
|
||||||
|
name: 'formUpload',
|
||||||
|
componentName: 'formUpload',
|
||||||
|
props: [
|
||||||
|
'value', 'action', 'headers', 'multiple', 'data', 'show-file-list', 'name', 'with-credentials', 'drag',
|
||||||
|
'accept', 'on-preview', 'on-remove', 'on-success', 'on-error', 'on-progress', 'on-change',
|
||||||
|
'before-upload', 'before-remove', 'list-type', 'auto-upload', 'file-list', 'http-request',
|
||||||
|
'disabled', 'limit', 'on-exceed',
|
||||||
|
],
|
||||||
|
data() {
|
||||||
|
return {
|
||||||
|
currentValue: this.value,
|
||||||
|
};
|
||||||
|
},
|
||||||
|
watch: {
|
||||||
|
// eslint-disable-next-line
|
||||||
|
value(val, oldValue) {
|
||||||
|
this.setCurrentValue(val);
|
||||||
|
},
|
||||||
|
// eslint-disable-next-line
|
||||||
|
fileList(val, oldValue) {
|
||||||
|
this.setCurrentValue(val);
|
||||||
|
},
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
clearFiles() {
|
||||||
|
this.$refs.ElUpload.clearFiles();
|
||||||
|
},
|
||||||
|
abort(file) {
|
||||||
|
this.$refs.ElUpload.abort(file);
|
||||||
|
},
|
||||||
|
dispatch(componentName, eventName, params) {
|
||||||
|
let parent = this.$parent || this.$root;
|
||||||
|
let name = parent.$options.componentName;
|
||||||
|
while (parent && (!name || name !== componentName)) {
|
||||||
|
parent = parent.$parent;
|
||||||
|
if (parent) {
|
||||||
|
name = parent.$options.componentName;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (parent) {
|
||||||
|
parent.$emit(...[eventName].concat(params));
|
||||||
|
}
|
||||||
|
},
|
||||||
|
setCurrentValue(value) {
|
||||||
|
this.currentValue = value;
|
||||||
|
this.dispatch('ElFormItem', 'el.form.change', [].concat(value));
|
||||||
|
},
|
||||||
|
},
|
||||||
|
};
|
||||||
|
</script>
|
@ -245,55 +245,17 @@
|
|||||||
/>
|
/>
|
||||||
|
|
||||||
<!-- 添加或修改食材对话框 -->
|
<!-- 添加或修改食材对话框 -->
|
||||||
<el-dialog :title="title" :visible.sync="open" width="620px" append-to-body>
|
<el-dialog :title="title" :visible.sync="open" width="720px" append-to-body>
|
||||||
<el-row :gutter="15">
|
<el-row :gutter="8">
|
||||||
<el-form ref="form" :model="form" :rules="rules" label-width="80px">
|
<el-form ref="form" :model="form" :rules="rules" label-width="80px">
|
||||||
<el-col :span="12">
|
<el-col :span="8">
|
||||||
<el-form-item label="食材名称" prop="name" label-width="90px">
|
<el-form-item label="食材名称" prop="name" label-width="90px">
|
||||||
<el-input v-model="form.name" placeholder="请输入食材名称" />
|
<el-input v-model="form.name" placeholder="请输入名称" />
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
</el-col>
|
</el-col>
|
||||||
<el-col :span="12">
|
<el-col :span="8">
|
||||||
<el-form-item
|
<el-form-item label="食材类别" prop="type" label-width="100px">
|
||||||
label="蛋白质比例"
|
<el-select v-model="form.type" placeholder="请选择类别">
|
||||||
prop="proteinRatio"
|
|
||||||
label-width="90px"
|
|
||||||
>
|
|
||||||
<el-input
|
|
||||||
v-model="form.proteinRatio"
|
|
||||||
placeholder="请输入蛋白质比例"
|
|
||||||
style="width: 150px"
|
|
||||||
/>
|
|
||||||
/100g
|
|
||||||
</el-form-item>
|
|
||||||
</el-col>
|
|
||||||
<el-col :span="12">
|
|
||||||
<el-form-item label="脂肪比例" prop="fatRatio" label-width="90px">
|
|
||||||
<el-input
|
|
||||||
v-model="form.fatRatio"
|
|
||||||
placeholder="请输入脂肪比例"
|
|
||||||
style="width: 150px"
|
|
||||||
/>
|
|
||||||
/100g
|
|
||||||
</el-form-item>
|
|
||||||
</el-col>
|
|
||||||
<el-col :span="12">
|
|
||||||
<el-form-item
|
|
||||||
label="碳水比例"
|
|
||||||
prop="carbonRatio"
|
|
||||||
label-width="90px"
|
|
||||||
>
|
|
||||||
<el-input
|
|
||||||
v-model="form.carbonRatio"
|
|
||||||
placeholder="请输入碳水比例"
|
|
||||||
style="width: 150px"
|
|
||||||
/>
|
|
||||||
/100g
|
|
||||||
</el-form-item>
|
|
||||||
</el-col>
|
|
||||||
<el-col :span="12">
|
|
||||||
<el-form-item label="食材类别" prop="type" label-width="90px">
|
|
||||||
<el-select v-model="form.type" placeholder="请选择食材类别">
|
|
||||||
<el-option
|
<el-option
|
||||||
v-for="dict in typeOptions"
|
v-for="dict in typeOptions"
|
||||||
:key="dict.dictValue"
|
:key="dict.dictValue"
|
||||||
@ -303,8 +265,8 @@
|
|||||||
</el-select>
|
</el-select>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
</el-col>
|
</el-col>
|
||||||
<el-col :span="12">
|
<el-col :span="8">
|
||||||
<el-form-item label="地域" prop="area" label-width="90px">
|
<el-form-item label="地域" prop="area" label-width="100px">
|
||||||
<el-select v-model="form.area" placeholder="请选择地域">
|
<el-select v-model="form.area" placeholder="请选择地域">
|
||||||
<el-option
|
<el-option
|
||||||
v-for="dict in areaOptions"
|
v-for="dict in areaOptions"
|
||||||
@ -315,8 +277,35 @@
|
|||||||
</el-select>
|
</el-select>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
</el-col>
|
</el-col>
|
||||||
|
<el-col :span="8">
|
||||||
|
<el-form-item
|
||||||
|
label="蛋白质/100g"
|
||||||
|
prop="proteinRatio"
|
||||||
|
label-width="100px"
|
||||||
|
>
|
||||||
|
<el-input
|
||||||
|
v-model="form.proteinRatio"
|
||||||
|
placeholder="蛋白质比例"
|
||||||
|
width="80px"
|
||||||
|
/>
|
||||||
|
</el-form-item>
|
||||||
|
</el-col>
|
||||||
|
<el-col :span="8">
|
||||||
|
<el-form-item label="脂肪/100g" prop="fatRatio" label-width="90px">
|
||||||
|
<el-input v-model="form.fatRatio" placeholder="脂肪比例" />
|
||||||
|
</el-form-item>
|
||||||
|
</el-col>
|
||||||
|
<el-col :span="8">
|
||||||
|
<el-form-item
|
||||||
|
label="碳水/100g"
|
||||||
|
prop="carbonRatio"
|
||||||
|
label-width="90px"
|
||||||
|
>
|
||||||
|
<el-input v-model="form.carbonRatio" placeholder="碳水比例" />
|
||||||
|
</el-form-item>
|
||||||
|
</el-col>
|
||||||
<el-col :span="12">
|
<el-col :span="12">
|
||||||
<el-form-item label="忌口人群" label-width="90px">
|
<el-form-item label="忌口人群" label-width="76px">
|
||||||
<el-select
|
<el-select
|
||||||
v-model="form.notRecIds"
|
v-model="form.notRecIds"
|
||||||
multiple
|
multiple
|
||||||
@ -333,7 +322,7 @@
|
|||||||
</el-form-item>
|
</el-form-item>
|
||||||
</el-col>
|
</el-col>
|
||||||
<el-col :span="12">
|
<el-col :span="12">
|
||||||
<el-form-item label="推荐人群" label-width="90px">
|
<el-form-item label="推荐人群" label-width="76px">
|
||||||
<el-select
|
<el-select
|
||||||
v-model="form.recIds"
|
v-model="form.recIds"
|
||||||
multiple
|
multiple
|
||||||
@ -349,9 +338,17 @@
|
|||||||
</el-select>
|
</el-select>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
</el-col>
|
</el-col>
|
||||||
<el-col :span="12">
|
<el-col
|
||||||
<el-form-item label="审核状态" prop="reviewStatus">
|
:span="12"
|
||||||
|
style="position: absolute; left: 100px; top: -70px"
|
||||||
|
>
|
||||||
|
<el-form-item
|
||||||
|
label="审核状态"
|
||||||
|
prop="reviewStatus"
|
||||||
|
label-width="76px"
|
||||||
|
>
|
||||||
<el-select
|
<el-select
|
||||||
|
style="position: absolute"
|
||||||
v-model="form.reviewStatus"
|
v-model="form.reviewStatus"
|
||||||
placeholder="请选择审核状态"
|
placeholder="请选择审核状态"
|
||||||
clearable
|
clearable
|
||||||
@ -365,9 +362,43 @@
|
|||||||
</el-select>
|
</el-select>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
</el-col>
|
</el-col>
|
||||||
|
<el-col :span="20">
|
||||||
|
<el-form-item label="食材图片" prop="imgList">
|
||||||
|
<el-upload
|
||||||
|
drag
|
||||||
|
:auto-upload="true"
|
||||||
|
:headers="{ Authorization: 'Bearer ' + token }"
|
||||||
|
:limit="5"
|
||||||
|
:multiple="true"
|
||||||
|
:file-list="form.imgList"
|
||||||
|
:action="actionUrl"
|
||||||
|
:on-success="handleOnUploadSuccess"
|
||||||
|
:on-remove="handleOnUploadRemove"
|
||||||
|
>
|
||||||
|
<em class="el-icon-upload" />
|
||||||
|
<div class="el-upload__text">
|
||||||
|
将文件拖到此处,或<em>点击上传</em>
|
||||||
|
</div>
|
||||||
|
<div class="el-upload__tip" slot="tip">
|
||||||
|
最多可上传5个文件,且每个文件不超过10M
|
||||||
|
</div>
|
||||||
|
</el-upload>
|
||||||
|
</el-form-item>
|
||||||
|
</el-col>
|
||||||
|
<el-col :span="24">
|
||||||
|
<el-form-item label="介绍" prop="info" label-width="90px">
|
||||||
|
<el-input
|
||||||
|
:rows="5"
|
||||||
|
v-model="form.info"
|
||||||
|
type="textarea"
|
||||||
|
placeholder="请输入内容"
|
||||||
|
/>
|
||||||
|
</el-form-item>
|
||||||
|
</el-col>
|
||||||
<el-col :span="24">
|
<el-col :span="24">
|
||||||
<el-form-item label="备注" prop="remark" label-width="90px">
|
<el-form-item label="备注" prop="remark" label-width="90px">
|
||||||
<el-input
|
<el-input
|
||||||
|
:rows="3"
|
||||||
v-model="form.remark"
|
v-model="form.remark"
|
||||||
type="textarea"
|
type="textarea"
|
||||||
placeholder="请输入内容"
|
placeholder="请输入内容"
|
||||||
@ -395,6 +426,8 @@ import {
|
|||||||
} from "@/api/custom/ingredient";
|
} from "@/api/custom/ingredient";
|
||||||
|
|
||||||
import AutoHideInfo from "@/components/AutoHideInfo";
|
import AutoHideInfo from "@/components/AutoHideInfo";
|
||||||
|
import FileUpload from "@/components/FileUpload";
|
||||||
|
import { getToken } from "@/utils/auth";
|
||||||
|
|
||||||
import { listPhysicalSigns } from "@/api/custom/physicalSigns";
|
import { listPhysicalSigns } from "@/api/custom/physicalSigns";
|
||||||
|
|
||||||
@ -402,11 +435,14 @@ export default {
|
|||||||
name: "Ingredient",
|
name: "Ingredient",
|
||||||
components: {
|
components: {
|
||||||
autohideinfo: AutoHideInfo,
|
autohideinfo: AutoHideInfo,
|
||||||
|
FileUpload,
|
||||||
},
|
},
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
// 遮罩层
|
// 遮罩层
|
||||||
loading: true,
|
loading: true,
|
||||||
|
//
|
||||||
|
actionUrl: process.env.VUE_APP_BASE_API + "/custom/fileUpload/ingredient",
|
||||||
// 选中数组
|
// 选中数组
|
||||||
ids: [],
|
ids: [],
|
||||||
// 非单个禁用
|
// 非单个禁用
|
||||||
@ -431,6 +467,8 @@ export default {
|
|||||||
areaOptions: [],
|
areaOptions: [],
|
||||||
//
|
//
|
||||||
physicalSignsOptions: [],
|
physicalSignsOptions: [],
|
||||||
|
//
|
||||||
|
token: getToken(),
|
||||||
// 查询参数
|
// 查询参数
|
||||||
queryParams: {
|
queryParams: {
|
||||||
pageNum: 1,
|
pageNum: 1,
|
||||||
@ -506,6 +544,7 @@ export default {
|
|||||||
createTime: null,
|
createTime: null,
|
||||||
updateBy: null,
|
updateBy: null,
|
||||||
updateTime: null,
|
updateTime: null,
|
||||||
|
imgList: [],
|
||||||
};
|
};
|
||||||
this.resetForm("form");
|
this.resetForm("form");
|
||||||
},
|
},
|
||||||
@ -621,6 +660,12 @@ export default {
|
|||||||
string2Arr(str) {
|
string2Arr(str) {
|
||||||
return str ? str.split(",") : [];
|
return str ? str.split(",") : [];
|
||||||
},
|
},
|
||||||
|
handleOnUploadSuccess() {
|
||||||
|
|
||||||
|
},
|
||||||
|
handleOnUploadRemove() {
|
||||||
|
|
||||||
|
}
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user