Commit da8d947b authored by 冯超鹏's avatar 冯超鹏

添加新的功能

parent 4613efb9
Pipeline #20 canceled with stages
...@@ -74,3 +74,4 @@ available at https://www.contributor-covenant.org/version/1/4/code-of-conduct.ht ...@@ -74,3 +74,4 @@ available at https://www.contributor-covenant.org/version/1/4/code-of-conduct.ht
For answers to common questions about this code of conduct, see For answers to common questions about this code of conduct, see
https://www.contributor-covenant.org/faq https://www.contributor-covenant.org/faq
admin@laravadmin@laravue.devue.devadmin@laravue.dev
\ No newline at end of file
...@@ -13,7 +13,8 @@ use Illuminate\Http\Request; ...@@ -13,7 +13,8 @@ use Illuminate\Http\Request;
use Illuminate\Http\Response; use Illuminate\Http\Response;
use Illuminate\Support\Facades\Auth; use Illuminate\Support\Facades\Auth;
use App\Http\Resources\UserResource; use App\Http\Resources\UserResource;
use Illuminate\Support\Facades\DB;
use App\Laravue\Models\Users;
/** /**
* Class AuthController * Class AuthController
* *
...@@ -24,8 +25,9 @@ class AuthController extends Controller ...@@ -24,8 +25,9 @@ class AuthController extends Controller
/** /**
* @param Request $request * @param Request $request
* @return \Illuminate\Http\JsonResponse * @return \Illuminate\Http\JsonResponse
* @ 管理员登入
*/ */
public function login(Request $request) public function login(Request $request , Users $users)
{ {
$credentials = $request->only('email', 'password'); $credentials = $request->only('email', 'password');
if (!Auth::attempt($credentials)) { if (!Auth::attempt($credentials)) {
...@@ -35,9 +37,11 @@ class AuthController extends Controller ...@@ -35,9 +37,11 @@ class AuthController extends Controller
$user = $request->user(); $user = $request->user();
$tokenResult = $user->createToken('Personal Access Token'); $tokenResult = $user->createToken('Personal Access Token');
$token = $tokenResult->token; $token = $tokenResult->token;
$token->save(); $token->save();
return response()->json(new UserResource($user), Response::HTTP_OK)->header('Authorization', $tokenResult->accessToken); return response()->json(new UserResource($user), Response::HTTP_OK)->header('Authorization', $tokenResult->accessToken);
} }
public function logout(Request $request) public function logout(Request $request)
...@@ -50,4 +54,22 @@ class AuthController extends Controller ...@@ -50,4 +54,22 @@ class AuthController extends Controller
{ {
return new UserResource(Auth::user()); return new UserResource(Auth::user());
} }
// 用户登入接口
public function userslogin(Request $request , Users $users){
$credentials = $request->only('email', 'password');
$email = $credentials['email'];
$password = $credentials['password'];
// if (!Auth::attempt($credentials)) {
// return response()->json(new JsonResponse([], 'login_error'), Response::HTTP_UNAUTHORIZED);
// }
$BackgroundUser = $users->where([['username','=',$email],['password','=',sha1($password)],['state','=','2']])->first();
if ($BackgroundUser){
$tokenResult = $BackgroundUser->createToken('Personal Access Token');
$token = $tokenResult->token;
$token->save();
return response()->json(new UserResource($BackgroundUser), Response::HTTP_OK)->header('Authorization', $tokenResult->accessToken);
}else{
return response()->json(new JsonResponse([], 'login_error'), Response::HTTP_UNAUTHORIZED);
}
}
} }
...@@ -6,7 +6,8 @@ use Illuminate\Foundation\Auth\Access\AuthorizesRequests; ...@@ -6,7 +6,8 @@ use Illuminate\Foundation\Auth\Access\AuthorizesRequests;
use Illuminate\Foundation\Bus\DispatchesJobs; use Illuminate\Foundation\Bus\DispatchesJobs;
use Illuminate\Foundation\Validation\ValidatesRequests; use Illuminate\Foundation\Validation\ValidatesRequests;
use Illuminate\Routing\Controller as BaseController; use Illuminate\Routing\Controller as BaseController;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Auth;
class Controller extends BaseController class Controller extends BaseController
{ {
use AuthorizesRequests, DispatchesJobs, ValidatesRequests; use AuthorizesRequests, DispatchesJobs, ValidatesRequests;
...@@ -58,4 +59,12 @@ class Controller extends BaseController ...@@ -58,4 +59,12 @@ class Controller extends BaseController
], ],
]; ];
} }
/*
* 验证当前登入用户
* */
public function isadmin (){
$user = Auth::user();//获取当前用户信息
$isadmin = DB::table('users')->where([['name', '=', $user['name']], ['email', '=', $user['email']]])->first();
return $isadmin;
}
} }
...@@ -67,10 +67,41 @@ class DevicesController extends Controller ...@@ -67,10 +67,41 @@ class DevicesController extends Controller
} }
} }
//返回逻辑删除的设备
public function physicsdelete(Request $request){
$deviceid = $request->input('deviceid');
$databadevice = DB::table('device');
if($_POST){
$up = $databadevice
->where('id','=',$deviceid)
->update(['delete'=>2]);
return $this->jsonSuccessData($up);
}else{
//返回物理删除设备列表
$type = (int)$request->input('type');//设备类型
$pagenNum=$request->input('page')-1;//页数
$limit = $request->input('limit');//条数
if($pagenNum === '' || $limit == ''){
return $this->jsonErrorData(105,'页数或limit不能为空');
}
$devicelist = $databadevice
->where('dtype','=',$type == '' ? '1':$type)
->where('delete','=','1')//设备逻辑删除状态
->join('device_type as dy',"device.dtype",'=','dy.tid')
->join('gas as g',"device.status",'=','g.id')
->select('dy.tname','g.gas','device.*')
->orderBy('device.id', 'desc')
->offset($pagenNum)
->limit($limit)
->get()->toArray();
return $this->jsonSuccessData($devicelist);
}
}
//添加设备 //添加设备
public function adddevice(Request $request){ public function adddevice(Request $request){
} }
//返回设备类型和单位和介质 //返回设备类型和单位和介质
...@@ -85,6 +116,7 @@ class DevicesController extends Controller ...@@ -85,6 +116,7 @@ class DevicesController extends Controller
$databadevice = DB::table('device'); $databadevice = DB::table('device');
$devicelist = $databadevice $devicelist = $databadevice
->where('dtype','=',$type) ->where('dtype','=',$type)
->where('delete','=','2')//设备不是删除状态
->join('device_type as dy',"device.dtype",'=','dy.tid') ->join('device_type as dy',"device.dtype",'=','dy.tid')
->join('gas as g',"device.status",'=','g.id') ->join('gas as g',"device.status",'=','g.id')
->select('dy.tname','g.gas','device.*') ->select('dy.tname','g.gas','device.*')
...@@ -104,10 +136,13 @@ class DevicesController extends Controller ...@@ -104,10 +136,13 @@ class DevicesController extends Controller
private function getValidationRulesdevice($isNew = true) private function getValidationRulesdevice($isNew = true)
{ {
return [ return [
'devicenum'=>'required|between:2,25|regex:/^[A-Za-z0-9\-\_]+$/|unique:BackgroundUser,username', 'devicenum'=>'required|between:2,25|unique:device,devicenum',//设备编号
'password'=> 'sometimes|required|string|min:6', 'username'=>'required|unique:device,username|max:40',//设备名称
'contacts_phone'=> 'required|regex:/^1[3465789]\d{9}$/|unique:BackgroundUser', 'devicephone'=> 'required|regex:/^1[3465789]\d{9}$/|unique:device,devicephone|max:11',//联系人手机号
'nickname'=>'required|between:2,25|regex:/^[A-Za-z0-9\-\_]+$/|unique:BackgroundUser,nickname' 'devicelinkman'=>'required|max:15',
'dtypeid'=>'sometimes|required',
'statusid'=>'sometimes|required',
'devicemonadid'=>'sometimes|required'
]; ];
} }
......
...@@ -18,6 +18,7 @@ use App\Laravue\Models\Role; ...@@ -18,6 +18,7 @@ use App\Laravue\Models\Role;
use App\Laravue\Models\User; use App\Laravue\Models\User;
use App\Laravue\Models\Users; use App\Laravue\Models\Users;
use Illuminate\Http\Request; use Illuminate\Http\Request;
use Illuminate\Support\Facades\Auth;
use Illuminate\Http\Resources\Json\ResourceCollection; use Illuminate\Http\Resources\Json\ResourceCollection;
use Illuminate\Support\Arr; use Illuminate\Support\Arr;
use Illuminate\Support\Facades\DB; use Illuminate\Support\Facades\DB;
...@@ -36,7 +37,7 @@ class UserController extends Controller ...@@ -36,7 +37,7 @@ class UserController extends Controller
/** /**
* Display a listing of the user resource. * Display a listing of the user resource.
* *
* @param \Illuminate\Http\Request $request * @param \Illuminate\Http\Request $request
* @return \Illuminate\Http\Response|ResourceCollection * @return \Illuminate\Http\Response|ResourceCollection
*/ */
public function index(Request $request) public function index(Request $request)
...@@ -48,7 +49,9 @@ class UserController extends Controller ...@@ -48,7 +49,9 @@ class UserController extends Controller
$keyword = Arr::get($searchParams, 'keyword', ''); $keyword = Arr::get($searchParams, 'keyword', '');
if (!empty($role)) { if (!empty($role)) {
$userQuery->whereHas('roles', function($q) use ($role) { $q->where('name', $role); }); $userQuery->whereHas('roles', function ($q) use ($role) {
$q->where('name', $role);
});
} }
if (!empty($keyword)) { if (!empty($keyword)) {
...@@ -62,7 +65,7 @@ class UserController extends Controller ...@@ -62,7 +65,7 @@ class UserController extends Controller
/** /**
* Store a newly created resource in storage. * Store a newly created resource in storage.
* *
* @param \Illuminate\Http\Request $request * @param \Illuminate\Http\Request $request
* @return \Illuminate\Http\Response * @return \Illuminate\Http\Response
*/ */
public function store(Request $request) public function store(Request $request)
...@@ -109,7 +112,7 @@ class UserController extends Controller ...@@ -109,7 +112,7 @@ class UserController extends Controller
* Update the specified resource in storage. * Update the specified resource in storage.
* *
* @param Request $request * @param Request $request
* @param User $user * @param User $user
* @return UserResource|\Illuminate\Http\JsonResponse * @return UserResource|\Illuminate\Http\JsonResponse
*/ */
public function update(Request $request, User $user) public function update(Request $request, User $user)
...@@ -142,7 +145,7 @@ class UserController extends Controller ...@@ -142,7 +145,7 @@ class UserController extends Controller
* Update the specified resource in storage. * Update the specified resource in storage.
* *
* @param Request $request * @param Request $request
* @param User $user * @param User $user
* @return UserResource|\Illuminate\Http\JsonResponse * @return UserResource|\Illuminate\Http\JsonResponse
*/ */
public function updatePermissions(Request $request, User $user) public function updatePermissions(Request $request, User $user)
...@@ -157,7 +160,7 @@ class UserController extends Controller ...@@ -157,7 +160,7 @@ class UserController extends Controller
$permissionIds = $request->get('permissions', []); $permissionIds = $request->get('permissions', []);
$rolePermissionIds = array_map( $rolePermissionIds = array_map(
function($permission) { function ($permission) {
return $permission['id']; return $permission['id'];
}, },
...@@ -225,6 +228,18 @@ class UserController extends Controller ...@@ -225,6 +228,18 @@ class UserController extends Controller
]; ];
} }
/**
* @param bool $isNew
* @return array
*/
private function getValidationRulescontacts($isNew = true)
{
return [
'contacts_name' => 'required|max:3',
'contacts_phone' => 'required|regex:/^1[3465789]\d{9}$/|max:11|unique:contactsuser,contacts_phone'
];
}
/** /**
* @param bool $isNew * @param bool $isNew
* @return array * @return array
...@@ -234,41 +249,43 @@ class UserController extends Controller ...@@ -234,41 +249,43 @@ class UserController extends Controller
{ {
return [ return [
'email' => $isNew ? 'required|email|unique:users' : 'required|email', 'email' => $isNew ? 'required|email|unique:users' : 'required|email',
'username'=>'required|between:2,25|regex:/^[A-Za-z0-9\-\_]+$/|unique:BackgroundUser,username', 'username' => 'required|between:2,25|regex:/^[A-Za-z0-9\-\_]+$/|unique:BackgroundUser,username',
'password'=> 'sometimes|required|string|min:6', 'password' => 'sometimes|required|string|min:6',
'contacts_phone'=> 'required|regex:/^1[3465789]\d{9}$/|unique:BackgroundUser', 'nickname' => 'required|between:2,25|regex:/^[A-Za-z0-9\-\_]+$/|unique:BackgroundUser,nickname'
'nickname'=>'required|between:2,25|regex:/^[A-Za-z0-9\-\_]+$/|unique:BackgroundUser,nickname'
]; ];
} }
// 后台管理用户列表 // 后台管理用户列表
public function HUserList(Request $request){ public function HUserList(Request $request)
$pagenNum=$request->input('page')-1;//页数 {
$pagenNum = $request->input('page') - 1;//页数
$limit = $request->input('limit'); $limit = $request->input('limit');
$users = DB::table('BackgroundUser as b') $users = DB::table('BackgroundUser as b')
->where('b.state','=','2') ->where('b.state', '=', '2')
->join('areachina as p', 'b.provinceid', '=', 'p.areaid') ->join('areachina as p', 'b.provinceid', '=', 'p.areaid')
->join('areachina as c', 'b.cityid', '=', 'c.areaid') ->join('areachina as c', 'b.cityid', '=', 'c.areaid')
->join('areachina as a', 'b.areaid', '=', 'a.areaid') ->join('areachina as a', 'b.areaid', '=', 'a.areaid')
->orderBy('b.id', 'desc') ->orderBy('b.id', 'desc')
->select('b.username','b.nickname','b.contacts_name','b.contacts_phone','b.email','b.state','a.area_name as area','c.area_name as city','p.area_name as province') ->select('b.username', 'b.nickname', 'b.email', 'b.state', '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();
if ($users){ if ($users) {
return $this->jsonSuccessData($users); return $this->jsonSuccessData($users);
}else{ } else {
return $this->jsonErrorData(105,'获取失败'); return $this->jsonErrorData(105, '获取失败');
} }
} }
//新增用户 //新增用户
public function addUser(Request $request){ public function addUser(Request $request)
{
$userdata = $request->all(); $userdata = $request->all();
//获取用户列表 //获取用户列表
$validator = Validator::make($request->all(), $this->getValidationRulesuser(false,false)); $validator = Validator::make($request->all(), $this->getValidationRulesuser(false));
if ($validator->fails()) { if ($validator->fails()) {
return response()->json(['errors' => $validator->errors()], 403); return response()->json(['errors' => $validator->errors()], 403);
}else{ } else {
$type = new Users(); $type = new Users();
$arr = $type->getTypeAllToArray($userdata); $arr = $type->getTypeAllToArray($userdata);
return $this->jsonSuccessData($arr); return $this->jsonSuccessData($arr);
...@@ -282,98 +299,126 @@ class UserController extends Controller ...@@ -282,98 +299,126 @@ class UserController extends Controller
* 2 == 物理删除用户 * 2 == 物理删除用户
* duserid 删除用户的id * duserid 删除用户的id
* */ * */
public function deleteuser(Request $request){ public function deleteuser(Request $request)
{
$type = (int)$request->input('type'); $type = (int)$request->input('type');
$duserid = (int)$request->input('duserid'); $duserid = (int)$request->input('duserid');
if($type == ''){ if ($type == '') {
return $this->jsonErrorData(105,'type参数不能为空'); return $this->jsonErrorData(105, 'type参数不能为空');
} }
if($duserid == ''){ if ($duserid == '') {
return $this->jsonErrorData(105,'duserid参数不能为空'); return $this->jsonErrorData(105, 'duserid参数不能为空');
} }
if($type == 1){ // 逻辑删除 if ($type == 1) { // 逻辑删除
$users = Users::where('id','=',$duserid) $users = Users::where('id', '=', $duserid)
->update(['state'=>1]); ->update(['state' => 1]);
if($users){ if ($users) {
return $this->jsonSuccessData($users); return $this->jsonSuccessData($users);
}else{ } else {
return $this->jsonErrorData(105,'获取用户数据失败'); return $this->jsonErrorData(105, '获取用户数据失败');
} }
}else if($type == 2){ } else if ($type == 2) {
$users = Users::where('id','=',$duserid) $users = Users::where('id', '=', $duserid)
->delete(); ->delete();
if($users){ if ($users) {
return $this->jsonSuccessData($users); return $this->jsonSuccessData($users);
}else{ } else {
return $this->jsonErrorData(105,'获取用户数据失败'); return $this->jsonErrorData(105, '获取用户数据失败');
} }
} }
} }
//更新用户 //更新用户
public function Upuser(Request $request){ public function Upuser(Request $request)
if($_POST){ {
if ($_POST) {
$userdata = $request->all(); $userdata = $request->all();
$uid = $userdata['userid']; $uid = $userdata['userid'];
if(!isset($userdata['userid']) || $userdata['userid'] == ''){ if (!isset($userdata['userid']) || $userdata['userid'] == '') {
return $this->jsonErrorData(105,'用户id不能为空'); return $this->jsonErrorData(105, '用户id不能为空');
} }
$validator = Validator::make($request->all(), $this->getValidationRulesuser(false)); $validator = Validator::make($request->all(), $this->getValidationRulesuser(false));
if ($validator->fails()) { if ($validator->fails()) {
return response()->json(['errors' => $validator->errors()], 403); return response()->json(['errors' => $validator->errors()], 403);
}else{ } else {
foreach ($userdata as $k=>$v){ foreach ($userdata as $k => $v) {
if ($k == 'userid'){ if ($k == 'userid') {
unset($userdata[$k]); unset($userdata[$k]);
} }
} }
$re =Users::where('id','=',(int)$uid)->update($userdata); $re = Users::where('id', '=', (int)$uid)->update($userdata);
if ($re){ if ($re) {
return $this->jsonSuccessData($re); return $this->jsonSuccessData($re);
}else{ } else {
return $this->jsonErrorData(105,'更新失败'); return $this->jsonErrorData(105, '更新失败');
} }
} }
}else{ } else {
// 获取用户数据 // 获取用户数据
$userid = (int)$request->input('userid'); $userid = (int)$request->input('userid');
if($userid == ''){ if ($userid == '') {
return $this->jsonErrorData(105,'用户id不能为空'); return $this->jsonErrorData(105, '用户id不能为空');
} }
$userdata = Users::where('id','=',$userid) $userdata = Users::where('id', '=', $userid)
->select('username','nickname','contacts_name','contacts_phone','email','title','company','mapcenter') ->select('username', 'nickname', 'email', 'title', 'company', 'mapcenter')
->where('state','=',2) ->where('state', '=', 2)
->first(); ->first();
if ($userdata){ if ($userdata) {
return $this->jsonSuccessData($userdata); return $this->jsonSuccessData($userdata);
}else{ } else {
return $this->jsonErrorData(105,'获取数据失败'); return $this->jsonErrorData(105, '获取数据失败');
} }
} }
} }
//返回地址列表 //返回地址列表
public function areachina (Request $request){ public function areachina(Request $request)
{
$region = Db::table('areachina'); $region = Db::table('areachina');
if($_POST){ if ($_POST) {
$areaid = $request->input('areaid'); $areaid = $request->input('areaid');
if($areaid == ''){ if ($areaid == '') {
return $this->jsonErrorData('105','地区id不能为空'); return $this->jsonErrorData('105', '地区id不能为空');
} }
$area = $region->where('pid','=',$areaid) $area = $region->where('pid', '=', $areaid)
->where('status','=','1') ->where('status', '=', '1')
->select('area_name','areaid') ->select('area_name', 'areaid')
->get();
} else {
$area = $region->where('pid', '=', '0')
->where('status', '=', '1')
->select('area_name', 'areaid')
->get(); ->get();
}else{
$area = $region->where('pid','=','0')
->where('status','=','1')
->select('area_name','areaid')
->get();
} }
if($area){ if ($area) {
return $this->jsonSuccessData($area); return $this->jsonSuccessData($area);
}else{ } else {
return $this->jsonErrorData(105,'获取失败'); return $this->jsonErrorData(105, '获取失败');
} }
} }
} //添加联系人
public function addcontactsuser(Request $request)
{
$data = $request->all();
if (!is_null($this->isadmin())) {//当前登入管理员
$validator = Validator::make($request->all(), $this->getValidationRulescontacts(false));
if ($validator->fails()) {
return response()->json(['errors' => $validator->errors()], 403);
} else {
$data['isadmin'] = 1;
}
} else {
$data['isadmin'] = 2;
}
$data['contactsid'] = Auth::id();
$isadmin = DB::table('contactsuser')->insert($data);
return $this->jsonSuccessData($isadmin);
}
/*
* 返回当前登入的联系人列表
* */
public function contactslist(){
return DB::table('contactsuser')->where([['contactsid','=',Auth::id()],['isadmin','=',is_null($this->isadmin()) ? '2' : '1']])->get();
}
}
\ No newline at end of file
...@@ -9,7 +9,7 @@ ...@@ -9,7 +9,7 @@
namespace App\Http\Controllers; namespace App\Http\Controllers;
use App\Laravue\Models\wxUser; use App\Laravue\Models\wxUser;
use Illuminate\Http\Request; use Illuminate\Http\Request;
use Illuminate\Support\Facades\DB; use Illuminate\Support\Facades\DB;
use Illuminate\Http\Resources\Json\ResourceCollection; use Illuminate\Http\Resources\Json\ResourceCollection;
......
...@@ -75,6 +75,7 @@ class User extends Authenticatable ...@@ -75,6 +75,7 @@ class User extends Authenticatable
/** /**
* @return bool * @return bool
* 验证是否管理员
*/ */
public function isAdmin(): bool public function isAdmin(): bool
{ {
......
...@@ -14,13 +14,14 @@ use Spatie\Permission\Traits\HasRoles; ...@@ -14,13 +14,14 @@ use Spatie\Permission\Traits\HasRoles;
* @property string $email * @property string $email
* @property string $password * @property string $password
* @property Role[] $roles * @property Role[] $roles
* *protected
* @method static User create(array $user) * @method static User create(array $user)
* @package App * @package App
*/ */
class Users extends Authenticatable class Users extends Authenticatable
{ {
use Notifiable, HasRoles, HasApiTokens; use Notifiable, HasRoles, HasApiTokens;
protected $table = "BackgroundUser"; protected $table = "BackgroundUser";
public $timestamps = false; public $timestamps = false;
...@@ -29,4 +30,59 @@ class Users extends Authenticatable ...@@ -29,4 +30,59 @@ class Users extends Authenticatable
$userdata['add_time'] = time(); $userdata['add_time'] = time();
return $this->insertGetId($userdata); return $this->insertGetId($userdata);
} }
protected $fillable = [
'email', 'password',
];
protected $hidden = [
'password', 'remember_token',
];
/**
* The attributes that should be cast to native types.
*
* @var array
*/
protected $casts = [
'email_verified_at' => 'datetime',
];
/**
* Set permissions guard to API by default
* @var string
*/
protected $guard_name = 'api';
/**
* @inheritdoc
*/
public function getJWTIdentifier()
{
return $this->getKey();
}
/**
* @inheritdoc
*/
public function getJWTCustomClaims()
{
return [];
}
/**
* @return bool
* 验证是否管理员
*/
public function isAdmin(): bool
{
foreach ($this->roles as $role) {
if ($role->isAdmin()) {
return true;
}
}
return false;
}
} }
\ No newline at end of file
...@@ -46,6 +46,11 @@ return [ ...@@ -46,6 +46,11 @@ return [
'provider' => 'users', 'provider' => 'users',
'hash' => false, 'hash' => false,
], ],
'admin' => [
'driver' => 'passport',
'provider' => 'user',
'hash' => false,
],
], ],
/* /*
...@@ -70,11 +75,10 @@ return [ ...@@ -70,11 +75,10 @@ return [
'driver' => 'eloquent', 'driver' => 'eloquent',
'model' => App\Laravue\Models\User::class, 'model' => App\Laravue\Models\User::class,
], ],
'user' => [
// 'users' => [ 'driver' => 'eloquent',
// 'driver' => 'database', 'model' => App\Laravue\Models\Users::class,
// 'table' => 'users', ],
// ],
], ],
/* /*
......
File added
...@@ -77,6 +77,7 @@ export default { ...@@ -77,6 +77,7 @@ export default {
}, },
login: { login: {
title: '系统登录', title: '系统登录',
user:'用户登录',
logIn: '登录', logIn: '登录',
username: '账号', username: '账号',
password: '密码', password: '密码',
......
<template> <template>
<div class="login-container"> <div class="login-container">
<el-form ref="loginForm" :model="loginForm" :rules="loginRules" class="login-form" auto-complete="on" label-position="left"> <el-form ref="loginForm" :model="loginForm" :rules="loginRules" class="login-form" auto-complete="on" label-position="left">
<h3 class="title">
{{ $t('login.title') }} <el-tabs v-model="activeName" @tab-click="handleClick">
</h3> <el-tab-pane label="系统登录" name="first" class="el-tabs__item">
<!-- <h3 class="title">
{{ $t('login.title') }}
</h3> -->
</el-tab-pane>
<el-tab-pane label="用户登录" name="second">
<!-- <h3 class="title">
{{ $t('login.user') }}
</h3> -->
</el-tab-pane>
</el-tabs>
<lang-select class="set-language" /> <lang-select class="set-language" />
<el-form-item prop="email"> <el-form-item prop="email">
<span class="svg-container"> <span class="svg-container">
...@@ -43,7 +53,6 @@ ...@@ -43,7 +53,6 @@
<script> <script>
import LangSelect from '@/components/LangSelect'; import LangSelect from '@/components/LangSelect';
import { validEmail } from '@/utils/validate'; import { validEmail } from '@/utils/validate';
export default { export default {
name: 'Login', name: 'Login',
components: { LangSelect }, components: { LangSelect },
...@@ -74,6 +83,7 @@ export default { ...@@ -74,6 +83,7 @@ export default {
loading: false, loading: false,
pwdType: 'password', pwdType: 'password',
redirect: undefined, redirect: undefined,
activeName: 'second',
}; };
}, },
watch: { watch: {
...@@ -85,6 +95,9 @@ export default { ...@@ -85,6 +95,9 @@ export default {
}, },
}, },
methods: { methods: {
handleClick(tab, event) {
console.log(tab, event);
},
showPwd() { showPwd() {
if (this.pwdType === 'password') { if (this.pwdType === 'password') {
this.pwdType = ''; this.pwdType = '';
...@@ -165,6 +178,18 @@ $light_gray:#eee; ...@@ -165,6 +178,18 @@ $light_gray:#eee;
max-width: 100%; max-width: 100%;
padding: 35px 35px 15px 35px; padding: 35px 35px 15px 35px;
margin: 120px auto; margin: 120px auto;
.el-tabs__item {
padding: 0 20px;
height: 40px;
box-sizing: border-box;
line-height: 40px;
display: inline-block;
list-style: none;
font-size: 14px;
font-weight: 500;
color: #fff;
position: relative;
}
} }
.tips { .tips {
font-size: 14px; font-size: 14px;
......
...@@ -35,7 +35,7 @@ ...@@ -35,7 +35,7 @@
</el-table-column> </el-table-column>
<el-table-column label="用户头像" align="center" width="120"> <el-table-column label="用户头像" align="center" width="120">
<template slot-scope="scope"> <template slot-scope="scope">
<el-image :src="scope.row.headimgurl":fit="fit"></el-image> <el-image :src="scope.row.headimgurl" :fit="fit"></el-image>
</template> </template>
</el-table-column> </el-table-column>
<el-table-column label="用户名称" width="130px" align="center"> <el-table-column label="用户名称" width="130px" align="center">
...@@ -199,7 +199,7 @@ export default { ...@@ -199,7 +199,7 @@ export default {
title: undefined, title: undefined,
type: undefined, type: undefined,
sort: '+id', sort: '+id',
fits: ['fill', 'contain', 'cover', 'none', 'scale-down'], fits: ['fill', 'contain', 'cover', 'none', 'scale-down'],
}, },
calendarTypeOptions, calendarTypeOptions,
sortOptions: [{ label: 'ID Ascending', key: '+id' }, { label: 'ID Descending', key: '-id' }], sortOptions: [{ label: 'ID Ascending', key: '+id' }, { label: 'ID Descending', key: '-id' }],
......
...@@ -16,6 +16,7 @@ use \App\Laravue\JsonResponse; ...@@ -16,6 +16,7 @@ use \App\Laravue\JsonResponse;
*/ */
Route::post('auth/login', 'AuthController@login'); Route::post('auth/login', 'AuthController@login');
Route::post('auth/userslogin', 'AuthController@userslogin');
Route::group(['middleware' => 'auth:api'], function () { Route::group(['middleware' => 'auth:api'], function () {
Route::get('auth/user', 'AuthController@user'); Route::get('auth/user', 'AuthController@user');
Route::post('auth/logout', 'AuthController@logout'); Route::post('auth/logout', 'AuthController@logout');
...@@ -32,6 +33,8 @@ Route::group(['middleware' => 'auth:api'], function () { ...@@ -32,6 +33,8 @@ Route::group(['middleware' => 'auth:api'], function () {
Route::post('user/deleteuser','UserController@deleteuser')->middleware('permission:' . \App\Laravue\Acl::PERMISSION_PERMISSION_MANAGE);//删除用户 Route::post('user/deleteuser','UserController@deleteuser')->middleware('permission:' . \App\Laravue\Acl::PERMISSION_PERMISSION_MANAGE);//删除用户
Route::match(['get','post'],'user/Upuser','UserController@Upuser')->middleware('permission:' . \App\Laravue\Acl::PERMISSION_PERMISSION_MANAGE);//更新用户 Route::match(['get','post'],'user/Upuser','UserController@Upuser')->middleware('permission:' . \App\Laravue\Acl::PERMISSION_PERMISSION_MANAGE);//更新用户
Route::match(['get','post'],'user/areachina','UserController@areachina')->middleware('permission:' . \App\Laravue\Acl::PERMISSION_PERMISSION_MANAGE);//获取地址列表 Route::match(['get','post'],'user/areachina','UserController@areachina')->middleware('permission:' . \App\Laravue\Acl::PERMISSION_PERMISSION_MANAGE);//获取地址列表
Route::post('user/addcontactsuser','UserController@addcontactsuser')->middleware('permission:' . \App\Laravue\Acl::PERMISSION_PERMISSION_MANAGE);//添加联系人
Route::get('user/contactslist','UserController@contactslist');
}); });
//设备路由 //设备路由
...@@ -40,6 +43,7 @@ Route::group(['middleware'=>'auth:api'],function (){ ...@@ -40,6 +43,7 @@ Route::group(['middleware'=>'auth:api'],function (){
Route::get('devices/devicetype','DevicesController@devicetype');//设备类型 Route::get('devices/devicetype','DevicesController@devicetype');//设备类型
Route::post('devices/deletedecice','DevicesController@deletedecice')->middleware('permission:' . \App\Laravue\Acl::PERMISSION_PERMISSION_MANAGE);//删除设备 Route::post('devices/deletedecice','DevicesController@deletedecice')->middleware('permission:' . \App\Laravue\Acl::PERMISSION_PERMISSION_MANAGE);//删除设备
Route::post('devices/adddevice','DevicesController@adddevice')->middleware('permission:' . \App\Laravue\Acl::PERMISSION_PERMISSION_MANAGE);//新增设备 Route::post('devices/adddevice','DevicesController@adddevice')->middleware('permission:' . \App\Laravue\Acl::PERMISSION_PERMISSION_MANAGE);//新增设备
Route::match(['get','post'],'device/physicsdelete','DevicesController@physicsdelete')->middleware('permission:' . \App\Laravue\Acl::PERMISSION_PERMISSION_MANAGE);//返回设备列表和更改设备
}); });
// Fake APIs // Fake APIs
......
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