1
This commit is contained in:
parent
db4e26f946
commit
bc61944330
@ -13,7 +13,7 @@ public class CusBankImportDTO {
|
||||
private String taxId;
|
||||
@Excel(name = "银行名称")
|
||||
private String bankName;
|
||||
@Excel(name = "银行账号")
|
||||
@Excel(name = "银行账户")
|
||||
private String bankAccount;
|
||||
@Excel(name = "分支机构代码")
|
||||
private String branchCode;
|
||||
|
||||
@ -15,4 +15,13 @@ import com.ruoyi.cus.domain.CusContacts;
|
||||
*/
|
||||
public interface ICusContactsService extends IService<CusContacts> {
|
||||
IPage<CusContacts> queryListPage(CusContacts pageReqVO, Page<CusContacts> page);
|
||||
|
||||
/**
|
||||
* 批量保存客户联系人信息
|
||||
*
|
||||
* @param cusContactsList List<CusContacts>
|
||||
* @author PQZ
|
||||
* @date 9:32 2025/11/21
|
||||
**/
|
||||
void saveOrUpdateByCusName(List<CusContacts> cusContactsList);
|
||||
}
|
||||
|
||||
@ -1,8 +1,15 @@
|
||||
package com.ruoyi.cus.service.impl;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.ruoyi.common.utils.StringUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
@ -26,4 +33,60 @@ public class CusContactsServiceImpl extends ServiceImpl<CusContactsMapper,CusCon
|
||||
public IPage<CusContacts> queryListPage(CusContacts pageReqVO, Page<CusContacts> page) {
|
||||
return cusContactsMapper.queryListPage(pageReqVO, page);
|
||||
}
|
||||
/**
|
||||
* 批量保存客户联系人信息
|
||||
*
|
||||
* @param cusContactsList List<CusContacts>
|
||||
* @author PQZ
|
||||
* @date 9:32 2025/11/21
|
||||
**/
|
||||
@Override
|
||||
public void saveOrUpdateByCusName(List<CusContacts> cusContactsList) {
|
||||
if(cusContactsList == null || cusContactsList.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
// 1. 提取有效的客户名称并去重
|
||||
List<String> cusNames = cusContactsList.stream()
|
||||
.map(CusContacts::getCusName)
|
||||
.filter(StringUtils::isNotEmpty)
|
||||
.distinct()
|
||||
.collect(Collectors.toList());
|
||||
|
||||
//2. 查询数据库中已有的客户联系人信息,并按照客户名称+姓名分组
|
||||
Map<String,CusContacts> existingCusContactMap = new HashMap<>();
|
||||
List<CusContacts> existingContactsList = this.list(new LambdaQueryWrapper<CusContacts>()
|
||||
.in(CusContacts::getCusName, cusNames));
|
||||
existingCusContactMap = existingContactsList.stream()
|
||||
.collect(Collectors.toMap(
|
||||
contact -> contact.getCusName() + "_" + contact.getName(),
|
||||
contact -> contact,
|
||||
// 保留第一个,忽略后续重复项
|
||||
(existing, replacement) -> existing
|
||||
));
|
||||
|
||||
// 3. 分离需要新增和更新的数据
|
||||
List<CusContacts> toSaveList = new ArrayList<>();
|
||||
List<CusContacts> toUpdateList = new ArrayList<>();
|
||||
for(CusContacts cusContacts : cusContactsList) {
|
||||
String key = cusContacts.getCusName() + "_" + cusContacts.getName();
|
||||
CusContacts existing = existingCusContactMap.get(key);
|
||||
if(existing != null) {
|
||||
// 存在就更新
|
||||
cusContacts.setId(existing.getId());
|
||||
//保留原来的客户id
|
||||
cusContacts.setCusId(existing.getCusId());
|
||||
toUpdateList.add(cusContacts);
|
||||
} else {
|
||||
// 不存在就新增
|
||||
toSaveList.add(cusContacts);
|
||||
}
|
||||
}
|
||||
// 4. 批量保存与更新
|
||||
if(!toSaveList.isEmpty()) {
|
||||
this.saveBatch(toSaveList);
|
||||
}
|
||||
if(!toUpdateList.isEmpty()) {
|
||||
this.updateBatchById(toUpdateList);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -203,7 +203,7 @@ public class CusImportServiceImpl implements ICusImportService {
|
||||
}
|
||||
// 批量保存客户联系人信息
|
||||
if (!cusContactsList.isEmpty()) {
|
||||
cusContactsService.saveBatch(cusContactsList);
|
||||
cusContactsService.saveOrUpdateByCusName(cusContactsList);
|
||||
}
|
||||
//批量保存银行账户信息
|
||||
if (!cusBankList.isEmpty()) {
|
||||
|
||||
@ -44,7 +44,7 @@
|
||||
<el-row :gutter="10" class="mb8">
|
||||
<el-col :span="1.5">
|
||||
<el-dropdown v-hasPermi="['cus:main:add']" @command="handleCommand">
|
||||
<el-button type="primary" plain size="mini">
|
||||
<el-button type="primary" plain size="mini">
|
||||
新建客户<i class="el-icon-arrow-down el-icon--right"></i>
|
||||
</el-button>
|
||||
<el-dropdown-menu slot="dropdown">
|
||||
@ -61,7 +61,8 @@
|
||||
size="mini"
|
||||
@click="handleExport"
|
||||
v-hasPermi="['cus:main:export']"
|
||||
>导出</el-button>
|
||||
>导出
|
||||
</el-button>
|
||||
</el-col>
|
||||
<el-col :span="1.5">
|
||||
<el-button
|
||||
@ -70,7 +71,8 @@
|
||||
icon="el-icon-upload2"
|
||||
size="mini"
|
||||
@click="handleImport"
|
||||
>导入</el-button>
|
||||
>导入
|
||||
</el-button>
|
||||
|
||||
</el-col>
|
||||
<right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
|
||||
@ -91,9 +93,11 @@
|
||||
</el-tooltip>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="星标" align="center" prop="ifStar" >
|
||||
<el-table-column label="星标" align="center" prop="ifStar">
|
||||
<template slot-scope="scope">
|
||||
<i v-if="scope.row.ifStar" class="el-icon-star-on" style="color: rgb(64, 158, 255);font-size: 18px;cursor: pointer"></i>
|
||||
<i v-if="scope.row.ifStar" class="el-icon-star-on"
|
||||
style="color: rgb(64, 158, 255);font-size: 18px;cursor: pointer"
|
||||
></i>
|
||||
<i v-else class="el-icon-star-off" style="cursor: pointer"></i>
|
||||
</template>
|
||||
</el-table-column>
|
||||
@ -174,7 +178,7 @@
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="业务类型" align="center" prop="busiType" width="120"/>
|
||||
<el-table-column label="企业网站" align="center" prop="siteUrl" >
|
||||
<el-table-column label="企业网站" align="center" prop="siteUrl">
|
||||
<template slot-scope="scope">
|
||||
<el-tooltip :content="scope.row.siteUrl" placement="top" effect="dark">
|
||||
<div class="text-ellipsis-single">{{ scope.row.siteUrl }}</div>
|
||||
@ -219,22 +223,24 @@
|
||||
type="text"
|
||||
@click="handleUpdate(scope.row)"
|
||||
v-hasPermi="['cus:main:edit']"
|
||||
>修改</el-button>
|
||||
>修改
|
||||
</el-button>
|
||||
<el-button
|
||||
size="mini"
|
||||
type="text"
|
||||
@click="handleUpdate(scope.row)"
|
||||
v-hasPermi="['cus:main:edit']"
|
||||
>发邮件</el-button>
|
||||
>发邮件
|
||||
</el-button>
|
||||
<el-dropdown @command="handleOpt">
|
||||
<span class="el-dropdown-link">
|
||||
更多<i class="el-icon-arrow-down el-icon--right"></i>
|
||||
</span>
|
||||
<el-dropdown-menu slot="dropdown">
|
||||
<el-dropdown-item command="quick" >新建跟进</el-dropdown-item>
|
||||
<el-dropdown-item command="quick" >移交客户</el-dropdown-item>
|
||||
<el-dropdown-item command="quick" >转入公海</el-dropdown-item>
|
||||
<el-dropdown-item v-hasPermi="['cus:main:remove']" command="del" >删除</el-dropdown-item>
|
||||
<el-dropdown-item command="quick">新建跟进</el-dropdown-item>
|
||||
<el-dropdown-item command="quick">移交客户</el-dropdown-item>
|
||||
<el-dropdown-item command="quick">转入公海</el-dropdown-item>
|
||||
<el-dropdown-item v-hasPermi="['cus:main:remove']" command="del">删除</el-dropdown-item>
|
||||
</el-dropdown-menu>
|
||||
</el-dropdown>
|
||||
</template>
|
||||
@ -253,7 +259,10 @@
|
||||
<draw-form ref="drawForm"></draw-form>
|
||||
<!-- 客户信息导入对话框 -->
|
||||
<el-dialog :title="upload.title" :visible.sync="upload.open" width="400px" append-to-body>
|
||||
<el-upload ref="upload" :limit="1" accept=".xlsx, .xls" :headers="upload.headers" :action="upload.url + '?updateSupport=' + upload.updateSupport" :disabled="upload.isUploading" :on-progress="handleFileUploadProgress" :on-success="handleFileSuccess" :auto-upload="false" drag>
|
||||
<el-upload ref="upload" :limit="1" accept=".xlsx, .xls" :headers="upload.headers"
|
||||
:action="upload.url + '?updateSupport=' + upload.updateSupport" :disabled="upload.isUploading"
|
||||
:on-progress="handleFileUploadProgress" :on-success="handleFileSuccess" :auto-upload="false" drag
|
||||
>
|
||||
<i class="el-icon-upload"></i>
|
||||
<div class="el-upload__text">将文件拖到此处,或<em>点击上传</em></div>
|
||||
<div class="el-upload__tip text-center" slot="tip">
|
||||
@ -270,14 +279,14 @@
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { listMain, getMain, delMain, addMain, updateMain } from "@/api/cus/main";
|
||||
import { listMain, getMain, delMain, addMain, updateMain } from '@/api/cus/main'
|
||||
import DrawForm from './drawForm'
|
||||
import { getToken } from "@/utils/auth";
|
||||
import { getToken } from '@/utils/auth'
|
||||
|
||||
export default {
|
||||
name: "Main",
|
||||
name: 'Main',
|
||||
components: { DrawForm },
|
||||
dicts: ['cus_main_product', 'cus_label', 'cus_type','sys_user_sex','cus_from','cus_level','cus_busi_type','cus_follow_step'],
|
||||
dicts: ['cus_main_product', 'cus_label', 'cus_type', 'sys_user_sex', 'cus_from', 'cus_level', 'cus_busi_type', 'cus_follow_step'],
|
||||
data() {
|
||||
return {
|
||||
// 遮罩层
|
||||
@ -300,93 +309,105 @@ export default {
|
||||
shortName: null,
|
||||
cusType: null,
|
||||
country: null,
|
||||
mainProds: null,
|
||||
mainProds: null
|
||||
},
|
||||
// 客户导入参数
|
||||
upload: {
|
||||
// 是否显示弹出层(用户导入)
|
||||
open: false,
|
||||
// 弹出层标题(用户导入)
|
||||
title: "",
|
||||
title: '',
|
||||
// 是否禁用上传
|
||||
isUploading: false,
|
||||
// 是否更新已经存在的用户数据
|
||||
updateSupport: 0,
|
||||
// 设置上传的请求头部
|
||||
headers: { Authorization: "Bearer " + getToken() },
|
||||
headers: { Authorization: 'Bearer ' + getToken() },
|
||||
// 上传的地址
|
||||
url: process.env.VUE_APP_BASE_API + "/cus/main/importCus"
|
||||
},
|
||||
};
|
||||
url: process.env.VUE_APP_BASE_API + '/cus/main/importCus'
|
||||
}
|
||||
}
|
||||
},
|
||||
activated() {
|
||||
// 关键:返回列表页时,强制调用数据请求方法刷新列表
|
||||
this.getList();
|
||||
this.getList()
|
||||
},
|
||||
created() {
|
||||
this.getList();
|
||||
this.getList()
|
||||
},
|
||||
methods: {
|
||||
|
||||
// 文件上传中处理
|
||||
handleFileUploadProgress(event, file, fileList) {
|
||||
this.upload.isUploading = true
|
||||
},
|
||||
// 文件上传成功处理
|
||||
handleFileSuccess(response, file, fileList) {
|
||||
this.upload.open = false
|
||||
this.upload.isUploading = false
|
||||
this.$refs.upload.clearFiles()
|
||||
this.$alert('<div style=\'overflow: auto;overflow-x: hidden;max-height: 70vh;padding: 10px 20px 0;\'>' + response.msg + '</div>', '导入结果', { dangerouslyUseHTMLString: true })
|
||||
this.getList()
|
||||
},
|
||||
// 提交上传文件
|
||||
submitFileForm() {
|
||||
this.$refs.upload.submit();
|
||||
this.$refs.upload.submit()
|
||||
},
|
||||
|
||||
/** 导入按钮操作 */
|
||||
handleImport() {
|
||||
this.upload.title = "用户导入";
|
||||
this.upload.open = true;
|
||||
this.upload.title = '用户导入'
|
||||
this.upload.open = true
|
||||
},
|
||||
|
||||
/** 客户代码点击事件 */
|
||||
handleCodeClick(row) {
|
||||
this.$router.push({path:'/cus/viewForm',query:{id:row.id}})
|
||||
this.$router.push({ path: '/cus/viewForm', query: { id: row.id } })
|
||||
},
|
||||
/** 查询客户信息列表 */
|
||||
getList() {
|
||||
this.loading = true;
|
||||
this.loading = true
|
||||
listMain(this.queryParams).then(response => {
|
||||
this.mainList = response.data.records;
|
||||
this.total = response.data.total;
|
||||
this.loading = false;
|
||||
});
|
||||
this.mainList = response.data.records
|
||||
this.total = response.data.total
|
||||
this.loading = false
|
||||
})
|
||||
},
|
||||
/** 搜索按钮操作 */
|
||||
handleQuery() {
|
||||
this.queryParams.pageNum = 1;
|
||||
this.getList();
|
||||
this.queryParams.pageNum = 1
|
||||
this.getList()
|
||||
},
|
||||
/** 重置按钮操作 */
|
||||
resetQuery() {
|
||||
this.resetForm("queryForm");
|
||||
this.handleQuery();
|
||||
this.resetForm('queryForm')
|
||||
this.handleQuery()
|
||||
},
|
||||
/**
|
||||
* 新建操作集成按钮
|
||||
*/
|
||||
handleCommand(command){
|
||||
if("quick"==command){
|
||||
handleCommand(command) {
|
||||
if ('quick' == command) {
|
||||
this.handleAddQuick()
|
||||
}else if("add"){
|
||||
} else if ('add') {
|
||||
this.handleAdd()
|
||||
}
|
||||
},
|
||||
/**
|
||||
* 更多操作集成按钮
|
||||
*/
|
||||
handleOpt(command){
|
||||
switch ( command) {
|
||||
case "del":
|
||||
this.handleDelete();
|
||||
break;
|
||||
handleOpt(command) {
|
||||
switch (command) {
|
||||
case 'del':
|
||||
this.handleDelete()
|
||||
break
|
||||
default:
|
||||
break;
|
||||
break
|
||||
}
|
||||
},
|
||||
/** 新增按钮操作 */
|
||||
handleAdd() {
|
||||
this.$router.push({path:'/cus/newForm'})
|
||||
this.$router.push({ path: '/cus/newForm' })
|
||||
},
|
||||
/** 快速新增按钮操作 */
|
||||
handleAddQuick() {
|
||||
@ -395,37 +416,38 @@ export default {
|
||||
/** 修改按钮操作 */
|
||||
handleUpdate(row) {
|
||||
const id = row.id
|
||||
this.$router.push({path:'/cus/newForm',query:{id:id}})
|
||||
this.$router.push({ path: '/cus/newForm', query: { id: id } })
|
||||
},
|
||||
/** 提交按钮 */
|
||||
submitForm() {
|
||||
this.$refs["form"].validate(valid => {
|
||||
this.$refs['form'].validate(valid => {
|
||||
if (valid) {
|
||||
if (this.form.id != null) {
|
||||
updateMain(this.form).then(response => {
|
||||
this.$modal.msgSuccess("修改成功");
|
||||
this.open = false;
|
||||
this.getList();
|
||||
});
|
||||
this.$modal.msgSuccess('修改成功')
|
||||
this.open = false
|
||||
this.getList()
|
||||
})
|
||||
} else {
|
||||
addMain(this.form).then(response => {
|
||||
this.$modal.msgSuccess("新增成功");
|
||||
this.open = false;
|
||||
this.getList();
|
||||
});
|
||||
this.$modal.msgSuccess('新增成功')
|
||||
this.open = false
|
||||
this.getList()
|
||||
})
|
||||
}
|
||||
}
|
||||
});
|
||||
})
|
||||
},
|
||||
/** 删除按钮操作 */
|
||||
handleDelete(row) {
|
||||
const id = row.cusCode
|
||||
this.$modal.confirm('是否确认删除客户编号为"' + id + '"的数据项?').then(function() {
|
||||
return delMain(ids);
|
||||
return delMain(ids)
|
||||
}).then(() => {
|
||||
this.getList();
|
||||
this.$modal.msgSuccess("删除成功");
|
||||
}).catch(() => {});
|
||||
this.getList()
|
||||
this.$modal.msgSuccess('删除成功')
|
||||
}).catch(() => {
|
||||
})
|
||||
},
|
||||
/** 导出按钮操作 */
|
||||
handleExport() {
|
||||
@ -434,7 +456,7 @@ export default {
|
||||
}, `main_${new Date().getTime()}.xlsx`)
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
</script>
|
||||
<style scoped>
|
||||
/* 可点击的客户代码样式 */
|
||||
@ -447,6 +469,7 @@ export default {
|
||||
.clickable-code:hover {
|
||||
color: #40a9ff;
|
||||
}
|
||||
|
||||
/* 核心优化:使用固定容器 + 绝对定位避免布局抖动 */
|
||||
.tag-cell-container {
|
||||
display: flex;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user