1
This commit is contained in:
parent
fb0d8cde1e
commit
4f9b4afcfd
@ -117,6 +117,7 @@ public class CusMainController extends BaseController
|
||||
@Log(title = "客户信息", businessType = BusinessType.INSERT)
|
||||
@PostMapping
|
||||
public AjaxResult add(@RequestBody CusMainVO cusMainVO){
|
||||
cusMainVO.getMainInfo().setCusCode(codeGenerator.generate());
|
||||
cusMainService.saveNewCus(cusMainVO);
|
||||
return success();
|
||||
}
|
||||
|
||||
@ -1,12 +1,16 @@
|
||||
package com.ruoyi.cus.service.impl;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.ruoyi.cus.domain.*;
|
||||
import com.ruoyi.cus.mapper.*;
|
||||
import com.ruoyi.cus.service.*;
|
||||
import com.ruoyi.cus.vo.CusMainVO;
|
||||
import com.ruoyi.cus.vo.MarkVO;
|
||||
import com.ruoyi.utils.SnowflakeIdGenerator;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
@ -53,6 +57,9 @@ public class CusMainServiceImpl extends ServiceImpl<CusMainMapper,CusMain> impl
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void saveNewCus(CusMainVO cusMainVO) {
|
||||
CusMain cusMain = cusMainVO.getMainInfo();
|
||||
if(!cusMainVO.getMainInfo().getMainProdList().isEmpty()){
|
||||
cusMain.setMainProds(String.join(",",cusMainVO.getMainInfo().getMainProdList()));
|
||||
}
|
||||
cusMainMapper.insert(cusMain);
|
||||
//联系人信息
|
||||
List<CusContacts> contacts = cusMainVO.getContact();
|
||||
@ -62,24 +69,56 @@ public class CusMainServiceImpl extends ServiceImpl<CusMainMapper,CusMain> impl
|
||||
}
|
||||
cusContactsService.saveBatch(contacts);
|
||||
//公司信息
|
||||
CusCompany cusCompany = cusMainVO.getCompanyInfo();
|
||||
CusCompany cusCompany = Optional.ofNullable(cusMainVO.getCompanyInfo()).orElseGet(CusCompany::new);
|
||||
cusCompany.setCusId(cusMain.getId());
|
||||
cusCompanyService.save(cusCompany);
|
||||
//管理信息
|
||||
CusManager cusManager = cusMainVO.getManagementInfo();
|
||||
CusManager cusManager = Optional.ofNullable(cusMainVO.getManagementInfo()).orElseGet(CusManager::new);
|
||||
cusManager.setCusId(cusMain.getId());
|
||||
cusManagerService.save(cusManager);
|
||||
//银行信息
|
||||
List<CusBank> bankList = cusMainVO.getBankInfo();
|
||||
List<CusBank> bankList = Optional.ofNullable(cusMainVO.getBankInfo()).orElseGet(ArrayList::new);
|
||||
if(!bankList.isEmpty()){
|
||||
bankList.forEach(bank -> bank.setCusId(cusMain.getId()));
|
||||
cusBankService.saveBatch(bankList);
|
||||
}
|
||||
//唛头信息
|
||||
List<CusMark> markList = cusMainVO.getMark();
|
||||
if(!markList.isEmpty()){
|
||||
markList.forEach(mark -> mark.setCusId(cusMain.getId()));
|
||||
cusMarkService.saveBatch(markList);
|
||||
}
|
||||
List<CusMark> markList = this.getMarkList(Optional.ofNullable(cusMainVO.getMark()).orElseGet(MarkVO::new), cusMain.getId());
|
||||
cusMarkService.saveBatch(markList);
|
||||
}
|
||||
|
||||
/**
|
||||
* 将mark对象转为list存储
|
||||
* @author vinjor-M
|
||||
* @date 15:09 2025/11/7
|
||||
* @return java.util.List<com.ruoyi.cus.domain.CusMark>
|
||||
**/
|
||||
private List<CusMark> getMarkList(MarkVO markVO, String cusId) {
|
||||
List<CusMark> markList = new ArrayList<>();
|
||||
markList.add(CusMark.builder()
|
||||
.cusId(cusId)
|
||||
.markPosition("主唛")
|
||||
.textContent(markVO.getMainText())
|
||||
.imageUrl(markVO.getMainPic())
|
||||
.build());
|
||||
markList.add(CusMark.builder()
|
||||
.cusId(cusId)
|
||||
.markPosition("主侧唛")
|
||||
.textContent(markVO.getMainSideText())
|
||||
.imageUrl(markVO.getMainSidePic())
|
||||
.build());
|
||||
markList.add(CusMark.builder()
|
||||
.cusId(cusId)
|
||||
.markPosition("内主唛")
|
||||
.textContent(markVO.getInText())
|
||||
.imageUrl(markVO.getInPic())
|
||||
.build());
|
||||
markList.add(CusMark.builder()
|
||||
.cusId(cusId)
|
||||
.markPosition("内侧唛")
|
||||
.textContent(markVO.getInSideText())
|
||||
.imageUrl(markVO.getInSidePic())
|
||||
.build());
|
||||
return markList;
|
||||
}
|
||||
}
|
||||
|
||||
@ -2,13 +2,14 @@ package com.ruoyi.cus.vo;
|
||||
|
||||
import com.ruoyi.cus.domain.*;
|
||||
import lombok.Data;
|
||||
import org.yaml.snakeyaml.error.Mark;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
public class CusMainVO {
|
||||
/** 客户信息 */
|
||||
private CusMain mainInfo;
|
||||
private MainVO mainInfo;
|
||||
/** 联系人信息 */
|
||||
private List<CusContacts> contact;
|
||||
/** 公司信息 */
|
||||
@ -18,5 +19,5 @@ public class CusMainVO {
|
||||
/** 银行信息 */
|
||||
private List<CusBank> bankInfo;
|
||||
/** 唛头信息 */
|
||||
private List<CusMark> mark;
|
||||
private MarkVO mark;
|
||||
}
|
||||
|
||||
@ -0,0 +1,14 @@
|
||||
package com.ruoyi.cus.vo;
|
||||
|
||||
import com.ruoyi.cus.domain.CusMain;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Data
|
||||
public class MainVO extends CusMain {
|
||||
/** 主营产品list */
|
||||
private List<String> mainProdList;
|
||||
}
|
||||
@ -0,0 +1,23 @@
|
||||
package com.ruoyi.cus.vo;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class MarkVO {
|
||||
/** 主唛(文字)*/
|
||||
private String mainText;
|
||||
/** 主唛(图形) */
|
||||
private String mainPic;
|
||||
/** 主侧唛(文字) */
|
||||
private String mainSideText;
|
||||
/** 主侧唛(图形) */
|
||||
private String mainSidePic;
|
||||
/** 内主唛(文字) */
|
||||
private String inText;
|
||||
/** 内主唛(图形) */
|
||||
private String inPic;
|
||||
/** 内侧唛(文字) */
|
||||
private String inSideText;
|
||||
/** 内侧唛(图形) */
|
||||
private String inSidePic;
|
||||
}
|
||||
@ -42,6 +42,7 @@ public class DlBaseEntity implements Serializable
|
||||
|
||||
/** 是否删除(0未删除|1已删除) */
|
||||
@TableLogic
|
||||
@TableField(value = "del_flag", fill = FieldFill.INSERT)
|
||||
private String delFlag;
|
||||
|
||||
/** 查询条件 */
|
||||
|
||||
@ -20,7 +20,7 @@
|
||||
<!-- 必填项 -->
|
||||
<el-row>
|
||||
<el-col :span="12">
|
||||
<el-form-item label="客户名称" prop="fullName" label-width="100px">
|
||||
<el-form-item label="客户名称" prop="mainInfo.fullName" label-width="100px">
|
||||
<el-input v-model="formData.mainInfo.fullName" placeholder="客户名称">
|
||||
</el-input>
|
||||
</el-form-item>
|
||||
@ -40,7 +40,7 @@
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="12">
|
||||
<el-form-item label="客户类型" prop="cusType" label-width="100px">
|
||||
<el-form-item label="客户类型" prop="mainInfo.cusType" label-width="100px">
|
||||
<el-select style="width: 100%" v-model="formData.mainInfo.cusType" filterable placeholder="客户类型" clearable>
|
||||
<el-option
|
||||
v-for="dict in dict.type.cus_type"
|
||||
@ -84,7 +84,7 @@
|
||||
<el-col :span="12">
|
||||
<el-form-item label="主营产品" label-width="100px">
|
||||
<!-- collapse-tags-->
|
||||
<el-select style="width: 100%" v-model="formData.mainInfo.mainProds" multiple collapse-tags filterable placeholder="主营产品" clearable>
|
||||
<el-select style="width: 100%" v-model="formData.mainInfo.mainProdList" multiple collapse-tags filterable placeholder="主营产品" clearable>
|
||||
<el-option
|
||||
v-for="dict in dict.type.cus_main_product"
|
||||
:key="dict.value"
|
||||
@ -246,7 +246,7 @@
|
||||
</el-form>
|
||||
</div>
|
||||
<div class="dl-drawer-footer">
|
||||
<el-button type="primary" @click="submitForm">确 定</el-button>
|
||||
<el-button type="primary" @click="submitForm">保 存</el-button>
|
||||
<el-button @click="cancel">取 消</el-button>
|
||||
</div>
|
||||
</el-drawer>
|
||||
@ -279,7 +279,7 @@ export default {
|
||||
country: '',
|
||||
shortName: '',
|
||||
zoneName: '',
|
||||
mainProds: "",
|
||||
mainProdList: "",
|
||||
siteUrl: '',
|
||||
remark: "",
|
||||
files: ""
|
||||
@ -309,13 +309,10 @@ export default {
|
||||
timeZoneList: [],
|
||||
// 表单校验
|
||||
rules: {
|
||||
cusCode: [
|
||||
{ required: true, message: '请输入客户编码', trigger: 'blur' }
|
||||
],
|
||||
fullName: [
|
||||
"mainInfo.fullName": [
|
||||
{ required: true, message: '请输入客户名称', trigger: 'blur' }
|
||||
],
|
||||
cusType: [
|
||||
"mainInfo.cusType": [
|
||||
{ required: true, message: '请选择客户类型', trigger: 'blur' }
|
||||
],
|
||||
'contact': [
|
||||
@ -338,7 +335,7 @@ export default {
|
||||
name: '',
|
||||
ifDefault: false,
|
||||
nickName: '',
|
||||
sex: '0',
|
||||
sex: '1',
|
||||
birthday: '',
|
||||
contactAddress: '',
|
||||
email: '',
|
||||
@ -417,7 +414,7 @@ export default {
|
||||
country: '',
|
||||
shortName: '',
|
||||
zoneName: '',
|
||||
mainProds: "",
|
||||
mainProdList: "",
|
||||
siteUrl: '',
|
||||
remark: "",
|
||||
files: ""
|
||||
@ -444,9 +441,33 @@ export default {
|
||||
},
|
||||
/** 提交按钮 */
|
||||
submitForm() {
|
||||
this.$refs["formData"].validate(valid => {
|
||||
this.$refs["form"].validate(valid => {
|
||||
if (valid) {
|
||||
//操作联系人数据
|
||||
if(this.formData.contact.length>0){
|
||||
this.formData.contact.map((item)=>{
|
||||
if(item.telephone && item.telephonePre){
|
||||
item.telephone = item.telephonePre + item.telephone
|
||||
}
|
||||
if(item.whatsApp && item.whatsAppPre){
|
||||
item.whatsApp = item.whatsAppPre + item.whatsApp
|
||||
}
|
||||
})
|
||||
}else{
|
||||
this.$message.warning("请至少添加一个联系人")
|
||||
return
|
||||
}
|
||||
addMain(this.formData).then(response => {
|
||||
if(response.code==200){
|
||||
this.$message.success("新增成功");
|
||||
setTimeout(() => {
|
||||
this.cancel()
|
||||
},700)
|
||||
|
||||
}else{
|
||||
this.$message.error(response.msg);
|
||||
}
|
||||
})
|
||||
}
|
||||
})
|
||||
},
|
||||
|
||||
@ -43,24 +43,15 @@
|
||||
|
||||
<el-row :gutter="10" class="mb8">
|
||||
<el-col :span="1.5">
|
||||
<el-button
|
||||
type="primary"
|
||||
plain
|
||||
icon="el-icon-plus"
|
||||
size="mini"
|
||||
@click="handleAddQuick"
|
||||
v-hasPermi="['cus:main:add']"
|
||||
>快速新增</el-button>
|
||||
</el-col>
|
||||
<el-col :span="1.5">
|
||||
<el-button
|
||||
type="primary"
|
||||
plain
|
||||
icon="el-icon-plus"
|
||||
size="mini"
|
||||
@click="handleAdd"
|
||||
v-hasPermi="['cus:main:add']"
|
||||
>新增</el-button>
|
||||
<el-dropdown v-hasPermi="['cus:main:add']" @command="handleCommand">
|
||||
<el-button type="primary" plain size="mini">
|
||||
新建客户<i class="el-icon-arrow-down el-icon--right"></i>
|
||||
</el-button>
|
||||
<el-dropdown-menu slot="dropdown">
|
||||
<el-dropdown-item command="quick" @click="handleAddQuick">快速新建</el-dropdown-item>
|
||||
<el-dropdown-item command="add" @click="handleAdd">普通新建</el-dropdown-item>
|
||||
</el-dropdown-menu>
|
||||
</el-dropdown>
|
||||
</el-col>
|
||||
<el-col :span="1.5">
|
||||
<el-button
|
||||
@ -197,72 +188,12 @@ export default {
|
||||
country: null,
|
||||
mainProds: null,
|
||||
},
|
||||
//当前选中的联系人索引
|
||||
chooseContactIndexs: [],
|
||||
// 只显示必填项开关状态
|
||||
onlyRequired: {
|
||||
mainInfo: false,
|
||||
contact: false,
|
||||
},
|
||||
// 表单参数
|
||||
formData: {
|
||||
mainInfo: {
|
||||
cusCode: '',
|
||||
fullName: '',
|
||||
cusType: '',
|
||||
country: '',
|
||||
shortName: '',
|
||||
zoneName: '',
|
||||
mainProds: "",
|
||||
siteUrl: '',
|
||||
remark: "",
|
||||
files: ""
|
||||
},
|
||||
contact: [
|
||||
{
|
||||
name: '',
|
||||
ifDefault: true,
|
||||
nickName: '',
|
||||
sex: '1',
|
||||
birthday: '',
|
||||
contactAddress: '',
|
||||
email: '',
|
||||
telephone: '',
|
||||
telephonePre: '',
|
||||
whatsApp: '',
|
||||
whatsAppPre: '',
|
||||
wechat: '',
|
||||
qq: '',
|
||||
}
|
||||
]
|
||||
},
|
||||
// 表单校验
|
||||
//可选国家列表
|
||||
countryList: [],
|
||||
//可选时区列表
|
||||
timeZoneList: [],
|
||||
// 表单校验
|
||||
rules: {
|
||||
cusCode: [
|
||||
{ required: true, message: '请输入客户编码', trigger: 'blur' }
|
||||
],
|
||||
fullName: [
|
||||
{ required: true, message: '请输入客户名称', trigger: 'blur' }
|
||||
],
|
||||
cusType: [
|
||||
{ required: true, message: '请选择客户类型', trigger: 'blur' }
|
||||
],
|
||||
'contact': [
|
||||
{
|
||||
type: 'array',
|
||||
required: true,
|
||||
message: '请至少添加一个联系人',
|
||||
trigger: 'change'
|
||||
}
|
||||
]
|
||||
}
|
||||
};
|
||||
},
|
||||
activated() {
|
||||
// 关键:返回列表页时,强制调用数据请求方法刷新列表
|
||||
this.getList();
|
||||
},
|
||||
created() {
|
||||
this.getList();
|
||||
},
|
||||
@ -293,6 +224,13 @@ export default {
|
||||
this.single = selection.length!==1
|
||||
this.multiple = !selection.length
|
||||
},
|
||||
handleCommand(command){
|
||||
if("quick"==command){
|
||||
this.handleAddQuick()
|
||||
}else if("add"){
|
||||
this.handleAdd()
|
||||
}
|
||||
},
|
||||
/** 新增按钮操作 */
|
||||
handleAdd() {
|
||||
this.$router.push({path:'/cus/newForm'})
|
||||
|
||||
@ -69,20 +69,19 @@
|
||||
<!-- 必填项 -->
|
||||
<el-row>
|
||||
<el-col :span="8">
|
||||
<el-form-item label="客户名称" prop="fullName">
|
||||
<el-form-item label="客户名称" prop="mainInfo.fullName">
|
||||
<el-input v-model="formData.mainInfo.fullName" placeholder="客户名称">
|
||||
</el-input>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="8">
|
||||
<el-form-item label="客户编码" prop="cusCode">
|
||||
<el-input v-model="formData.mainInfo.cusCode" placeholder="请输入客户编码">
|
||||
<el-button slot="append">申请编码</el-button>
|
||||
<el-input readonly v-model="formData.mainInfo.cusCode" placeholder="保存后系统自动生成">
|
||||
</el-input>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="8">
|
||||
<el-form-item label="客户类型" prop="cusType">
|
||||
<el-form-item label="客户类型" prop="mainInfo.cusType">
|
||||
<el-select style="width: 100%" v-model="formData.mainInfo.cusType" filterable placeholder="客户类型" clearable>
|
||||
<el-option
|
||||
v-for="dict in dict.type.cus_type"
|
||||
@ -132,7 +131,7 @@
|
||||
<el-col :span="16">
|
||||
<el-form-item label="主营产品">
|
||||
<!-- collapse-tags-->
|
||||
<el-select style="width: 100%" v-model="formData.mainInfo.mainProds" multiple filterable placeholder="主营产品" clearable>
|
||||
<el-select style="width: 100%" v-model="formData.mainInfo.mainProdList" multiple filterable placeholder="主营产品" clearable>
|
||||
<el-option
|
||||
v-for="dict in dict.type.cus_main_product"
|
||||
:key="dict.value"
|
||||
@ -489,7 +488,7 @@
|
||||
</el-col>
|
||||
<el-col :span="12">
|
||||
<el-form-item label="内主唛(图形)" label-width="150px">
|
||||
<image-upload v-model="formData.mark.inSidePic" :limit="1"/>
|
||||
<image-upload v-model="formData.mark.inPic" :limit="1"/>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
</el-row>
|
||||
@ -515,7 +514,7 @@
|
||||
<el-row>
|
||||
<el-col :span="24">
|
||||
<el-form-item label="附件">
|
||||
<file-upload v-model="formData.files"/>
|
||||
<file-upload v-model="formData.mainInfo.files"/>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
</el-row>
|
||||
@ -583,7 +582,7 @@ export default {
|
||||
country: '',
|
||||
shortName: '',
|
||||
zoneName: '',
|
||||
mainProds: "",
|
||||
mainProdList: "",
|
||||
siteUrl: '',
|
||||
remark:"",
|
||||
files:""
|
||||
@ -646,13 +645,10 @@ export default {
|
||||
timeZoneList: [],
|
||||
// 表单校验
|
||||
rules: {
|
||||
cusCode: [
|
||||
{ required: true, message: '请输入客户编码', trigger: 'blur' }
|
||||
],
|
||||
fullName: [
|
||||
'mainInfo.fullName': [
|
||||
{ required: true, message: '请输入客户名称', trigger: 'blur' }
|
||||
],
|
||||
cusType: [
|
||||
'mainInfo.cusType': [
|
||||
{ required: true, message: '请选择客户类型', trigger: 'blur' }
|
||||
],
|
||||
'contact': [
|
||||
@ -671,6 +667,15 @@ export default {
|
||||
const contentContainer = this.$refs.contentContainer
|
||||
this.debouncedScroll = debounce(this.handleContentScroll)
|
||||
contentContainer.addEventListener('scroll', this.debouncedScroll)
|
||||
//生成客户编号
|
||||
// getCode().then(response => {
|
||||
// if(response.code==200){
|
||||
// this.formData.mainInfo.cusCode=response.data;
|
||||
// }else{
|
||||
// this.$message.error(response.msg);
|
||||
// }
|
||||
// }
|
||||
// );
|
||||
},
|
||||
beforeDestroy() {
|
||||
// 移除滚动事件监听,避免内存泄漏
|
||||
@ -753,7 +758,7 @@ export default {
|
||||
name: '',
|
||||
ifDefault: false,
|
||||
nickName: '',
|
||||
sex: '0',
|
||||
sex: '1',
|
||||
birthday: '',
|
||||
contactAddress: '',
|
||||
email: '',
|
||||
@ -814,11 +819,40 @@ export default {
|
||||
handleSaveAndNew() {
|
||||
// 保存并新建逻辑
|
||||
console.log('保存并新建')
|
||||
this.handleSave("refresh")
|
||||
},
|
||||
handleSave() {
|
||||
handleSave(str) {
|
||||
// 保存逻辑
|
||||
this.$refs['form'].validate(valid => {
|
||||
if (valid) {
|
||||
//操作联系人数据
|
||||
if(this.formData.contact.length>0){
|
||||
this.formData.contact.map((item)=>{
|
||||
if(item.telephone && item.telephonePre){
|
||||
item.telephone = item.telephonePre + item.telephone
|
||||
}
|
||||
if(item.whatsApp && item.whatsAppPre){
|
||||
item.whatsApp = item.whatsAppPre + item.whatsApp
|
||||
}
|
||||
})
|
||||
}else{
|
||||
this.$message.warning("请至少添加一个联系人")
|
||||
return
|
||||
}
|
||||
addMain(this.formData).then(response => {
|
||||
if(response.code==200){
|
||||
this.$message.success("新增成功");
|
||||
setTimeout(() => {
|
||||
if(str=="refresh"){
|
||||
location.reload()
|
||||
}else{
|
||||
history.back()
|
||||
}
|
||||
},700)
|
||||
}else{
|
||||
this.$message.error(response.msg);
|
||||
}
|
||||
})
|
||||
}
|
||||
})
|
||||
},
|
||||
|
||||
Loading…
Reference in New Issue
Block a user