Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in / Register
Toggle navigation
L
laravelzh
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
冯超鹏
laravelzh
Commits
74522788
Commit
74522788
authored
Dec 11, 2020
by
Administrator
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
编辑用户
parent
4bf1f661
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
131 additions
and
3 deletions
+131
-3
UserController.php
app/Http/Controllers/UserController.php
+15
-2
2020_12_08_155345_create_user_roles_table.php
.../migrations/2020_12_08_155345_create_user_roles_table.php
+32
-0
2020_12_11_134805_add_phone_and_user_role_id_to_users_table.php
...2_11_134805_add_phone_and_user_role_id_to_users_table.php
+34
-0
UserRolesSeeder.php
database/seeds/UserRolesSeeder.php
+22
-0
index.vue
resources/js/views/user/index.vue
+28
-1
No files found.
app/Http/Controllers/UserController.php
View file @
74522788
...
...
@@ -280,8 +280,21 @@ class UserController extends Controller
->
leftjoin
(
'areachina as p'
,
'b.provinceid'
,
'='
,
'p.areaid'
)
->
leftjoin
(
'areachina as c'
,
'b.cityid'
,
'='
,
'c.areaid'
)
->
leftjoin
(
'areachina as a'
,
'b.areaid'
,
'='
,
'a.areaid'
)
->
leftJoin
(
'user_roles AS ur'
,
'b.user_role_id'
,
'='
,
'ur.id'
)
->
orderBy
(
'b.id'
,
'desc'
)
->
select
(
'b.username'
,
'b.id'
,
'b.created_at'
,
'b.name'
,
'b.email'
,
'b.state'
,
'a.area_name as area'
,
'c.area_name as city'
,
'p.area_name as province'
)
->
select
(
'b.username'
,
'b.id'
,
'b.created_at'
,
'b.name'
,
'b.email'
,
'b.state'
,
'b.phone_number'
,
'ur.name AS role_name'
,
'a.area_name as area'
,
'c.area_name as city'
,
'p.area_name as province'
)
->
offset
(
$pagenNum
)
->
limit
(
$limit
)
->
get
();
...
...
@@ -434,7 +447,7 @@ class UserController extends Controller
return
$this
->
jsonErrorData
(
105
,
'用户id不能为空'
);
}
$userdata
=
Users
::
where
(
'id'
,
'='
,
$userid
)
->
select
(
'username'
,
'name'
,
'email'
,
'title'
,
'company'
,
'mapcenter'
)
->
select
(
'username'
,
'name'
,
'email'
,
'title'
,
'company'
,
'mapcenter'
,
'phone_number'
,
'user_role_id'
)
->
first
();
if
(
$userdata
)
{
return
$this
->
jsonSuccessData
(
$userdata
);
...
...
database/migrations/2020_12_08_155345_create_user_roles_table.php
0 → 100644
View file @
74522788
<?php
use
Illuminate\Database\Migrations\Migration
;
use
Illuminate\Database\Schema\Blueprint
;
use
Illuminate\Support\Facades\Schema
;
class
CreateUserRolesTable
extends
Migration
{
/**
* Run the migrations.
*
* @return void
*/
public
function
up
()
{
Schema
::
create
(
'user_roles'
,
function
(
Blueprint
$table
)
{
$table
->
id
();
$table
->
string
(
'name'
)
->
unique
();
$table
->
timestamps
();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public
function
down
()
{
Schema
::
dropIfExists
(
'user_roles'
);
}
}
database/migrations/2020_12_11_134805_add_phone_and_user_role_id_to_users_table.php
0 → 100644
View file @
74522788
<?php
use
Illuminate\Database\Migrations\Migration
;
use
Illuminate\Database\Schema\Blueprint
;
use
Illuminate\Support\Facades\Schema
;
class
AddPhoneAndUserRoleIdToUsersTable
extends
Migration
{
/**
* Run the migrations.
*
* @return void
*/
public
function
up
()
{
Schema
::
table
(
'users'
,
function
(
Blueprint
$table
)
{
$table
->
string
(
'phone_number'
,
11
)
->
default
(
null
)
->
comment
(
'手机号码'
);
$table
->
integer
(
'user_role_id'
)
->
comment
(
'用户角色ID'
);
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public
function
down
()
{
Schema
::
table
(
'users'
,
function
(
Blueprint
$table
)
{
$table
->
dropColumn
(
'phone_number'
);
$table
->
dropColumn
(
'user_role_id'
);
});
}
}
database/seeds/UserRolesSeeder.php
0 → 100644
View file @
74522788
<?php
use
Illuminate\Database\Seeder
;
use
Illuminate\Support\Facades\DB
;
class
UserRolesSeeder
extends
Seeder
{
/**
* Run the database seeds.
*
* @return void
*/
public
function
run
()
{
Db
::
table
(
'user_roles'
)
->
insert
([
[
'name'
=>
'行业主管部门负责人'
,
'created_at'
=>
date
(
'Y-m-d H:i:s'
)],
[
'name'
=>
'燃气用户'
,
'created_at'
=>
date
(
'Y-m-d H:i:s'
)],
[
'name'
=>
'应急抢修人员'
,
'created_at'
=>
date
(
'Y-m-d H:i:s'
)],
[
'name'
=>
'村内“两员”'
,
'created_at'
=>
date
(
'Y-m-d H:i:s'
)]
]);
}
}
resources/js/views/user/index.vue
View file @
74522788
...
...
@@ -47,7 +47,17 @@
</el-table-column>
<el-table-column
align=
"center"
label=
"用户地址"
width=
"340"
>
<
template
slot-scope=
"scope"
>
<span>
{{
scope
.
row
.
province
}}
-
{{
scope
.
row
.
area
}}
-
{{
scope
.
row
.
city
}}
</span>
<span>
{{
scope
.
row
.
province
}}
<br>
{{
scope
.
row
.
area
}}
<br>
{{
scope
.
row
.
city
}}
</span>
</
template
>
</el-table-column>
<el-table-column
align=
"center"
label=
"手机号"
>
<
template
slot-scope=
"scope"
>
<span>
{{
scope
.
row
.
phone_number
}}
</span>
</
template
>
</el-table-column>
<el-table-column
align=
"center"
label=
"角色"
>
<
template
slot-scope=
"scope"
>
<span>
{{
scope
.
row
.
role_name
}}
</span>
</
template
>
</el-table-column>
<el-table-column
align=
"center"
label=
"创建时间"
width=
"170"
>
...
...
@@ -87,6 +97,14 @@
<
el
-
form
-
item
label
=
"邮箱"
prop
=
"email"
>
<
el
-
input
v
-
model
.
number
=
"upUserData.email"
><
/el-input
>
<
/el-form-item
>
<
el
-
form
-
item
label
=
"手机号"
prop
=
"phone_number"
>
<
el
-
input
v
-
model
.
number
=
"upUserData.phone_number"
><
/el-input
>
<
/el-form-item
>
<
el
-
form
-
item
label
=
"角色"
prop
=
"user_role"
>
<
el
-
select
v
-
model
=
"upUserData.user_role_id"
clearable
class
=
"filter-item"
@
change
=
"selectOne"
>
<
el
-
option
v
-
for
=
"item in user_roles"
:
key
=
"item.id"
:
label
=
"item.name"
:
value
=
"item.id"
/>
<
/el-select
>
<
/el-form-item
>
<
el
-
form
-
item
label
=
"自定义标题"
prop
=
"title"
>
<
el
-
input
v
-
model
.
number
=
"upUserData.title"
><
/el-input
>
<
/el-form-item
>
...
...
@@ -133,8 +151,16 @@ export default {
email
:
undefined
,
company
:
undefined
,
userid
:
undefined
,
phone_number
:
undefined
,
user_role_id
:
undefined
,
}
,
paper
:
undefined
,
user_roles
:
[
{
id
:
1
,
name
:
'行业主管部门负责人'
}
,
{
id
:
2
,
name
:
'燃气用户'
}
,
{
id
:
3
,
name
:
'应急抢修人员'
}
,
{
id
:
4
,
name
:
'村内“两员”'
}
,
],
}
;
}
,
created
()
{
...
...
@@ -280,6 +306,7 @@ export default {
type
:
'warning'
,
}
);
}
else
{
console
.
log
(
response
.
data
);
for
(
const
key
in
this
.
upUserData
)
{
for
(
const
k
in
response
.
data
)
{
if
(
key
===
k
)
{
...
...
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