Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
杨树贤
/
liexin_supplier
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
bd80f014
authored
Aug 08, 2023
by
杨树贤
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
完善页面
parent
54833dee
Show whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
225 additions
and
26 deletions
app/Http/Controllers/Api/SupplierAccountApiController.php
app/Http/Controllers/Filter/SupplierAccountFilter.php
app/Http/Controllers/SupplierAccountController.php
app/Http/Services/SupplierSubAccountService.php
resources/views/script/SaveSupplierAccountMessagePermScript.blade.php
resources/views/script/SaveSupplierSubAccountScript.blade.php
resources/views/script/SupplierSubAccountListScript.blade.php
resources/views/web/SaveSupplierAccountMessagePerm.blade.php
resources/views/web/SaveSupplierSubAccount.blade.php
resources/views/web/SupplierSubAccountList.blade.php
app/Http/Controllers/Api/SupplierAccountApiController.php
View file @
bd80f014
...
...
@@ -212,21 +212,21 @@ class SupplierAccountApiController extends Controller
$sbatId
=
$request
->
input
(
'sbat_id'
);
$status
=
$request
->
input
(
'status'
);
$result
=
(
new
SupplierSubAccountService
())
->
changeSupplierSubAccountStatus
(
$accountId
,
$sbatId
,
$status
);
if
(
$result
)
{
if
(
$result
===
true
)
{
$this
->
response
(
0
,
'操作成功'
);
}
$this
->
response
(
-
1
,
'操作失败'
,
$result
);
}
//
删除子账号
public
function
DeleteSupplierSubAccount
(
$request
)
//
保存消息菜单
public
function
SaveSupplierAccountMessagePerm
(
$request
)
{
$
id
=
$request
->
get
(
'
id'
);
$
model
=
new
SupplierAccountModel
(
);
$result
=
$model
->
where
(
'id'
,
$id
)
->
delete
(
);
if
(
$result
)
{
$this
->
response
(
0
,
'
禁用
成功'
);
$
accountId
=
$request
->
get
(
'account_
id'
);
$
userMessageRule
=
$request
->
input
(
'user_message_rule'
);
$result
=
(
new
SupplierSubAccountService
())
->
saveMessageMenu
(
$accountId
,
$userMessageRule
);
if
(
$result
===
true
)
{
$this
->
response
(
0
,
'
保存
成功'
);
}
$this
->
response
(
-
1
,
'
禁用
失败'
,
$result
);
$this
->
response
(
-
1
,
'
保存
失败'
,
$result
);
}
}
app/Http/Controllers/Filter/SupplierAccountFilter.php
View file @
bd80f014
...
...
@@ -13,7 +13,13 @@ class SupplierAccountFilter
{
$map
=
$request
->
all
();
$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'
]))
{
//先去供应商主表找出id
$supplierChannelModel
=
new
SupplierChannelModel
();
...
...
app/Http/Controllers/SupplierAccountController.php
View file @
bd80f014
...
...
@@ -115,11 +115,26 @@ class SupplierAccountController extends Controller
$this
->
data
[
'account'
]
=
$account
;
}
$menuPerms
=
(
new
SupplierSubAccountService
())
->
getSupplierAccountPermList
(
$accountId
,
$sbatId
);
//区分主账号还是子账号保存消息权限
if
(
$sbatId
)
{
$messagePerms
=
(
new
SupplierSubAccountService
())
->
getSupplierAccountMessagePermList
(
$accountId
,
$ynatId
);
// dd($menuPerms);
}
else
{
$messagePerms
=
(
new
SupplierSubAccountService
())
->
getSupplierAccountMessagePermList
(
$accountId
,
$ynatId
);
}
$this
->
data
[
'menuPerms'
]
=
$menuPerms
;
$this
->
data
[
'messagePerms'
]
=
$messagePerms
;
$this
->
data
[
'title'
]
=
'子账号编辑'
;
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
(
'子账号编辑'
);
}
}
app/Http/Services/SupplierSubAccountService.php
View file @
bd80f014
...
...
@@ -62,12 +62,15 @@ class SupplierSubAccountService
$params
=
$this
->
generateRequestAuthData
(
$accountId
);
$params
=
array_merge
(
$data
,
$params
);
$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
;
}
else
{
return
$result
[
'msg'
];
}
}
return
false
;
}
public
function
updateSupplierSubAccount
(
$accountId
,
$data
)
{
...
...
@@ -75,12 +78,15 @@ class SupplierSubAccountService
$params
=
$this
->
generateRequestAuthData
(
$accountId
);
$params
=
array_merge
(
$data
,
$params
);
$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
;
}
else
{
return
$result
[
'msg'
];
}
}
return
false
;
}
//获取用户的权限菜单
...
...
@@ -130,7 +136,7 @@ class SupplierSubAccountService
return
$childPermList
;
}
public
function
getSupplierAccountMessagePermList
(
$accountId
,
$ynatId
)
public
function
getSupplierAccountMessagePermList
(
$accountId
,
$ynatId
=
0
)
{
$url
=
config
(
'website.CloudUrl'
)
.
'/inner/subAccount/getMessageMenu'
;
$params
=
$this
->
generateRequestAuthData
(
$accountId
);
...
...
@@ -165,8 +171,28 @@ class SupplierSubAccountService
$params
[
'status'
]
=
$status
;
$params
[
'sbat_id'
]
=
$sbatId
;
$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
;
}
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
;
}
...
...
resources/views/script/SaveSupplierAccountMessagePermScript.blade.php
0 → 100644
View file @
bd80f014
<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>
resources/views/script/SaveSupplierSubAccountScript.blade.php
View file @
bd80f014
...
...
@@ -33,27 +33,54 @@
admin
.
closeThisDialog
();
});
let
permTreeData
=
{
!!
json_encode
(
$menuPerms
)
!!
};
// 渲染树形组件
tree
.
render
({
let
permTree
=
tree
.
render
({
elem
:
'#permTree'
,
id
:
'permTree'
,
showCheckbox
:
true
,
data
:
{
!!
json_encode
(
$menuPerms
)
!!
}
,
data
:
permTreeData
,
click
:
function
(
obj
)
{
tree
.
reload
(
'permTree'
);
}
});
let
messagePermTreeData
=
{
!!
json_encode
(
$messagePerms
)
!!
};
// 渲染树形组件
tree
.
render
({
let
messagePermTree
=
tree
.
render
({
elem
:
'#messagePermTree'
,
id
:
'messagePermTree'
,
showCheckbox
:
true
,
data
:
{
!!
json_encode
(
$messagePerms
)
!!
}
,
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
;
}
})
}
})
}
$
(
'#selectAllPerm'
).
click
(
function
()
{
allSelect
(
permTreeData
);
tree
.
reload
(
'permTree'
);
});
$
(
'#selectAllMessagePerm'
).
click
(
function
()
{
allSelect
(
messagePermTreeData
);
tree
.
reload
(
'messagePermTree'
);
});
});
</script>
resources/views/script/SupplierSubAccountListScript.blade.php
View file @
bd80f014
...
...
@@ -68,8 +68,10 @@
});
}
if (event === '
delete
') {
layer.confirm('
你确定要删除该子账号吗?
', {
btn: ['
确定
', '
取消
'] //按钮
let confirmHtml = '
<
p
>
确定
<
span
style
=
"color: red"
>
删除
<
/span>当前子账号吗?</
p
><
p
style
=
"color: #7f7f7f"
>
' + '
PS
:删除后,该子账号从系统清除,无法再登录芯链系统!
<
/p>
'
layer
.
confirm
(
confirmHtml
,
{
btn
:
[
'确定'
,
'取消'
],
//按钮
title
:
'删除'
},
function
(
index
)
{
const
url
=
'/api/supplier_account/ChangeSupplierSubAccountStatus'
;
const
data
=
{
...
...
@@ -88,8 +90,10 @@
});
}
if
(
event
===
'enable'
)
{
layer.confirm('
你确定要启用该子账号吗?
', {
btn: ['
确定
', '
取消
'] //按钮
let
confirmHtml
=
'
<
p
>
确定
<
span
style
=
"color: #00bfbf"
>
启用
<
/span>当前子账号吗?</
p
><
p
style
=
"color: #7f7f7f"
>
' + '
PS
:启用后,该子账号可登录芯链系统,操作对应权限页面!
<
/p>
'
layer
.
confirm
(
confirmHtml
,
{
btn
:
[
'确定'
,
'取消'
],
//按钮
title
:
'启用'
},
function
(
index
)
{
const
url
=
'/api/supplier_account/ChangeSupplierSubAccountStatus'
;
const
data
=
{
...
...
@@ -110,8 +114,10 @@
}
if
(
event
===
'disable'
)
{
layer.confirm('
你确定要禁用该子账号吗?
', {
btn: ['
确定
', '
取消
'] //按钮
let
confirmHtml
=
'
<
p
>
确定
<
span
style
=
"color: orange"
>
禁用
<
/span>当前子账号吗?</
p
><
p
style
=
"color: #7f7f7f"
>
' + '
PS
:禁用后,该子账号无法再登录芯链系统!
<
/p>
'
layer
.
confirm
(
confirmHtml
,
{
btn
:
[
'确定'
,
'取消'
],
title
:
'禁用'
},
function
(
index
)
{
const
url
=
'/api/supplier_account/ChangeSupplierSubAccountStatus'
;
const
data
=
{
...
...
@@ -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
)
{
whereCondition
=
$
.
extend
(
false
,
initCondition
,
data
.
field
);
//执行重载
...
...
resources/views/web/SaveSupplierAccountMessagePerm.blade.php
0 → 100644
View file @
bd80f014
<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>
resources/views/web/SaveSupplierSubAccount.blade.php
View file @
bd80f014
...
...
@@ -68,12 +68,14 @@
style=
"color: orange;font-size: 16px"
></i>
勾选以下页面后,子账号可以看到对应的页面内容并进行操作;没有勾选的页面,子账号则无权查看;
</span>
</span>
</blockquote>
<div
class=
"layui-form-item"
>
<button
class=
"layui-btn layui-btn-sm"
type=
"button"
id=
"selectAllPerm"
>
全选
</button>
<div
id=
"permTree"
></div>
</div>
<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"
>
...
...
resources/views/web/SupplierSubAccountList.blade.php
View file @
bd80f014
...
...
@@ -53,7 +53,7 @@
<td>
{{$supplierAccount['email']}}
</td>
<td>
{{$supplierAccount['create_time']}}
</td>
<td>
<button
class=
"layui-btn layui-btn-sm"
id=
"
updateSupplierAccount
Perm"
>
详情
</button>
<button
class=
"layui-btn layui-btn-sm"
id=
"
saveSupplierAccountMessage
Perm"
>
详情
</button>
</td>
</tr>
</tbody>
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment