Commit bd80f014 by 杨树贤

完善页面

parent 54833dee
...@@ -212,21 +212,21 @@ class SupplierAccountApiController extends Controller ...@@ -212,21 +212,21 @@ class SupplierAccountApiController extends Controller
$sbatId = $request->input('sbat_id'); $sbatId = $request->input('sbat_id');
$status = $request->input('status'); $status = $request->input('status');
$result = (new SupplierSubAccountService())->changeSupplierSubAccountStatus($accountId, $sbatId, $status); $result = (new SupplierSubAccountService())->changeSupplierSubAccountStatus($accountId, $sbatId, $status);
if ($result) { if ($result === true) {
$this->response(0, '操作成功'); $this->response(0, '操作成功');
} }
$this->response(-1, '操作失败', $result); $this->response(-1, '操作失败', $result);
} }
//删除子账号 //保存消息菜单
public function DeleteSupplierSubAccount($request) public function SaveSupplierAccountMessagePerm($request)
{ {
$id = $request->get('id'); $accountId = $request->get('account_id');
$model = new SupplierAccountModel(); $userMessageRule = $request->input('user_message_rule');
$result = $model->where('id', $id)->delete(); $result = (new SupplierSubAccountService())->saveMessageMenu($accountId, $userMessageRule);
if ($result) { if ($result === true) {
$this->response(0, '禁用成功'); $this->response(0, '保存成功');
} }
$this->response(-1, '禁用失败', $result); $this->response(-1, '保存失败', $result);
} }
} }
...@@ -13,7 +13,13 @@ class SupplierAccountFilter ...@@ -13,7 +13,13 @@ class SupplierAccountFilter
{ {
$map = $request->all(); $map = $request->all();
$model = new SupplierAccountModel(); $model = new SupplierAccountModel();
$query = $model->orderBy('id', 'desc'); $query = $model->where('parent_id',0)->orderBy('id', 'desc');
if (!checkPerm('ViewAllSupplierAccount')) {
$supplierIds = SupplierChannelModel::where('yunxin_channel_uid',$request->user->codeId)->pluck('supplier_id')->toArray();
$query->whereIn('supplier_id', $supplierIds);
}
if (!empty($map['supplier_name'])) { if (!empty($map['supplier_name'])) {
//先去供应商主表找出id //先去供应商主表找出id
$supplierChannelModel = new SupplierChannelModel(); $supplierChannelModel = new SupplierChannelModel();
......
...@@ -115,11 +115,26 @@ class SupplierAccountController extends Controller ...@@ -115,11 +115,26 @@ class SupplierAccountController extends Controller
$this->data['account'] = $account; $this->data['account'] = $account;
} }
$menuPerms = (new SupplierSubAccountService())->getSupplierAccountPermList($accountId, $sbatId); $menuPerms = (new SupplierSubAccountService())->getSupplierAccountPermList($accountId, $sbatId);
//区分主账号还是子账号保存消息权限
if ($sbatId) {
$messagePerms = (new SupplierSubAccountService())->getSupplierAccountMessagePermList($accountId, $ynatId); $messagePerms = (new SupplierSubAccountService())->getSupplierAccountMessagePermList($accountId, $ynatId);
// dd($menuPerms); } else {
$messagePerms = (new SupplierSubAccountService())->getSupplierAccountMessagePermList($accountId, $ynatId);
}
$this->data['menuPerms'] = $menuPerms; $this->data['menuPerms'] = $menuPerms;
$this->data['messagePerms'] = $messagePerms; $this->data['messagePerms'] = $messagePerms;
$this->data['title'] = '子账号编辑'; $this->data['title'] = '子账号编辑';
return $this->view('子账号编辑'); return $this->view('子账号编辑');
} }
//修改主账号的消息权限
//新增修改子账号
public function SaveSupplierAccountMessagePerm($request)
{
$accountId = $request->input('account_id');
$messagePerms = (new SupplierSubAccountService())->getSupplierAccountMessagePermList($accountId, $accountId);
$this->data['messagePerms'] = $messagePerms;
$this->data['title'] = '子账号编辑';
return $this->view('子账号编辑');
}
} }
...@@ -62,12 +62,15 @@ class SupplierSubAccountService ...@@ -62,12 +62,15 @@ class SupplierSubAccountService
$params = $this->generateRequestAuthData($accountId); $params = $this->generateRequestAuthData($accountId);
$params = array_merge($data, $params); $params = array_merge($data, $params);
$result = json_decode(curl($url, $params, true), true); $result = json_decode(curl($url, $params, true), true);
if (isset($result['code']) && $result['code'] == 0) { if (isset($result['code'])) {
if ($result['code'] == 0) {
return true; return true;
} else { } else {
return $result['msg']; return $result['msg'];
} }
} }
return false;
}
public function updateSupplierSubAccount($accountId, $data) public function updateSupplierSubAccount($accountId, $data)
{ {
...@@ -75,12 +78,15 @@ class SupplierSubAccountService ...@@ -75,12 +78,15 @@ class SupplierSubAccountService
$params = $this->generateRequestAuthData($accountId); $params = $this->generateRequestAuthData($accountId);
$params = array_merge($data, $params); $params = array_merge($data, $params);
$result = json_decode(curl($url, $params, true), true); $result = json_decode(curl($url, $params, true), true);
if (isset($result['code']) && $result['code'] == 0) { if (isset($result['code'])) {
if ($result['code'] == 0) {
return true; return true;
} else { } else {
return $result['msg']; return $result['msg'];
} }
} }
return false;
}
//获取用户的权限菜单 //获取用户的权限菜单
...@@ -130,7 +136,7 @@ class SupplierSubAccountService ...@@ -130,7 +136,7 @@ class SupplierSubAccountService
return $childPermList; return $childPermList;
} }
public function getSupplierAccountMessagePermList($accountId, $ynatId) public function getSupplierAccountMessagePermList($accountId, $ynatId = 0)
{ {
$url = config('website.CloudUrl') . '/inner/subAccount/getMessageMenu'; $url = config('website.CloudUrl') . '/inner/subAccount/getMessageMenu';
$params = $this->generateRequestAuthData($accountId); $params = $this->generateRequestAuthData($accountId);
...@@ -165,8 +171,28 @@ class SupplierSubAccountService ...@@ -165,8 +171,28 @@ class SupplierSubAccountService
$params['status'] = $status; $params['status'] = $status;
$params['sbat_id'] = $sbatId; $params['sbat_id'] = $sbatId;
$result = json_decode(curl($url, $params, true), true); $result = json_decode(curl($url, $params, true), true);
if (isset($result['code']) && $result['code'] == 0) { if (isset($result['code'])) {
if ($result['code'] == 0) {
return true; return true;
} else {
return $result['msg'];
}
}
return false;
}
public function saveMessageMenu($accountId, $userMessageRule)
{
$url = config('website.CloudUrl') . '/inner/subAccount/saveMessageMenu ';
$params = $this->generateRequestAuthData($accountId);
$params['user_message_rule'] = is_array($userMessageRule) ? json_encode($userMessageRule) : $userMessageRule;
$result = json_decode(curl($url, $params, true), true);
if (isset($result['code'])) {
if ($result['code'] == 0) {
return true;
} else {
return $result['msg'];
}
} }
return false; return false;
} }
......
<script>
layui.use(['table', 'form', 'tree', 'element', 'table', 'layer', 'admin', 'xmSelect'], function () {
let admin = layui.admin;
let form = layui.form;
let tree = layui.tree;
form.on('submit(saveSupplierAccountMessageMenu)', function (data) {
let userMessageRule = [];
$('#messagePermTree').find('.layui-form-checked').next('span').each(function (index, item) {
userMessageRule.push($(item).text());
});
data.field.account_id = getQueryVariable('account_id');
data.field.user_message_rule = userMessageRule;
let url = '/api/supplier_account/SaveSupplierAccountMessagePerm';
let res = ajax(url, data.field);
if (!res) {
layer.msg('网络错误,请重试', {icon: 6});
} else {
if (res.err_code === 0) {
admin.closeThisDialog();
parent.layer.msg(res.err_msg, {icon: 6});
} else {
parent.layer.msg(res.err_msg, {icon: 5});
}
}
return false;
});
form.on('submit(cancel)', function (data) {
admin.closeThisDialog();
});
let messagePermTreeData = {!! json_encode($messagePerms) !!};
// 渲染树形组件
let messagePermTree = tree.render({
elem: '#messagePermTree',
id: 'messagePermTree',
showCheckbox: true,
data: messagePermTreeData,
click: function (obj) {
tree.reload('messagePermTree');
}
});
function allSelect(data) {
$.each(data, function (index, item) {
item.checked = true;
if (item.children.length) {
$.each(item.children, function (index2, item2) {
if (!item2.checked) {
item2.checked = true;
}
})
}
})
}
$('#selectAllMessagePerm').click(function () {
allSelect(messagePermTreeData);
tree.reload('messagePermTree');
});
});
</script>
...@@ -33,27 +33,54 @@ ...@@ -33,27 +33,54 @@
admin.closeThisDialog(); admin.closeThisDialog();
}); });
let permTreeData = {!! json_encode($menuPerms) !!};
// 渲染树形组件 // 渲染树形组件
tree.render({ let permTree = tree.render({
elem: '#permTree', elem: '#permTree',
id: 'permTree', id: 'permTree',
showCheckbox: true, showCheckbox: true,
data: {!! json_encode($menuPerms) !!}, data: permTreeData,
click: function (obj) { click: function (obj) {
tree.reload('permTree'); tree.reload('permTree');
} }
}); });
let messagePermTreeData = {!! json_encode($messagePerms) !!};
// 渲染树形组件 // 渲染树形组件
tree.render({ let messagePermTree = tree.render({
elem: '#messagePermTree', elem: '#messagePermTree',
id: 'messagePermTree', id: 'messagePermTree',
showCheckbox: true, showCheckbox: true,
data: {!! json_encode($messagePerms) !!}, data: messagePermTreeData,
click: function (obj) { click: function (obj) {
tree.reload('messagePermTree'); tree.reload('messagePermTree');
} }
}); });
function allSelect(data) {
$.each(data, function (index, item) {
item.checked = true;
if (item.children.length) {
$.each(item.children, function (index2, item2) {
if (!item2.checked) {
item2.checked = true;
}
})
}
})
}
$('#selectAllPerm').click(function () {
allSelect(permTreeData);
tree.reload('permTree');
});
$('#selectAllMessagePerm').click(function () {
allSelect(messagePermTreeData);
tree.reload('messagePermTree');
});
}); });
</script> </script>
...@@ -68,8 +68,10 @@ ...@@ -68,8 +68,10 @@
}); });
} }
if (event === 'delete') { if (event === 'delete') {
layer.confirm('你确定要删除该子账号吗?', { let confirmHtml = '<p>确定<span style="color: red">删除</span>当前子账号吗?</p><p style="color: #7f7f7f">' + 'PS:删除后,该子账号从系统清除,无法再登录芯链系统!</p>'
btn: ['确定', '取消'] //按钮 layer.confirm(confirmHtml, {
btn: ['确定', '取消'], //按钮
title: '删除'
}, function (index) { }, function (index) {
const url = '/api/supplier_account/ChangeSupplierSubAccountStatus'; const url = '/api/supplier_account/ChangeSupplierSubAccountStatus';
const data = { const data = {
...@@ -88,8 +90,10 @@ ...@@ -88,8 +90,10 @@
}); });
} }
if (event === 'enable') { if (event === 'enable') {
layer.confirm('你确定要启用该子账号吗?', { let confirmHtml = '<p>确定<span style="color: #00bfbf">启用</span>当前子账号吗?</p><p style="color: #7f7f7f">' + 'PS:启用后,该子账号可登录芯链系统,操作对应权限页面!</p>'
btn: ['确定', '取消'] //按钮 layer.confirm(confirmHtml, {
btn: ['确定', '取消'], //按钮
title: '启用'
}, function (index) { }, function (index) {
const url = '/api/supplier_account/ChangeSupplierSubAccountStatus'; const url = '/api/supplier_account/ChangeSupplierSubAccountStatus';
const data = { const data = {
...@@ -110,8 +114,10 @@ ...@@ -110,8 +114,10 @@
} }
if (event === 'disable') { if (event === 'disable') {
layer.confirm('你确定要禁用该子账号吗?', { let confirmHtml = '<p>确定<span style="color: orange">禁用</span>当前子账号吗?</p><p style="color: #7f7f7f">' + 'PS:禁用后,该子账号无法再登录芯链系统!</p>'
btn: ['确定', '取消'] //按钮 layer.confirm(confirmHtml, {
btn: ['确定', '取消'],
title: '禁用'
}, function (index) { }, function (index) {
const url = '/api/supplier_account/ChangeSupplierSubAccountStatus'; const url = '/api/supplier_account/ChangeSupplierSubAccountStatus';
const data = { const data = {
...@@ -146,6 +152,24 @@ ...@@ -146,6 +152,24 @@
}); });
$('#saveSupplierAccountMessagePerm').click(function () {
let accountId = getQueryVariable('account_id');
layer.open({
type: 2,
area: ['75%', '75%'],
fixed: false,
title: '详情',
content: '/supplier_account/SaveSupplierAccountMessagePerm?view=iframe&account_id=' + accountId,
end: function () {
table.reload('supplierSubAccountList', {
page: {
curr: 1 //重新从第 1 页开始
},
});
}
});
});
form.on('submit(load)', function (data) { form.on('submit(load)', function (data) {
whereCondition = $.extend(false, initCondition, data.field); whereCondition = $.extend(false, initCondition, data.field);
//执行重载 //执行重载
......
<style>
.layui-form-item {
margin-bottom: 5px;
}
.layui-tree .layui-tree-set {
display: inline-block;
margin-right: 10px; /* 控制节点之间的水平间距 */
vertical-align: top; /* 将节点对齐到顶部 */
}
</style>
<div class="layui-card">
<div class="layui-card-body">
<form class="layui-form" action="">
<blockquote class="layui-elem-quote layui-text">
<b>消息推送配置</b>
</blockquote>
<div class="layui-form-item">
<button class="layui-btn layui-btn-sm" type="button" id="selectAllMessagePerm">全选</button>
<div id="messagePermTree"></div>
</div>
<div class="layui-form-item">
<div align="center" style="margin-top: 20px;text-align: right">
<button type="button" class="layui-btn layui-btn-sm layui-btn-info submit-loading" lay-submit
lay-filter="saveSupplierAccountMessageMenu">确定
</button>
<button type="button" class="layui-btn layui-btn-sm layui-btn-primary" lay-submit
lay-filter="cancel">取消
</button>
</div>
</div>
</form>
</div>
</div>
...@@ -68,12 +68,14 @@ ...@@ -68,12 +68,14 @@
style="color: orange;font-size: 16px"></i> 勾选以下页面后,子账号可以看到对应的页面内容并进行操作;没有勾选的页面,子账号则无权查看;</span> </span> style="color: orange;font-size: 16px"></i> 勾选以下页面后,子账号可以看到对应的页面内容并进行操作;没有勾选的页面,子账号则无权查看;</span> </span>
</blockquote> </blockquote>
<div class="layui-form-item"> <div class="layui-form-item">
<button class="layui-btn layui-btn-sm" type="button" id="selectAllPerm">全选</button>
<div id="permTree"></div> <div id="permTree"></div>
</div> </div>
<blockquote class="layui-elem-quote layui-text"> <blockquote class="layui-elem-quote layui-text">
<b>子账号消息推送配置</b> <b>子账号消息推送配置</b>
</blockquote> </blockquote>
<div class="layui-form-item"> <div class="layui-form-item">
<button class="layui-btn layui-btn-sm" type="button" id="selectAllMessagePerm">全选</button>
<div id="messagePermTree"></div> <div id="messagePermTree"></div>
</div> </div>
<div class="layui-form-item"> <div class="layui-form-item">
......
...@@ -53,7 +53,7 @@ ...@@ -53,7 +53,7 @@
<td>{{$supplierAccount['email']}}</td> <td>{{$supplierAccount['email']}}</td>
<td>{{$supplierAccount['create_time']}}</td> <td>{{$supplierAccount['create_time']}}</td>
<td> <td>
<button class="layui-btn layui-btn-sm" id="updateSupplierAccountPerm">详情</button> <button class="layui-btn layui-btn-sm" id="saveSupplierAccountMessagePerm">详情</button>
</td> </td>
</tr> </tr>
</tbody> </tbody>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment