Commit 1d9f84e0 by 前端

修复bug

1 parent 86f1f1a2
...@@ -739,29 +739,24 @@ var _merchantModel; // 商户模型变量 ...@@ -739,29 +739,24 @@ var _merchantModel; // 商户模型变量
var _xmSelectData = [] //存储上级商户的下拉数据 var _xmSelectData = [] //存储上级商户的下拉数据
var _currentMerchantLevel = '' //当前的账户等级 var _currentMerchantLevel = '' //当前的账户等级
var _superMerchantInfo= {} //上级商户的信息 var _superMerchantInfo= {} //上级商户的信息
var _searchValue = ''
var _searchCount = 0
var _initFactoryCheckArr = []
// var accountlevelselect = $('#accountLevelElTab'); function loadSuperiorMerchants(pageNum = 1) {
// accountLevelselect.empty(); console.log('accountLevelUpdate',_currentMerchantLevel)
// //根据当前商户等级和下级商户情况调整账户等级选项
// 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 = '') {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
var params = { var params = {
method: 'merchants.api.open.findMerchantListByPage', method: 'merchants.api.open.findMerchantListByPage',
pageSize: 100, pageSize: 50,
pageNum: pageNum, pageNum: pageNum,
merchantNoOrName: val, merchantNoOrName: _searchValue,
merchantModel: _merchantModel merchantModel: _merchantModel,
accountLevelUpdate:_currentMerchantLevel
}; };
request(params, function(response) { request(params, function(response) {
_searchCount = response.data.count
var list = response.data.data.map(function(merchant) { var list = response.data.data.map(function(merchant) {
return { return {
name: merchant.merchantName, name: merchant.merchantName,
...@@ -786,25 +781,28 @@ var mySelect = layui.xmSelect.render({ ...@@ -786,25 +781,28 @@ var mySelect = layui.xmSelect.render({
remoteMethod: function(val, cb, show) { remoteMethod: function(val, cb, show) {
// 输入时触发搜索 // 输入时触发搜索
if (val) { if (val) {
_searchValue = val
loadSuperiorMerchants(currentPage = 1, val).then(function(res){ loadSuperiorMerchants(currentPage = 1, val).then(function(res){
cb([]) cb([])
mySelect.update({ data: res }); cb(res)
}); });
} }
else{ else{
cb([]) cb([])
_searchValue = ''
if(_merchantModel !== undefined){ if(_merchantModel !== undefined){
loadSuperiorMerchants(currentPage).then(function(list) { loadSuperiorMerchants(currentPage = 1).then(function(list) {
console.log(list)
cb([]) cb([])
mySelect.update({ data: list }); cb(list)
}); });
} }
} }
}, },
on: function(data) { on: function(data) {
console.log('上级商户选择的数据',data)
_superMerchantInfo = data?.arr[0] _superMerchantInfo = data?.arr[0]
var handleAccountTypeToArray = data?.arr[0]?.accountType.split(',') var handleAccountTypeToArray = data?.arr[0]?.accountType?.split(',')
renderAccountTypes(handleAccountTypeToArray,merchantForm.accountType,merchantForm.subAccountTypeList,_currentMerchantLevel) renderAccountTypes(handleAccountTypeToArray,merchantForm.accountType,merchantForm.subAccountTypeList,_currentMerchantLevel)
clearRoleAuthTabContent(); clearRoleAuthTabContent();
prepareExecuteFindMenuFun() prepareExecuteFindMenuFun()
...@@ -830,16 +828,11 @@ $(document).on('mouseup', function(e) { ...@@ -830,16 +828,11 @@ $(document).on('mouseup', function(e) {
function resetXmSelectSearch() { function resetXmSelectSearch() {
// 重置 currentPage 为初始值 // 重置 currentPage 为初始值
currentPage = 1; currentPage = 1;
// 可选:如果你需要重置搜索框的值
// var searchInput = document.querySelector('#superiorMerchantSelect .xm-input');
// if (searchInput) {
// searchInput.value = '';
// }
var superiorMerchant = layui.xmSelect.get('#superiorMerchantSelect', true)?.getValue(); var superiorMerchant = layui.xmSelect.get('#superiorMerchantSelect', true)?.getValue();
// // 重新加载数据 // // 重新加载数据
loadSuperiorMerchants(currentPage).then(function(list) { loadSuperiorMerchants(currentPage).then(function(list) {
mySelect.update({ data: list }); mySelect.update({ data: list });
if(_currentMerchantLevel != 1){ if(_currentMerchantLevel != 1 && superiorMerchant.length !== 0){
mySelect.setValue([{name:superiorMerchant[0]?.name, value:superiorMerchant[0]?.value}]); mySelect.setValue([{name:superiorMerchant[0]?.name, value:superiorMerchant[0]?.value}]);
} }
}); });
...@@ -847,19 +840,18 @@ function resetXmSelectSearch() { ...@@ -847,19 +840,18 @@ function resetXmSelectSearch() {
var debouncedScroll = debounce(function() { var debouncedScroll = debounce(function() {
var scrollContainer = document.querySelector('#superiorMerchantSelect .scroll-body'); var scrollContainer = document.querySelector('#superiorMerchantSelect .scroll-body');
if (scrollContainer && isScrolledToBottom(scrollContainer)) { if (scrollContainer && isScrolledToBottom(scrollContainer)) {
if(_xmSelectData.length>=_searchCount)return;
loadMoreData(); loadMoreData();
} }
}, 100) }, 100)
function loadMoreData() { function loadMoreData() {
removeScrollListener(); removeScrollListener();
currentPage++; currentPage++;
loadSuperiorMerchants(currentPage).then(function(list) { loadSuperiorMerchants(currentPage).then(function(list) {
_xmSelectData = _xmSelectData.concat(list); _xmSelectData = _xmSelectData.concat(list);
console.log(_xmSelectData)
mySelect.update({ data: _xmSelectData }); mySelect.update({ data: _xmSelectData });
setTimeout(attachScrollListener, 500); setTimeout(attachScrollListener, 500);
}); });
} }
...@@ -913,7 +905,7 @@ form.on('checkbox', function(data) { ...@@ -913,7 +905,7 @@ form.on('checkbox', function(data) {
selectedValues.push($(this).val()); selectedValues.push($(this).val());
} }
}); });
// console.log("选中的账户类型值: ", selectedValues); console.log("选中的账户类型值: ", selectedValues);
if (selectedValues.length === 0) { if (selectedValues.length === 0) {
layer.msg('账户类型不能为空', { icon: 5, anim: 6 }); layer.msg('账户类型不能为空', { icon: 5, anim: 6 });
$('#accountTypeElRole .accounttypeId').each(function() { $('#accountTypeElRole .accounttypeId').each(function() {
...@@ -939,6 +931,7 @@ if (!$(data.elem).closest('[id^=project]').length) { ...@@ -939,6 +931,7 @@ if (!$(data.elem).closest('[id^=project]').length) {
}); });
function prepareExecuteFindMenuFun(){ function prepareExecuteFindMenuFun(){
// 修改check_arr
if(_currentMerchantLevel != '1' && !_superMerchantInfo) return if(_currentMerchantLevel != '1' && !_superMerchantInfo) return
var rolePageParams = {} var rolePageParams = {}
...@@ -957,7 +950,8 @@ function prepareExecuteFindMenuFun(){ ...@@ -957,7 +950,8 @@ function prepareExecuteFindMenuFun(){
accountLevel:_currentMerchantLevel accountLevel:_currentMerchantLevel
} }
} }
findMenuFunTreeByMerId(rolePageParams) getById(_superMerchantInfo?.parentId,rolePageParams)
// findMenuFunTreeByMerId(rolePageParams)
} }
function clearRoleAuthTabContent() { function clearRoleAuthTabContent() {
// 清空特定选项卡标题 // 清空特定选项卡标题
...@@ -1034,85 +1028,92 @@ function clearRoleAuthTabContent() { ...@@ -1034,85 +1028,92 @@ function clearRoleAuthTabContent() {
// 监听账户等级下拉框的选择事件 // 监听账户等级下拉框的选择事件
// form.on('select(accountLevelFilter)', function(data) { form.on('select(accountLevelFilter)', function(data) {
// if(data.value == 1 || data.value ==4){ if(data.value == 1 || data.value ==4){
// $('#accountLevelElTab option[value="1"]').prop('disabled',false) $('#accountLevelElTab option[value="1"]').prop('disabled',false)
// $('#accountLevelElTab option[value="2"]').prop('disabled',false) $('#accountLevelElTab option[value="2"]').prop('disabled',false)
// $('#accountLevelElTab option[value="3"]').prop('disabled',false) $('#accountLevelElTab option[value="3"]').prop('disabled',false)
// $('#accountLevelElTab option[value="4"]').prop('disabled',false) $('#accountLevelElTab option[value="4"]').prop('disabled',false)
// }
// // 如果选中的是“工厂”
// if (data.value == '1') {
// // 隐藏上级商户的表单项
// $('#superiorMerchantContainer').hide();
// } else {
// // 显示上级商户的表单项
// $('#superiorMerchantContainer').show();
// }
// _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(); // 可选,根据需要重新渲染表单
// });
// Listen for the account level dropdown selection event
form.on('select(accountLevelFilter)', function(data) {
var $accountLevelElTab = $('#accountLevelElTab');
var $options = $accountLevelElTab.find('option');
var $superiorMerchantContainer = $('#superiorMerchantContainer');
var _currentMerchantLevel = data.value;
function setOptionsDisabled(disabled) {
$options.each(function() {
var value = $(this).attr('value');
$(this).prop('disabled', disabled.includes(value));
});
} }
function toggleMerchantContainerDisplay(show) { // 如果选中的是“工厂”
if (show) { if (data.value == '1') {
$superiorMerchantContainer.show(); // 隐藏上级商户的表单项
$('#superiorMerchantContainer').hide();
} else { } else {
$superiorMerchantContainer.hide(); // 显示上级商户的表单项
$('#superiorMerchantContainer').show();
} }
_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;");
} }
switch (_currentMerchantLevel) { console.log('账户等级下拉框的渲染账户类型参数',
case '1': '上级商户类型',_superMerchantInfo?.accountType?.split(','),
case '4': '本身的商户类型',merchantForm.accountType,
setOptionsDisabled([]); '本身的子商户类型',merchantForm.subAccountTypeList,
toggleMerchantContainerDisplay(_currentMerchantLevel !== '1'); '页面的账户等级',_currentMerchantLevel)
break;
case '2':
setOptionsDisabled(['3']);
toggleMerchantContainerDisplay(true);
break;
case '3':
setOptionsDisabled(['2']);
toggleMerchantContainerDisplay(true);
break;
}
renderAccountTypes(_superMerchantInfo?.accountType?.split(','), merchantForm.accountType, merchantForm.subAccountTypeList,_currentMerchantLevel);
clearRoleAuthTabContent();
prepareExecuteFindMenuFun()
loadSuperiorMerchants()
form.render(); // 可选,根据需要重新渲染表单
});
if ((_currentMerchantLevel === '2' || _currentMerchantLevel === '3') && _subMerchantNoList?.length > 0) { // form.on('select(accountLevelFilter)', function(data) {
$accountLevelElTab.prop('disabled', true).css('background-color', '#EEEEEE'); // var $accountLevelElTab = $('#accountLevelElTab');
} else { // var $options = $accountLevelElTab.find('option');
$accountLevelElTab.prop('disabled', false).css('background-color', ''); // var $superiorMerchantContainer = $('#superiorMerchantContainer');
} // var _currentMerchantLevel = data.value;
// function setOptionsDisabled(disabled) {
// $options.each(function() {
// var value = $(this).attr('value');
// $(this).prop('disabled', disabled.includes(value));
// });
// }
renderAccountTypes(_superMerchantInfo?.accountType?.split(','), merchantForm.accountType, merchantForm.subAccountTypeList, _currentMerchantLevel); // function toggleMerchantContainerDisplay(show) {
clearRoleAuthTabContent(); // if (show) {
prepareExecuteFindMenuFun(); // $superiorMerchantContainer.show();
form.render(); // } else {
}); // $superiorMerchantContainer.hide();
// }
// }
// switch (_currentMerchantLevel) {
// case '1':
// case '4':
// setOptionsDisabled([]);
// toggleMerchantContainerDisplay(_currentMerchantLevel !== '1');
// break;
// case '2':
// setOptionsDisabled(['3']);
// toggleMerchantContainerDisplay(true);
// break;
// case '3':
// setOptionsDisabled(['2']);
// toggleMerchantContainerDisplay(true);
// break;
// }
// if ((_currentMerchantLevel === '2' || _currentMerchantLevel === '3') && _subMerchantNoList?.length > 0) {
// $accountLevelElTab.prop('disabled', true).css('background-color', '#EEEEEE');
// } else {
// $accountLevelElTab.prop('disabled', false).css('background-color', '');
// }
// renderAccountTypes(_superMerchantInfo?.accountType?.split(','), merchantForm.accountType, merchantForm.subAccountTypeList, _currentMerchantLevel);
// clearRoleAuthTabContent();
// prepareExecuteFindMenuFun();
// form.render();
// });
// 校验 // 校验
...@@ -1986,9 +1987,12 @@ loadSuperiorMerchants(currentPage).then(function(list) { ...@@ -1986,9 +1987,12 @@ loadSuperiorMerchants(currentPage).then(function(list) {
parentId:merchantForm.parentId, parentId:merchantForm.parentId,
accountType:merchantForm.superiorAccountType accountType:merchantForm.superiorAccountType
} }
mySelect.setValue([{name:merchantForm.superiorMerchantName, value:merchantForm.superiorMerchantNo}]); console.log(merchantForm)
}else{ mySelect.setValue([{
mySelect.setValue([]) name:merchantForm.superiorMerchantName,
value:merchantForm.superiorMerchantNo,
accountType:merchantForm.superiorAccountType,
parentId:merchantForm.parentId}]);
} }
}); });
...@@ -2056,22 +2060,24 @@ loadSuperiorMerchants(currentPage).then(function(list) { ...@@ -2056,22 +2060,24 @@ loadSuperiorMerchants(currentPage).then(function(list) {
if(accountLevel == 1){ if(accountLevel == 1){
types = [] types = []
for(let i in typeMapping){ for(let i in typeMapping){
types.push(i); types.push(i);
} }
} }
types.forEach(function(type) { types.forEach(function(type) {
var typeLabel = typeMapping[type]; var typeLabel = typeMapping[type];
var isChecked = currentMerchantType.includes(type); var isChecked = currentMerchantType.split(',').includes(type);
var isDisable = subAccountTypeList.includes(type) var isDisable = subAccountTypeList.includes(type)
var checkboxHtml = $('<input type="checkbox" class="accounttypeId" name="accountType[' + type + ']" value="' + type + '" title="' + typeLabel + '">'); var checkboxHtml = $('<input type="checkbox" class="accounttypeId" name="accountType[' + type + ']" value="' + type + '" title="' + typeLabel + '">');
// 设置为选中和禁用,并添加高亮类 // 设置为选中和禁用,并添加高亮类
if (isChecked) { if (isChecked) {
checkboxHtml.attr('checked', true).addClass('highlighted') checkboxHtml.attr('checked', true)
// .addClass('highlighted')
} }
if(isDisable){ if(isDisable){
checkboxHtml.attr('disabled', true).addClass('highlighted-disabled') checkboxHtml.attr('disabled', true)
// .addClass('highlighted-disabled')
} }
el.append(checkboxHtml); el.append(checkboxHtml);
...@@ -2427,6 +2433,7 @@ loadSuperiorMerchants(currentPage).then(function(list) { ...@@ -2427,6 +2433,7 @@ loadSuperiorMerchants(currentPage).then(function(list) {
var str = $('<input lay-filter="filter" data-id="' + id + '" type="checkbox" name="check[' + id + ']" value="' + i.productId + '" title="' + i.productName + '" lay-skin="primary" />') var str = $('<input lay-filter="filter" data-id="' + id + '" type="checkbox" name="check[' + id + ']" value="' + i.productId + '" title="' + i.productName + '" lay-skin="primary" />')
$('#project' + id).append(str) $('#project' + id).append(str)
if (productList) { if (productList) {
console.log('productList',productList)
productList.forEach(j => { productList.forEach(j => {
if (j.productId == i.productId) { if (j.productId == i.productId) {
str.attr('checked', true) str.attr('checked', true)
...@@ -2552,6 +2559,7 @@ loadSuperiorMerchants(currentPage).then(function(list) { ...@@ -2552,6 +2559,7 @@ loadSuperiorMerchants(currentPage).then(function(list) {
// 查询商户的菜单权限树 // 查询商户的菜单权限树
function findMenuFunTreeByMerId(rolePageParams) { function findMenuFunTreeByMerId(rolePageParams) {
console.log('rolePageParams',rolePageParams)
var params = {} var params = {}
if(rolePageParams){ if(rolePageParams){
params = rolePageParams params = rolePageParams
...@@ -2579,7 +2587,24 @@ loadSuperiorMerchants(currentPage).then(function(list) { ...@@ -2579,7 +2587,24 @@ loadSuperiorMerchants(currentPage).then(function(list) {
layer.close(loadingIndex); layer.close(loadingIndex);
if (res.code == '0') { if (res.code == '0') {
menuFunTreeData = res.data menuFunTreeData = res.data
check_arr = res.data // 插个眼
console.log('check_arr',check_arr)
console.log('menuFunTreeData',menuFunTreeData)
console.log('_initFactoryCheckArr',_initFactoryCheckArr)
if(_initFactoryCheckArr && _currentMerchantLevel == 1){
menuFunTreeData.forEach(item => {
if(!_initFactoryCheckArr.some(initItem => initItem.accounttypeId == item.accounttypeId)){
const newItem = {...item,products:[]}
_initFactoryCheckArr.push(newItem)
}
})
}
check_arr =_currentMerchantLevel == 1 ? _initFactoryCheckArr : check_arr.filter(item =>_currentaccountType.includes(String(item.accounttypeId)))
var accountType = $('#accountType') var accountType = $('#accountType')
accountType.empty() accountType.empty()
menuFunTreeData.forEach((item, index) => { menuFunTreeData.forEach((item, index) => {
...@@ -2592,9 +2617,9 @@ loadSuperiorMerchants(currentPage).then(function(list) { ...@@ -2592,9 +2617,9 @@ loadSuperiorMerchants(currentPage).then(function(list) {
var id = item.accounttypeId var id = item.accounttypeId
str.attr('checked', true) str.attr('checked', true)
var obj = { title: item.accounttypeName, value: item.accounttypeId } var obj = { title: item.accounttypeName, value: item.accounttypeId }
// console.log(obj, productData.products)
active.tabAdd(obj, productData.products) active.tabAdd(obj, productData.products)
if (productData.products && productData.products.length != 0) { if (productData.products && productData.products.length != 0) {
// console.log('进入页面',productData)
productData.products.forEach(j => { productData.products.forEach(j => {
var products = item.products.find(n => n.productId == j.productId) var products = item.products.find(n => n.productId == j.productId)
if (products) { if (products) {
...@@ -2634,18 +2659,26 @@ loadSuperiorMerchants(currentPage).then(function(list) { ...@@ -2634,18 +2659,26 @@ loadSuperiorMerchants(currentPage).then(function(list) {
} }
// 根据id获取角色详情 // 根据id获取角色详情
function getById() { function getById(parentIdToCheckArr,rolePageParams) {
console.log(
'parentIdToCheckArr',parentIdToCheckArr,
'rolePageParams',rolePageParams
)
var params = { var params = {
method: 'merchants.api.merchant.findPermissionsByMerId', method: 'merchants.api.merchant.findPermissionsByMerId',
id: merchantId id: parentIdToCheckArr ? parentIdToCheckArr : merchantId
} }
request(params, function (res) { request(params, function (res) {
if (res.code == '0') { if (res.code == '0') {
var accounttypeId = '' var accounttypeId = ''
if (res.data) { if (res.data) {
check_arr = res.data check_arr = res.data
if(_currentMerchantLevel == 1){
_initFactoryCheckArr = check_arr
}
} }
findMenuFunTreeByMerId() findMenuFunTreeByMerId(rolePageParams)
form.val('roleForm', { form.val('roleForm', {
roleName: res.data.roleName, roleName: res.data.roleName,
roleDescription: res.data.roleDescription roleDescription: res.data.roleDescription
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!