完善分配客户的功能

This commit is contained in:
jishenghua
2025-07-10 21:38:48 +08:00
parent 9330629196
commit af70f83839
7 changed files with 118 additions and 199 deletions

View File

@@ -5,6 +5,7 @@ import com.alibaba.fastjson.JSONObject;
import com.jsh.erp.base.BaseController;
import com.jsh.erp.base.TableDataInfo;
import com.jsh.erp.datasource.entities.Supplier;
import com.jsh.erp.datasource.vo.SupplierSimple;
import com.jsh.erp.service.SupplierService;
import com.jsh.erp.service.SystemConfigService;
import com.jsh.erp.service.UserService;
@@ -297,51 +298,51 @@ public class SupplierController extends BaseController {
}
/**
* 用户对应客户显示
* 获取全部客户信息
* @param search
* @param request
* @return
* @throws Exception
*/
@GetMapping(value = "/getAllCustomer")
@ApiOperation(value = "获取全部客户信息")
public TableDataInfo getAllCustomer(@RequestParam(value = Constants.SEARCH, required = false) String search,
HttpServletRequest request)throws Exception {
List<SupplierSimple> list = supplierService.getAllCustomer();
return getDataTable(list);
}
/**
* 获取用户对应客户的关系数组
* @param type
* @param keyId
* @param request
* @return
*/
@GetMapping(value = "/findUserCustomer")
@ApiOperation(value = "用户对应客户显示")
public JSONArray findUserCustomer(@RequestParam("UBType") String type, @RequestParam("UBKeyId") String keyId,
HttpServletRequest request) throws Exception{
JSONArray arr = new JSONArray();
@GetMapping(value = "/getUserCustomerValue")
@ApiOperation(value = "获取用户对应客户的关系数组")
public JSONObject getUserCustomerValue(@RequestParam("UBType") String type, @RequestParam("UBKeyId") String keyId,
HttpServletRequest request) throws Exception{
JSONObject obj = new JSONObject();
try {
//获取权限信息
String ubValue = userBusinessService.getUBValueByTypeAndKeyId(type, keyId);
List<Supplier> dataList = supplierService.findUserCustomer();
//开始拼接json数据
JSONObject outer = new JSONObject();
outer.put("id", 0);
outer.put("key", 0);
outer.put("value", 0);
outer.put("title", "客户列表");
outer.put("attributes", "客户列表");
//存放数据json数组
JSONArray dataArray = new JSONArray();
if (null != dataList) {
for (Supplier supplier : dataList) {
JSONObject item = new JSONObject();
item.put("id", supplier.getId());
item.put("key", supplier.getId());
item.put("value", supplier.getId());
item.put("title", supplier.getSupplier());
item.put("attributes", supplier.getSupplier());
Boolean flag = ubValue.contains("[" + supplier.getId().toString() + "]");
if (flag) {
item.put("checked", true);
}
dataArray.add(item);
if(StringUtil.isNotEmpty(ubValue)) {
String ubStr = ubValue.substring(1, ubValue.length()-1);
String [] ubArr = ubStr.split("]\\[");
Long[] ubLongArray = new Long[ubArr.length];
for (int i = 0; i < ubArr.length; i++) {
ubLongArray[i] = Long.parseLong(ubArr[i]);
}
obj.put("data", ubLongArray);
}
outer.put("children", dataArray);
arr.add(outer);
obj.put("code", 200);
} catch (Exception e) {
obj.put("code", 500);
obj.put("data", "服务内部错误");
logger.error(e.getMessage(), e);
}
return arr;
return obj;
}
/**

View File

@@ -2,6 +2,7 @@ package com.jsh.erp.datasource.mappers;
import com.jsh.erp.datasource.entities.Supplier;
import com.jsh.erp.datasource.entities.SupplierExample;
import com.jsh.erp.datasource.vo.SupplierSimple;
import org.apache.ibatis.annotations.Param;
import java.util.Date;
@@ -28,4 +29,6 @@ public interface SupplierMapperEx {
Supplier getSupplierByNameAndType(
@Param("supplier") String supplier,
@Param("type") String type);
List<SupplierSimple> getAllCustomer();
}

View File

@@ -0,0 +1,12 @@
package com.jsh.erp.datasource.vo;
import lombok.Data;
@Data
public class SupplierSimple {
private Long id;
private String supplier;
}

View File

@@ -6,6 +6,7 @@ import com.jsh.erp.constants.ExceptionConstants;
import com.jsh.erp.datasource.entities.*;
import com.jsh.erp.datasource.mappers.*;
import com.jsh.erp.datasource.vo.DepotHeadVo4StatementAccount;
import com.jsh.erp.datasource.vo.SupplierSimple;
import com.jsh.erp.exception.BusinessRunTimeException;
import com.jsh.erp.exception.JshException;
import com.jsh.erp.utils.*;
@@ -674,4 +675,8 @@ public class SupplierService {
}
return res;
}
public List<SupplierSimple> getAllCustomer() {
return supplierMapperEx.getAllCustomer();
}
}

View File

@@ -75,4 +75,11 @@
where supplier = #{supplier} and type = #{type}
and ifnull(delete_flag,'0') !='1'
</select>
<select id="getAllCustomer" resultType="com.jsh.erp.datasource.vo.SupplierSimple">
select id, supplier from jsh_supplier
where type = '客户' and enabled = 1
and ifnull(delete_flag,'0') !='1'
order by sort asc, id desc
</select>
</mapper>

View File

@@ -16,42 +16,22 @@
okText="保存"
style="top:5%;height: 95%;">
<a-spin :spinning="confirmLoading">
<div class="drawer-bootom-button">
<a-dropdown :trigger="['click']" placement="topCenter">
<a-menu slot="overlay">
<a-menu-item key="1" @click="switchCheckStrictly(1)">父子关联</a-menu-item>
<a-menu-item key="2" @click="switchCheckStrictly(2)">取消关联</a-menu-item>
<a-menu-item key="3" @click="checkALL">全部勾选</a-menu-item>
<a-menu-item key="4" @click="cancelCheckALL">取消全选</a-menu-item>
<a-menu-item key="5" @click="expandAll">展开所有</a-menu-item>
<a-menu-item key="6" @click="closeAll">合并所有</a-menu-item>
</a-menu>
<a-button>
树操作 <a-icon type="up" />
</a-button>
</a-dropdown>
</div>
<a-col :md="10" :sm="24">
<template>
<a-tree
checkable
multiple
@check="onCheck"
:selectedKeys="selectedKeys"
:checkedKeys="checkedKeys"
:treeData="roleFunctionTree"
:checkStrictly="checkStrictly"
:expandedKeys="iExpandedKeys"
:autoExpandParent="true"
@expand="onExpand"/>
</template>
</a-col>
<a-table
ref="table"
size="small"
rowKey="id"
:columns="columns"
:dataSource="dataSource"
:pagination="false"
:customRow="null"
:loading="loading"
:rowSelection="{selectedRowKeys: selectedRowKeys, onChange: onSelectChange}">
</a-table>
</a-spin>
</a-modal>
</div>
</template>
<script>
import pick from 'lodash.pick'
import {mixinDevice} from '@/utils/mixin'
import {addUserBusiness,editUserBusiness,checkUserBusiness} from '@/api/api'
import {getAction} from '../../../api/manage'
@@ -64,22 +44,19 @@
visible: false,
model: {},
roleId: 0,
iExpandedKeys: [],
roleFunctionTree: [],
checkedKeys: [],
selectedKeys: [],
checkStrictly: false,
hiding: true,
labelCol: {
xs: { span: 24 },
sm: { span: 5 },
},
wrapperCol: {
xs: { span: 24 },
sm: { span: 16 },
},
// 表头
columns: [
{ title: '客户名称', dataIndex: 'supplier', width: 200 }
],
dataSource:[],
selectedRowKeys: [],
loading:false,
confirmLoading: false,
form: this.$form.createForm(this),
url: {
cusList: "/supplier/getAllCustomer",
selectedList: "/supplier/getUserCustomerValue",
}
}
},
created () {
@@ -89,16 +66,41 @@
this.form.resetFields();
this.model = Object.assign({}, {});
this.visible = true;
this.$nextTick(() => {
this.form.setFieldsValue(pick(this.model,'name', 'type', 'description'))
});
this.roleId = record.id
this.checkedKeys = []
this.loadTree(record.id)
this.loadData()
this.loadSelected(record.id)
},
close () {
this.$emit('close');
this.visible = false;
this.$emit('close')
this.visible = false
},
handleCancel () {
this.close()
},
loadData() {
this.loading = true
getAction(this.url.cusList).then((res) => {
if (res.code===200) {
this.dataSource = res.data.rows
} else if(res.code===510){
this.$message.warning(res.data)
} else {
this.$message.warning(res.data.message)
}
this.loading = false
})
},
loadSelected(id) {
getAction(this.url.selectedList + '?UBType=UserCustomer&UBKeyId='+id).then((res) => {
if (res.code===200) {
this.selectedRowKeys = res.data
} else {
this.$message.warning(res.data)
}
})
},
onSelectChange(selectedRowKeys, selectionRows) {
this.selectedRowKeys = selectedRowKeys
},
handleOk () {
const that = this;
@@ -109,7 +111,7 @@
let formData = Object.assign(this.model, values);
formData.type = 'UserCustomer'
formData.keyId = this.roleId
formData.value = this.checkedKeys
formData.value = this.selectedRowKeys
let obj;
checkUserBusiness({'type': 'UserCustomer','keyId': this.roleId}).then((res)=>{
if(res.data && res.data.id) {
@@ -131,88 +133,12 @@
})
}
})
},
handleCancel () {
this.close()
},
loadTree(id) {
let that = this
that.treeData = []
that.roleFunctionTree = []
let params = {};
params.id='';
getAction('/supplier/findUserCustomer?UBType=UserCustomer&UBKeyId='+id).then((res) => {
if (res) {
//机构全选后,再添加机构,选中数量增多
this.allTreeKeys = [];
for (let i = 0; i < res.length; i++) {
let temp = res[i]
that.treeData.push(temp)
that.roleFunctionTree.push(temp)
that.setThisExpandedKeys(temp)
that.getAllKeys(temp);
}
console.log(JSON.stringify(this.checkedKeys))
this.loading = false
}
})
},
onCheck(checkedKeys, info) {
console.log('onCheck', checkedKeys, info)
this.hiding = false
if(this.checkStrictly){
this.checkedKeys = checkedKeys.checked;
}else{
this.checkedKeys = checkedKeys
}
},
setThisExpandedKeys(node) {
if(node.checked==true) {
this.checkedKeys.push(node.key)
}
if (node.children && node.children.length > 0) {
this.iExpandedKeys.push(node.key)
for (let a = 0; a < node.children.length; a++) {
this.setThisExpandedKeys(node.children[a])
}
}
},
getAllKeys(node) {
// console.log('node',node);
this.allTreeKeys.push(node.key)
if (node.children && node.children.length > 0) {
for (let a = 0; a < node.children.length; a++) {
this.getAllKeys(node.children[a])
}
}
},
expandAll () {
this.iExpandedKeys = this.allTreeKeys
},
closeAll () {
this.iExpandedKeys = []
},
checkALL () {
this.checkStriccheckStrictlytly = false
this.checkedKeys = this.allTreeKeys
},
cancelCheckALL () {
this.checkedKeys = []
},
switchCheckStrictly (v) {
if(v==1){
this.checkStrictly = false
}else if(v==2){
this.checkStrictly = true
}
},
onExpand(expandedKeys) {
console.log('onExpand', expandedKeys)
this.iExpandedKeys = expandedKeys
}
}
}
</script>
<style scoped>
.virtual-table {
height: 500px; /* 必须指定高度 */
}
</style>

View File

@@ -16,21 +16,6 @@
okText="保存"
style="top:5%;height: 95%;">
<a-spin :spinning="confirmLoading">
<div class="drawer-bootom-button">
<a-dropdown :trigger="['click']" placement="topCenter">
<a-menu slot="overlay">
<a-menu-item key="1" @click="switchCheckStrictly(1)">父子关联</a-menu-item>
<a-menu-item key="2" @click="switchCheckStrictly(2)">取消关联</a-menu-item>
<a-menu-item key="3" @click="checkALL">全部勾选</a-menu-item>
<a-menu-item key="4" @click="cancelCheckALL">取消全选</a-menu-item>
<a-menu-item key="5" @click="expandAll">展开所有</a-menu-item>
<a-menu-item key="6" @click="closeAll">合并所有</a-menu-item>
</a-menu>
<a-button>
树操作 <a-icon type="up" />
</a-button>
</a-dropdown>
</div>
<a-col :md="10" :sm="24">
<template>
<a-tree
@@ -186,26 +171,6 @@
}
}
},
expandAll () {
this.iExpandedKeys = this.allTreeKeys
},
closeAll () {
this.iExpandedKeys = []
},
checkALL () {
this.checkStriccheckStrictlytly = false
this.checkedKeys = this.allTreeKeys
},
cancelCheckALL () {
this.checkedKeys = []
},
switchCheckStrictly (v) {
if(v==1){
this.checkStrictly = false
}else if(v==2){
this.checkStrictly = true
}
},
onExpand(expandedKeys) {
console.log('onExpand', expandedKeys)
this.iExpandedKeys = expandedKeys