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
14736857
authored
Aug 08, 2023
by
杨树贤
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
优化树形节点选中
parent
bd80f014
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
29 additions
and
12 deletions
app/Http/Controllers/Api/SupplierAccountApiController.php
app/Http/Services/SupplierSubAccountService.php
resources/views/script/SaveSupplierAccountMessagePermScript.blade.php
resources/views/script/SaveSupplierSubAccountScript.blade.php
resources/views/web/SaveSupplierAccountMessagePerm.blade.php
resources/views/web/SaveSupplierSubAccount.blade.php
app/Http/Controllers/Api/SupplierAccountApiController.php
View file @
14736857
...
...
@@ -196,7 +196,7 @@ class SupplierAccountApiController extends Controller
unset
(
$data
[
'sbat_id'
]);
$result
=
(
new
SupplierSubAccountService
())
->
addSupplierSubAccount
(
$accountId
,
$data
);
}
else
{
$result
=
(
new
SupplierSubAccountService
())
->
add
SupplierSubAccount
(
$accountId
,
$data
);
$result
=
(
new
SupplierSubAccountService
())
->
update
SupplierSubAccount
(
$accountId
,
$data
);
}
if
(
$result
===
true
)
{
$this
->
response
(
0
,
'操作成功'
);
...
...
app/Http/Services/SupplierSubAccountService.php
View file @
14736857
...
...
@@ -100,20 +100,27 @@ class SupplierSubAccountService
}
else
{
$params
[
'method'
]
=
'add'
;
}
// dump($params);
$result
=
json_decode
(
curl
(
$url
,
$params
),
true
);
if
(
isset
(
$result
[
'code'
])
&&
$result
[
'code'
]
==
0
)
{
$permList
=
$result
[
'data'
][
'data'
];
// dump($permList);
//还要转换成layui能用的格式
$list
=
[];
// dump($permList);
foreach
(
$permList
as
$perm
)
{
$children
=
!
empty
(
$perm
[
'children'
])
?
$this
->
getChildPermList
(
$perm
[
'children'
])
:
[];
$list
[]
=
[
'title'
=>
$perm
[
'name'
],
'id'
=>
!
empty
(
$perm
[
'path'
])
?
$perm
[
'path'
]
:
''
,
'checked'
=>
$perm
[
'checked'
],
'checked'
=>
false
,
'disabled'
=>
$perm
[
'disabled'
],
'id'
=>
$perm
[
'id'
],
'spread'
=>
true
,
'children'
=>
!
empty
(
$perm
[
'children'
])
?
$this
->
getChildPermList
(
$perm
[
'children'
])
:
[],
'children'
=>
$children
];
}
// dd($list);
return
$list
;
}
return
[];
...
...
@@ -125,11 +132,12 @@ class SupplierSubAccountService
return
[];
}
$childPermList
=
[];
foreach
(
$perm
as
$item
)
{
foreach
(
$perm
as
$
key
=>
$
item
)
{
$childPermList
[]
=
[
'title'
=>
$item
[
'name'
],
'id'
=>
!
empty
(
$item
[
'
path'
])
?
$item
[
'path'
]
:
''
,
'id'
=>
!
empty
(
$item
[
'
id'
])
?
$item
[
'id'
]
:
str_random
(
100
)
,
'checked'
=>
$item
[
'checked'
],
'disabled'
=>
isset
(
$item
[
'disabled'
])
?
$item
[
'disabled'
]
:
false
,
'spread'
=>
true
,
];
}
...
...
@@ -150,9 +158,9 @@ class SupplierSubAccountService
$list
=
[];
foreach
(
$permList
as
$perm
)
{
$list
[]
=
[
'id'
=>
$perm
[
'id'
],
'title'
=>
$perm
[
'name'
],
'id'
=>
!
empty
(
$perm
[
'path'
])
?
$perm
[
'path'
]
:
''
,
'checked'
=>
$perm
[
'checked'
],
'checked'
=>
false
,
'spread'
=>
true
,
'children'
=>
!
empty
(
$perm
[
'children'
])
?
$this
->
getChildPermList
(
$perm
[
'children'
])
:
[],
];
...
...
@@ -185,6 +193,7 @@ class SupplierSubAccountService
{
$url
=
config
(
'website.CloudUrl'
)
.
'/inner/subAccount/saveMessageMenu '
;
$params
=
$this
->
generateRequestAuthData
(
$accountId
);
$userMessageRule
=
$userMessageRule
?:
[];
$params
[
'user_message_rule'
]
=
is_array
(
$userMessageRule
)
?
json_encode
(
$userMessageRule
)
:
$userMessageRule
;
$result
=
json_decode
(
curl
(
$url
,
$params
,
true
),
true
);
if
(
isset
(
$result
[
'code'
]))
{
...
...
resources/views/script/SaveSupplierAccountMessagePermScript.blade.php
View file @
14736857
...
...
@@ -30,6 +30,7 @@
});
let
messagePermTreeData
=
{
!!
json_encode
(
$messagePerms
)
!!
};
console
.
log
(
messagePermTreeData
);
// 渲染树形组件
let
messagePermTree
=
tree
.
render
({
elem
:
'#messagePermTree'
,
...
...
resources/views/script/SaveSupplierSubAccountScript.blade.php
View file @
14736857
...
...
@@ -34,14 +34,15 @@
});
let
permTreeData
=
{
!!
json_encode
(
$menuPerms
)
!!
};
console
.
log
(
permTreeData
);
// 渲染树形组件
let
permTree
=
tree
.
render
({
elem
:
'#permTree'
,
id
:
'permTree'
,
showCheckbox
:
true
,
data
:
permTreeData
,
cli
ck
:
function
(
obj
)
{
tree
.
reload
(
'permTree
'
);
onche
ck
:
function
(
obj
)
{
$
(
'#permTree .layui-checkbox-disbaled'
).
addClass
(
'layui-form-checked
'
);
}
});
...
...
@@ -52,8 +53,7 @@
id
:
'messagePermTree'
,
showCheckbox
:
true
,
data
:
messagePermTreeData
,
click
:
function
(
obj
)
{
tree
.
reload
(
'messagePermTree'
);
oncheck
:
function
(
obj
)
{
}
});
...
...
@@ -82,5 +82,9 @@
tree
.
reload
(
'messagePermTree'
);
});
$
(
function
()
{
$
(
'#permTree .layui-checkbox-disbaled'
).
addClass
(
'layui-form-checked'
);
});
});
</script>
resources/views/web/SaveSupplierAccountMessagePerm.blade.php
View file @
14736857
...
...
@@ -17,6 +17,7 @@
</blockquote>
<div
class=
"layui-form-item"
>
<button
class=
"layui-btn layui-btn-sm"
type=
"button"
id=
"selectAllMessagePerm"
>
全选
</button>
<br>
<div
id=
"messagePermTree"
></div>
</div>
<div
class=
"layui-form-item"
>
...
...
resources/views/web/SaveSupplierSubAccount.blade.php
View file @
14736857
...
...
@@ -69,6 +69,7 @@
</blockquote>
<div
class=
"layui-form-item"
>
<button
class=
"layui-btn layui-btn-sm"
type=
"button"
id=
"selectAllPerm"
>
全选
</button>
<br>
<div
id=
"permTree"
></div>
</div>
<blockquote
class=
"layui-elem-quote layui-text"
>
...
...
@@ -76,6 +77,7 @@
</blockquote>
<div
class=
"layui-form-item"
>
<button
class=
"layui-btn layui-btn-sm"
type=
"button"
id=
"selectAllMessagePerm"
>
全选
</button>
<br>
<div
id=
"messagePermTree"
></div>
</div>
<div
class=
"layui-form-item"
>
...
...
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