!133 食材添加信息

Merge pull request !133 from 德仔/develop
This commit is contained in:
德仔 2021-03-16 20:10:50 +08:00 committed by Gitee
commit b037802a9c
22 changed files with 983 additions and 591 deletions

View File

@ -141,36 +141,37 @@ public class SysCustomerCaseController extends BaseController
return getDataTable(list); return getDataTable(list);
} }
/** // 转移到SysFileUploadController.java
* 上传文件到OSS返回URL // /**
*/ // * 上传文件到OSS返回URL
@PostMapping("/uploadCaseFile") // */
@PreAuthorize("@ss.hasPermi('custom:customerCase:list')") // @PostMapping("/uploadCaseFile")
public AjaxResult uploadCseFile(MultipartFile file) throws Exception { // @PreAuthorize("@ss.hasPermi('custom:customerCase:list')")
try { // public AjaxResult uploadCseFile(MultipartFile file) throws Exception {
if(file == null){ // try {
return AjaxResult.error("文件不存在"); // if(file == null){
} // return AjaxResult.error("文件不存在");
int fileNameLength = file.getOriginalFilename().length(); // }
if (fileNameLength > FileUploadUtils.DEFAULT_FILE_NAME_LENGTH) // int fileNameLength = file.getOriginalFilename().length();
{ // if (fileNameLength > FileUploadUtils.DEFAULT_FILE_NAME_LENGTH)
throw new FileNameLengthLimitExceededException(FileUploadUtils.DEFAULT_FILE_NAME_LENGTH); // {
} // throw new FileNameLengthLimitExceededException(FileUploadUtils.DEFAULT_FILE_NAME_LENGTH);
FileUploadUtils.assertAllowed(file, MimeTypeUtils.DEFAULT_ALLOWED_EXTENSION); // }
// FileUploadUtils.assertAllowed(file, MimeTypeUtils.DEFAULT_ALLOWED_EXTENSION);
String fileUrl = AliyunOSSUtils.uploadFileInputSteam(AliyunOSSConfig.casePrefix, DateUtils.getDate()+"/"+file.getOriginalFilename(), file); //
// String fileUrl = AliyunOSSUtils.uploadFileInputSteam(AliyunOSSConfig.casePrefix, DateUtils.getDate()+"/"+file.getOriginalFilename(), file);
AjaxResult ajax = null; //
if(StringUtils.isNotEmpty(fileUrl)){ // AjaxResult ajax = null;
ajax = AjaxResult.success(); // if(StringUtils.isNotEmpty(fileUrl)){
ajax.put("fileUrl", fileUrl); // ajax = AjaxResult.success();
ajax.put("fileName", file.getOriginalFilename()); // ajax.put("fileUrl", fileUrl);
}else{ // ajax.put("fileName", file.getOriginalFilename());
ajax = AjaxResult.error("文件上传失败"); // }else{
} // ajax = AjaxResult.error("文件上传失败");
return ajax; // }
} catch (Exception e) { // return ajax;
return AjaxResult.error("文件上传失败"); // } catch (Exception e) {
} // return AjaxResult.error("文件上传失败");
} // }
// }
} }

View File

@ -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("文件上传失败");
}
}
}

View File

@ -248,7 +248,7 @@ public class AliyunOSSUtils {
/** /**
* *
* @param fileUrl * @param fileUrlList
* @return * @return
*/ */
public static List<String> generatePresignedUrl(List<String> fileUrlList){ public static List<String> generatePresignedUrl(List<String> fileUrlList){

View File

@ -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;
String createBy;
Date createTime;
String updateBy;
Date updateTime;
}

View File

@ -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
@ -15,8 +16,6 @@ import java.util.Date;
*/ */
@Data @Data
public class SysIngredient { public class SysIngredient {
private static final long serialVersionUID = 1L;
/** /**
* id * id
*/ */
@ -107,4 +106,11 @@ public class SysIngredient {
private Long[] notRecIds; private Long[] notRecIds;
/**
* 食材信息
*/
private String info;
private List<SysIngredentFile> imgList;
} }

View File

@ -1,6 +1,8 @@
package com.stdiet.custom.mapper; package com.stdiet.custom.mapper;
import java.util.List; import java.util.List;
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;
@ -80,4 +82,6 @@ public interface SysIngredientMapper
* @return * @return
*/ */
public SysIngredient selectSysIngredientByName(@Param("name") String name); public SysIngredient selectSysIngredientByName(@Param("name") String name);
int batchInsertIngredientImage(List<SysIngredentFile> list);
} }

View File

@ -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;
@ -60,24 +62,35 @@ public class SysIngredientServiceImpl implements ISysIngredientService {
insertRecommand(sysIngredient); insertRecommand(sysIngredient);
// //
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) {
Long[] recIds = ingredient.getRecIds(); Long[] recIds = ingredient.getRecIds();
if(StringUtils.isNotNull(recIds)) { if (StringUtils.isNotNull(recIds)) {
List<SysIngredientRec> list = new ArrayList<SysIngredientRec>(); List<SysIngredientRec> list = new ArrayList<SysIngredientRec>();
for(Long recId: recIds) { for (Long recId : recIds) {
SysIngredientRec rec = new SysIngredientRec(); SysIngredientRec rec = new SysIngredientRec();
rec.setIngredientId(ingredient.getId()); rec.setIngredientId(ingredient.getId());
rec.setRecommandId(recId); rec.setRecommandId(recId);
list.add(rec); list.add(rec);
} }
if(list.size() > 0) { if (list.size() > 0) {
sysIngredientMapper.batchIngredientRec(list); sysIngredientMapper.batchIngredientRec(list);
} }
} }
@ -85,19 +98,20 @@ public class SysIngredientServiceImpl implements ISysIngredientService {
/** /**
* 新增不推荐标签 * 新增不推荐标签
*
* @param ingredient * @param ingredient
*/ */
public void insertNotRecommand(SysIngredient ingredient) { public void insertNotRecommand(SysIngredient ingredient) {
Long[] notRecIds = ingredient.getNotRecIds(); Long[] notRecIds = ingredient.getNotRecIds();
if(StringUtils.isNotNull(notRecIds)) { if (StringUtils.isNotNull(notRecIds)) {
List<SysIngredientNotRec> list = new ArrayList<SysIngredientNotRec>(); List<SysIngredientNotRec> list = new ArrayList<SysIngredientNotRec>();
for(Long recId: notRecIds) { for (Long recId : notRecIds) {
SysIngredientNotRec notRec = new SysIngredientNotRec(); SysIngredientNotRec notRec = new SysIngredientNotRec();
notRec.setIngredientId(ingredient.getId()); notRec.setIngredientId(ingredient.getId());
notRec.setRecommandId(recId); notRec.setRecommandId(recId);
list.add(notRec); list.add(notRec);
} }
if(list.size() > 0) { if (list.size() > 0) {
sysIngredientMapper.batchIngredientNotRec(list); sysIngredientMapper.batchIngredientNotRec(list);
} }
} }
@ -148,11 +162,12 @@ public class SysIngredientServiceImpl implements ISysIngredientService {
/** /**
* 根据食材名称查询食材信息 * 根据食材名称查询食材信息
*
* @param name * @param name
* @return * @return
*/ */
@Override @Override
public SysIngredient selectSysIngredientByName(String name){ public SysIngredient selectSysIngredientByName(String name) {
return sysIngredientMapper.selectSysIngredientByName(name); return sysIngredientMapper.selectSysIngredientByName(name);
} }
} }

View File

@ -37,6 +37,7 @@
where del_flag = 0 where del_flag = 0
<if test="name != null and name != ''"> and name like concat('%', #{name}, '%')</if> <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="phone != null and phone != ''"> and phone like concat('%', #{phone}, '%')</if>
<if test="fansChannel != null "> and fans_channel = #{fansChannel}</if>
order by create_time desc order by create_time desc
</select> </select>

View File

@ -5,21 +5,23 @@
<mapper namespace="com.stdiet.custom.mapper.SysIngredientMapper"> <mapper namespace="com.stdiet.custom.mapper.SysIngredientMapper">
<resultMap type="SysIngredient" id="SysIngredientResult"> <resultMap type="SysIngredient" id="SysIngredientResult">
<result property="id" column="id" /> <result property="id" column="id"/>
<result property="name" column="name" /> <result property="name" column="name"/>
<result property="type" column="type" /> <result property="type" column="type"/>
<result property="proteinRatio" column="protein_ratio" /> <result property="proteinRatio" column="protein_ratio"/>
<result property="fatRatio" column="fat_ratio" /> <result property="fatRatio" column="fat_ratio"/>
<result property="carbonRatio" column="carbon_ratio" /> <result property="carbonRatio" column="carbon_ratio"/>
<result property="area" column="area" /> <result property="area" column="area"/>
<result property="remark" column="remark" /> <result property="remark" column="remark"/>
<result property="createBy" column="create_by" /> <result property="createBy" column="create_by"/>
<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="rec" column="rec"/>
<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"/>
<association property="imgList" column="id" select="selectIngredentFileById"/>
</resultMap> </resultMap>
<sql id="selectSysIngredientVo"> <sql id="selectSysIngredientVo">
@ -43,44 +45,44 @@
<sql id="selectSysIngredientByPhyVo"> <sql id="selectSysIngredientByPhyVo">
SELECT * FROM sys_ingredient igd SELECT * FROM sys_ingredient igd
RIGHT JOIN( RIGHT JOIN(
SELECT * FROM( SELECT * FROM(
SELECT DISTINCT(ingredient_id) as id FROM sys_ingredient_rec SELECT DISTINCT(ingredient_id) as id FROM sys_ingredient_rec
<where> <where>
<if test="recIds != null"> <if test="recIds != null">
physical_signs_id in physical_signs_id in
<foreach collection="recIds" item="item" index="index" open="(" separator="," close=")"> <foreach collection="recIds" item="item" index="index" open="(" separator="," close=")">
#{item} #{item}
</foreach> </foreach>
</if> </if>
</where> </where>
) recId ) recId
LEFT JOIN ( LEFT JOIN (
SELECT ingredient_id as id, GROUP_CONCAT(name SEPARATOR ',') rec FROM( SELECT ingredient_id as id, GROUP_CONCAT(name SEPARATOR ',') rec FROM(
SELECT physical_signs_id as id, ingredient_id SELECT physical_signs_id as id, ingredient_id
FROM sys_ingredient_rec FROM sys_ingredient_rec
) rec JOIN sys_physical_signs phy USING(id) ) rec JOIN sys_physical_signs phy USING(id)
GROUP BY id GROUP BY id
) recM USING(id) ) recM USING(id)
INNER JOIN ( INNER JOIN (
SELECT * FROM( SELECT * FROM(
SELECT DISTINCT(ingredient_id) as id FROM sys_ingredient_not_rec SELECT DISTINCT(ingredient_id) as id FROM sys_ingredient_not_rec
<where> <where>
<if test="notRecIds != null"> <if test="notRecIds != null">
physical_signs_id in physical_signs_id in
<foreach collection="notRecIds" item="item" index="index" open="(" separator="," close=")"> <foreach collection="notRecIds" item="item" index="index" open="(" separator="," close=")">
#{item} #{item}
</foreach> </foreach>
</if> </if>
</where> </where>
) notRecId ) notRecId
LEFT JOIN ( LEFT JOIN (
SELECT ingredient_id as id, GROUP_CONCAT(name SEPARATOR ',') not_rec FROM( SELECT ingredient_id as id, GROUP_CONCAT(name SEPARATOR ',') not_rec FROM(
SELECT physical_signs_id as id, ingredient_id SELECT physical_signs_id as id, ingredient_id
FROM sys_ingredient_not_rec FROM sys_ingredient_not_rec
) notRec JOIN sys_physical_signs phy USING(id) ) notRec JOIN sys_physical_signs phy USING(id)
GROUP BY id GROUP BY id
) notRecM USING(id) ) notRecM USING(id)
) notRecT USING(id) ) notRecT USING(id)
) recT USING(id) ) recT USING(id)
</sql> </sql>
@ -97,10 +99,10 @@
</otherwise> </otherwise>
</choose> </choose>
<where> <where>
<if test="name != null and name != ''"> and name like concat('%', #{name}, '%')</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="type != null and type != ''">and type = #{type}</if>
<if test="area != null and area != ''"> and area = #{area}</if> <if test="area != null and area != ''">and area = #{area}</if>
<if test="reviewStatus != null and reviewStatus != ''"> and review_status = #{reviewStatus}</if> <if test="reviewStatus != null and reviewStatus != ''">and review_status = #{reviewStatus}</if>
</where> </where>
</select> </select>
@ -124,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>
@ -138,17 +141,18 @@
<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>
<insert id="batchIngredientRec" > <insert id="batchIngredientRec">
insert into sys_ingredient_rec(ingredient_id, physical_signs_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, physical_signs_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})
@ -192,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>
@ -213,4 +218,28 @@
where name = #{name} limit 1 where name = #{name} limit 1
</select> </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> </mapper>

View File

@ -70,7 +70,7 @@
>复制 >复制
</el-button> </el-button>
<el-popover placement="top" trigger="click"> <el-popover placement="top" trigger="click">
<VueQr :text="copyValue" :logoSrc="logo" size="256" /> <VueQr :text="copyValue" :logoSrc="logo" :size="256" />
<el-button <el-button
slot="reference" slot="reference"
icon="el-icon-picture-outline" icon="el-icon-picture-outline"

View File

@ -1,74 +1,81 @@
<template> <template>
<el-upload class="upload-demo" <el-upload
ref="upload" class="upload-demo"
drag ref="upload"
:headers="upload.headers" drag
:action="upload.url" :headers="upload.headers"
:limit="upload.limit" :action="upload.url"
:disabled="upload.isUploading" :limit="upload.limit"
:file-list="upload.fileList" :disabled="upload.isUploading"
:multiple="upload.multiple" :file-list="upload.fileList"
:on-change="handleFileChange" :multiple="upload.multiple"
:on-remove="handleFileRemove" :on-change="handleFileChange"
:on-exceed="handleFileexceed" :on-remove="handleFileRemove"
:on-progress="handleFileUploadProgress" :on-exceed="handleFileexceed"
:on-success="handleFileSuccess" :on-progress="handleFileUploadProgress"
:on-error="handleFileFail" :on-success="handleFileSuccess"
:data="upload.data" :on-error="handleFileFail"
:auto-upload="false"> :data="upload.data"
<i class="el-icon-upload"></i> :auto-upload="false"
>
<em class="el-icon-upload" />
<div class="el-upload__text">将文件拖到此处<em>点击上传</em></div> <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> </el-upload>
</template> </template>
<script> <script>
import { getToken } from '@/utils/auth' import { getToken } from "@/utils/auth";
export default { export default {
name: "DragUpload", name: "DragUpload",
components: { components: {},
},
data() { data() {
return { return {
upload: { upload: {
// //
isUploading: false, 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, limit: 10,
//(byte) //(byte)
fileSize: 1024 * 1024 * 10, fileSize: 1024 * 1024 * 10,
// //
multiple: true multiple: true,
},
uploadResult: {
fileUrl: [],
fileName: [],
}, },
uploadResult:{
fileUrl:[],
fileName:[]
}
}; };
}, },
methods: { methods: {
uploadFile(){ uploadFile() {
if(this.upload.fileList.length > 0 && this.uploadResult.fileUrl.length < this.upload.fileList.length){ if (
this.upload.fileList.length > 0 &&
this.uploadResult.fileUrl.length < this.upload.fileList.length
) {
this.$refs.upload.submit(); this.$refs.upload.submit();
}else{ } else {
this.$emit('callbackMethod', this.uploadResult); this.$emit("callbackMethod", this.uploadResult);
} }
}, },
uploadReset(){ uploadReset() {
this.upload.fileList = []; this.upload.fileList = [];
this.uploadResult["fileUrl"] = []; this.uploadResult["fileUrl"] = [];
this.uploadResult["fileName"] = []; this.uploadResult["fileName"] = [];
}, },
// //
handleFileRemove(file, fileList){ handleFileRemove(file, fileList) {
this.upload.fileList = fileList; this.upload.fileList = fileList;
}, },
// //
@ -84,9 +91,9 @@ export default {
this.upload.fileList = fileList; this.upload.fileList = fileList;
}, },
// //
handleFileexceed(file, fileList){ handleFileexceed(file, fileList) {
this.$message({ this.$message({
message: "最多可上传"+ this.upload.limit +"份文件", message: "最多可上传" + this.upload.limit + "份文件",
type: "warning", type: "warning",
}); });
}, },
@ -96,39 +103,38 @@ export default {
}, },
// //
handleFileSuccess(response, file, fileList) { handleFileSuccess(response, file, fileList) {
if(response != null && response.code === 200){ if (response != null && response.code === 200) {
this.uploadResult.fileUrl.push(response.fileUrl); this.uploadResult.fileUrl.push(response.fileUrl);
this.uploadResult.fileName.push(response.fileName); 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.upload.fileList = fileList.pop();
this.$message.error('文件上传失败,请检查文件格式'); this.$message.error("文件上传失败,请检查文件格式");
this.$emit('changeSubmitFlag', false); this.$emit("changeSubmitFlag", false);
} }
}, },
// //
handleFileFail(err, file, fileList){ handleFileFail(err, file, fileList) {
this.$message.error('文件上传失败,请检查文件格式'); this.$message.error("文件上传失败,请检查文件格式");
this.upload.fileList = fileList.pop(); this.upload.fileList = fileList.pop();
this.$emit('changeSubmitFlag', false); this.$emit("changeSubmitFlag", false);
} },
}, },
props: { props: {
prefix: {
type: String,
default: "case",
},
}, },
created() { created() {
//this.uploadReset(); //this.uploadReset();
}, },
}; };
</script> </script>
<style scoped> <style scoped>
</style> </style>

View File

@ -1,41 +1,58 @@
<template> <template>
<div> <div>
<div v-for="(item, index) in oldCaseFileList"> <div v-for="(item, index) in oldCaseFileList" :key="index">
<span style="margin-right: 10px;"> <span style="margin-right: 10px">
{{item.fileName.length > 15 ? (item.fileName.substring(0,15)+"...") : item.fileName}} {{
item.fileName.length > 15
? item.fileName.substring(0, 15) + "..."
: item.fileName
}}
</span> </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> </div>
<el-upload class="upload-demo" style="margin-top: 10px;" <el-upload
ref="upload" class="upload-demo"
drag style="margin-top: 10px"
:headers="upload.headers" ref="upload"
:action="upload.url" drag
:limit="upload.limit" :headers="upload.headers"
:disabled="upload.isUploading" :action="upload.url"
:file-list="upload.fileList" :limit="upload.limit"
:multiple="upload.multiple" :disabled="upload.isUploading"
:on-remove="handleFileRemove" :file-list="upload.fileList"
:on-change="handleFileChange" :multiple="upload.multiple"
:on-exceed="handleFileexceed" :on-remove="handleFileRemove"
:on-progress="handleFileUploadProgress" :on-change="handleFileChange"
:on-success="handleFileSuccess" :on-exceed="handleFileexceed"
:on-error="handleFileFail" :on-progress="handleFileUploadProgress"
:data="upload.data" :on-success="handleFileSuccess"
:auto-upload="false"> :on-error="handleFileFail"
<i class="el-icon-upload"></i> :data="upload.data"
:auto-upload="false"
>
<em class="el-icon-upload" />
<div class="el-upload__text">将文件拖到此处<em>点击上传</em></div> <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> </el-upload>
</div> </div>
</template> </template>
<script> <script>
import { getToken } from '@/utils/auth' import { getToken } from "@/utils/auth";
import AutoHideMessage from "@/components/AutoHideMessage"; // import AutoHideMessage from "@/components/AutoHideMessage";
export default { export default {
name: "DragUploadEdit", name: "DragUploadEdit",
components: { components: {
"AutoHideMessage":AutoHideMessage // "AutoHideMessage":AutoHideMessage
}, },
data() { data() {
return { return {
@ -43,54 +60,57 @@ export default {
// //
isUploading: false, 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, limit: 10 - this.caseFileList.length,
//(byte) //(byte)
fileSize: 1024 * 1024 * 10, fileSize: 1024 * 1024 * 10,
// //
multiple: true multiple: true,
}, },
oldCaseFileList: this.caseFileList, oldCaseFileList: this.caseFileList,
uploadResult:{ uploadResult: {
fileUrl:[], fileUrl: [],
fileName:[] fileName: [],
} },
}; };
}, },
methods: { methods: {
async uploadFile(){ async uploadFile() {
if(this.upload.fileList.length > 0 && this.uploadResult.fileUrl.length < this.upload.fileList.length){ if (
this.upload.fileList.length > 0 &&
this.uploadResult.fileUrl.length < this.upload.fileList.length
) {
this.$refs.upload.submit(); 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) => { await this.oldCaseFileList.forEach((item, index) => {
this.uploadResult.fileUrl.unshift(item.fileUrl); this.uploadResult.fileUrl.unshift(item.fileUrl);
this.uploadResult.fileName.unshift(item.fileName); this.uploadResult.fileName.unshift(item.fileName);
}); });
} }
this.$emit('callbackMethod', this.uploadResult); this.$emit("callbackMethod", this.uploadResult);
} }
}, },
removeOldFile(index){ removeOldFile(index) {
this.oldCaseFileList.splice(index,1); this.oldCaseFileList.splice(index, 1);
this.upload.limit = 10 - this.oldCaseFileList.length; this.upload.limit = 10 - this.oldCaseFileList.length;
}, },
uploadReset(){ uploadReset() {
this.upload.fileList = []; this.upload.fileList = [];
this.uploadResult["fileUrl"] = []; this.uploadResult["fileUrl"] = [];
this.uploadResult["fileName"] = []; this.uploadResult["fileName"] = [];
this.oldCaseFileList = []; this.oldCaseFileList = [];
}, },
// //
handleFileRemove(file, fileList){ handleFileRemove(file, fileList) {
this.upload.fileList = fileList; this.upload.fileList = fileList;
}, },
// //
@ -106,9 +126,9 @@ export default {
this.upload.fileList = fileList; this.upload.fileList = fileList;
}, },
// //
handleFileexceed(file, fileList){ handleFileexceed(file, fileList) {
this.$message({ this.$message({
message: "最多可上传"+ this.upload.limit +"份文件", message: "最多可上传" + this.upload.limit + "份文件",
type: "warning", type: "warning",
}); });
}, },
@ -118,56 +138,54 @@ export default {
}, },
// //
async handleFileSuccess(response, file, fileList) { 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.fileUrl.push(response.fileUrl);
this.uploadResult.fileName.push(response.fileName); 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) => { await this.oldCaseFileList.forEach((item, index) => {
this.uploadResult.fileUrl.unshift(item.fileUrl); this.uploadResult.fileUrl.unshift(item.fileUrl);
this.uploadResult.fileName.unshift(item.fileName); this.uploadResult.fileName.unshift(item.fileName);
}); });
} }
this.$emit('callbackMethod', this.uploadResult); this.$emit("callbackMethod", this.uploadResult);
} }
}else{ } else {
this.upload.fileList = fileList.pop(); this.upload.fileList = fileList.pop();
this.$message.error('文件上传失败,请检查文件格式'); this.$message.error("文件上传失败,请检查文件格式");
this.$emit('changeSubmitFlag', false); this.$emit("changeSubmitFlag", false);
} }
}, },
// //
handleFileFail(err, file, fileList){ handleFileFail(err, file, fileList) {
this.$message.error('文件上传失败,请检查文件格式'); this.$message.error("文件上传失败,请检查文件格式");
this.upload.fileList = fileList.pop(); this.upload.fileList = fileList.pop();
this.$emit('changeSubmitFlag', false); this.$emit("changeSubmitFlag", false);
} },
}, },
props: { props: {
caseFileList:{ caseFileList: {
type: Array, type: Array,
default: function () { default: function () {
return []; 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> </script>
<style scoped> <style scoped>
</style> </style>

View 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>

View File

@ -25,7 +25,7 @@
trigger="click" trigger="click"
style="margin: 0 12px" style="margin: 0 12px"
> >
<VueQr :text="copyValue" :logoSrc="logo" size="256" /> <VueQr :text="copyValue" :logoSrc="logo" :size="256" />
<el-button <el-button
slot="reference" slot="reference"
size="mini" size="mini"

View File

@ -201,7 +201,7 @@
v-show="dataList.length == 0" v-show="dataList.length == 0"
style="font-size: 20px; text-align: center" 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"> <div style="text-align: center; margin-top: 20px">
<el-button <el-button
icon="el-icon-share" icon="el-icon-share"
@ -689,6 +689,28 @@ export default {
? medicalReportNameArray[2] ? medicalReportNameArray[2]
: "体检报告3" : "体检报告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; this.detailHealthy = detailHealthy;
for (let i = 0; i < this.healthyTitleData.length; i++) { for (let i = 0; i < this.healthyTitleData.length; i++) {
let stepArray = []; let stepArray = [];

View File

@ -25,7 +25,7 @@
v-if="cusOutId" v-if="cusOutId"
style="margin: 0 12px" style="margin: 0 12px"
> >
<VueQr :text="copyValue" :logoSrc="logo" size="256" /> <VueQr :text="copyValue" :logoSrc="logo" :size="256" />
<el-button <el-button
slot="reference" slot="reference"
size="mini" size="mini"

View File

@ -198,7 +198,7 @@
>复制 >复制
</el-button> </el-button>
<el-popover placement="top" trigger="click"> <el-popover placement="top" trigger="click">
<VueQr :text="copyValue" :logoSrc="logo" size="256"/> <VueQr :text="copyValue" :logoSrc="logo" :size="256"/>
<el-button <el-button
slot="reference" slot="reference"
icon="el-icon-picture-outline" icon="el-icon-picture-outline"

View File

@ -25,16 +25,17 @@
@keyup.enter.native="handleQuery" @keyup.enter.native="handleQuery"
/> />
</el-form-item> </el-form-item>
<!--<el-form-item label="主营养师" prop="mainDietitian"> <el-form-item label="进粉渠道" prop="fansChannel">
<el-input <el-select v-model="queryParams.fansChannel" placeholder="请选择">
v-model="queryParams.mainDietitian" <el-option
placeholder="请输入主营养师" v-for="dict in fansChannelOptions"
clearable :key="dict.dictValue"
size="small" :label="dict.dictLabel"
@keyup.enter.native="handleQuery" :value="parseInt(dict.dictValue)"
/> />
</el-select>
</el-form-item> </el-form-item>
<el-form-item label="营养师助理" prop="assistantDietitian"> <!--<el-form-item label="营养师助理" prop="assistantDietitian">
<el-input <el-input
v-model="queryParams.assistantDietitian" v-model="queryParams.assistantDietitian"
placeholder="请输入营养师助理" placeholder="请输入营养师助理"
@ -430,6 +431,7 @@ export default {
queryParams: { queryParams: {
pageNum: 1, pageNum: 1,
pageSize: 10, pageSize: 10,
fansChannel: null,
name: null, name: null,
phone: null, phone: null,
mainDietitian: null, mainDietitian: null,

View File

@ -1,6 +1,12 @@
<template> <template>
<div class="app-container"> <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-form-item label="案例信息" prop="name">
<el-input <el-input
v-model.trim="queryParams.name" v-model.trim="queryParams.name"
@ -17,12 +23,15 @@
allow-create allow-create
clearable clearable
default-first-option default-first-option
placeholder="关键词搜索" style="width: 100%;"> placeholder="关键词搜索"
style="width: 100%"
>
<el-option <el-option
v-for="dict in caseKeyOptions" v-for="dict in caseKeyOptions"
:key="dict.dictValue" :key="dict.dictValue"
:label="dict.dictLabel" :label="dict.dictLabel"
:value="dict.dictValue"> :value="dict.dictValue"
>
</el-option> </el-option>
</el-select> </el-select>
</el-form-item> </el-form-item>
@ -36,8 +45,16 @@
/> />
</el-form-item> </el-form-item>
<el-form-item> <el-form-item>
<el-button type="cyan" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button> <el-button
<el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</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-item>
</el-form> </el-form>
@ -49,7 +66,8 @@
size="mini" size="mini"
@click="handleAdd" @click="handleAdd"
v-hasPermi="['custom:customerCase:add']" v-hasPermi="['custom:customerCase:add']"
>新增</el-button> >新增</el-button
>
</el-col> </el-col>
<el-col :span="1.5"> <el-col :span="1.5">
<el-button <el-button
@ -59,7 +77,8 @@
:disabled="single" :disabled="single"
@click="handleUpdate" @click="handleUpdate"
v-hasPermi="['custom:customerCase:edit']" v-hasPermi="['custom:customerCase:edit']"
>修改</el-button> >修改</el-button
>
</el-col> </el-col>
<el-col :span="1.5"> <el-col :span="1.5">
<el-button <el-button
@ -69,7 +88,8 @@
:disabled="multiple" :disabled="multiple"
@click="handleDelete" @click="handleDelete"
v-hasPermi="['custom:customerCase:remove']" v-hasPermi="['custom:customerCase:remove']"
>删除</el-button> >删除</el-button
>
</el-col> </el-col>
<el-col :span="1.5"> <el-col :span="1.5">
<el-button <el-button
@ -78,40 +98,54 @@
size="mini" size="mini"
@click="handleExport" @click="handleExport"
v-hasPermi="['custom:customerCase:export']" v-hasPermi="['custom:customerCase:export']"
>导出</el-button> >导出</el-button
>
</el-col> </el-col>
<right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar> <right-toolbar
:showSearch.sync="showSearch"
@queryTable="getList"
></right-toolbar>
</el-row> </el-row>
<el-table v-loading="loading" :data="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 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"> <template slot-scope="scope">
<AutoHideMessage :data="scope.row.name" :maxLength="10"></AutoHideMessage> <AutoHideMessage
:data="scope.row.name"
:maxLength="10"
></AutoHideMessage>
</template> </template>
</el-table-column> </el-table-column>
<el-table-column label="关键词" align="center" prop="keyword" > <el-table-column label="关键词" align="center" prop="keyword">
<template slot-scope="scope"> <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>--> <!--<AutoHideInfo :data="scope.row.keyword.split(',')" :line="1"></AutoHideInfo>-->
</template> </template>
</el-table-column> </el-table-column>
<el-table-column label="备注" align="center" prop="remark" > <el-table-column label="备注" align="center" prop="remark">
<template slot-scope="scope"> <template slot-scope="scope">
<AutoHideMessage :data="scope.row.remark" :maxLength="10"></AutoHideMessage> <AutoHideMessage
:data="scope.row.remark"
:maxLength="10"
></AutoHideMessage>
</template> </template>
</el-table-column> </el-table-column>
<el-table-column label="所属客户" align="center" prop="customerName" /> <el-table-column label="所属客户" align="center" prop="customerName" />
<el-table-column <el-table-column label="文件" align="center">
label="文件"
align="center"
>
<template slot-scope="scope"> <template slot-scope="scope">
<el-button <el-button
size="mini" size="mini"
type="text" type="text"
@click="getFileListByCaseId(scope.row)" @click="getFileListByCaseId(scope.row)"
>文件列表 >文件列表
</el-button> </el-button>
</template> </template>
</el-table-column> </el-table-column>
@ -127,7 +161,11 @@
}}</span> }}</span>
</template> </template>
</el-table-column> </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"> <template slot-scope="scope">
<el-button <el-button
size="mini" size="mini"
@ -135,20 +173,22 @@
icon="el-icon-edit" icon="el-icon-edit"
@click="handleUpdate(scope.row)" @click="handleUpdate(scope.row)"
v-hasPermi="['custom:customerCase:edit']" v-hasPermi="['custom:customerCase:edit']"
>修改</el-button> >修改</el-button
>
<el-button <el-button
size="mini" size="mini"
type="text" type="text"
icon="el-icon-delete" icon="el-icon-delete"
@click="handleDelete(scope.row)" @click="handleDelete(scope.row)"
v-hasPermi="['custom:customerCase:remove']" v-hasPermi="['custom:customerCase:remove']"
>删除</el-button> >删除</el-button
>
</template> </template>
</el-table-column> </el-table-column>
</el-table> </el-table>
<pagination <pagination
v-show="total>0" v-show="total > 0"
:total="total" :total="total"
:page.sync="queryParams.pageNum" :page.sync="queryParams.pageNum"
:limit.sync="queryParams.pageSize" :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"> <div style="height: 600px; overflow: auto; padding-right: 20px">
<el-form ref="form" :model="form" :rules="rules" label-width="80px"> <el-form ref="form" :model="form" :rules="rules" label-width="80px">
<el-form-item label="案例名称" prop="name"> <el-form-item label="案例名称" prop="name">
<el-input v-model.trim="form.name" type="textarea" maxlength="50" rows = "1" show-word-limit placeholder="请输入案例名称" /> <el-input
</el-form-item> v-model.trim="form.name"
<el-form-item label="关键词" prop="keywordArray"> type="textarea"
<el-select maxlength="50"
v-model="form.keywordArray" rows="1"
multiple show-word-limit
filterable placeholder="请输入案例名称"
clearable />
allow-create </el-form-item>
default-first-option <el-form-item label="关键词" prop="keywordArray">
placeholder="请创建案例关键词按回车创建最多20个" style="width: 100%;"> <el-select
<el-option v-model="form.keywordArray"
v-for="dict in caseKeyOptions" multiple
:key="dict.dictValue" filterable
:label="dict.dictLabel" clearable
:value="dict.dictValue"> allow-create
</el-option> default-first-option
</el-select> placeholder="请创建案例关键词按回车创建最多20个"
</el-form-item> style="width: 100%"
<el-form-item label="案例备注" prop="remark"> >
<el-input <el-option
type="textarea" v-for="dict in caseKeyOptions"
placeholder="请输入案例备注" :key="dict.dictValue"
v-model.trim="form.remark" :label="dict.dictLabel"
maxlength="200" :value="dict.dictValue"
rows = "4" >
show-word-limit </el-option>
></el-input> </el-select>
</el-form-item> </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-form-item label="所属客户" prop="customerId">
<el-input v-model="form.customerName" placeholder="" style="width: 60%" :readonly="true" /> <el-input
<span style="margin-left: 10px"> <el-button type="primary" @click="selectCustomer">选择所属客户</el-button></span> v-model="form.customerName"
</el-form-item> placeholder=""
<el-form-item label="案例文件" prop="file" > style="width: 60%"
<DragUpload v-show="form.id == null || form.id <= 0" @changeSubmitFlag="changeSubmitFlag" @callbackMethod="addOrEditCustomerCase" ref="uploadCaseFile"></DragUpload> :readonly="true"
<DragUploadEdit v-show="form.id != null || form.id > 0" @callbackMethod="addOrEditCustomerCase" @changeSubmitFlag="changeSubmitFlag" :caseFileList="form.caseFileList" ref="editUploadCaseFile"></DragUploadEdit> />
</el-form-item> <span style="margin-left: 10px">
</el-form> <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>
<div slot="footer" class="dialog-footer"> <div slot="footer" class="dialog-footer">
<el-button type="primary" @click="submitForm"> </el-button> <el-button type="primary" @click="submitForm"> </el-button>
@ -207,258 +285,281 @@
</el-dialog> </el-dialog>
<MuchFileDown ref="muchFileDownRef"></MuchFileDown> <MuchFileDown ref="muchFileDownRef"></MuchFileDown>
<SelectCustomer @dealCustomerId="dealCustomerId" ref="selectCustomerRef"></SelectCustomer> <SelectCustomer
@dealCustomerId="dealCustomerId"
ref="selectCustomerRef"
></SelectCustomer>
</div> </div>
</template> </template>
<script> <script>
import { listCustomerCase, getCustomerCase, delCustomerCase, addCustomerCase, updateCustomerCase, exportCustomerCase,getFileListByCaseId,downCaseFile } from "@/api/custom/customerCase"; import {
import DragUpload from "@/components/FileUpload/DragUpload"; listCustomerCase,
import DragUploadEdit from "@/components/FileUpload/DragUploadEdit"; getCustomerCase,
import SelectCustomer from "@/components/Customer/SelectCustomer"; delCustomerCase,
import MuchFileDown from "@/components/FileDownload/MuchFileDown"; addCustomerCase,
import AutoHideMessage from "@/components/AutoHideMessage"; updateCustomerCase,
import AutoHideInfo from "@/components/AutoHideInfo"; 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 { export default {
name: "CustomerCase", name: "CustomerCase",
data() { data() {
return { return {
// //
loading: true, loading: true,
// //
ids: [], ids: [],
// //
single: true, single: true,
// //
multiple: true, multiple: true,
// //
showSearch: true, showSearch: true,
// //
total: 0, total: 0,
// //
customerCaseList: [], customerCaseList: [],
// //
title: "", title: "",
// //
open: false, open: false,
// //
queryParams: { queryParams: {
pageNum: 1, pageNum: 1,
pageSize: 10, pageSize: 10,
name: null, name: null,
keyword: null, keyword: null,
customerName: null customerName: null,
}, },
// //
form: { form: {},
//
}, rules: {
// name: [
rules: { { required: true, message: "案例名称不能为空", trigger: "blur" },
name: [ ],
{ required: true, message: "案例名称不能为空", trigger: "blur" }, keywordArray: [
], { required: true, message: "案例关键词不能为空", trigger: "blur" },
keywordArray: [ ],
{ required: true, message: "案例关键词不能为空", trigger: "blur" }, },
], keywordArray: [],
}, submitFlag: false,
keywordArray:[], caseKeyOptions: [],
submitFlag: false, };
caseKeyOptions: [], },
}; components: {
}, DragUpload: DragUpload,
components: { SelectCustomer: SelectCustomer,
"DragUpload": DragUpload, MuchFileDown: MuchFileDown,
"SelectCustomer":SelectCustomer, AutoHideMessage: AutoHideMessage,
"MuchFileDown": MuchFileDown, AutoHideInfo: AutoHideInfo,
"AutoHideMessage": AutoHideMessage, DragUploadEdit: DragUploadEdit,
"AutoHideInfo":AutoHideInfo, },
"DragUploadEdit":DragUploadEdit created() {
}, this.getList();
created() { this.getDicts("case_key").then((response) => {
this.getList(); this.caseKeyOptions = response.data;
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: { //
/** 查询客户案例管理列表 */ cancel() {
getList() { this.open = false;
this.loading = true; this.$refs["uploadCaseFile"] &&
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;
this.$refs["uploadCaseFile"].uploadReset(); this.$refs["uploadCaseFile"].uploadReset();
this.$refs["editUploadCaseFile"] &&
this.$refs["editUploadCaseFile"].uploadReset(); this.$refs["editUploadCaseFile"].uploadReset();
this.reset(); this.reset();
}, },
// //
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 = { this.form = {
id: null, id: response.data.id,
name: null, name: response.data.name,
keywordArray: [], keywordArray: response.data.keyword.split(","),
remark: null, remark: response.data.remark,
customerId: null, customerId: response.data.customerId,
customerName: null, customerName: response.data.customerName,
caseFileList:[], caseFileList: response.data.caseFileList,
caseFileUrl: [], 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.open = true;
this.title = "添加客户案例管理"; this.title = "修改客户案例管理";
}, });
/** 修改按钮操作 */ },
handleUpdate(row) { /** 提交按钮 */
this.reset(); submitForm() {
const id = row.id || this.ids this.$refs["form"].validate((valid) => {
getCustomerCase(id).then(response => { if (valid) {
this.form = { if (this.submitFlag) {
id: response.data.id, this.$message({
name: response.data.name, message: "正在上传提交中,请勿重复提交",
keywordArray: response.data.keyword.split(","), type: "warning",
remark: response.data.remark, });
customerId: response.data.customerId, return;
customerName: response.data.customerName, }
caseFileList: response.data.caseFileList, //
caseFileUrl: [], if (this.form.keywordArray.length > 20) {
caseFileName: [] this.$message({ message: "案例关键词最多20个", type: "warning" });
}; return;
this.open = true; }
this.title = "修改客户案例管理"; this.submitFlag = true;
}); this.form.keyword = this.form.keywordArray.join(",");
}, if (this.form.id != null) {
/** 提交按钮 */ this.$refs["editUploadCaseFile"].uploadFile();
submitForm() { } else {
this.$refs["form"].validate(valid => { this.$refs["uploadCaseFile"].uploadFile();
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 => { addOrEditCustomerCase(fileResult) {
if (response.code === 200) { this.form.caseFileName = fileResult.fileName;
this.$refs["editUploadCaseFile"].uploadReset(); this.form.caseFileUrl = fileResult.fileUrl;
this.msgSuccess("修改成功"); if (this.form.caseFileUrl.length == 0) {
this.open = false; this.$message.error("请至少选择一个文件上传");
this.getList(); this.submitFlag = false;
} return;
this.submitFlag = false; }
if (this.form.id != null) {
}); // console.log(this.form.caseFileName.length);
}else{ updateCustomerCase(this.form).then((response) => {
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) { 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;
}); });
}, } else {
/** 删除按钮操作 */ addCustomerCase(this.form).then((response) => {
handleDelete(row) { if (response.code === 200) {
const ids = row.id || this.ids; this.$refs["uploadCaseFile"].uploadReset();
this.$confirm('是否确认删除客户案例管理编号为"' + ids + '"的数据项?', "警告", { 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: "确定", confirmButtonText: "确定",
cancelButtonText: "取消", cancelButtonText: "取消",
type: "warning" type: "warning",
}).then(function() { }
)
.then(function () {
return delCustomerCase(ids); return delCustomerCase(ids);
}).then(() => { })
.then(() => {
this.getList(); this.getList();
this.msgSuccess("删除成功"); this.msgSuccess("删除成功");
}).catch(function() {}); })
}, .catch(function () {});
/** 导出按钮操作 */ },
handleExport() { /** 导出按钮操作 */
const queryParams = this.queryParams; handleExport() {
this.$confirm('是否确认导出所有客户案例管理数据项?', "警告", { const queryParams = this.queryParams;
confirmButtonText: "确定", this.$confirm("是否确认导出所有客户案例管理数据项?", "警告", {
cancelButtonText: "取消", confirmButtonText: "确定",
type: "warning" cancelButtonText: "取消",
}).then(function() { type: "warning",
})
.then(function () {
return exportCustomerCase(queryParams); return exportCustomerCase(queryParams);
}).then(response => { })
.then((response) => {
this.download(response.msg); this.download(response.msg);
}).catch(function() {}); })
} .catch(function () {});
} },
}; },
};
</script> </script>

View File

@ -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>

View File

@ -87,7 +87,7 @@ export default {
this.setNotRecIgds({ data: [] }); this.setNotRecIgds({ data: [] });
} }
this.selectedIgd = data.id; this.selectedIgd = data.id === this.selectedIgd ? 0 : data.id;
this.setNotRecIgds({ data: [this.selectedIgd] }); this.setNotRecIgds({ data: [this.selectedIgd] });
}, },

View File

@ -200,6 +200,7 @@ export default {
orderDialog: undefined, orderDialog: undefined,
reviewStatusOptions: [ reviewStatusOptions: [
{ dictValue: 0, dictLabel: "未制作" }, { dictValue: 0, dictLabel: "未制作" },
{ dictValue: 3, dictLabel: "制作中" },
{ dictValue: 1, dictLabel: "未审核" }, { dictValue: 1, dictLabel: "未审核" },
{ dictValue: 2, dictLabel: "已审核" }, { dictValue: 2, dictLabel: "已审核" },
], ],