Commit f14f0cc6 by 前端

优化代码

1 parent fbf6891a
...@@ -741,10 +741,10 @@ var _currentMerchantLevel = '' //当前的账户等级 ...@@ -741,10 +741,10 @@ var _currentMerchantLevel = '' //当前的账户等级
var _superMerchantInfo= {} //上级商户的信息 var _superMerchantInfo= {} //上级商户的信息
var _searchValue = '' var _searchValue = ''
var _searchCount = 0 var _searchCount = 0
var _initFactoryCheckArr = [] // var _initFactoryCheckArr = []
function loadSuperiorMerchants(pageNum = 1) { function loadSuperiorMerchants(pageNum = 1) {
console.log('accountLevelUpdate',_currentMerchantLevel) // console.log('accountLevelUpdate',_currentMerchantLevel)
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
var params = { var params = {
method: 'merchants.api.open.findMerchantListByPage', method: 'merchants.api.open.findMerchantListByPage',
...@@ -905,7 +905,7 @@ form.on('checkbox', function(data) { ...@@ -905,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() {
...@@ -950,10 +950,11 @@ function prepareExecuteFindMenuFun(){ ...@@ -950,10 +950,11 @@ function prepareExecuteFindMenuFun(){
accountLevel:_currentMerchantLevel accountLevel:_currentMerchantLevel
} }
} }
getById( findMenuFunTreeByMerId(rolePageParams)
// _superMerchantInfo?.parentId // getById(
rolePageParams) // // _superMerchantInfo?.parentId
// findMenuFunTreeByMerId(rolePageParams) // rolePageParams)
// // findMenuFunTreeByMerId(rolePageParams)
} }
function clearRoleAuthTabContent() { function clearRoleAuthTabContent() {
// 清空特定选项卡标题 // 清空特定选项卡标题
...@@ -1049,16 +1050,16 @@ function clearRoleAuthTabContent() { ...@@ -1049,16 +1050,16 @@ function clearRoleAuthTabContent() {
_currentMerchantLevel = data.value _currentMerchantLevel = data.value
if(data.value == 3) $('#accountLevelElTab option[value="2"]').prop('disabled',true) 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) $('#accountLevelElTab option[value="3"]').prop('disabled',true)
if(data.value ==2 && _subMerchantNoList?.length>0 || data.value ==3 && _subMerchantNoList?.length>0 ){ if(data.value == 2 && _subMerchantNoList?.length>0 || data.value ==3 && _subMerchantNoList?.length>0 ){
$("#accountLevelElTab").attr("disabled", "disabled"); $("#accountLevelElTab").attr("disabled", "disabled");
$("#accountLevelElTab").attr("style", "background-color: #EEEEEE;"); $("#accountLevelElTab").attr("style", "background-color: #EEEEEE;");
} }
console.log('账户等级下拉框的渲染账户类型参数', // console.log('账户等级下拉框的渲染账户类型参数',
'上级商户类型',_superMerchantInfo?.accountType?.split(','), // '上级商户类型',_superMerchantInfo?.accountType?.split(','),
'本身的商户类型',merchantForm.accountType, // '本身的商户类型',merchantForm.accountType,
'本身的子商户类型',merchantForm.subAccountTypeList, // '本身的子商户类型',merchantForm.subAccountTypeList,
'页面的账户等级',_currentMerchantLevel) // '页面的账户等级',_currentMerchantLevel)
renderAccountTypes(_superMerchantInfo?.accountType?.split(','), merchantForm.accountType, merchantForm.subAccountTypeList,_currentMerchantLevel); renderAccountTypes(_superMerchantInfo?.accountType?.split(','), merchantForm.accountType, merchantForm.subAccountTypeList,_currentMerchantLevel);
clearRoleAuthTabContent(); clearRoleAuthTabContent();
...@@ -1071,7 +1072,7 @@ function clearRoleAuthTabContent() { ...@@ -1071,7 +1072,7 @@ function clearRoleAuthTabContent() {
// var $accountLevelElTab = $('#accountLevelElTab'); // var $accountLevelElTab = $('#accountLevelElTab');
// var $options = $accountLevelElTab.find('option'); // var $options = $accountLevelElTab.find('option');
// var $superiorMerchantContainer = $('#superiorMerchantContainer'); // var $superiorMerchantContainer = $('#superiorMerchantContainer');
// var _currentMerchantLevel = data.value; // _currentMerchantLevel = data.value;
// function setOptionsDisabled(disabled) { // function setOptionsDisabled(disabled) {
// $options.each(function() { // $options.each(function() {
...@@ -1350,7 +1351,7 @@ function clearRoleAuthTabContent() { ...@@ -1350,7 +1351,7 @@ function clearRoleAuthTabContent() {
} }
}) })
params.merchantBrandListJson = JSON.stringify(merchantForm.merchantBrandList) params.merchantBrandListJson = JSON.stringify(merchantForm.merchantBrandList)
console.log(params.merchantBrandListJson) // console.log(params.merchantBrandListJson)
} }
if (merchantForm.merchantFiles.length) { if (merchantForm.merchantFiles.length) {
params.merchantFiles = JSON.stringify(merchantForm.merchantFiles) params.merchantFiles = JSON.stringify(merchantForm.merchantFiles)
...@@ -1989,7 +1990,7 @@ loadSuperiorMerchants(currentPage).then(function(list) { ...@@ -1989,7 +1990,7 @@ loadSuperiorMerchants(currentPage).then(function(list) {
parentId:merchantForm.parentId, parentId:merchantForm.parentId,
accountType:merchantForm.superiorAccountType accountType:merchantForm.superiorAccountType
} }
console.log(merchantForm) // console.log(merchantForm)
mySelect.setValue([{ mySelect.setValue([{
name:merchantForm.superiorMerchantName, name:merchantForm.superiorMerchantName,
value:merchantForm.superiorMerchantNo, value:merchantForm.superiorMerchantNo,
...@@ -2435,7 +2436,7 @@ loadSuperiorMerchants(currentPage).then(function(list) { ...@@ -2435,7 +2436,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) // 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)
...@@ -2561,7 +2562,6 @@ loadSuperiorMerchants(currentPage).then(function(list) { ...@@ -2561,7 +2562,6 @@ 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
...@@ -2590,29 +2590,28 @@ loadSuperiorMerchants(currentPage).then(function(list) { ...@@ -2590,29 +2590,28 @@ loadSuperiorMerchants(currentPage).then(function(list) {
if (res.code == '0') { if (res.code == '0') {
menuFunTreeData = res.data menuFunTreeData = res.data
// 插个眼 // 插个眼
console.log('check_arr',check_arr) // console.log('check_arr',check_arr)
console.log('menuFunTreeData',menuFunTreeData) // console.log('menuFunTreeData',menuFunTreeData)
console.log('_initFactoryCheckArr',_initFactoryCheckArr) // console.log('_initFactoryCheckArr',_initFactoryCheckArr)
// 下周优化 // 下周优化
if(_initFactoryCheckArr && _currentMerchantLevel == 1){ // if(_initFactoryCheckArr && _currentMerchantLevel == 1){
menuFunTreeData.forEach(item => { // menuFunTreeData.forEach(item => {
if(!_initFactoryCheckArr.some(initItem => initItem.accounttypeId == item.accounttypeId)){ // if(!_initFactoryCheckArr.some(initItem => initItem.accounttypeId == item.accounttypeId)){
const newItem = {...item,products:[]} // const newItem = {...item,products:[]}
_initFactoryCheckArr.push(newItem) // _initFactoryCheckArr.push(newItem)
} // }
}) // })
}else{ // }else{
menuFunTreeData.forEach(item => { menuFunTreeData.forEach(item => {
if(!check_arr.some(initItem => initItem.accounttypeId == item.accounttypeId)){ if(!check_arr.some(initItem => initItem.accounttypeId == item.accounttypeId)){
const newItem = {...item,products:[]} const newItem = {...item,products:[]}
check_arr.push(newItem) check_arr.push(newItem)
} }
}) })
} // }
console.log(check_arr) check_arr = check_arr.filter(item =>_currentaccountType.includes(String(item.accounttypeId)))
// check_arr =_currentMerchantLevel == 1 ? _initFactoryCheckArr : check_arr.filter(item =>_currentaccountType.includes(String(item.accounttypeId)))
check_arr =_currentMerchantLevel == 1 ? _initFactoryCheckArr : check_arr.filter(item =>_currentaccountType.includes(String(item.accounttypeId))))
var accountType = $('#accountType') var accountType = $('#accountType')
accountType.empty() accountType.empty()
...@@ -2626,7 +2625,6 @@ loadSuperiorMerchants(currentPage).then(function(list) { ...@@ -2626,7 +2625,6 @@ 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) {
productData.products.forEach(j => { productData.products.forEach(j => {
...@@ -2682,9 +2680,9 @@ loadSuperiorMerchants(currentPage).then(function(list) { ...@@ -2682,9 +2680,9 @@ loadSuperiorMerchants(currentPage).then(function(list) {
var accounttypeId = '' var accounttypeId = ''
if (res.data) { if (res.data) {
check_arr = res.data check_arr = res.data
if(_currentMerchantLevel == 1){ // if(_currentMerchantLevel == 1){
_initFactoryCheckArr = check_arr // _initFactoryCheckArr = check_arr
} // }
} }
findMenuFunTreeByMerId(rolePageParams) findMenuFunTreeByMerId(rolePageParams)
form.val('roleForm', { form.val('roleForm', {
...@@ -2854,7 +2852,8 @@ loadSuperiorMerchants(currentPage).then(function(list) { ...@@ -2854,7 +2852,8 @@ loadSuperiorMerchants(currentPage).then(function(list) {
merchantNoTarget: superiorMerchant[0]?.value, merchantNoTarget: superiorMerchant[0]?.value,
accountType: accountTypes.join(',') accountType: accountTypes.join(',')
} }
console.log(params.accountTypes) // console.log(superiorMerchant)
// console.log('params.merchantNoTarget',params.merchantNoTarget)
accountLevel == '1' && delete params.merchantNoTarget accountLevel == '1' && delete params.merchantNoTarget
params.method = 'merchants.api.merchant.updatePermissions' params.method = 'merchants.api.merchant.updatePermissions'
// 草稿 // 草稿
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!