From 7a3ab6bfef5f1a3a781b667f429f00e922517161 Mon Sep 17 00:00:00 2001 From: huangdeliang <huangdeliang@skieer.com> Date: Tue, 16 Mar 2021 15:05:53 +0800 Subject: [PATCH 1/3] =?UTF-8?q?=E5=AE=A2=E6=88=B7=E6=A1=A3=E6=A1=88?= =?UTF-8?q?=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../mapper/custom/SysCustomerMapper.xml | 1 + .../src/components/ContractDrawer/index.vue | 2 +- .../components/HeatStatisticsDrawer/index.vue | 2 +- .../components/PhysicalSignsDialog/index.vue | 24 ++++++++++++++++++- .../components/RecipesPlanDrawer/index.vue | 2 +- stdiet-ui/src/views/custom/contract/index.vue | 2 +- stdiet-ui/src/views/custom/customer/index.vue | 20 +++++++++------- .../custom/recipesBuild/VerifyView/index.vue | 2 +- .../src/views/custom/recipesPlan/index.vue | 1 + 9 files changed, 41 insertions(+), 15 deletions(-) diff --git a/stdiet-custom/src/main/resources/mapper/custom/SysCustomerMapper.xml b/stdiet-custom/src/main/resources/mapper/custom/SysCustomerMapper.xml index 9bf06d611..4e4c7bab9 100644 --- a/stdiet-custom/src/main/resources/mapper/custom/SysCustomerMapper.xml +++ b/stdiet-custom/src/main/resources/mapper/custom/SysCustomerMapper.xml @@ -37,6 +37,7 @@ where del_flag = 0 <if test="name != null and name != ''"> and name like concat('%', #{name}, '%')</if> <if test="phone != null and phone != ''"> and phone like concat('%', #{phone}, '%')</if> + <if test="fansChannel != null "> and fans_channel = #{fansChannel}</if> order by create_time desc </select> diff --git a/stdiet-ui/src/components/ContractDrawer/index.vue b/stdiet-ui/src/components/ContractDrawer/index.vue index 60dcc8ea8..7be5b4902 100644 --- a/stdiet-ui/src/components/ContractDrawer/index.vue +++ b/stdiet-ui/src/components/ContractDrawer/index.vue @@ -70,7 +70,7 @@ >复制 </el-button> <el-popover placement="top" trigger="click"> - <VueQr :text="copyValue" :logoSrc="logo" size="256" /> + <VueQr :text="copyValue" :logoSrc="logo" :size="256" /> <el-button slot="reference" icon="el-icon-picture-outline" diff --git a/stdiet-ui/src/components/HeatStatisticsDrawer/index.vue b/stdiet-ui/src/components/HeatStatisticsDrawer/index.vue index c8af6d54f..05416382c 100644 --- a/stdiet-ui/src/components/HeatStatisticsDrawer/index.vue +++ b/stdiet-ui/src/components/HeatStatisticsDrawer/index.vue @@ -25,7 +25,7 @@ trigger="click" style="margin: 0 12px" > - <VueQr :text="copyValue" :logoSrc="logo" size="256" /> + <VueQr :text="copyValue" :logoSrc="logo" :size="256" /> <el-button slot="reference" size="mini" diff --git a/stdiet-ui/src/components/PhysicalSignsDialog/index.vue b/stdiet-ui/src/components/PhysicalSignsDialog/index.vue index 3b505ea31..2d7f4c080 100644 --- a/stdiet-ui/src/components/PhysicalSignsDialog/index.vue +++ b/stdiet-ui/src/components/PhysicalSignsDialog/index.vue @@ -201,7 +201,7 @@ v-show="dataList.length == 0" style="font-size: 20px; text-align: center" > - <VueQr :text="copyValue" :logoSrc="logo" size="256"/> + <VueQr :text="copyValue" :logoSrc="logo" :size="256" /> <div style="text-align: center; margin-top: 20px"> <el-button icon="el-icon-share" @@ -689,6 +689,28 @@ export default { ? medicalReportNameArray[2] : "体检报告(3)" : ""; + detailHealthy.moistureDate = detailHealthy.moistureDate + .split(",") + .reduce((arr, cur) => { + const tarData = healthyData.moistureDateArray.find( + (obj) => obj.value === cur + ); + if (tarData) { + arr.push(tarData.name); + } + return arr; + }, []); + detailHealthy.bloodData = detailHealthy.bloodData + .split(",") + .reduce((arr, cur) => { + const tarData = healthyData.bloodDataArray.find( + (obj) => obj.value === cur + ); + if (tarData) { + arr.push(tarData.name); + } + return arr; + }, []); this.detailHealthy = detailHealthy; for (let i = 0; i < this.healthyTitleData.length; i++) { let stepArray = []; diff --git a/stdiet-ui/src/components/RecipesPlanDrawer/index.vue b/stdiet-ui/src/components/RecipesPlanDrawer/index.vue index 664a1d27c..b8547591e 100644 --- a/stdiet-ui/src/components/RecipesPlanDrawer/index.vue +++ b/stdiet-ui/src/components/RecipesPlanDrawer/index.vue @@ -25,7 +25,7 @@ v-if="cusOutId" style="margin: 0 12px" > - <VueQr :text="copyValue" :logoSrc="logo" size="256" /> + <VueQr :text="copyValue" :logoSrc="logo" :size="256" /> <el-button slot="reference" size="mini" diff --git a/stdiet-ui/src/views/custom/contract/index.vue b/stdiet-ui/src/views/custom/contract/index.vue index 9b82c243d..2c825e0a8 100644 --- a/stdiet-ui/src/views/custom/contract/index.vue +++ b/stdiet-ui/src/views/custom/contract/index.vue @@ -198,7 +198,7 @@ >复制 </el-button> <el-popover placement="top" trigger="click"> - <VueQr :text="copyValue" :logoSrc="logo" size="256"/> + <VueQr :text="copyValue" :logoSrc="logo" :size="256"/> <el-button slot="reference" icon="el-icon-picture-outline" diff --git a/stdiet-ui/src/views/custom/customer/index.vue b/stdiet-ui/src/views/custom/customer/index.vue index 2be568d01..e2484bd46 100644 --- a/stdiet-ui/src/views/custom/customer/index.vue +++ b/stdiet-ui/src/views/custom/customer/index.vue @@ -25,16 +25,17 @@ @keyup.enter.native="handleQuery" /> </el-form-item> - <!--<el-form-item label="主营养师" prop="mainDietitian"> - <el-input - v-model="queryParams.mainDietitian" - placeholder="请输入主营养师" - clearable - size="small" - @keyup.enter.native="handleQuery" - /> + <el-form-item label="进粉渠道" prop="fansChannel"> + <el-select v-model="queryParams.fansChannel" placeholder="请选择"> + <el-option + v-for="dict in fansChannelOptions" + :key="dict.dictValue" + :label="dict.dictLabel" + :value="parseInt(dict.dictValue)" + /> + </el-select> </el-form-item> - <el-form-item label="营养师助理" prop="assistantDietitian"> + <!--<el-form-item label="营养师助理" prop="assistantDietitian"> <el-input v-model="queryParams.assistantDietitian" placeholder="请输入营养师助理" @@ -430,6 +431,7 @@ export default { queryParams: { pageNum: 1, pageSize: 10, + fansChannel: null, name: null, phone: null, mainDietitian: null, diff --git a/stdiet-ui/src/views/custom/recipesBuild/VerifyView/index.vue b/stdiet-ui/src/views/custom/recipesBuild/VerifyView/index.vue index d5ae09756..bb423afbc 100644 --- a/stdiet-ui/src/views/custom/recipesBuild/VerifyView/index.vue +++ b/stdiet-ui/src/views/custom/recipesBuild/VerifyView/index.vue @@ -87,7 +87,7 @@ export default { this.setNotRecIgds({ data: [] }); } - this.selectedIgd = data.id; + this.selectedIgd = data.id === this.selectedIgd ? 0 : data.id; this.setNotRecIgds({ data: [this.selectedIgd] }); }, diff --git a/stdiet-ui/src/views/custom/recipesPlan/index.vue b/stdiet-ui/src/views/custom/recipesPlan/index.vue index 3f15d2125..1d1ee402a 100644 --- a/stdiet-ui/src/views/custom/recipesPlan/index.vue +++ b/stdiet-ui/src/views/custom/recipesPlan/index.vue @@ -200,6 +200,7 @@ export default { orderDialog: undefined, reviewStatusOptions: [ { dictValue: 0, dictLabel: "未制作" }, + { dictValue: 3, dictLabel: "制作中" }, { dictValue: 1, dictLabel: "未审核" }, { dictValue: 2, dictLabel: "已审核" }, ], From 03eb2508b6066143981450b4a137741e916920d2 Mon Sep 17 00:00:00 2001 From: huangdeliang <huangdeliang@skieer.com> Date: Tue, 16 Mar 2021 17:53:17 +0800 Subject: [PATCH 2/3] =?UTF-8?q?=E9=A3=9F=E6=9D=90=E6=B7=BB=E5=8A=A0?= =?UTF-8?q?=E4=BF=A1=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../custom/SysCustomerCaseController.java | 65 +- .../custom/SysFileUploadController.java | 54 ++ .../common/utils/oss/AliyunOSSUtils.java | 2 +- .../custom/domain/SysIngredentFile.java | 27 + .../stdiet/custom/domain/SysIngredient.java | 7 +- .../custom/mapper/SysIngredientMapper.java | 4 + .../impl/SysIngredientServiceImpl.java | 3 + .../mapper/custom/SysIngredientMapper.xml | 144 ++-- .../src/components/FileUpload/DragUpload.vue | 118 +-- .../components/FileUpload/DragUploadEdit.vue | 162 ++-- .../src/views/custom/customerCase/index.vue | 693 ++++++++++-------- 11 files changed, 761 insertions(+), 518 deletions(-) create mode 100644 stdiet-admin/src/main/java/com/stdiet/web/controller/custom/SysFileUploadController.java create mode 100644 stdiet-custom/src/main/java/com/stdiet/custom/domain/SysIngredentFile.java diff --git a/stdiet-admin/src/main/java/com/stdiet/web/controller/custom/SysCustomerCaseController.java b/stdiet-admin/src/main/java/com/stdiet/web/controller/custom/SysCustomerCaseController.java index aa4f90018..38ff8e102 100644 --- a/stdiet-admin/src/main/java/com/stdiet/web/controller/custom/SysCustomerCaseController.java +++ b/stdiet-admin/src/main/java/com/stdiet/web/controller/custom/SysCustomerCaseController.java @@ -141,36 +141,37 @@ public class SysCustomerCaseController extends BaseController return getDataTable(list); } - /** - * 上传文件到OSS返回URL - */ - @PostMapping("/uploadCaseFile") - @PreAuthorize("@ss.hasPermi('custom:customerCase:list')") - public AjaxResult uploadCseFile(MultipartFile file) throws Exception { - try { - if(file == null){ - return AjaxResult.error("文件不存在"); - } - int fileNameLength = file.getOriginalFilename().length(); - if (fileNameLength > FileUploadUtils.DEFAULT_FILE_NAME_LENGTH) - { - throw new FileNameLengthLimitExceededException(FileUploadUtils.DEFAULT_FILE_NAME_LENGTH); - } - FileUploadUtils.assertAllowed(file, MimeTypeUtils.DEFAULT_ALLOWED_EXTENSION); - - String fileUrl = AliyunOSSUtils.uploadFileInputSteam(AliyunOSSConfig.casePrefix, DateUtils.getDate()+"/"+file.getOriginalFilename(), file); - - AjaxResult ajax = null; - if(StringUtils.isNotEmpty(fileUrl)){ - ajax = AjaxResult.success(); - ajax.put("fileUrl", fileUrl); - ajax.put("fileName", file.getOriginalFilename()); - }else{ - ajax = AjaxResult.error("文件上传失败"); - } - return ajax; - } catch (Exception e) { - return AjaxResult.error("文件上传失败"); - } - } +// 转移到SysFileUploadController.java +// /** +// * 上传文件到OSS返回URL +// */ +// @PostMapping("/uploadCaseFile") +// @PreAuthorize("@ss.hasPermi('custom:customerCase:list')") +// public AjaxResult uploadCseFile(MultipartFile file) throws Exception { +// try { +// if(file == null){ +// return AjaxResult.error("文件不存在"); +// } +// int fileNameLength = file.getOriginalFilename().length(); +// if (fileNameLength > FileUploadUtils.DEFAULT_FILE_NAME_LENGTH) +// { +// throw new FileNameLengthLimitExceededException(FileUploadUtils.DEFAULT_FILE_NAME_LENGTH); +// } +// FileUploadUtils.assertAllowed(file, MimeTypeUtils.DEFAULT_ALLOWED_EXTENSION); +// +// String fileUrl = AliyunOSSUtils.uploadFileInputSteam(AliyunOSSConfig.casePrefix, DateUtils.getDate()+"/"+file.getOriginalFilename(), file); +// +// AjaxResult ajax = null; +// if(StringUtils.isNotEmpty(fileUrl)){ +// ajax = AjaxResult.success(); +// ajax.put("fileUrl", fileUrl); +// ajax.put("fileName", file.getOriginalFilename()); +// }else{ +// ajax = AjaxResult.error("文件上传失败"); +// } +// return ajax; +// } catch (Exception e) { +// return AjaxResult.error("文件上传失败"); +// } +// } } \ No newline at end of file diff --git a/stdiet-admin/src/main/java/com/stdiet/web/controller/custom/SysFileUploadController.java b/stdiet-admin/src/main/java/com/stdiet/web/controller/custom/SysFileUploadController.java new file mode 100644 index 000000000..2745957c1 --- /dev/null +++ b/stdiet-admin/src/main/java/com/stdiet/web/controller/custom/SysFileUploadController.java @@ -0,0 +1,54 @@ +package com.stdiet.web.controller.custom; + +import com.stdiet.common.core.controller.BaseController; +import com.stdiet.common.core.domain.AjaxResult; +import com.stdiet.common.exception.file.FileNameLengthLimitExceededException; +import com.stdiet.common.utils.DateUtils; +import com.stdiet.common.utils.StringUtils; +import com.stdiet.common.utils.file.FileUploadUtils; +import com.stdiet.common.utils.file.MimeTypeUtils; +import com.stdiet.common.utils.oss.AliyunOSSUtils; +import org.springframework.security.access.prepost.PreAuthorize; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; +import org.springframework.web.multipart.MultipartFile; + +@RestController +@RequestMapping("/custom/fileUpload") +public class SysFileUploadController extends BaseController { + + /** + * 上传文件到OSS返回URL + */ + @PostMapping(value = "/{prefix}") + @PreAuthorize("@ss.hasPermi('custom:file:upload')") + public AjaxResult uploadCseFile(MultipartFile file, @PathVariable String prefix) throws Exception { + + try { + if (file == null) { + return AjaxResult.error("文件不存在"); + } + int fileNameLength = file.getOriginalFilename().length(); + if (fileNameLength > FileUploadUtils.DEFAULT_FILE_NAME_LENGTH) { + throw new FileNameLengthLimitExceededException(FileUploadUtils.DEFAULT_FILE_NAME_LENGTH); + } + FileUploadUtils.assertAllowed(file, MimeTypeUtils.DEFAULT_ALLOWED_EXTENSION); + + String fileUrl = AliyunOSSUtils.uploadFileInputSteam(prefix + '/', DateUtils.getDate() + "/" + file.getOriginalFilename(), file); + + AjaxResult ajax = null; + if (StringUtils.isNotEmpty(fileUrl)) { + ajax = AjaxResult.success(); + ajax.put("fileUrl", fileUrl); + ajax.put("fileName", file.getOriginalFilename()); + } else { + ajax = AjaxResult.error("文件上传失败"); + } + return ajax; + } catch (Exception e) { + return AjaxResult.error("文件上传失败"); + } + } +} diff --git a/stdiet-common/src/main/java/com/stdiet/common/utils/oss/AliyunOSSUtils.java b/stdiet-common/src/main/java/com/stdiet/common/utils/oss/AliyunOSSUtils.java index 0f2199d0d..0b77da830 100644 --- a/stdiet-common/src/main/java/com/stdiet/common/utils/oss/AliyunOSSUtils.java +++ b/stdiet-common/src/main/java/com/stdiet/common/utils/oss/AliyunOSSUtils.java @@ -248,7 +248,7 @@ public class AliyunOSSUtils { /** * - * @param fileUrl + * @param fileUrlList * @return */ public static List<String> generatePresignedUrl(List<String> fileUrlList){ diff --git a/stdiet-custom/src/main/java/com/stdiet/custom/domain/SysIngredentFile.java b/stdiet-custom/src/main/java/com/stdiet/custom/domain/SysIngredentFile.java new file mode 100644 index 000000000..ceab8eccd --- /dev/null +++ b/stdiet-custom/src/main/java/com/stdiet/custom/domain/SysIngredentFile.java @@ -0,0 +1,27 @@ +package com.stdiet.custom.domain; + +import lombok.Data; + +import java.util.Date; + +@Data +public class SysIngredentFile { + + Long id; + + Long igdId; + + String fileUrl; + + String fileName; + + Integer delFlag; + + Long createBy; + + Date createTime; + + Long updateBy; + + Date updateTime; +} diff --git a/stdiet-custom/src/main/java/com/stdiet/custom/domain/SysIngredient.java b/stdiet-custom/src/main/java/com/stdiet/custom/domain/SysIngredient.java index c5cd66719..4f52f9902 100644 --- a/stdiet-custom/src/main/java/com/stdiet/custom/domain/SysIngredient.java +++ b/stdiet-custom/src/main/java/com/stdiet/custom/domain/SysIngredient.java @@ -15,8 +15,6 @@ import java.util.Date; */ @Data public class SysIngredient { - private static final long serialVersionUID = 1L; - /** * id */ @@ -107,4 +105,9 @@ public class SysIngredient { private Long[] notRecIds; + /** + * 食材信息 + */ + private String info; + } \ No newline at end of file diff --git a/stdiet-custom/src/main/java/com/stdiet/custom/mapper/SysIngredientMapper.java b/stdiet-custom/src/main/java/com/stdiet/custom/mapper/SysIngredientMapper.java index d1e8b9d9f..8ac25d4aa 100644 --- a/stdiet-custom/src/main/java/com/stdiet/custom/mapper/SysIngredientMapper.java +++ b/stdiet-custom/src/main/java/com/stdiet/custom/mapper/SysIngredientMapper.java @@ -1,6 +1,8 @@ package com.stdiet.custom.mapper; import java.util.List; + +import com.stdiet.custom.domain.SysIngredentFile; import com.stdiet.custom.domain.SysIngredient; import com.stdiet.custom.domain.SysIngredientNotRec; import com.stdiet.custom.domain.SysIngredientRec; @@ -80,4 +82,6 @@ public interface SysIngredientMapper * @return */ public SysIngredient selectSysIngredientByName(@Param("name") String name); + + int batchInsertIngredientImage(List<SysIngredentFile> ingredentFiles); } \ No newline at end of file diff --git a/stdiet-custom/src/main/java/com/stdiet/custom/service/impl/SysIngredientServiceImpl.java b/stdiet-custom/src/main/java/com/stdiet/custom/service/impl/SysIngredientServiceImpl.java index 2814d59bd..c37cf6f08 100644 --- a/stdiet-custom/src/main/java/com/stdiet/custom/service/impl/SysIngredientServiceImpl.java +++ b/stdiet-custom/src/main/java/com/stdiet/custom/service/impl/SysIngredientServiceImpl.java @@ -60,6 +60,9 @@ public class SysIngredientServiceImpl implements ISysIngredientService { insertRecommand(sysIngredient); // insertNotRecommand(sysIngredient); + // + + return rows; } diff --git a/stdiet-custom/src/main/resources/mapper/custom/SysIngredientMapper.xml b/stdiet-custom/src/main/resources/mapper/custom/SysIngredientMapper.xml index 68e4ab886..122e4bf06 100644 --- a/stdiet-custom/src/main/resources/mapper/custom/SysIngredientMapper.xml +++ b/stdiet-custom/src/main/resources/mapper/custom/SysIngredientMapper.xml @@ -5,21 +5,23 @@ <mapper namespace="com.stdiet.custom.mapper.SysIngredientMapper"> <resultMap type="SysIngredient" id="SysIngredientResult"> - <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="remark" column="remark" /> - <result property="createBy" column="create_by" /> - <result property="createTime" column="create_time" /> - <result property="updateBy" column="update_by" /> - <result property="updateTime" column="update_time" /> - <result property="rec" column="rec" /> - <result property="notRec" column="not_rec" /> - <result property="reviewStatus" column="review_status" /> + <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="remark" column="remark"/> + <result property="createBy" column="create_by"/> + <result property="createTime" column="create_time"/> + <result property="updateBy" column="update_by"/> + <result property="updateTime" column="update_time"/> + <result property="rec" column="rec"/> + <result property="notRec" column="not_rec"/> + <result property="reviewStatus" column="review_status"/> + <result property="info" column="info"/> + <association property="imgFiles" column="id" select="selectIngredentFileById"/> </resultMap> <sql id="selectSysIngredientVo"> @@ -43,44 +45,44 @@ <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) + 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> @@ -97,10 +99,10 @@ </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> - <if test="area != null and area != ''"> and area = #{area}</if> - <if test="reviewStatus != null and reviewStatus != ''"> and review_status = #{reviewStatus}</if> + <if test="name != null and name != ''">and name like concat('%', #{name}, '%')</if> + <if test="type != null and type != ''">and type = #{type}</if> + <if test="area != null and area != ''">and area = #{area}</if> + <if test="reviewStatus != null and reviewStatus != ''">and review_status = #{reviewStatus}</if> </where> </select> @@ -141,14 +143,14 @@ </trim> </insert> - <insert id="batchIngredientRec" > + <insert id="batchIngredientRec"> insert into sys_ingredient_rec(ingredient_id, physical_signs_id) values <foreach collection="list" separator="," item="item" index="index"> (#{item.ingredientId},#{item.recommandId}) </foreach> </insert> - <insert id="batchIngredientNotRec" > + <insert id="batchIngredientNotRec"> insert into sys_ingredient_not_rec(ingredient_id, physical_signs_id) values <foreach collection="list" separator="," item="item" index="index"> (#{item.ingredientId},#{item.notRecommandId}) @@ -213,4 +215,28 @@ where name = #{name} limit 1 </select> + <!-- 添加食材图片--> + <insert id="batchInsertIngredientImage"> + insert into sys_ingredient_file(igd_id, file_url, file_name, create_by, create_time, update_by, update_time ) + values + <foreach collection="list" separator="," item="item" index="index"> + (#{item.ingredientId},#{item.fileUrl},#{item.fileName},#{item.createBy},#{item.createTime},#{item.updateBy},#{item.updateTime}) + </foreach> + </insert> + + <resultMap id="SysIngredentFileResult" type="SysIngredentFile"> + <result property="id" column="id"/> + <result property="fileName" column="file_name"/> + <result property="fileUrl" column="file_url"/> + </resultMap> + + <!-- 查找图片--> + <select id="selectIngredentFileById" parameterType="Long" resultMap="SysIngredentFileResult"> + select id, file_url, file_name from sys_ingredent_file where igd_id = #{id} and del_flag = 0 + </select> + + <!-- 删除图片记录--> + <update id="deleteIngredentFileById" parameterType="Long"> + update sys_ingredent_file set del_flag=1 where id=#{id} + </update> </mapper> \ No newline at end of file diff --git a/stdiet-ui/src/components/FileUpload/DragUpload.vue b/stdiet-ui/src/components/FileUpload/DragUpload.vue index 46fedccf7..6a47e08a0 100644 --- a/stdiet-ui/src/components/FileUpload/DragUpload.vue +++ b/stdiet-ui/src/components/FileUpload/DragUpload.vue @@ -1,74 +1,81 @@ <template> - <el-upload class="upload-demo" - ref="upload" - drag - :headers="upload.headers" - :action="upload.url" - :limit="upload.limit" - :disabled="upload.isUploading" - :file-list="upload.fileList" - :multiple="upload.multiple" - :on-change="handleFileChange" - :on-remove="handleFileRemove" - :on-exceed="handleFileexceed" - :on-progress="handleFileUploadProgress" - :on-success="handleFileSuccess" - :on-error="handleFileFail" - :data="upload.data" - :auto-upload="false"> - <i class="el-icon-upload"></i> + <el-upload + class="upload-demo" + ref="upload" + drag + :headers="upload.headers" + :action="upload.url" + :limit="upload.limit" + :disabled="upload.isUploading" + :file-list="upload.fileList" + :multiple="upload.multiple" + :on-change="handleFileChange" + :on-remove="handleFileRemove" + :on-exceed="handleFileexceed" + :on-progress="handleFileUploadProgress" + :on-success="handleFileSuccess" + :on-error="handleFileFail" + :data="upload.data" + :auto-upload="false" + > + <em class="el-icon-upload" /> <div class="el-upload__text">将文件拖到此处,或<em>点击上传</em></div> - <div class="el-upload__tip" slot="tip">最多可上传{{upload.limit}}个文件,且每个文件不超过{{upload.fileSize/(1024*1024)}}M</div> + <div class="el-upload__tip" slot="tip"> + 最多可上传{{ upload.limit }}个文件,且每个文件不超过{{ + upload.fileSize / (1024 * 1024) + }}M + </div> </el-upload> </template> <script> - import { getToken } from '@/utils/auth' +import { getToken } from "@/utils/auth"; export default { name: "DragUpload", - components: { - - }, + components: {}, data() { return { upload: { // 是否禁用上传 isUploading: false, // 上传的地址 - url: process.env.VUE_APP_BASE_API + "/custom/customerCase/uploadCaseFile", + url: process.env.VUE_APP_BASE_API + "/custom/fileUpload/" + this.prefix, // 设置上传的请求头部 - headers: {Authorization: 'Bearer ' + getToken()}, + headers: { Authorization: "Bearer " + getToken() }, // 其他需要携带的数据 - data:{}, + data: {}, //文件列表 - fileList:[], + fileList: [], //同时上传文件上限 limit: 10, //每个文件大小(单位:byte) fileSize: 1024 * 1024 * 10, //是否支持同时选择多张 - multiple: true + multiple: true, + }, + uploadResult: { + fileUrl: [], + fileName: [], }, - uploadResult:{ - fileUrl:[], - fileName:[] - } }; }, methods: { - uploadFile(){ - if(this.upload.fileList.length > 0 && this.uploadResult.fileUrl.length < this.upload.fileList.length){ + uploadFile() { + if ( + this.upload.fileList.length > 0 && + this.uploadResult.fileUrl.length < this.upload.fileList.length + ) { this.$refs.upload.submit(); - }else{ - this.$emit('callbackMethod', this.uploadResult); + } else { + this.$emit("callbackMethod", this.uploadResult); } }, - uploadReset(){ + uploadReset() { this.upload.fileList = []; this.uploadResult["fileUrl"] = []; this.uploadResult["fileName"] = []; }, //移除文件 - handleFileRemove(file, fileList){ + handleFileRemove(file, fileList) { this.upload.fileList = fileList; }, //监控上传文件列表 @@ -84,9 +91,9 @@ export default { this.upload.fileList = fileList; }, // 文件数量超过限度 - handleFileexceed(file, fileList){ + handleFileexceed(file, fileList) { this.$message({ - message: "最多可上传"+ this.upload.limit +"份文件", + message: "最多可上传" + this.upload.limit + "份文件", type: "warning", }); }, @@ -96,39 +103,38 @@ export default { }, // 文件上传成功处理 handleFileSuccess(response, file, fileList) { - if(response != null && response.code === 200){ + if (response != null && response.code === 200) { this.uploadResult.fileUrl.push(response.fileUrl); this.uploadResult.fileName.push(response.fileName); - if(this.uploadResult.fileUrl.length === this.upload.fileList.length){ + if (this.uploadResult.fileUrl.length === this.upload.fileList.length) { //文件全部上传成功,则调用回调方法 - this.$emit('callbackMethod', this.uploadResult); + this.$emit("callbackMethod", this.uploadResult); } - }else{ + } else { this.upload.fileList = fileList.pop(); - this.$message.error('文件上传失败,请检查文件格式'); - this.$emit('changeSubmitFlag', false); + this.$message.error("文件上传失败,请检查文件格式"); + this.$emit("changeSubmitFlag", false); } }, // 文件上传失败处理 - handleFileFail(err, file, fileList){ - this.$message.error('文件上传失败,请检查文件格式'); + handleFileFail(err, file, fileList) { + this.$message.error("文件上传失败,请检查文件格式"); this.upload.fileList = fileList.pop(); - this.$emit('changeSubmitFlag', false); - } + this.$emit("changeSubmitFlag", false); + }, }, props: { - + prefix: { + type: String, + default: "case", + }, }, created() { - //this.uploadReset(); + //this.uploadReset(); }, - }; </script> <style scoped> - - - </style> diff --git a/stdiet-ui/src/components/FileUpload/DragUploadEdit.vue b/stdiet-ui/src/components/FileUpload/DragUploadEdit.vue index 14da04c39..ed00da5b0 100644 --- a/stdiet-ui/src/components/FileUpload/DragUploadEdit.vue +++ b/stdiet-ui/src/components/FileUpload/DragUploadEdit.vue @@ -1,41 +1,58 @@ <template> <div> - <div v-for="(item, index) in oldCaseFileList"> - <span style="margin-right: 10px;"> - {{item.fileName.length > 15 ? (item.fileName.substring(0,15)+"...") : item.fileName}} + <div v-for="(item, index) in oldCaseFileList" :key="index"> + <span style="margin-right: 10px"> + {{ + item.fileName.length > 15 + ? item.fileName.substring(0, 15) + "..." + : item.fileName + }} </span> - <el-button style="margin-left: 10px;" type="danger" size="small" @click="removeOldFile(index)">移除该文件</el-button> + <el-button + style="margin-left: 10px" + type="danger" + size="small" + @click="removeOldFile(index)" + >移除该文件</el-button + > </div> - <el-upload class="upload-demo" style="margin-top: 10px;" - ref="upload" - drag - :headers="upload.headers" - :action="upload.url" - :limit="upload.limit" - :disabled="upload.isUploading" - :file-list="upload.fileList" - :multiple="upload.multiple" - :on-remove="handleFileRemove" - :on-change="handleFileChange" - :on-exceed="handleFileexceed" - :on-progress="handleFileUploadProgress" - :on-success="handleFileSuccess" - :on-error="handleFileFail" - :data="upload.data" - :auto-upload="false"> - <i class="el-icon-upload"></i> + <el-upload + class="upload-demo" + style="margin-top: 10px" + ref="upload" + drag + :headers="upload.headers" + :action="upload.url" + :limit="upload.limit" + :disabled="upload.isUploading" + :file-list="upload.fileList" + :multiple="upload.multiple" + :on-remove="handleFileRemove" + :on-change="handleFileChange" + :on-exceed="handleFileexceed" + :on-progress="handleFileUploadProgress" + :on-success="handleFileSuccess" + :on-error="handleFileFail" + :data="upload.data" + :auto-upload="false" + > + <em class="el-icon-upload" /> <div class="el-upload__text">将文件拖到此处,或<em>点击上传</em></div> - <div class="el-upload__tip" slot="tip">已存在{{oldCaseFileList.length}}个文件,还可上传{{upload.limit}}个文件,且每个文件不超过{{upload.fileSize/(1024*1024)}}M</div> + <div class="el-upload__tip" slot="tip"> + 已存在{{ oldCaseFileList.length }}个文件,还可上传{{ + upload.limit + }}个文件,且每个文件不超过{{ upload.fileSize / (1024 * 1024) }}M + </div> </el-upload> </div> </template> <script> - import { getToken } from '@/utils/auth' - import AutoHideMessage from "@/components/AutoHideMessage"; +import { getToken } from "@/utils/auth"; +// import AutoHideMessage from "@/components/AutoHideMessage"; export default { name: "DragUploadEdit", components: { - "AutoHideMessage":AutoHideMessage + // "AutoHideMessage":AutoHideMessage }, data() { return { @@ -43,54 +60,57 @@ export default { // 是否禁用上传 isUploading: false, // 上传的地址 - url: process.env.VUE_APP_BASE_API + "/custom/customerCase/uploadCaseFile", + url: process.env.VUE_APP_BASE_API + "/custom/fileUpload/" + this.prefix, // 设置上传的请求头部 - headers: {Authorization: 'Bearer ' + getToken()}, + headers: { Authorization: "Bearer " + getToken() }, // 其他需要携带的数据 - data:{}, + data: {}, //文件列表 - fileList:[], + fileList: [], //同时上传文件上限 limit: 10 - this.caseFileList.length, //每个文件大小(单位:byte) fileSize: 1024 * 1024 * 10, //是否支持同时选择多张 - multiple: true + multiple: true, }, oldCaseFileList: this.caseFileList, - uploadResult:{ - fileUrl:[], - fileName:[] - } + uploadResult: { + fileUrl: [], + fileName: [], + }, }; }, methods: { - async uploadFile(){ - if(this.upload.fileList.length > 0 && this.uploadResult.fileUrl.length < this.upload.fileList.length){ + async uploadFile() { + if ( + this.upload.fileList.length > 0 && + this.uploadResult.fileUrl.length < this.upload.fileList.length + ) { this.$refs.upload.submit(); - }else{ + } else { //合并旧文件 - if(this.oldCaseFileList != null && this.oldCaseFileList.length > 0){ + if (this.oldCaseFileList != null && this.oldCaseFileList.length > 0) { await this.oldCaseFileList.forEach((item, index) => { this.uploadResult.fileUrl.unshift(item.fileUrl); this.uploadResult.fileName.unshift(item.fileName); }); } - this.$emit('callbackMethod', this.uploadResult); + this.$emit("callbackMethod", this.uploadResult); } }, - removeOldFile(index){ - this.oldCaseFileList.splice(index,1); + removeOldFile(index) { + this.oldCaseFileList.splice(index, 1); this.upload.limit = 10 - this.oldCaseFileList.length; }, - uploadReset(){ + uploadReset() { this.upload.fileList = []; this.uploadResult["fileUrl"] = []; this.uploadResult["fileName"] = []; this.oldCaseFileList = []; }, //移除文件 - handleFileRemove(file, fileList){ + handleFileRemove(file, fileList) { this.upload.fileList = fileList; }, //监控上传文件列表 @@ -106,9 +126,9 @@ export default { this.upload.fileList = fileList; }, // 文件数量超过限度 - handleFileexceed(file, fileList){ + handleFileexceed(file, fileList) { this.$message({ - message: "最多可上传"+ this.upload.limit +"份文件", + message: "最多可上传" + this.upload.limit + "份文件", type: "warning", }); }, @@ -118,56 +138,54 @@ export default { }, // 文件上传成功处理 async handleFileSuccess(response, file, fileList) { - if(response != null && response.code === 200){ + if (response != null && response.code === 200) { this.uploadResult.fileUrl.push(response.fileUrl); this.uploadResult.fileName.push(response.fileName); - if(this.uploadResult.fileUrl.length === this.upload.fileList.length){ + if (this.uploadResult.fileUrl.length === this.upload.fileList.length) { //文件全部上传成功,则调用回调方法 - if(this.oldCaseFileList != null && this.oldCaseFileList.length > 0){ + if (this.oldCaseFileList != null && this.oldCaseFileList.length > 0) { await this.oldCaseFileList.forEach((item, index) => { this.uploadResult.fileUrl.unshift(item.fileUrl); this.uploadResult.fileName.unshift(item.fileName); }); } - this.$emit('callbackMethod', this.uploadResult); + this.$emit("callbackMethod", this.uploadResult); } - }else{ + } else { this.upload.fileList = fileList.pop(); - this.$message.error('文件上传失败,请检查文件格式'); - this.$emit('changeSubmitFlag', false); + this.$message.error("文件上传失败,请检查文件格式"); + this.$emit("changeSubmitFlag", false); } }, // 文件上传失败处理 - handleFileFail(err, file, fileList){ - this.$message.error('文件上传失败,请检查文件格式'); + handleFileFail(err, file, fileList) { + this.$message.error("文件上传失败,请检查文件格式"); this.upload.fileList = fileList.pop(); - this.$emit('changeSubmitFlag', false); - } + this.$emit("changeSubmitFlag", false); + }, }, props: { - caseFileList:{ + caseFileList: { type: Array, default: function () { return []; - } - } + }, + }, + prefix: { + type: String, + default: "case", + }, }, - created() { - + created() {}, + watch: { + caseFileList: function (newVal, oldVal) { + //console.log(newVal.length); + this.oldCaseFileList = newVal; + }, }, - watch : { - caseFileList:function(newVal, oldVal) { - //console.log(newVal.length); - this.oldCaseFileList = newVal; - } - } - }; </script> <style scoped> - - - </style> diff --git a/stdiet-ui/src/views/custom/customerCase/index.vue b/stdiet-ui/src/views/custom/customerCase/index.vue index b1ec42819..53800dc9f 100644 --- a/stdiet-ui/src/views/custom/customerCase/index.vue +++ b/stdiet-ui/src/views/custom/customerCase/index.vue @@ -1,6 +1,12 @@ <template> <div class="app-container"> - <el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="68px"> + <el-form + :model="queryParams" + ref="queryForm" + :inline="true" + v-show="showSearch" + label-width="68px" + > <!--<el-form-item label="案例信息" prop="name"> <el-input v-model.trim="queryParams.name" @@ -17,12 +23,15 @@ allow-create clearable default-first-option - placeholder="关键词搜索" style="width: 100%;"> + placeholder="关键词搜索" + style="width: 100%" + > <el-option v-for="dict in caseKeyOptions" :key="dict.dictValue" :label="dict.dictLabel" - :value="dict.dictValue"> + :value="dict.dictValue" + > </el-option> </el-select> </el-form-item> @@ -36,8 +45,16 @@ /> </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-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> @@ -49,7 +66,8 @@ size="mini" @click="handleAdd" v-hasPermi="['custom:customerCase:add']" - >新增</el-button> + >新增</el-button + > </el-col> <el-col :span="1.5"> <el-button @@ -59,7 +77,8 @@ :disabled="single" @click="handleUpdate" v-hasPermi="['custom:customerCase:edit']" - >修改</el-button> + >修改</el-button + > </el-col> <el-col :span="1.5"> <el-button @@ -69,7 +88,8 @@ :disabled="multiple" @click="handleDelete" v-hasPermi="['custom:customerCase:remove']" - >删除</el-button> + >删除</el-button + > </el-col> <el-col :span="1.5"> <el-button @@ -78,40 +98,54 @@ size="mini" @click="handleExport" v-hasPermi="['custom:customerCase:export']" - >导出</el-button> + >导出</el-button + > </el-col> - <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar> + <right-toolbar + :showSearch.sync="showSearch" + @queryTable="getList" + ></right-toolbar> </el-row> - <el-table v-loading="loading" :data="customerCaseList" @selection-change="handleSelectionChange"> + <el-table + v-loading="loading" + :data="customerCaseList" + @selection-change="handleSelectionChange" + > <el-table-column type="selection" width="55" align="center" /> - <el-table-column label="案例名称" align="center" prop="name" > + <el-table-column label="案例名称" align="center" prop="name"> <template slot-scope="scope"> - <AutoHideMessage :data="scope.row.name" :maxLength="10"></AutoHideMessage> + <AutoHideMessage + :data="scope.row.name" + :maxLength="10" + ></AutoHideMessage> </template> </el-table-column> - <el-table-column label="关键词" align="center" prop="keyword" > + <el-table-column label="关键词" align="center" prop="keyword"> <template slot-scope="scope"> - <AutoHideMessage :data="scope.row.keyword" :maxLength="10"></AutoHideMessage> + <AutoHideMessage + :data="scope.row.keyword" + :maxLength="10" + ></AutoHideMessage> <!--<AutoHideInfo :data="scope.row.keyword.split(',')" :line="1"></AutoHideInfo>--> </template> </el-table-column> - <el-table-column label="备注" align="center" prop="remark" > + <el-table-column label="备注" align="center" prop="remark"> <template slot-scope="scope"> - <AutoHideMessage :data="scope.row.remark" :maxLength="10"></AutoHideMessage> + <AutoHideMessage + :data="scope.row.remark" + :maxLength="10" + ></AutoHideMessage> </template> </el-table-column> <el-table-column label="所属客户" align="center" prop="customerName" /> - <el-table-column - label="文件" - align="center" - > + <el-table-column label="文件" align="center"> <template slot-scope="scope"> <el-button size="mini" type="text" @click="getFileListByCaseId(scope.row)" - >文件列表 + >文件列表 </el-button> </template> </el-table-column> @@ -127,7 +161,11 @@ }}</span> </template> </el-table-column> - <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"> <el-button size="mini" @@ -135,20 +173,22 @@ icon="el-icon-edit" @click="handleUpdate(scope.row)" v-hasPermi="['custom:customerCase:edit']" - >修改</el-button> + >修改</el-button + > <el-button size="mini" type="text" icon="el-icon-delete" @click="handleDelete(scope.row)" v-hasPermi="['custom:customerCase:remove']" - >删除</el-button> + >删除</el-button + > </template> </el-table-column> </el-table> <pagination - v-show="total>0" + v-show="total > 0" :total="total" :page.sync="queryParams.pageNum" :limit.sync="queryParams.pageSize" @@ -156,49 +196,87 @@ /> <!-- 添加或修改客户案例管理对话框 --> - <el-dialog :title="title" :visible.sync="open" @closed="cancel" width="520px" append-to-body> + <el-dialog + :title="title" + :visible.sync="open" + @closed="cancel" + width="520px" + append-to-body + > <div style="height: 600px; overflow: auto; padding-right: 20px"> - <el-form ref="form" :model="form" :rules="rules" label-width="80px"> - <el-form-item label="案例名称" prop="name"> - <el-input v-model.trim="form.name" type="textarea" maxlength="50" rows = "1" show-word-limit placeholder="请输入案例名称" /> - </el-form-item> - <el-form-item label="关键词" prop="keywordArray"> - <el-select - v-model="form.keywordArray" - multiple - filterable - clearable - allow-create - default-first-option - placeholder="请创建案例关键词,按回车创建,最多20个" style="width: 100%;"> - <el-option - v-for="dict in caseKeyOptions" - :key="dict.dictValue" - :label="dict.dictLabel" - :value="dict.dictValue"> - </el-option> - </el-select> - </el-form-item> - <el-form-item label="案例备注" prop="remark"> - <el-input - type="textarea" - placeholder="请输入案例备注" - v-model.trim="form.remark" - maxlength="200" - rows = "4" - show-word-limit - ></el-input> - </el-form-item> + <el-form ref="form" :model="form" :rules="rules" label-width="80px"> + <el-form-item label="案例名称" prop="name"> + <el-input + v-model.trim="form.name" + type="textarea" + maxlength="50" + rows="1" + show-word-limit + placeholder="请输入案例名称" + /> + </el-form-item> + <el-form-item label="关键词" prop="keywordArray"> + <el-select + v-model="form.keywordArray" + multiple + filterable + clearable + allow-create + default-first-option + placeholder="请创建案例关键词,按回车创建,最多20个" + style="width: 100%" + > + <el-option + v-for="dict in caseKeyOptions" + :key="dict.dictValue" + :label="dict.dictLabel" + :value="dict.dictValue" + > + </el-option> + </el-select> + </el-form-item> + <el-form-item label="案例备注" prop="remark"> + <el-input + type="textarea" + placeholder="请输入案例备注" + v-model.trim="form.remark" + maxlength="200" + rows="4" + show-word-limit + ></el-input> + </el-form-item> - <el-form-item label="所属客户" prop="customerId"> - <el-input v-model="form.customerName" placeholder="" style="width: 60%" :readonly="true" /> - <span style="margin-left: 10px"> <el-button type="primary" @click="selectCustomer">选择所属客户</el-button></span> - </el-form-item> - <el-form-item label="案例文件" prop="file" > - <DragUpload v-show="form.id == null || form.id <= 0" @changeSubmitFlag="changeSubmitFlag" @callbackMethod="addOrEditCustomerCase" ref="uploadCaseFile"></DragUpload> - <DragUploadEdit v-show="form.id != null || form.id > 0" @callbackMethod="addOrEditCustomerCase" @changeSubmitFlag="changeSubmitFlag" :caseFileList="form.caseFileList" ref="editUploadCaseFile"></DragUploadEdit> - </el-form-item> - </el-form> + <el-form-item label="所属客户" prop="customerId"> + <el-input + v-model="form.customerName" + placeholder="" + style="width: 60%" + :readonly="true" + /> + <span style="margin-left: 10px"> + <el-button type="primary" @click="selectCustomer" + >选择所属客户</el-button + ></span + > + </el-form-item> + <el-form-item label="案例文件" prop="file"> + <DragUpload + v-if="form.id == null || form.id <= 0" + @changeSubmitFlag="changeSubmitFlag" + @callbackMethod="addOrEditCustomerCase" + ref="uploadCaseFile" + prefix="case" + /> + <DragUploadEdit + v-else + @callbackMethod="addOrEditCustomerCase" + @changeSubmitFlag="changeSubmitFlag" + :caseFileList="form.caseFileList" + ref="editUploadCaseFile" + prefix="case" + /> + </el-form-item> + </el-form> </div> <div slot="footer" class="dialog-footer"> <el-button type="primary" @click="submitForm">确 定</el-button> @@ -207,258 +285,281 @@ </el-dialog> <MuchFileDown ref="muchFileDownRef"></MuchFileDown> - <SelectCustomer @dealCustomerId="dealCustomerId" ref="selectCustomerRef"></SelectCustomer> + <SelectCustomer + @dealCustomerId="dealCustomerId" + ref="selectCustomerRef" + ></SelectCustomer> </div> </template> <script> - import { listCustomerCase, getCustomerCase, delCustomerCase, addCustomerCase, updateCustomerCase, exportCustomerCase,getFileListByCaseId,downCaseFile } from "@/api/custom/customerCase"; - import DragUpload from "@/components/FileUpload/DragUpload"; - import DragUploadEdit from "@/components/FileUpload/DragUploadEdit"; - import SelectCustomer from "@/components/Customer/SelectCustomer"; - import MuchFileDown from "@/components/FileDownload/MuchFileDown"; - import AutoHideMessage from "@/components/AutoHideMessage"; - import AutoHideInfo from "@/components/AutoHideInfo"; +import { + listCustomerCase, + getCustomerCase, + delCustomerCase, + addCustomerCase, + updateCustomerCase, + exportCustomerCase, + getFileListByCaseId, +} from "@/api/custom/customerCase"; +import DragUpload from "@/components/FileUpload/DragUpload"; +import DragUploadEdit from "@/components/FileUpload/DragUploadEdit"; +import SelectCustomer from "@/components/Customer/SelectCustomer"; +import MuchFileDown from "@/components/FileDownload/MuchFileDown"; +import AutoHideMessage from "@/components/AutoHideMessage"; +import AutoHideInfo from "@/components/AutoHideInfo"; - export default { - name: "CustomerCase", - data() { - return { - // 遮罩层 - loading: true, - // 选中数组 - ids: [], - // 非单个禁用 - single: true, - // 非多个禁用 - multiple: true, - // 显示搜索条件 - showSearch: true, - // 总条数 - total: 0, - // 客户案例管理表格数据 - customerCaseList: [], - // 弹出层标题 - title: "", - // 是否显示弹出层 - open: false, - // 查询参数 - queryParams: { - pageNum: 1, - pageSize: 10, - name: null, - keyword: null, - customerName: null - }, - // 表单参数 - form: { - - }, - // 表单校验 - rules: { - name: [ - { required: true, message: "案例名称不能为空", trigger: "blur" }, - ], - keywordArray: [ - { required: true, message: "案例关键词不能为空", trigger: "blur" }, - ], - }, - keywordArray:[], - submitFlag: false, - caseKeyOptions: [], - }; - }, - components: { - "DragUpload": DragUpload, - "SelectCustomer":SelectCustomer, - "MuchFileDown": MuchFileDown, - "AutoHideMessage": AutoHideMessage, - "AutoHideInfo":AutoHideInfo, - "DragUploadEdit":DragUploadEdit - }, - created() { - this.getList(); - this.getDicts("case_key").then((response) => { - this.caseKeyOptions = response.data; +export default { + name: "CustomerCase", + data() { + return { + // 遮罩层 + loading: true, + // 选中数组 + ids: [], + // 非单个禁用 + single: true, + // 非多个禁用 + multiple: true, + // 显示搜索条件 + showSearch: true, + // 总条数 + total: 0, + // 客户案例管理表格数据 + customerCaseList: [], + // 弹出层标题 + title: "", + // 是否显示弹出层 + open: false, + // 查询参数 + queryParams: { + pageNum: 1, + pageSize: 10, + name: null, + keyword: null, + customerName: null, + }, + // 表单参数 + form: {}, + // 表单校验 + rules: { + name: [ + { required: true, message: "案例名称不能为空", trigger: "blur" }, + ], + keywordArray: [ + { required: true, message: "案例关键词不能为空", trigger: "blur" }, + ], + }, + keywordArray: [], + submitFlag: false, + caseKeyOptions: [], + }; + }, + components: { + DragUpload: DragUpload, + SelectCustomer: SelectCustomer, + MuchFileDown: MuchFileDown, + AutoHideMessage: AutoHideMessage, + AutoHideInfo: AutoHideInfo, + DragUploadEdit: DragUploadEdit, + }, + created() { + this.getList(); + this.getDicts("case_key").then((response) => { + this.caseKeyOptions = response.data; + }); + }, + methods: { + /** 查询客户案例管理列表 */ + getList() { + this.loading = true; + this.queryParams.keyword = this.keywordArray.join(","); + listCustomerCase(this.queryParams).then((response) => { + this.customerCaseList = response.rows; + this.total = response.total; + this.loading = false; }); }, - methods: { - /** 查询客户案例管理列表 */ - getList() { - this.loading = true; - this.queryParams.keyword = this.keywordArray.join(","); - listCustomerCase(this.queryParams).then(response => { - this.customerCaseList = response.rows; - this.total = response.total; - this.loading = false; - }); - }, - // 取消按钮 - cancel() { - this.open = false; + // 取消按钮 + cancel() { + this.open = false; + this.$refs["uploadCaseFile"] && this.$refs["uploadCaseFile"].uploadReset(); + this.$refs["editUploadCaseFile"] && this.$refs["editUploadCaseFile"].uploadReset(); - this.reset(); - }, - // 表单重置 - reset() { + this.reset(); + }, + // 表单重置 + reset() { + this.form = { + id: null, + name: null, + keywordArray: [], + remark: null, + customerId: null, + customerName: null, + caseFileList: [], + caseFileUrl: [], + caseFileName: [], + }; + 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; + getCustomerCase(id).then((response) => { this.form = { - id: null, - name: null, - keywordArray: [], - remark: null, - customerId: null, - customerName: null, - caseFileList:[], + id: response.data.id, + name: response.data.name, + keywordArray: response.data.keyword.split(","), + remark: response.data.remark, + customerId: response.data.customerId, + customerName: response.data.customerName, + caseFileList: response.data.caseFileList, caseFileUrl: [], - caseFileName: [] + caseFileName: [], }; - 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 - getCustomerCase(id).then(response => { - this.form = { - id: response.data.id, - name: response.data.name, - keywordArray: response.data.keyword.split(","), - remark: response.data.remark, - customerId: response.data.customerId, - customerName: response.data.customerName, - caseFileList: response.data.caseFileList, - caseFileUrl: [], - caseFileName: [] - }; - this.open = true; - this.title = "修改客户案例管理"; - }); - }, - /** 提交按钮 */ - submitForm() { - this.$refs["form"].validate(valid => { - if (valid) { - if(this.submitFlag){ - this.$message({ - message: "正在上传提交中,请勿重复提交", - type: "warning", - }); - return; - } - //判断案例关键词 - if(this.form.keywordArray.length > 20){ - this.$message({message: "案例关键词最多20个", type: "warning"}); - return; - } - this.submitFlag = true; - this.form.keyword = this.form.keywordArray.join(","); - if (this.form.id != null) { - this.$refs["editUploadCaseFile"].uploadFile(); - } else { - this.$refs["uploadCaseFile"].uploadFile(); - } + this.title = "修改客户案例管理"; + }); + }, + /** 提交按钮 */ + submitForm() { + this.$refs["form"].validate((valid) => { + if (valid) { + if (this.submitFlag) { + this.$message({ + message: "正在上传提交中,请勿重复提交", + type: "warning", + }); + return; + } + //判断案例关键词 + if (this.form.keywordArray.length > 20) { + this.$message({ message: "案例关键词最多20个", type: "warning" }); + return; + } + this.submitFlag = true; + this.form.keyword = this.form.keywordArray.join(","); + if (this.form.id != null) { + this.$refs["editUploadCaseFile"].uploadFile(); + } else { + this.$refs["uploadCaseFile"].uploadFile(); } - }); - }, - addOrEditCustomerCase(fileResult){ - this.form.caseFileName = fileResult.fileName; - this.form.caseFileUrl = fileResult.fileUrl; - if(this.form.caseFileUrl.length == 0){ - this.$message.error('请至少选择一个文件上传'); - this.submitFlag = false; - return; } - if(this.form.id != null){ - // console.log(this.form.caseFileName.length); - updateCustomerCase(this.form).then(response => { - if (response.code === 200) { - this.$refs["editUploadCaseFile"].uploadReset(); - this.msgSuccess("修改成功"); - this.open = false; - this.getList(); - } - this.submitFlag = false; - - }); - }else{ - addCustomerCase(this.form).then(response => { - if (response.code === 200) { - this.$refs["uploadCaseFile"].uploadReset(); - this.msgSuccess("新增成功"); - this.open = false; - this.getList(); - } - this.submitFlag = false; - }); - } - }, - changeSubmitFlag(flag){ - this.submitFlag = flag; - }, - selectCustomer(){ - this.$refs['selectCustomerRef'].showDialog("选择案例所属客户"); - }, - dealCustomerId(customerId, customerName){ - this.form.customerId = customerId; - this.form.customerName = customerName; - }, - getFileListByCaseId(customerCase){ - getFileListByCaseId(customerCase.id).then(response => { + }); + }, + addOrEditCustomerCase(fileResult) { + this.form.caseFileName = fileResult.fileName; + this.form.caseFileUrl = fileResult.fileUrl; + if (this.form.caseFileUrl.length == 0) { + this.$message.error("请至少选择一个文件上传"); + this.submitFlag = false; + return; + } + if (this.form.id != null) { + // console.log(this.form.caseFileName.length); + updateCustomerCase(this.form).then((response) => { if (response.code === 200) { - this.$refs["muchFileDownRef"].showDialog(customerCase.name, response.rows); + this.$refs["editUploadCaseFile"].uploadReset(); + this.msgSuccess("修改成功"); + this.open = false; + this.getList(); } + this.submitFlag = false; }); - }, - /** 删除按钮操作 */ - handleDelete(row) { - const ids = row.id || this.ids; - this.$confirm('是否确认删除客户案例管理编号为"' + ids + '"的数据项?', "警告", { + } else { + addCustomerCase(this.form).then((response) => { + if (response.code === 200) { + this.$refs["uploadCaseFile"].uploadReset(); + this.msgSuccess("新增成功"); + this.open = false; + this.getList(); + } + this.submitFlag = false; + }); + } + }, + changeSubmitFlag(flag) { + this.submitFlag = flag; + }, + selectCustomer() { + this.$refs["selectCustomerRef"].showDialog("选择案例所属客户"); + }, + dealCustomerId(customerId, customerName) { + this.form.customerId = customerId; + this.form.customerName = customerName; + }, + getFileListByCaseId(customerCase) { + getFileListByCaseId(customerCase.id).then((response) => { + if (response.code === 200) { + this.$refs["muchFileDownRef"].showDialog( + customerCase.name, + response.rows + ); + } + }); + }, + /** 删除按钮操作 */ + handleDelete(row) { + const ids = row.id || this.ids; + this.$confirm( + '是否确认删除客户案例管理编号为"' + ids + '"的数据项?', + "警告", + { confirmButtonText: "确定", cancelButtonText: "取消", - type: "warning" - }).then(function() { + type: "warning", + } + ) + .then(function () { return delCustomerCase(ids); - }).then(() => { + }) + .then(() => { this.getList(); this.msgSuccess("删除成功"); - }).catch(function() {}); - }, - /** 导出按钮操作 */ - handleExport() { - const queryParams = this.queryParams; - this.$confirm('是否确认导出所有客户案例管理数据项?', "警告", { - confirmButtonText: "确定", - cancelButtonText: "取消", - type: "warning" - }).then(function() { + }) + .catch(function () {}); + }, + /** 导出按钮操作 */ + handleExport() { + const queryParams = this.queryParams; + this.$confirm("是否确认导出所有客户案例管理数据项?", "警告", { + confirmButtonText: "确定", + cancelButtonText: "取消", + type: "warning", + }) + .then(function () { return exportCustomerCase(queryParams); - }).then(response => { + }) + .then((response) => { this.download(response.msg); - }).catch(function() {}); - } - } - }; + }) + .catch(function () {}); + }, + }, +}; </script> From 1b5a4f37772c00f4fdfe3c053095a86638532cc8 Mon Sep 17 00:00:00 2001 From: huangdeliang <huangdeliang@skieer.com> Date: Tue, 16 Mar 2021 20:09:28 +0800 Subject: [PATCH 3/3] =?UTF-8?q?=E9=A3=9F=E6=9D=90=E6=B7=BB=E5=8A=A0?= =?UTF-8?q?=E4=BF=A1=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../custom/domain/SysIngredentFile.java | 4 +- .../stdiet/custom/domain/SysIngredient.java | 3 + .../custom/mapper/SysIngredientMapper.java | 2 +- .../impl/SysIngredientServiceImpl.java | 30 ++-- .../mapper/custom/SysIngredientMapper.xml | 5 +- stdiet-ui/src/components/FileUpload/index.vue | 60 +++++++ .../src/views/custom/ingredient/index.vue | 147 ++++++++++++------ 7 files changed, 187 insertions(+), 64 deletions(-) create mode 100644 stdiet-ui/src/components/FileUpload/index.vue diff --git a/stdiet-custom/src/main/java/com/stdiet/custom/domain/SysIngredentFile.java b/stdiet-custom/src/main/java/com/stdiet/custom/domain/SysIngredentFile.java index ceab8eccd..fa7eef4a4 100644 --- a/stdiet-custom/src/main/java/com/stdiet/custom/domain/SysIngredentFile.java +++ b/stdiet-custom/src/main/java/com/stdiet/custom/domain/SysIngredentFile.java @@ -17,11 +17,11 @@ public class SysIngredentFile { Integer delFlag; - Long createBy; + String createBy; Date createTime; - Long updateBy; + String updateBy; Date updateTime; } diff --git a/stdiet-custom/src/main/java/com/stdiet/custom/domain/SysIngredient.java b/stdiet-custom/src/main/java/com/stdiet/custom/domain/SysIngredient.java index 4f52f9902..0898611a0 100644 --- a/stdiet-custom/src/main/java/com/stdiet/custom/domain/SysIngredient.java +++ b/stdiet-custom/src/main/java/com/stdiet/custom/domain/SysIngredient.java @@ -6,6 +6,7 @@ import lombok.Data; import java.math.BigDecimal; import java.util.Date; +import java.util.List; /** * 食材对象 sys_ingredient @@ -110,4 +111,6 @@ public class SysIngredient { */ private String info; + private List<SysIngredentFile> imgList; + } \ No newline at end of file diff --git a/stdiet-custom/src/main/java/com/stdiet/custom/mapper/SysIngredientMapper.java b/stdiet-custom/src/main/java/com/stdiet/custom/mapper/SysIngredientMapper.java index 8ac25d4aa..c8655fe19 100644 --- a/stdiet-custom/src/main/java/com/stdiet/custom/mapper/SysIngredientMapper.java +++ b/stdiet-custom/src/main/java/com/stdiet/custom/mapper/SysIngredientMapper.java @@ -83,5 +83,5 @@ public interface SysIngredientMapper */ public SysIngredient selectSysIngredientByName(@Param("name") String name); - int batchInsertIngredientImage(List<SysIngredentFile> ingredentFiles); + int batchInsertIngredientImage(List<SysIngredentFile> list); } \ No newline at end of file diff --git a/stdiet-custom/src/main/java/com/stdiet/custom/service/impl/SysIngredientServiceImpl.java b/stdiet-custom/src/main/java/com/stdiet/custom/service/impl/SysIngredientServiceImpl.java index c37cf6f08..fbfa31886 100644 --- a/stdiet-custom/src/main/java/com/stdiet/custom/service/impl/SysIngredientServiceImpl.java +++ b/stdiet-custom/src/main/java/com/stdiet/custom/service/impl/SysIngredientServiceImpl.java @@ -1,7 +1,9 @@ package com.stdiet.custom.service.impl; import com.stdiet.common.utils.DateUtils; +import com.stdiet.common.utils.SecurityUtils; import com.stdiet.common.utils.StringUtils; +import com.stdiet.custom.domain.SysIngredentFile; import com.stdiet.custom.domain.SysIngredient; import com.stdiet.custom.domain.SysIngredientNotRec; import com.stdiet.custom.domain.SysIngredientRec; @@ -61,26 +63,34 @@ public class SysIngredientServiceImpl implements ISysIngredientService { // 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; } /** * 新增推荐标签 + * * @param ingredient */ public void insertRecommand(SysIngredient ingredient) { Long[] recIds = ingredient.getRecIds(); - if(StringUtils.isNotNull(recIds)) { + if (StringUtils.isNotNull(recIds)) { List<SysIngredientRec> list = new ArrayList<SysIngredientRec>(); - for(Long recId: recIds) { + for (Long recId : recIds) { SysIngredientRec rec = new SysIngredientRec(); rec.setIngredientId(ingredient.getId()); rec.setRecommandId(recId); list.add(rec); } - if(list.size() > 0) { + if (list.size() > 0) { sysIngredientMapper.batchIngredientRec(list); } } @@ -88,19 +98,20 @@ public class SysIngredientServiceImpl implements ISysIngredientService { /** * 新增不推荐标签 + * * @param ingredient */ public void insertNotRecommand(SysIngredient ingredient) { Long[] notRecIds = ingredient.getNotRecIds(); - if(StringUtils.isNotNull(notRecIds)) { + if (StringUtils.isNotNull(notRecIds)) { List<SysIngredientNotRec> list = new ArrayList<SysIngredientNotRec>(); - for(Long recId: notRecIds) { + for (Long recId : notRecIds) { SysIngredientNotRec notRec = new SysIngredientNotRec(); notRec.setIngredientId(ingredient.getId()); notRec.setRecommandId(recId); list.add(notRec); } - if(list.size() > 0) { + if (list.size() > 0) { sysIngredientMapper.batchIngredientNotRec(list); } } @@ -151,11 +162,12 @@ public class SysIngredientServiceImpl implements ISysIngredientService { /** * 根据食材名称查询食材信息 + * * @param name * @return */ @Override - public SysIngredient selectSysIngredientByName(String name){ + public SysIngredient selectSysIngredientByName(String name) { return sysIngredientMapper.selectSysIngredientByName(name); } } \ No newline at end of file diff --git a/stdiet-custom/src/main/resources/mapper/custom/SysIngredientMapper.xml b/stdiet-custom/src/main/resources/mapper/custom/SysIngredientMapper.xml index 122e4bf06..4e6ad6777 100644 --- a/stdiet-custom/src/main/resources/mapper/custom/SysIngredientMapper.xml +++ b/stdiet-custom/src/main/resources/mapper/custom/SysIngredientMapper.xml @@ -21,7 +21,7 @@ <result property="notRec" column="not_rec"/> <result property="reviewStatus" column="review_status"/> <result property="info" column="info"/> - <association property="imgFiles" column="id" select="selectIngredentFileById"/> + <association property="imgList" column="id" select="selectIngredentFileById"/> </resultMap> <sql id="selectSysIngredientVo"> @@ -126,6 +126,7 @@ <if test="updateBy != null">update_by,</if> <if test="updateTime != null">update_time,</if> <if test="reviewStatus != null">review_status,</if> + <if test="info != null">info,</if> </trim> <trim prefix="values (" suffix=")" suffixOverrides=","> <if test="name != null">#{name},</if> @@ -140,6 +141,7 @@ <if test="updateBy != null">#{updateBy},</if> <if test="updateTime != null">#{updateTime},</if> <if test="reviewStatus != null">#{reviewStatus},</if> + <if test="info != null">#{info},</if> </trim> </insert> @@ -194,6 +196,7 @@ <if test="updateBy != null">update_by = #{updateBy},</if> <if test="updateTime != null">update_time = #{updateTime},</if> <if test="reviewStatus != null">review_status = #{reviewStatus},</if> + <if test="info != null">info = #{info},</if> </trim> where id = #{id} </update> diff --git a/stdiet-ui/src/components/FileUpload/index.vue b/stdiet-ui/src/components/FileUpload/index.vue new file mode 100644 index 000000000..4fe046dee --- /dev/null +++ b/stdiet-ui/src/components/FileUpload/index.vue @@ -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> diff --git a/stdiet-ui/src/views/custom/ingredient/index.vue b/stdiet-ui/src/views/custom/ingredient/index.vue index 61fbff02c..4c58c211a 100644 --- a/stdiet-ui/src/views/custom/ingredient/index.vue +++ b/stdiet-ui/src/views/custom/ingredient/index.vue @@ -245,55 +245,17 @@ /> <!-- 添加或修改食材对话框 --> - <el-dialog :title="title" :visible.sync="open" width="620px" append-to-body> - <el-row :gutter="15"> + <el-dialog :title="title" :visible.sync="open" width="720px" append-to-body> + <el-row :gutter="8"> <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-input v-model="form.name" placeholder="请输入食材名称" /> + <el-input v-model="form.name" placeholder="请输入名称" /> </el-form-item> </el-col> - <el-col :span="12"> - <el-form-item - label="蛋白质比例" - 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-col :span="8"> + <el-form-item label="食材类别" prop="type" label-width="100px"> + <el-select v-model="form.type" placeholder="请选择类别"> <el-option v-for="dict in typeOptions" :key="dict.dictValue" @@ -303,8 +265,8 @@ </el-select> </el-form-item> </el-col> - <el-col :span="12"> - <el-form-item label="地域" prop="area" label-width="90px"> + <el-col :span="8"> + <el-form-item label="地域" prop="area" label-width="100px"> <el-select v-model="form.area" placeholder="请选择地域"> <el-option v-for="dict in areaOptions" @@ -315,8 +277,35 @@ </el-select> </el-form-item> </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-form-item label="忌口人群" label-width="90px"> + <el-form-item label="忌口人群" label-width="76px"> <el-select v-model="form.notRecIds" multiple @@ -333,7 +322,7 @@ </el-form-item> </el-col> <el-col :span="12"> - <el-form-item label="推荐人群" label-width="90px"> + <el-form-item label="推荐人群" label-width="76px"> <el-select v-model="form.recIds" multiple @@ -349,9 +338,17 @@ </el-select> </el-form-item> </el-col> - <el-col :span="12"> - <el-form-item label="审核状态" prop="reviewStatus"> + <el-col + :span="12" + style="position: absolute; left: 100px; top: -70px" + > + <el-form-item + label="审核状态" + prop="reviewStatus" + label-width="76px" + > <el-select + style="position: absolute" v-model="form.reviewStatus" placeholder="请选择审核状态" clearable @@ -365,9 +362,43 @@ </el-select> </el-form-item> </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-form-item label="备注" prop="remark" label-width="90px"> <el-input + :rows="3" v-model="form.remark" type="textarea" placeholder="请输入内容" @@ -395,6 +426,8 @@ import { } from "@/api/custom/ingredient"; import AutoHideInfo from "@/components/AutoHideInfo"; +import FileUpload from "@/components/FileUpload"; +import { getToken } from "@/utils/auth"; import { listPhysicalSigns } from "@/api/custom/physicalSigns"; @@ -402,11 +435,14 @@ export default { name: "Ingredient", components: { autohideinfo: AutoHideInfo, + FileUpload, }, data() { return { // 遮罩层 loading: true, + // + actionUrl: process.env.VUE_APP_BASE_API + "/custom/fileUpload/ingredient", // 选中数组 ids: [], // 非单个禁用 @@ -431,6 +467,8 @@ export default { areaOptions: [], // physicalSignsOptions: [], + // + token: getToken(), // 查询参数 queryParams: { pageNum: 1, @@ -506,6 +544,7 @@ export default { createTime: null, updateBy: null, updateTime: null, + imgList: [], }; this.resetForm("form"); }, @@ -621,6 +660,12 @@ export default { string2Arr(str) { return str ? str.split(",") : []; }, + handleOnUploadSuccess() { + + }, + handleOnUploadRemove() { + + } }, }; </script>