案例修改、图片预览

This commit is contained in:
xiezhijun 2021-03-06 18:06:39 +08:00
parent edd5b5559d
commit e35992d984
13 changed files with 374 additions and 78 deletions
stdiet-admin/src/main/java/com/stdiet/web/controller/custom
stdiet-common/src/main/java/com/stdiet/common/utils/oss
stdiet-custom/src/main
stdiet-ui/src
components
views/custom
customerCase
wxDistribution

@ -81,7 +81,7 @@ public class SysCustomerCaseController extends BaseController
@GetMapping(value = "/{id}")
public AjaxResult getInfo(@PathVariable("id") Long id)
{
return AjaxResult.success(sysCustomerCaseService.selectSysCustomerCaseById(id));
return AjaxResult.success(sysCustomerCaseService.selectSysCustomerCaseById(id, true));
}
/**
@ -134,6 +134,7 @@ public class SysCustomerCaseController extends BaseController
int index = 0;
for (String downUrl : downUrlList) {
list.get(index).setDownUrl(downUrl);
index++;
}
}
return getDataTable(list);

@ -5,14 +5,7 @@ import java.util.List;
import com.stdiet.common.utils.StringUtils;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.*;
import com.stdiet.common.annotation.Log;
import com.stdiet.common.core.controller.BaseController;
import com.stdiet.common.core.domain.AjaxResult;
@ -40,9 +33,11 @@ public class SysWxSaleAccountController extends BaseController
*/
@PreAuthorize("@ss.hasPermi('custom:wxAccount:list')")
@GetMapping("/list")
public TableDataInfo list(SysWxSaleAccount sysWxSaleAccount)
public TableDataInfo list(SysWxSaleAccount sysWxSaleAccount, @RequestParam(value = "pageFlag", required = false, defaultValue = "true")boolean pageFlag)
{
startPage();
if(pageFlag){
startPage();
}
List<SysWxSaleAccount> list = sysWxSaleAccountService.selectSysWxSaleAccountList(sysWxSaleAccount);
return getDataTable(list);
}

@ -15,7 +15,6 @@ import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.net.URL;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
@ -74,10 +73,10 @@ public class AliyunOSSUtils {
//去尾
String tail = oranName.substring(cutPoint);
//返回正确的带路径的图片名称
return prefix + head + uuid + "_" + tail;
return prefix + head + tail + "_" + uuid;
}
//不存在 直接返回
return prefix + uuid + "_" + oranName;
return prefix + oranName + "_" + uuid;
}
/**

@ -4,6 +4,8 @@ import com.stdiet.common.annotation.Excel;
import com.stdiet.common.core.domain.BaseEntity;
import lombok.Data;
import java.util.List;
/**
* 客户案例管理对象 sys_customer_case
*
@ -35,6 +37,11 @@ public class SysCustomerCase extends BaseEntity
/** 删除标识 0未删除 1已删除默认0 */
private Long delFlag;
/**
* 文件列表
*/
private List<SysCustomerCaseFile> caseFileList;
//案例文件名称数组
private String[] caseFileName;

@ -17,7 +17,7 @@ public interface ISysCustomerCaseService {
* @param id 客户案例管理ID
* @return 客户案例管理
*/
public SysCustomerCase selectSysCustomerCaseById(Long id);
public SysCustomerCase selectSysCustomerCaseById(Long id, boolean fileListFlag);
/**
* 查询客户案例管理列表

@ -35,9 +35,13 @@ public class SysCustomerCaseServiceImpl implements ISysCustomerCaseService
* @return 客户案例管理
*/
@Override
public SysCustomerCase selectSysCustomerCaseById(Long id)
public SysCustomerCase selectSysCustomerCaseById(Long id, boolean fileListFlag)
{
return sysCustomerCaseMapper.selectSysCustomerCaseById(id);
SysCustomerCase customerCase = sysCustomerCaseMapper.selectSysCustomerCaseById(id);
if(customerCase != null && fileListFlag){
customerCase.setCaseFileList(sysCustomerCaseFileMapper.selectSysCustomerCaseFileListByCaseId(customerCase.getId()));
}
return customerCase;
}
/**
@ -64,19 +68,7 @@ public class SysCustomerCaseServiceImpl implements ISysCustomerCaseService
sysCustomerCase.setCreateTime(DateUtils.getNowDate());
int rows = sysCustomerCaseMapper.insertSysCustomerCase(sysCustomerCase);
if(rows > 0){
//批量添加文件对应列表
SysCustomerCaseFile caseFile = null;
if(sysCustomerCase.getCaseFileUrl() != null && sysCustomerCase.getCaseFileUrl().length > 0){
List<SysCustomerCaseFile> caseFileList = new ArrayList<>();
for (String url : sysCustomerCase.getCaseFileUrl()) {
caseFile = new SysCustomerCaseFile();
caseFile.setCaseId(sysCustomerCase.getId());
caseFile.setFileName(sysCustomerCase.getCaseFileName()[caseFileList.size()]);
caseFile.setFileUrl(url);
caseFileList.add(caseFile);
}
rows = sysCustomerCaseFileMapper.insertBatch(caseFileList);
}
rows = addCaseFile(sysCustomerCase);
}
return rows;
}
@ -91,7 +83,38 @@ public class SysCustomerCaseServiceImpl implements ISysCustomerCaseService
public int updateSysCustomerCase(SysCustomerCase sysCustomerCase)
{
sysCustomerCase.setUpdateTime(DateUtils.getNowDate());
return sysCustomerCaseMapper.updateSysCustomerCase(sysCustomerCase);
int rows = sysCustomerCaseMapper.updateSysCustomerCase(sysCustomerCase);
if(rows > 0){
rows = addCaseFile(sysCustomerCase);
}
return rows;
}
/**
* 批量添加文件对应列表
* @param sysCustomerCase
* @return
*/
private int addCaseFile(SysCustomerCase sysCustomerCase){
int rows = 0;
//批量添加文件对应列表
SysCustomerCaseFile caseFile = null;
if(sysCustomerCase.getCaseFileUrl() != null && sysCustomerCase.getCaseFileUrl().length > 0){
List<SysCustomerCaseFile> caseFileList = new ArrayList<>();
for (String url : sysCustomerCase.getCaseFileUrl()) {
caseFile = new SysCustomerCaseFile();
caseFile.setCaseId(sysCustomerCase.getId());
caseFile.setFileName(sysCustomerCase.getCaseFileName()[caseFileList.size()]);
caseFile.setFileUrl(url);
caseFileList.add(caseFile);
}
//如果是修改操作直接先删除全部再添加
if(sysCustomerCase.getId() != null){
sysCustomerCaseFileMapper.deleteSysCustomerCaseFileByCaseId(sysCustomerCase.getId());
}
rows = sysCustomerCaseFileMapper.insertBatch(caseFileList);
}
return rows;
}
/**

@ -28,6 +28,7 @@
<if test="wxNickName != null and wxNickName != ''"> and wx_nick_name like concat('%', #{wxNickName}, '%')</if>
<if test="wxAccount != null and wxAccount != ''"> and wx_account like concat('%', #{wxAccount}, '%')</if>
<if test="wxPhone != null and wxPhone != ''"> and wx_phone like concat('%', #{wxPhone}, '%')</if>
order by id desc
</select>
<select id="selectSysWxSaleAccountById" parameterType="Long" resultMap="SysWxSaleAccountResult">

@ -1,11 +1,35 @@
<template>
<div>
<!-- 多文件下载对话框 -->
<el-dialog :title="title" :visible.sync="open" @closed="cancel" width="600px" append-to-body>
<div class="app-container">
<el-dialog :title="title" :visible.sync="open" @closed="cancel" width="700px" append-to-body>
<div class="app-container" style="height: 400px; overflow: auto">
<div style="margin: -20px auto 15px auto">
<el-button type="primary" @click="lazyShow = true" plain>滚动下拉预览</el-button>
</div>
<el-table v-loading="loading" :data="fileList">
<el-table-column label="文件名" align="center" prop="fileName" />
<el-table-column label="上传时间" align="center" prop="createTime" />
<el-table-column label="文件预览" align="center" prop="fileUrl">
<template slot-scope="scope">
<el-image v-if="scope.row.imageFlag" title="点击大图预览"
style="width: 80px; height: 80px"
:src="scope.row.downUrl"
:preview-src-list="imageList">
</el-image>
<span v-else>不可预览</span>
</template>
</el-table-column>
<el-table-column label="文件名" align="center" prop="fileName" width="200">
<template slot-scope="scope">
<AutoHideMessage :maxLength="10" :data="scope.row.fileName"></AutoHideMessage>
</template>
</el-table-column>
<el-table-column label="上传时间" align="center" prop="createTime" >
<template slot-scope="scope">
<span>{{
parseTime(scope.row.createTime, "{y}-{m}-{d}")
}}</span>
</template>
</el-table-column>
<el-table-column label="操作" align="center" class-name="small-padding fixed-width">
<template slot-scope="scope">
<el-button
@ -17,21 +41,30 @@
</template>
</el-table-column>
</el-table>
</div>
<div slot="footer" class="dialog-footer">
<el-button @click="cancel"> </el-button>
</div>
</el-dialog>
<el-dialog :title="'滚动下拉预览'" v-if="lazyShow" :visible.sync="lazyShow" width="600px" style="height: 90%; overflow: auto" append-to-body>
<div class="demo-image__lazy">
<el-image v-for="(url,index) in imageList" :class="index !=0 ? 'top-10' : ''" :key="url" :src="url" lazy></el-image>
</div>
<div slot="footer" class="dialog-footer">
<el-button @click="lazyShow = false"> </el-button>
</div>
</el-dialog>
</div>
</template>
<script>
import { downCaseFile } from "@/api/custom/customerCase";
import AutoHideMessage from "@/components/AutoHideMessage";
export default {
name: "MuchFileDown",
components: {
AutoHideMessage
},
data() {
return {
@ -43,8 +76,14 @@ export default {
open: false,
//id
caseId: null,
//
imgArr: ['jpg', 'jpeg', 'png', 'gif'],
//
fileList: []
fileList: [],
//
imageList:[],
//
lazyShow: false
};
},
created() {
@ -55,6 +94,13 @@ export default {
methods: {
showDialog(title, fileList) {
this.title = title ? title : "文件列表";
fileList.forEach((item, index) => {
item["imageFlag"] = this.isImage(item.fileName);
if(item["imageFlag"]){
//this.$set(this.imageList, this.imageList.length, item.downUrl)
this.imageList.push(item.downUrl);
}
});
this.fileList = fileList;
this.loading = false;
this.open = true;
@ -64,10 +110,29 @@ export default {
this.open = false;
this.caseId = null;
this.fileList = [];
this.imageList = [];
},
downloadFile(file){
if(file == undefined || file == null || file.downUrl == null || file.downUrl == ""){
this.$message({message: "文件不存在", type: "warning",});
return;
}
downCaseFile(file.downUrl);
},
isImage(name){
var idx = name.indexOf('.');
if (idx === -1) {
return false;
}
var type = name.substr(idx + 1);
return this.imgArr.indexOf(type) !== -1 ? true : false;
}
},
};
</script>
<style scoped>
.top-10{
margin-top: 10px;
}
</style>

@ -9,6 +9,7 @@
:file-list="upload.fileList"
:multiple="upload.multiple"
:on-change="handleFileChange"
:on-remove="handleFileRemove"
:on-exceed="handleFileexceed"
:on-progress="handleFileUploadProgress"
:on-success="handleFileSuccess"
@ -17,7 +18,7 @@
:auto-upload="false">
<i class="el-icon-upload"></i>
<div class="el-upload__text">将文件拖到此处<em>点击上传</em></div>
<div class="el-upload__tip" slot="tip">每个案例最多上传5个文件且每个文件不超过10M</div>
<div class="el-upload__tip" slot="tip">最多可上传{{upload.limit}}个文件且每个文件不超过{{upload.fileSize/(1024*1024)}}M</div>
</el-upload>
</template>
<script>
@ -41,8 +42,8 @@ export default {
//
fileList:[],
//
limit: 5,
//
limit: 10,
//(byte)
fileSize: 1024 * 1024 * 10,
//
multiple: true
@ -66,6 +67,10 @@ export default {
this.uploadResult["fileUrl"] = [];
this.uploadResult["fileName"] = [];
},
//
handleFileRemove(file, fileList){
this.upload.fileList = fileList;
},
//
handleFileChange(file, fileList) {
let sizeFlag = file.size > this.upload.fileSize;
@ -110,9 +115,10 @@ export default {
}
},
props: {
},
created() {
this.uploadReset();
},
};

@ -0,0 +1,165 @@
<template>
<div>
<div v-for="(item, index) in oldCaseFileList">
<span style="margin-right: 10px;">
{{item.fileName ? (item.fileName.substring(0,15)+"..."): ""}}
</span>
<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>
<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>
</el-upload>
</div>
</template>
<script>
import { getToken } from '@/utils/auth'
import AutoHideMessage from "@/components/AutoHideMessage";
export default {
name: "DragUploadEdit",
components: {
"AutoHideMessage":AutoHideMessage
},
data() {
return {
upload: {
//
isUploading: false,
//
url: process.env.VUE_APP_BASE_API + "/custom/customerCase/uploadCaseFile",
//
headers: {Authorization: 'Bearer ' + getToken()},
//
data:{},
//
fileList:[],
//
limit: 10 - this.caseFileList.length,
//(byte)
fileSize: 1024 * 1024 * 10,
//
multiple: true
},
oldCaseFileList: this.caseFileList,
uploadResult:{
fileUrl:[],
fileName:[]
}
};
},
methods: {
uploadFile(){
if(this.upload.fileList.length > 0 && this.uploadResult.fileUrl.length < this.upload.fileList.length){
this.$refs.upload.submit();
}else{
//
if(this.oldCaseFileList != null && this.oldCaseFileList.length > 0){
this.oldCaseFileList.forEach((item, index) => {
this.uploadResult.fileUrl.unshift(item.fileUrl);
this.uploadResult.fileName.unshift(item.fileName);
});
}
this.$emit('callbackMethod', this.uploadResult);
}
},
removeOldFile(index){
this.oldCaseFileList.splice(index,1);
this.upload.limit = 10 - this.oldCaseFileList.length;
},
uploadReset(){
this.upload.fileList = [];
this.uploadResult["fileUrl"] = [];
this.uploadResult["fileName"] = [];
this.oldCaseFileList = [];
},
//
handleFileRemove(file, fileList){
this.upload.fileList = fileList;
},
//
handleFileChange(file, fileList) {
let sizeFlag = file.size > this.upload.fileSize;
if (sizeFlag) {
this.$message({
message: "当前文件过大",
type: "warning",
});
fileList.pop();
}
this.upload.fileList = fileList;
},
//
handleFileexceed(file, fileList){
this.$message({
message: "最多可上传"+ this.upload.limit +"份文件",
type: "warning",
});
},
//
handleFileUploadProgress(event, file, fileList) {
//this.upload.isUploading = true;
},
//
handleFileSuccess(response, file, fileList) {
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.oldCaseFileList != null && this.oldCaseFileList.length > 0){
this.oldCaseFileList.forEach((item, index) => {
this.uploadResult.fileUrl.unshift(item.fileUrl);
this.uploadResult.fileName.unshift(item.fileName);
});
}
this.$emit('callbackMethod', this.uploadResult);
}
}else{
this.upload.fileList = fileList.pop();
this.$message.error('文件上传失败,请检查文件格式');
}
},
//
handleFileFail(err, file, fileList){
this.$message.error('文件上传失败,请检查文件格式');
this.upload.fileList = fileList.pop();
}
},
props: {
caseFileList:{
type: Array,
default: function () {
return [];
}
}
},
created() {
},
};
</script>
<style scoped>
</style>

@ -66,8 +66,8 @@ export default {
},
methods: {
removeOldFile(index){
this.form.medicalReport = this.form.medicalReport.splice(index,index);
this.form.medicalReportName = this.form.medicalReportName.splice(index,index);
this.form.medicalReport.splice(index,1);
this.form.medicalReportName.splice(index,1);
this.upload.limit = 3 - this.form.medicalReport.length;
},
getReportName(index){

@ -67,9 +67,22 @@
<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="keyword" />
<el-table-column label="备注" align="center" prop="remark" />
<el-table-column label="案例名称" align="center" prop="name" >
<template slot-scope="scope">
<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>
<!--<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>
</template>
</el-table-column>
<el-table-column label="所属客户" align="center" prop="customerName" />
<el-table-column
label="文件"
@ -125,7 +138,8 @@
/>
<!-- 添加或修改客户案例管理对话框 -->
<el-dialog :title="title" :visible.sync="open" @closed="cancel" width="500px" 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="请输入案例名称" />
@ -155,11 +169,12 @@
<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" v-show="form.id == null || form.id <= 0">
<DragUpload @callbackMethod="addCustomerCase" ref="uploadCaseFile"></DragUpload>
<el-form-item label="案例文件" prop="file" >
<DragUpload v-if="form.id == null || form.id <= 0" @callbackMethod="addOrEditCustomerCase" ref="uploadCaseFile"></DragUpload>
<DragUploadEdit v-else @callbackMethod="addOrEditCustomerCase" :caseFileList="form.caseFileList" ref="editUploadCaseFile"></DragUploadEdit>
</el-form-item>
</el-form>
</div>
<div slot="footer" class="dialog-footer">
<el-button type="primary" @click="submitForm"> </el-button>
<el-button @click="cancel"> </el-button>
@ -174,8 +189,12 @@
<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";
export default {
name: "CustomerCase",
data() {
@ -224,7 +243,10 @@
components: {
"DragUpload": DragUpload,
"SelectCustomer":SelectCustomer,
"MuchFileDown": MuchFileDown
"MuchFileDown": MuchFileDown,
"AutoHideMessage": AutoHideMessage,
"AutoHideInfo":AutoHideInfo,
"DragUploadEdit":DragUploadEdit
},
created() {
this.getList();
@ -242,7 +264,8 @@
//
cancel() {
this.open = false;
this.$refs["uploadCaseFile"].uploadReset();
//this.$refs["uploadCaseFile"].uploadReset();
//this.$refs["editUploadCaseFile"].uploadReset();
this.reset();
},
//
@ -250,10 +273,11 @@
this.form = {
id: null,
name: null,
keywordArray: null,
keywordArray: [],
remark: null,
customerId: null,
customerName: null,
caseFileList:[],
caseFileUrl: [],
caseFileName: []
};
@ -293,6 +317,7 @@
remark: response.data.remark,
customerId: response.data.customerId,
customerName: response.data.customerName,
caseFileList: response.data.caseFileList,
caseFileUrl: [],
caseFileName: []
};
@ -311,24 +336,22 @@
});
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) {
updateCustomerCase(this.form).then(response => {
if (response.code === 200) {
this.msgSuccess("修改成功");
this.open = false;
this.getList();
}
this.submitFlag = false;
});
} else {
this.$refs["uploadCaseFile"].uploadFile();
}
this.$refs["editUploadCaseFile"].uploadFile();
} else {
this.$refs["uploadCaseFile"].uploadFile();
}
}
});
},
addCustomerCase(fileResult){
addOrEditCustomerCase(fileResult){
this.form.caseFileName = fileResult.fileName;
this.form.caseFileUrl = fileResult.fileUrl;
if(this.form.caseFileUrl.length == 0){
@ -336,21 +359,31 @@
this.submitFlag = false;
return;
}
addCustomerCase(this.form).then(response => {
if (response.code === 200) {
this.msgSuccess("新增成功");
this.open = false;
this.$refs["uploadCaseFile"].uploadReset();
this.getList();
}
this.submitFlag = false;
});
if(this.form.id != null){
console.log(this.form.caseFileName.length);
updateCustomerCase(this.form).then(response => {
if (response.code === 200) {
this.msgSuccess("修改成功");
this.open = false;
this.getList();
}
this.submitFlag = false;
});
}else{
addCustomerCase(this.form).then(response => {
if (response.code === 200) {
this.msgSuccess("新增成功");
this.open = false;
this.getList();
}
this.submitFlag = false;
});
}
},
selectCustomer(){
this.$refs['selectCustomerRef'].showDialog("选择案例所属客户");
},
dealCustomerId(customerId, customerName){
//console.log(customerId);
this.form.customerId = customerId;
this.form.customerName = customerName;
},

@ -301,6 +301,7 @@ export default {
saleGroupId: null,
accountId: null,
wechatAccount: null,
pageFlag: false
},
//
form: {},