食材添加信息

This commit is contained in:
huangdeliang
2021-03-16 17:53:17 +08:00
parent 7a3ab6bfef
commit 03eb2508b6
11 changed files with 761 additions and 518 deletions

View File

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

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
*/
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;
Long createBy;
Date createTime;
Long updateBy;
Date updateTime;
}

View File

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

View File

@ -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);
}

View File

@ -60,6 +60,9 @@ public class SysIngredientServiceImpl implements ISysIngredientService {
insertRecommand(sysIngredient);
//
insertNotRecommand(sysIngredient);
//
return rows;
}

View File

@ -20,6 +20,8 @@
<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">
@ -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>

View File

@ -1,5 +1,6 @@
<template>
<el-upload class="upload-demo"
<el-upload
class="upload-demo"
ref="upload"
drag
:headers="upload.headers"
@ -15,28 +16,31 @@
:on-success="handleFileSuccess"
:on-error="handleFileFail"
:data="upload.data"
:auto-upload="false">
<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__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: {},
//文件列表
@ -46,20 +50,23 @@ export default {
//每个文件大小(单位byte)
fileSize: 1024 * 1024 * 10,
//是否支持同时选择多张
multiple: true
multiple: true,
},
uploadResult: {
fileUrl: [],
fileName:[]
}
fileName: [],
},
};
},
methods: {
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();
} else {
this.$emit('callbackMethod', this.uploadResult);
this.$emit("callbackMethod", this.uploadResult);
}
},
uploadReset() {
@ -101,34 +108,33 @@ export default {
this.uploadResult.fileName.push(response.fileName);
if (this.uploadResult.fileUrl.length === this.upload.fileList.length) {
//文件全部上传成功,则调用回调方法
this.$emit('callbackMethod', this.uploadResult);
this.$emit("callbackMethod", this.uploadResult);
}
} 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('文件上传失败,请检查文件格式');
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();
},
};
</script>
<style scoped>
</style>

View File

@ -1,12 +1,24 @@
<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;"
<el-upload
class="upload-demo"
style="margin-top: 10px"
ref="upload"
drag
:headers="upload.headers"
@ -22,20 +34,25 @@
:on-success="handleFileSuccess"
:on-error="handleFileFail"
:data="upload.data"
:auto-upload="false">
<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__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,9 +60,9 @@ 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: {},
//文件列表
@ -55,18 +72,21 @@ export default {
//每个文件大小(单位byte)
fileSize: 1024 * 1024 * 10,
//是否支持同时选择多张
multiple: true
multiple: true,
},
oldCaseFileList: this.caseFileList,
uploadResult: {
fileUrl: [],
fileName:[]
}
fileName: [],
},
};
},
methods: {
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();
} else {
//合并旧文件
@ -76,7 +96,7 @@ export default {
this.uploadResult.fileName.unshift(item.fileName);
});
}
this.$emit('callbackMethod', this.uploadResult);
this.$emit("callbackMethod", this.uploadResult);
}
},
removeOldFile(index) {
@ -129,45 +149,43 @@ export default {
this.uploadResult.fileName.unshift(item.fileName);
});
}
this.$emit('callbackMethod', this.uploadResult);
this.$emit("callbackMethod", this.uploadResult);
}
} 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('文件上传失败,请检查文件格式');
this.$message.error("文件上传失败,请检查文件格式");
this.upload.fileList = fileList.pop();
this.$emit('changeSubmitFlag', false);
}
this.$emit("changeSubmitFlag", false);
},
},
props: {
caseFileList: {
type: Array,
default: function () {
return [];
}
}
},
created() {
},
prefix: {
type: String,
default: "case",
},
},
created() {},
watch: {
caseFileList: function (newVal, oldVal) {
//console.log(newVal.length);
this.oldCaseFileList = newVal;
}
}
},
},
};
</script>
<style scoped>
</style>

View File

@ -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,34 +98,48 @@
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">
<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">
<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">
<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"
@ -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,14 +173,16 @@
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>
@ -156,11 +196,24 @@
/>
<!-- 添加或修改客户案例管理对话框 -->
<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-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
@ -170,12 +223,15 @@
clearable
allow-create
default-first-option
placeholder="请创建案例关键词按回车创建最多20个" style="width: 100%;">
placeholder="请创建案例关键词按回车创建最多20个"
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>
@ -191,12 +247,34 @@
</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-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>
<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>
@ -207,12 +285,23 @@
</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 {
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";
@ -248,12 +337,10 @@
pageSize: 10,
name: null,
keyword: null,
customerName: null
customerName: null,
},
// 表单参数
form: {
},
form: {},
// 表单校验
rules: {
name: [
@ -269,12 +356,12 @@
};
},
components: {
"DragUpload": DragUpload,
"SelectCustomer":SelectCustomer,
"MuchFileDown": MuchFileDown,
"AutoHideMessage": AutoHideMessage,
"AutoHideInfo":AutoHideInfo,
"DragUploadEdit":DragUploadEdit
DragUpload: DragUpload,
SelectCustomer: SelectCustomer,
MuchFileDown: MuchFileDown,
AutoHideMessage: AutoHideMessage,
AutoHideInfo: AutoHideInfo,
DragUploadEdit: DragUploadEdit,
},
created() {
this.getList();
@ -287,7 +374,7 @@
getList() {
this.loading = true;
this.queryParams.keyword = this.keywordArray.join(",");
listCustomerCase(this.queryParams).then(response => {
listCustomerCase(this.queryParams).then((response) => {
this.customerCaseList = response.rows;
this.total = response.total;
this.loading = false;
@ -296,7 +383,9 @@
// 取消按钮
cancel() {
this.open = false;
this.$refs["uploadCaseFile"] &&
this.$refs["uploadCaseFile"].uploadReset();
this.$refs["editUploadCaseFile"] &&
this.$refs["editUploadCaseFile"].uploadReset();
this.reset();
},
@ -311,7 +400,7 @@
customerName: null,
caseFileList: [],
caseFileUrl: [],
caseFileName: []
caseFileName: [],
};
this.resetForm("form");
},
@ -327,9 +416,9 @@
},
// 多选框选中数据
handleSelectionChange(selection) {
this.ids = selection.map(item => item.id)
this.single = selection.length!==1
this.multiple = !selection.length
this.ids = selection.map((item) => item.id);
this.single = selection.length !== 1;
this.multiple = !selection.length;
},
/** 新增按钮操作 */
handleAdd() {
@ -340,8 +429,8 @@
/** 修改按钮操作 */
handleUpdate(row) {
this.reset();
const id = row.id || this.ids
getCustomerCase(id).then(response => {
const id = row.id || this.ids;
getCustomerCase(id).then((response) => {
this.form = {
id: response.data.id,
name: response.data.name,
@ -351,7 +440,7 @@
customerName: response.data.customerName,
caseFileList: response.data.caseFileList,
caseFileUrl: [],
caseFileName: []
caseFileName: [],
};
this.open = true;
this.title = "修改客户案例管理";
@ -359,7 +448,7 @@
},
/** 提交按钮 */
submitForm() {
this.$refs["form"].validate(valid => {
this.$refs["form"].validate((valid) => {
if (valid) {
if (this.submitFlag) {
this.$message({
@ -387,13 +476,13 @@
this.form.caseFileName = fileResult.fileName;
this.form.caseFileUrl = fileResult.fileUrl;
if (this.form.caseFileUrl.length == 0) {
this.$message.error('请至少选择一个文件上传');
this.$message.error("请至少选择一个文件上传");
this.submitFlag = false;
return;
}
if (this.form.id != null) {
// console.log(this.form.caseFileName.length);
updateCustomerCase(this.form).then(response => {
updateCustomerCase(this.form).then((response) => {
if (response.code === 200) {
this.$refs["editUploadCaseFile"].uploadReset();
this.msgSuccess("修改成功");
@ -401,10 +490,9 @@
this.getList();
}
this.submitFlag = false;
});
} else {
addCustomerCase(this.form).then(response => {
addCustomerCase(this.form).then((response) => {
if (response.code === 200) {
this.$refs["uploadCaseFile"].uploadReset();
this.msgSuccess("新增成功");
@ -419,46 +507,59 @@
this.submitFlag = flag;
},
selectCustomer() {
this.$refs['selectCustomerRef'].showDialog("选择案例所属客户");
this.$refs["selectCustomerRef"].showDialog("选择案例所属客户");
},
dealCustomerId(customerId, customerName) {
this.form.customerId = customerId;
this.form.customerName = customerName;
},
getFileListByCaseId(customerCase) {
getFileListByCaseId(customerCase.id).then(response => {
getFileListByCaseId(customerCase.id).then((response) => {
if (response.code === 200) {
this.$refs["muchFileDownRef"].showDialog(customerCase.name, response.rows);
this.$refs["muchFileDownRef"].showDialog(
customerCase.name,
response.rows
);
}
});
},
/** 删除按钮操作 */
handleDelete(row) {
const ids = row.id || this.ids;
this.$confirm('是否确认删除客户案例管理编号为"' + 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() {});
})
.catch(function () {});
},
/** 导出按钮操作 */
handleExport() {
const queryParams = this.queryParams;
this.$confirm('是否确认导出所有客户案例管理数据项?', "警告", {
this.$confirm("是否确认导出所有客户案例管理数据项?", "警告", {
confirmButtonText: "确定",
cancelButtonText: "取消",
type: "warning"
}).then(function() {
type: "warning",
})
.then(function () {
return exportCustomerCase(queryParams);
}).then(response => {
})
.then((response) => {
this.download(response.msg);
}).catch(function() {});
}
}
})
.catch(function () {});
},
},
};
</script>