Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
semour
/
semour_admin
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
9384e9c0
authored
Dec 06, 2022
by
孙龙
Browse files
Options
_('Browse Files')
Download
Plain Diff
Merge branch 'master' of
http://git.ichunt.net/semour/semour_admin
parents
17b8b07a
fa1595cd
Hide whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
70 additions
and
17 deletions
app/Admin/Actions/User/UserAssignAction.php
app/Admin/Controllers/UserController.php
app/Admin/Forms/User/AssignUserHandle.php
app/Admin/Forms/User/EditUserHandle.php
app/Admin/Forms/User/TransferUserHandle.php
app/Admin/Renderable/CreateUser.php
app/Admin/Service/CmsUserService.php
app/Admin/Service/UserService.php
app/Models/Cms/CmsUser.php
resources/lang/en/user.php
resources/lang/zh_CN/user.php
app/Admin/Actions/User/UserAssignAction.php
View file @
9384e9c0
...
...
@@ -19,16 +19,16 @@ class UserAssignAction extends BatchAction
protected
$action
;
protected
$htmlClasses
=
[
'btn btn-primary btn-sm btn-mini'
];
// 注意action的构造方法参数一定要给默认值
public
function
__construct
()
// 注意action的构造方法参数一定要给默认值
1指派,2转让
public
function
__construct
(
$action
=
1
)
{
$this
->
title
=
""
;
$this
->
action
=
1
;
$this
->
action
=
$action
;
}
public
function
render
()
{
$form
=
AssignUserHandle
::
make
();
$form
=
AssignUserHandle
::
make
(
[
'action'
=>
$this
->
action
]
);
$buttonName
=
trans
(
'user.labels.assign'
);
return
Modal
::
make
()
->
lg
()
->
title
(
$this
->
title
)
->
body
(
$form
->
payload
([]))
->
onLoad
(
$this
->
getModalScript
())
->
button
(
'<button class="btn btn-primary">
<i class="feather icon-check-circle"></i><span class="d-none d-sm-inline" style="margin-left: 5px">'
.
$buttonName
.
'</span>
...
...
app/Admin/Controllers/UserController.php
View file @
9384e9c0
...
...
@@ -91,7 +91,7 @@ class UserController extends AdminController
];
$validator
=
Validator
::
make
(
$params
,
[
'company_name'
=>
'required'
,
//
'company_name' => 'required',
'first_name'
=>
'required'
,
'last_name'
=>
'required'
,
'phone'
=>
'required'
,
...
...
@@ -112,6 +112,12 @@ class UserController extends AdminController
$error
=
$validator
->
errors
()
->
first
();
throw
new
\Exception
(
$error
);
}
if
(
$params
[
'account_properties'
]
==
\App\Models\User
::
ACCOUNT_PROPERTIES_ENTERPRISE
)
{
if
(
empty
(
$params
[
'company_name'
]))
{
throw
new
\Exception
(
trans
(
"user.error_msg.requiredByCompanyName"
));
}
}
UserService
::
createUserAndAddress
(
$params
);
}
catch
(
\Throwable
$throwable
)
{
// var_dump((string)$throwable);
...
...
app/Admin/Forms/User/AssignUserHandle.php
View file @
9384e9c0
...
...
@@ -43,7 +43,7 @@ class AssignUserHandle extends Form implements LazyRenderable
{
$this
->
disableResetButton
();
$this
->
hidden
(
'id'
)
->
attribute
(
'id'
,
'id'
);
$this
->
select
(
'sale_id'
)
->
options
(
CmsUser
::
pluck
(
'name'
,
'userId'
)
->
toArray
())
->
default
(
0
)
->
required
();
$this
->
select
(
'sale_id'
)
->
options
(
CmsUser
::
getUserList
())
->
default
(
0
)
->
required
();
}
/**
...
...
app/Admin/Forms/User/EditUserHandle.php
View file @
9384e9c0
...
...
@@ -33,6 +33,11 @@ class EditUserHandle extends Form implements LazyRenderable
$input
=
array_filter
(
$input
,
function
(
$value
)
{
return
$value
!==
null
;
});
if
(
$input
[
'account_properties'
]
==
\App\Models\User
::
ACCOUNT_PROPERTIES_ENTERPRISE
)
{
if
(
empty
(
$input
[
'company_name'
]))
{
throw
new
\Exception
(
trans
(
"user.error_msg.requiredByCompanyName"
));
}
}
User
::
updateById
(
$id
,
$input
);
return
$this
...
...
@@ -53,7 +58,7 @@ class EditUserHandle extends Form implements LazyRenderable
$this
->
disableResetButton
();
$this
->
hidden
(
'id'
)
->
attribute
(
'id'
,
'id'
)
->
width
(
4
);
$this
->
row
(
function
(
Row
$form
)
{
$form
->
width
(
5
)
->
text
(
'company_name'
)
->
required
()
;
$form
->
width
(
5
)
->
text
(
'company_name'
);
$form
->
width
(
5
)
->
text
(
'user_sn'
)
->
disable
();
});
$this
->
row
(
function
(
Row
$form
)
{
...
...
app/Admin/Forms/User/TransferUserHandle.php
View file @
9384e9c0
...
...
@@ -2,6 +2,7 @@
namespace
App\Admin\Forms\User
;
use
App\Admin\Service\PermService
;
use
App\Admin\Service\UserService
;
use
App\Models\Cms\CmsUser
;
use
App\Models\Inquiry
;
...
...
@@ -32,10 +33,47 @@ class TransferUserHandle extends Form implements LazyRenderable
->
refresh
();
}
catch
(
\Throwable
$throwable
)
{
// var_dump((string)$throwable);
return
$this
->
response
()
->
error
(
trans
(
'admin.update_failed'
)
.
":
{
$throwable
->
getMessage
()
}
"
);
return
$this
->
response
()
->
error
(
trans
(
'admin.update_failed'
)
.
":
{
$throwable
->
getMessage
()
}
"
);
}
}
public
function
getCmsUserList
()
{
CmsUser
::
getUserList
();
$where
=
[];
$where
[]
=
[
function
(
$query
)
{
$viewList
=
User
::
$ruleViewList
;
$adminUser
=
"userId"
;
$nowSaleId
=
getAdminUserId
();
if
(
$nowSaleId
==
1000
)
{
return
$query
;
}
//查看所有
if
(
checkPerm
(
$viewList
[
0
]))
{
return
$query
;
}
//查看下级
if
(
checkPerm
(
$viewList
[
1
]))
{
//查看下级的权限//获取用户部门下的所有用户
$userIds
=
PermService
::
getSubUserId
(
$nowSaleId
);
if
(
!
empty
(
$userIds
))
{
return
$query
->
whereIn
(
$adminUser
,
$userIds
);
}
}
//查看同组
$user_info
=
CmsUser
::
getInfoByUserId
(
$nowSaleId
);
if
(
empty
(
$user_info
)
||
!
$user_info
[
'department_id'
])
{
return
$query
->
where
(
$adminUser
,
$nowSaleId
);
}
// 获取下级部门的人员
$sub_user_ids
=
CmsUser
::
getUserIdsByDepartmentIds
([
$user_info
[
'department_id'
]]);
return
$query
->
whereIn
(
$adminUser
,
$sub_user_ids
);
}
];
return
CmsUser
::
where
(
$where
)
->
pluck
(
'name'
,
'userId'
)
->
toArray
();
}
/**
* Build a form here.
*/
...
...
@@ -43,7 +81,7 @@ class TransferUserHandle extends Form implements LazyRenderable
{
$this
->
disableResetButton
();
$this
->
hidden
(
'id'
)
->
attribute
(
'id'
,
'id'
);
$this
->
select
(
'sale_id'
)
->
options
(
CmsUser
::
pluck
(
'name'
,
'userId'
)
->
toArray
())
->
default
(
0
)
->
required
();
$this
->
select
(
'sale_id'
)
->
options
(
$this
->
getCmsUserList
())
->
default
(
0
)
->
required
();
}
/**
...
...
app/Admin/Renderable/CreateUser.php
View file @
9384e9c0
...
...
@@ -26,7 +26,7 @@ class CreateUser extends \Dcat\Admin\Support\LazyRenderable
$form
->
disableResetButton
();
$form
->
disableCreatingCheck
();
$form
->
row
(
function
(
Form\Row
$form
)
{
$form
->
width
(
4
)
->
text
(
'company_name'
)
->
required
()
;
$form
->
width
(
4
)
->
text
(
'company_name'
);
$form
->
width
(
4
)
->
text
(
'user_sn'
)
->
disable
();
});
$form
->
row
(
function
(
Form\Row
$form
)
{
...
...
app/Admin/Service/CmsUserService.php
View file @
9384e9c0
...
...
@@ -9,16 +9,13 @@ class CmsUserService
/**
* 根据不同的部门权限以及部门id来获取员工列表
* getCmsUserListByDepartmentType
* @param $departmentType
* @param $departmentId
* @return array
* @author tioncico
* Time: 9:38 AM
*/
public
static
function
getCmsUserListByDepartmentType
(
$departmentType
,
$departmentId
)
public
static
function
getCmsUserListByDepartmentType
()
{
$res
=
CmsUser
::
pluck
(
'name'
,
'userId'
)
->
toArray
();
$res
=
CmsUser
::
getUserList
();
return
$res
;
}
...
...
app/Admin/Service/UserService.php
View file @
9384e9c0
...
...
@@ -34,7 +34,7 @@ class UserService
$filter
->
startWith
(
'name'
)
->
width
(
2
);
$filter
->
equal
(
'status'
)
->
select
(
admin_trans
(
'user.options.status'
))
->
width
(
2
);
$filter
->
equal
(
'sale_id'
,
trans
(
'user.fields.sale_name'
))
->
select
(
CmsUser
Service
::
getCmsUserListByDepartmentType
(
1
,
0
))
->
width
(
3
);
(
CmsUser
::
getUserList
(
))
->
width
(
3
);
$filter
->
equal
(
'reg_source'
)
->
select
(
admin_trans
(
'user.options.reg_source'
))
->
width
(
2
);
});
}
...
...
app/Models/Cms/CmsUser.php
View file @
9384e9c0
...
...
@@ -2,9 +2,10 @@
namespace
App\Models\Cms
;
use
App\Models\BaseModel
;
use
Illuminate\Database\Eloquent\Model
;
class
CmsUser
extends
Model
class
CmsUser
extends
Base
Model
{
protected
$connection
=
'cms'
;
protected
$table
=
'user_info'
;
...
...
resources/lang/en/user.php
View file @
9384e9c0
...
...
@@ -48,4 +48,7 @@ return [
"2"
=>
"Enterprise"
],
],
"error_msg"
=>
[
"requiredByCompanyName"
=>
"Company name is required when account properties is company"
,
]
];
resources/lang/zh_CN/user.php
View file @
9384e9c0
...
...
@@ -48,4 +48,7 @@ return [
"2"
=>
"企业"
],
],
"error_msg"
=>
[
"requiredByCompanyName"
=>
"当帐户属性为公司时,需要公司名称必填"
,
]
];
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