...
 
Commits (1)
......@@ -153,6 +153,9 @@ public class InfoController {
@Operation(summary = "获得客户拜访打印信息根据公司名称")
@PreAuthorize("@ss.hasPermission('visit:customer-info:print')")
public CommonResult<List<InfoPrintVO>> getPrintListByCompanyName(@RequestParam("companyName") String companyName) {
if (companyName.isEmpty()){
throw new RuntimeException("公司名称获取异常!");
}
InfoPrintVO info = infoService.getInfoByCompanyName(companyName);
List<InfoPrintVO> infoPrintVO = new ArrayList<>();
if (info == null){
......
......@@ -19,6 +19,8 @@ import org.apache.http.entity.ContentType;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClients;
import org.apache.http.util.EntityUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.validation.annotation.Validated;
......@@ -46,6 +48,7 @@ import static java.nio.file.Files.createFile;
@Validated
public class InfoServiceImpl implements InfoService {
private static final Logger log = LoggerFactory.getLogger(InfoServiceImpl.class);
@Resource
private InfoMapper infoMapper;
......@@ -243,11 +246,11 @@ public class InfoServiceImpl implements InfoService {
info.forEach(infoDO -> {
InfoPrintVO infoPrintVO = new InfoPrintVO();
infoPrintVO.setServiceContent(Collections.singletonList(infoDO.getServiceContent()));//本次服务内容
//服务图片(最多张)
//服务图片(最多10张)
String imagesStr = infoDO.getServiceImages();
if (StringUtils.isNotBlank(imagesStr)) {
String limitedImagesStr = Arrays.stream(imagesStr.split(","))
.limit(4)
.limit(10)
.collect(Collectors.joining(","));
infoPrintVO.setServiceImages(limitedImagesStr);
} else {
......@@ -271,9 +274,9 @@ public class InfoServiceImpl implements InfoService {
@Override
public InfoPrintVO getInfoByCompanyName(String companyName) {
InfoPrintVO infoPrintVO = new InfoPrintVO();
//服务内容(最近次)
//服务内容(最近次)
List<String> serviceContent = new ArrayList<>();
//服务图片(最多张)
//服务图片(最多张)
List<String> serviceImages = new ArrayList<>();
//拜访时间记录
List<LocalDate> visitDateList = new ArrayList<>();
......@@ -281,26 +284,35 @@ public class InfoServiceImpl implements InfoService {
YearMonth currentYearMonth = YearMonth.now();
//现根据客户名称获取历史拜访记录
List<InfoDO> info = infoMapper.selectByCompanyName(companyName);
System.out.println("拜访信息" + info);
if (info != null && !info.isEmpty()){
//取最近
//取最近
info = info.stream()
// 筛选本月记录(基于 LocalDateTime)
.filter(infoDO -> {
LocalDateTime visitDateTime = infoDO.getVisitDate();
return YearMonth.from(visitDateTime.toLocalDate()).equals(currentYearMonth);
})
.sorted(Comparator.comparing(InfoDO::getVisitDate).reversed()).limit(4).collect(Collectors.toList());
//取最多4张服务图片
int maxImages = 4;
// .filter(infoDO -> {
// LocalDateTime visitDateTime = infoDO.getVisitDate();
// return YearMonth.from(visitDateTime.toLocalDate()).equals(currentYearMonth);
// })
.sorted(Comparator.comparing(InfoDO::getVisitDate)).limit(5).collect(Collectors.toList());
//取最多10张服务图片
int maxImages = 10;
int maxObjects = 5; // 最多处理5个对象
int objectCount = 0; // 对象计数器
for (InfoDO infoDO : info) {
if (serviceImages.size() >= maxImages) break;
// 超过最大对象数或已收集足够图片则停止
if (objectCount >= maxObjects || serviceImages.size() >= maxImages) break;
String imagesStr = infoDO.getServiceImages();
if (StringUtils.isNotBlank(imagesStr)) {
List<String> imageList = Arrays.asList(imagesStr.split(","));
int remaining = maxImages - serviceImages.size();
serviceImages.addAll(imageList.stream().limit(remaining).collect(Collectors.toList()));
// 每个对象最多取2张,同时不超过剩余需要数量
int take = Math.min(2, remaining);
serviceImages.addAll(imageList.stream().limit(take).collect(Collectors.toList()));
}
objectCount++;
}
//获取客户拜访记录成功,获取客户信息
info.forEach(infoDO -> {
......@@ -326,7 +338,7 @@ public class InfoServiceImpl implements InfoService {
//拜访次数
infoPrintVO.setServiceCount(info.size());
}else {
return null;
return infoPrintVO;
}
return infoPrintVO;
}
......
......@@ -4,8 +4,8 @@ NODE_ENV=development
VITE_DEV=true
# 请求路径
# VITE_BASE_URL='http://192.168.0.182:48080'
VITE_BASE_URL='https://hntqwl.com'
VITE_BASE_URL='http://192.168.0.144:48080'
#VITE_BASE_URL='https://hntqwl.com'
# VITE_BASE_URL='http://localhost:48080'
# 文件上传类型:server - 后端上传, client - 前端直连上传,仅支持 S3 服务
......
......@@ -84,6 +84,7 @@ export const InfoApi = {
//查询打印客户拜访记录
getPrintListByCompanyName: async (companyName: string) => {
console.log(companyName)
return await request.get({ url: `/visit/info/getPrintListByCompanyName`, params: { companyName } })
},
......
......@@ -22,7 +22,7 @@
</slot>
</div>
<template #file="{ file }">
<img :src="file.url" class="upload-image" />
<img :src="file.url" class="upload-image" @contextmenu.prevent />
<div class="upload-handle" @click.stop>
<div class="handle-icon" @click="imagePreview(file.url!)">
<Icon icon="ep:zoom-in" />
......@@ -43,6 +43,7 @@
<script lang="ts" setup>
import type { UploadFile, UploadProps, UploadUserFile } from 'element-plus'
import { ElNotification } from 'element-plus'
import { nextTick } from 'vue';
import { createImageViewer } from '@/components/ImageViewer'
import { propTypes } from '@/utils/propTypes'
......@@ -56,7 +57,15 @@ const imagePreview = (imgUrl: string) => {
createImageViewer({
zIndex: 9999999,
urlList: [imgUrl]
})
});
nextTick(() => {
// 禁止预览图右键
const viewer = document.querySelector('.el-image-viewer__wrapper');
if (viewer) {
viewer.addEventListener('contextmenu', (e) => e.preventDefault());
}
});
}
type FileTypes =
......
......@@ -242,7 +242,6 @@ const printComp = ref()
const handlePrint = async (companyName) => {
printData.value = await InfoApi.getPrintListByCompanyName(companyName)
await nextTick()
console.log(printData.value)
//判断是否有数据
if (printData.value.length === 0) {
message.warning('该客户暂无拜访记录')
......
......@@ -141,18 +141,23 @@
</div>
<div
style="display: flex;
flex-direction: column;
height: 800px; /* 父容器高度,按需设置 */"
/*flex-direction: column;*/
flex-direction: row;
flex-wrap: wrap;
justify-content: space-between;
height: 160px; /* 父容器高度,按需设置 */"
>
<img
crossorigin="anonymous"
v-for="(url, i) in getSafeImages(item.serviceImages)"
:key="i"
:src="url"
style="width: 100%;
height: 25%;
style="
width: 48%;
height: 100%;
object-fit: fill;/* cover是切一部分 */
border: 1px solid #ccc;"
border: 1px solid #ccc;
margin: 5px 0"
/>
</div>
</div>
......@@ -168,14 +173,24 @@ import {DICT_TYPE, getDictLabel} from "@/utils/dict";
const props = defineProps({ dataList: Array })
const printRef = ref(null)
const serviceImagesList = ref([])
serviceImagesList.value = props.dataList.map(item => item.serviceImages)
const formatDate = (date: string | Date) => {
const d = new Date(date)
return d.toLocaleDateString()
}
const getSafeImages = (val?: string) => {
if (!val||val==='') return []
return val.split(',').slice(0, 4)
console.log(val)
return val.split(',').slice(0, 10)
}
// const getSafeImages = (imageStr: string) => {
// if (!imageStr) return [];
// return imageStr.split(',').filter(url => url.trim() !== '').map(url => {
// return url;
// });
// };
defineExpose({ printRef })
......