Commit b748a552 by 前端

菜单联动处理

1 parent 28b08c68
...@@ -729,11 +729,26 @@ ...@@ -729,11 +729,26 @@
} }
} }
// 处理账户等级
// var _accountLevels = [{level:1,name:'工厂'},{level:2,name:'省代'},{level:3,name:'市代'},{level:4,name:'门店'}]
var _subMerchantNoList
var currentPage = 1; // 初始化页码 var currentPage = 1; // 初始化页码
var _merchantModel; // 商户模型变量 var _merchantModel; // 商户模型变量
var _xmSelectData = [] //存储上级商户的下拉数据 var _xmSelectData = [] //存储上级商户的下拉数据
var _currentMerchantLevel = '' //当前的账户等级 var _currentMerchantLevel = '' //当前的账户等级
var _superMerchantInfo= {} //上级商户的信息 var _superMerchantInfo= {} //上级商户的信息
// var accountlevelselect = $('#accountLevelElTab');
// accountLevelselect.empty();
// //根据当前商户等级和下级商户情况调整账户等级选项
// accountLevels.forEach(function(level) {
// var option = new Option(level.name,level.level)
// if(_subMerchantNoList && level.level == 2){
// }
// })
// accountLevelselect.val(merchantAccountLevel);
// form.render( ' select');
function loadSuperiorMerchants(pageNum = 1, val = '') { function loadSuperiorMerchants(pageNum = 1, val = '') {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
var params = { var params = {
...@@ -786,10 +801,12 @@ var mySelect = layui.xmSelect.render({ ...@@ -786,10 +801,12 @@ var mySelect = layui.xmSelect.render({
} }
}, },
on: function(data) { on: function(data) {
_superMerchantInfo = data?.change[0]
console.log(_superMerchantInfo) _superMerchantInfo = data?.arr[0]
var handleAccountTypeToArray = data?.arr[0].accountType.split(',') var handleAccountTypeToArray = data?.arr[0]?.accountType.split(',')
renderAccountTypes(handleAccountTypeToArray,_superMerchantInfo.accountType,_superMerchantInfo.subAccountTypeList) renderAccountTypes(handleAccountTypeToArray,merchantForm.accountType,merchantForm.subAccountTypeList,_currentMerchantLevel)
clearRoleAuthTabContent();
prepareExecuteFindMenuFun()
}, },
}); });
...@@ -893,6 +910,7 @@ form.on('checkbox', function(data) { ...@@ -893,6 +910,7 @@ form.on('checkbox', function(data) {
}); });
console.log("选中的账户类型值: ", selectedValues); console.log("选中的账户类型值: ", selectedValues);
_currentaccountType = selectedValues
// 检查触发事件的元素是否不是以"project"为前缀的id的元素的一部分 // 检查触发事件的元素是否不是以"project"为前缀的id的元素的一部分
if (!$(data.elem).closest('[id^=project]').length) { if (!$(data.elem).closest('[id^=project]').length) {
...@@ -905,26 +923,25 @@ if (!$(data.elem).closest('[id^=project]').length) { ...@@ -905,26 +923,25 @@ if (!$(data.elem).closest('[id^=project]').length) {
}); });
function prepareExecuteFindMenuFun(){ function prepareExecuteFindMenuFun(){
if(_currentMerchantLevel != '1' && !_superMerchantInfo) return
var rolePageParams = {} var rolePageParams = {}
console.log(merchantForm) if(_currentMerchantLevel != '1'){
console.log(_superMerchantInfo)
console.log(_currentMerchantLevel)
if(_currentMerchantLevel !== 1){
rolePageParams = { rolePageParams = {
method:'merchants.api.merchant.findMenuFunTreeByMerId', method:'merchants.api.merchant.findMenuFunTreeByMerId',
id: merchantForm.id, id: merchantForm.id,
parentId: _superMerchantInfo.parentId, parentId: _superMerchantInfo?.parentId,
accountlevel: _currentMerchantLevel accountlevel: _currentMerchantLevel
} }
}else{ }else{
rolePageParams = { rolePageParams = {
method: 'merchants.api.merchant.accountTypeSearchRequest', method: 'merchants.api.merchant.accountTypeSearchRequest',
ids: _currentaccountType, ids: Array.isArray(_currentaccountType)?_currentaccountType.join(',') : _currentaccountType,
merchantId: merchantForm.id, merchantId: merchantForm.id,
accountLevel:_currentMerchantLevel accountLevel:_currentMerchantLevel
} }
} }
// findMenuFunTreeByMerId(rolePageParams) findMenuFunTreeByMerId(rolePageParams)
} }
function clearRoleAuthTabContent() { function clearRoleAuthTabContent() {
// 清空特定选项卡标题 // 清空特定选项卡标题
...@@ -999,10 +1016,18 @@ function clearRoleAuthTabContent() { ...@@ -999,10 +1016,18 @@ function clearRoleAuthTabContent() {
// tab 切换 // tab 切换
element.on('tab(editTab)', function (val) {}) element.on('tab(editTab)', function (val) {})
// 监听账户等级下拉框的选择事件 // 监听账户等级下拉框的选择事件
form.on('select(accountLevelFilter)', function(data) { form.on('select(accountLevelFilter)', function(data) {
if(data.value == 1 || data.value ==4){
$('#accountLevelElTab option[value="1"]').prop('disabled',false)
$('#accountLevelElTab option[value="2"]').prop('disabled',false)
$('#accountLevelElTab option[value="3"]').prop('disabled',false)
$('#accountLevelElTab option[value="4"]').prop('disabled',false)
}
// 如果选中的是“工厂” // 如果选中的是“工厂”
if (data.value === '1') { if (data.value == '1') {
// 隐藏上级商户的表单项 // 隐藏上级商户的表单项
$('#superiorMerchantContainer').hide(); $('#superiorMerchantContainer').hide();
} else { } else {
...@@ -1010,6 +1035,15 @@ function clearRoleAuthTabContent() { ...@@ -1010,6 +1035,15 @@ function clearRoleAuthTabContent() {
$('#superiorMerchantContainer').show(); $('#superiorMerchantContainer').show();
} }
_currentMerchantLevel = data.value _currentMerchantLevel = data.value
if(data.value == 3) $('#accountLevelElTab option[value="2"]').prop('disabled',true)
if(data.value == 2) $('#accountLevelElTab option[value="3"]').prop('disabled',true)
if(data.value ==2 && _subMerchantNoList?.length>0 || data.value ==3 && _subMerchantNoList?.length>0 ){
$("#accountLevelElTab").attr("disabled", "disabled");
$("#accountLevelElTab").attr("style", "background-color: #EEEEEE;");
}
renderAccountTypes(_superMerchantInfo?.accountType?.split(','), merchantForm.accountType, merchantForm.subAccountTypeList,_currentMerchantLevel);
clearRoleAuthTabContent();
prepareExecuteFindMenuFun()
form.render(); // 可选,根据需要重新渲染表单 form.render(); // 可选,根据需要重新渲染表单
}); });
...@@ -1853,6 +1887,13 @@ function uniqueNodes(nodes) { ...@@ -1853,6 +1887,13 @@ function uniqueNodes(nodes) {
// 设置账户等级下拉框的初始值 // 设置账户等级下拉框的初始值
var accountLevel = merchantForm.merchantAccountLevel; // 获取账户等级 var accountLevel = merchantForm.merchantAccountLevel; // 获取账户等级
_currentMerchantLevel = accountLevel
if(accountLevel ==2 && merchantForm.subMerchantNoList?.length > 0 || accountLevel ==3 && merchantForm.subMerchantNoList?.length >0 ){
$("#accountLevelElTab").attr("disabled", "disabled");
$("#accountLevelElTab").attr("style", "background-color: #EEEEEE;");
}
if(accountLevel == 3) $('#accountLevelElTab option[value="2"]').prop('disabled',true)
if(accountLevel == 2) $('#accountLevelElTab option[value="3"]').prop('disabled',true)
$('#accountLevelElTab').val(accountLevel); // 设置select元素的值 $('#accountLevelElTab').val(accountLevel); // 设置select元素的值
// 根据账户等级决定是否显示或隐藏上级商户 // 根据账户等级决定是否显示或隐藏上级商户
...@@ -1864,8 +1905,12 @@ function uniqueNodes(nodes) { ...@@ -1864,8 +1905,12 @@ function uniqueNodes(nodes) {
// 插个眼 账户类型 // 插个眼 账户类型
// 获取并处理上级账户类型 // 获取并处理上级账户类型
var superiorAccountType = merchantForm.superiorAccountType?.split(','); // 假设是以逗号分隔的字符串 var superiorAccountType = merchantForm.superiorAccountType?.split(','); // 假设是以逗号分隔的字符串
_currentaccountType = merchantForm.accountType
renderAccountTypes(superiorAccountType, merchantForm.accountType, merchantForm.subAccountTypeList,accountLevel); renderAccountTypes(superiorAccountType, merchantForm.accountType, merchantForm.subAccountTypeList,accountLevel);
// 设置下级账户类型
_subMerchantNoList = merchantForm.subMerchantNoList
// 更新 LayUI 表单视图 // 更新 LayUI 表单视图
form.render('select'); form.render('select');
...@@ -1874,7 +1919,12 @@ function uniqueNodes(nodes) { ...@@ -1874,7 +1919,12 @@ function uniqueNodes(nodes) {
loadSuperiorMerchants(currentPage).then(function(list) { loadSuperiorMerchants(currentPage).then(function(list) {
_xmSelectData = list _xmSelectData = list
mySelect.update({ data: list }); mySelect.update({ data: list });
if(merchantForm?.superiorMerchantName && merchantForm?.superiorMerchantNo){ if(accountLevel !== 1){
_superMerchantInfo = {name:merchantForm.superiorMerchantName,
value:merchantForm.superiorMerchantNo,
parentId:merchantForm.parentId,
accountType:merchantForm.superiorAccountType
}
mySelect.setValue([{name:merchantForm.superiorMerchantName, value:merchantForm.superiorMerchantNo}]); mySelect.setValue([{name:merchantForm.superiorMerchantName, value:merchantForm.superiorMerchantNo}]);
} }
}); });
...@@ -1926,8 +1976,9 @@ loadSuperiorMerchants(currentPage).then(function(list) { ...@@ -1926,8 +1976,9 @@ loadSuperiorMerchants(currentPage).then(function(list) {
// merchantId, check_arr // merchantId,
function renderAccountTypes(types, currentMerchantType,subAccountTypeList,accountLevel) { function renderAccountTypes(types, currentMerchantType,subAccountTypeList,accountLevel) {
console.log(types, currentMerchantType,subAccountTypeList,accountLevel)
if(!subAccountTypeList) subAccountTypeList = '' if(!subAccountTypeList) subAccountTypeList = ''
if(!types) types = []; if(!types) types = [];
var el = $('#accountTypeElRole'); var el = $('#accountTypeElRole');
...@@ -1941,10 +1992,13 @@ loadSuperiorMerchants(currentPage).then(function(list) { ...@@ -1941,10 +1992,13 @@ loadSuperiorMerchants(currentPage).then(function(list) {
}); });
if(accountLevel == 1){ if(accountLevel == 1){
types = []
for(let i in typeMapping){ for(let i in typeMapping){
types.push(i); types.push(i);
} }
} }
console.log(types)
types.forEach(function(type) { types.forEach(function(type) {
var typeLabel = typeMapping[type]; var typeLabel = typeMapping[type];
var isChecked = currentMerchantType.includes(type); var isChecked = currentMerchantType.includes(type);
...@@ -2272,7 +2326,6 @@ loadSuperiorMerchants(currentPage).then(function(list) { ...@@ -2272,7 +2326,6 @@ loadSuperiorMerchants(currentPage).then(function(list) {
* products:对应的菜单下的产品list,包含了对应的权限树,原始数据,需作为参数传入treeTabAdd中,在实例化tree时传入的数据使用 * products:对应的菜单下的产品list,包含了对应的权限树,原始数据,需作为参数传入treeTabAdd中,在实例化tree时传入的数据使用
*/ */
tabAdd: function (item, productList) { tabAdd: function (item, productList) {
console.log(item,productList)
// 渠道的id,一层选项卡的id // 渠道的id,一层选项卡的id
var id = item.value var id = item.value
// roleAuth 一层选项卡过滤器的名称 // roleAuth 一层选项卡过滤器的名称
...@@ -2441,7 +2494,7 @@ loadSuperiorMerchants(currentPage).then(function(list) { ...@@ -2441,7 +2494,7 @@ loadSuperiorMerchants(currentPage).then(function(list) {
console.log('parentMerchantId',parentMerchantId) console.log('parentMerchantId',parentMerchantId)
console.log('merchantId',merchantId) console.log('merchantId',merchantId)
console.log('accountlevel',merchantForm.merchantAccountLevel) console.log('accountlevel',merchantForm.merchantAccountLevel)
console.log('ids',merchantForm.accountType) console.log('ids', merchantForm.accountType)
if(rolePageParams){ if(rolePageParams){
params = rolePageParams params = rolePageParams
}else{ }else{
...@@ -2461,11 +2514,10 @@ loadSuperiorMerchants(currentPage).then(function(list) { ...@@ -2461,11 +2514,10 @@ loadSuperiorMerchants(currentPage).then(function(list) {
} }
} }
} }
console.log(params)
request(params, function (res) { request(params, function (res) {
if (res.code == '0') { if (res.code == '0') {
menuFunTreeData = res.data menuFunTreeData = res.data
console.log(menuFunTreeData) check_arr = res.data
var accountType = $('#accountType') var accountType = $('#accountType')
accountType.empty() accountType.empty()
menuFunTreeData.forEach((item, index) => { menuFunTreeData.forEach((item, index) => {
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!