Commit 74522788 authored by Administrator's avatar Administrator

编辑用户

parent 4bf1f661
...@@ -280,8 +280,21 @@ class UserController extends Controller ...@@ -280,8 +280,21 @@ class UserController extends Controller
->leftjoin('areachina as p', 'b.provinceid', '=', 'p.areaid') ->leftjoin('areachina as p', 'b.provinceid', '=', 'p.areaid')
->leftjoin('areachina as c', 'b.cityid', '=', 'c.areaid') ->leftjoin('areachina as c', 'b.cityid', '=', 'c.areaid')
->leftjoin('areachina as a', 'b.areaid', '=', 'a.areaid') ->leftjoin('areachina as a', 'b.areaid', '=', 'a.areaid')
->leftJoin('user_roles AS ur', 'b.user_role_id', '=', 'ur.id')
->orderBy('b.id', 'desc') ->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) ->offset($pagenNum)
->limit($limit) ->limit($limit)
->get(); ->get();
...@@ -434,7 +447,7 @@ class UserController extends Controller ...@@ -434,7 +447,7 @@ class UserController extends Controller
return $this->jsonErrorData(105, '用户id不能为空'); return $this->jsonErrorData(105, '用户id不能为空');
} }
$userdata = Users::where('id', '=', $userid) $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(); ->first();
if ($userdata) { if ($userdata) {
return $this->jsonSuccessData($userdata); return $this->jsonSuccessData($userdata);
......
<?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');
}
}
<?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');
});
}
}
<?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')]
]);
}
}
...@@ -47,7 +47,17 @@ ...@@ -47,7 +47,17 @@
</el-table-column> </el-table-column>
<el-table-column align="center" label="用户地址" width="340"> <el-table-column align="center" label="用户地址" width="340">
<template slot-scope="scope"> <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> </template>
</el-table-column> </el-table-column>
<el-table-column align="center" label="创建时间" width="170"> <el-table-column align="center" label="创建时间" width="170">
...@@ -87,6 +97,14 @@ ...@@ -87,6 +97,14 @@
<el-form-item label="邮箱" prop="email"> <el-form-item label="邮箱" prop="email">
<el-input v-model.number="upUserData.email"></el-input> <el-input v-model.number="upUserData.email"></el-input>
</el-form-item> </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-form-item label="自定义标题" prop="title">
<el-input v-model.number="upUserData.title"></el-input> <el-input v-model.number="upUserData.title"></el-input>
</el-form-item> </el-form-item>
...@@ -133,8 +151,16 @@ export default { ...@@ -133,8 +151,16 @@ export default {
email: undefined, email: undefined,
company: undefined, company: undefined,
userid: undefined, userid: undefined,
phone_number: undefined,
user_role_id: undefined,
}, },
paper: undefined, paper: undefined,
user_roles: [
{ id: 1, name: '行业主管部门负责人' },
{ id: 2, name: '燃气用户' },
{ id: 3, name: '应急抢修人员' },
{ id: 4, name: '村内“两员”' },
],
}; };
}, },
created() { created() {
...@@ -280,6 +306,7 @@ export default { ...@@ -280,6 +306,7 @@ export default {
type: 'warning', type: 'warning',
}); });
} else { } else {
console.log(response.data);
for (const key in this.upUserData) { for (const key in this.upUserData) {
for (const k in response.data) { for (const k in response.data) {
if (key === k) { if (key === k) {
......
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 to comment