Commit c137a733 by 前端

更新代码

1 parent 54da19d1
......@@ -765,7 +765,8 @@ var mySelect = layui.xmSelect.render({
}
},
on: function(data) {
console.log(data)
var handleAccountTypeToArray = data?.arr[0].accountType.split(',')
renderAccountTypes(handleAccountTypeToArray)
}
});
......@@ -1726,17 +1727,24 @@ function uniqueNodes(nodes) {
}
// 设置账户等级下拉框的初始值
// 设置账户等级下拉框的初始值
var accountLevel = merchantForm.merchantAccountLevel; // 获取账户等级
$('#accountLevelElTab').val(accountLevel); // 设置select元素的值
// 根据账户等级决定是否显示或隐藏上级商户
if (accountLevel === '1') { // 假设'1'代表工厂
if (accountLevel == '1') { // 假设'1'代表工厂
$('#superiorMerchantContainer').hide();
} else {
$('#superiorMerchantContainer').show();
}
// 插个眼账户类型
// 获取并处理上级账户类型
var superiorAccountType = merchantForm.superiorAccountType?.split(','); // 假设是以逗号分隔的字符串
renderAccountTypes(superiorAccountType,accountLevel);
// 更新 LayUI 表单视图
form.render('select');
......@@ -1744,13 +1752,11 @@ function uniqueNodes(nodes) {
// 页面加载时获取初始数据
loadSuperiorMerchants(currentPage).then(function(list) {
mySelect.update({ data: list });
mySelect.setValue([{name:merchantForm.superiorMerchantName, value:merchantForm.superiorMerchantNo}]);
if(merchantForm?.superiorMerchantName && merchantForm?.superiorMerchantNo){
mySelect.setValue([{name:merchantForm.superiorMerchantName, value:merchantForm.superiorMerchantNo}]);
}
});
// 插个眼账户类型
// 获取并处理上级账户类型
var superiorAccountType = merchantForm.superiorAccountType?.split(','); // 假设是以逗号分隔的字符串
renderAccountTypes(superiorAccountType);
// 省市回显
if (merchantForm.provinceName) {
......@@ -1798,18 +1804,23 @@ loadSuperiorMerchants(currentPage).then(function(list) {
// merchantId, check_arr
function renderAccountTypes(types, accountLevel) {
if(!types) types = []
var el = $('#accountTypeElRole');
el.empty(); // Clear existing contents
function renderAccountTypes(types, merchantId, check_arr) {
var el = $('#accountTypeElRole');
el.empty(); // Clear existing contents
// Assumed mapping object
var typeMapping = {};
getDictData('account_type', function (res) {
res.data.forEach(function(dict) {
// Assumed mapping object
var typeMapping = {};
getDictData('account_type', function (res) {
res.data.forEach(function(dict) {
typeMapping[dict.dictValue] = dict.dictLabel;
});
if(accountLevel == 1){
for(let i in typeMapping){
types.push(i)
}
}
types?.forEach(function(type) {
var typeLabel = typeMapping[type]; // Get the label corresponding to the type
var checkboxHtml = '<input type="checkbox" class="accounttypeId" name="accountType[' + type + ']" value="' + type + '" title="' + typeLabel + '">';
......@@ -2325,6 +2336,10 @@ loadSuperiorMerchants(currentPage).then(function(list) {
// 查询商户的菜单权限树
function findMenuFunTreeByMerId() {
var params = {}
console.log('parentMerchantId',parentMerchantId)
console.log('merchantId',merchantId)
console.log('accountlevel',merchantForm.merchantAccountLevel)
console.log('ids',merchantForm.accountType)
if (parentMerchantId) {
params = {
method: 'merchants.api.merchant.findMenuFunTreeByMerId',
......@@ -2341,6 +2356,7 @@ loadSuperiorMerchants(currentPage).then(function(list) {
}
}
request(params, function (res) {
console.log(res)
if (res.code == '0') {
menuFunTreeData = res.data
var accountType = $('#accountType')
......@@ -2355,7 +2371,6 @@ loadSuperiorMerchants(currentPage).then(function(list) {
var id = item.accounttypeId
str.attr('checked', true)
var obj = { title: item.accounttypeName, value: item.accounttypeId }
console.log('merchantId',merchantId)
active.tabAdd(obj, productData.products)
if (productData.products && productData.products.length != 0) {
productData.products.forEach(j => {
......@@ -2541,7 +2556,7 @@ loadSuperiorMerchants(currentPage).then(function(list) {
function submitAuth() {
var accountLevel = $('#accountLevelElTab').val();
var superiorMerchant = layui.xmSelect.get('#superiorMerchantSelect', true).getValue();
var superiorMerchant = layui.xmSelect.get('#superiorMerchantSelect', true)?.getValue();
var accountTypeElements = $('#accountTypeElRole input[type="checkbox"]:checked');
var accountTypes = [];
......@@ -2549,11 +2564,18 @@ loadSuperiorMerchants(currentPage).then(function(list) {
accountTypes.push($(this).val());
});
if (accountLevel !== '1' && superiorMerchant.length ==0) {
layer.msg('请选择上级商户', {icon: 2});
return;
}
if (accountTypes.length === 0) {
// 如果没有勾选任何账户类型
layer.msg('请选择账户类型', {icon: 2});
return;
}
if (!accountInfo && merchantAccountLevel == 4 && qs('status') == 1 && !merchantForm.effectiveStarttime) {
layer.msg('请去“修改基本信息”填写账户有效期', {
icon: 2
......@@ -2566,7 +2588,7 @@ loadSuperiorMerchants(currentPage).then(function(list) {
merchantId: merchantId,
accountTypes: JSON.stringify(requestList),
merchantAccountLevel: accountLevel,
merchantNoTarget: superiorMerchant[0].value,
merchantNoTarget: accountLevel == '1'? '' : superiorMerchant[0]?.value,
accountType: accountTypes.join(',')
}
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!