Commit 9eac874d authored by 冯超鹏's avatar 冯超鹏

提交新模块

parent b126101b
Pipeline #22 failed with stages
......@@ -101,7 +101,13 @@ class DevicesController extends Controller
//添加设备
public function adddevice(Request $request){
//验证用户提交表单
$validator = Validator::make($request->all(), $this->getValidationRulesdevice(false));
if ($validator->fails()) {
return response()->json(['errors' => $validator->errors()], 403);
}
$type = new Device();
return $this->jsonSuccessData($type->adddevice($request->all()));
}
//返回设备类型和单位和介质
......@@ -138,11 +144,13 @@ class DevicesController extends Controller
return [
'devicenum'=>'required|between:2,25|unique:device,devicenum',//设备编号
'username'=>'required|unique:device,username|max:40',//设备名称
'devicephone'=> 'required|regex:/^1[3465789]\d{9}$/|unique:device,devicephone|max:11',//联系人手机号
'devicephone'=> 'required|regex:/^1[3465789]\d{9}$/|max:11',//联系人手机号
'devicelinkman'=>'required|max:15',
'dtypeid'=>'sometimes|required',
'statusid'=>'sometimes|required',
'devicemonadid'=>'sometimes|required'
'dtype'=>'required',
'status'=>'required',
'devicemonad'=>'required',
'deviceremark'=>'sometimes|required|max:15',
'devicecoord'=>'sometimes|required'
];
}
......
<?php
namespace App\Http\Controllers;
use App\Http\Resources\PermissionResource;
use App\Http\Requests\UsersRequest;
use App\Http\Resources\UserResource;
use App\Laravue\JsonResponse;
use App\Laravue\Models\Installer;
use Illuminate\Http\Request;
use Illuminate\Http\Resources\Json\ResourceCollection;
use Illuminate\Support\Arr;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Hash;
use Illuminate\Support\Facades\Redis;
use Validator;
class InstallerController extends Controller
{
//装维人员列表
public function installerlist (){
return $this->jsonSuccessData(Installer::where('delete','=','1')
->get());
}
//用户添加
public function addinstaller(Request $request){
$validator = Validator::make($request->all(), $this->getValidationRulesinstaller(false));
if ($validator->fails()) {
return response()->json(['errors' => $validator->errors()], 403);
}
$type = new Installer();
return $this->jsonSuccessData($type->addinstall($request->all()));
}
//验证用户提交表单
private function getValidationRulesinstaller($isNew = true){
return [
'username'=>'required|unique:installer,username|max:3',
'name'=> 'required|max:10',
'phone'=> 'required|regex:/^1[3465789]\d{9}$/|unique:installer,phone|max:11',
'email' => 'required|email',
'password' =>'required|max:10',
];
}
}
\ No newline at end of file
......@@ -6,9 +6,43 @@ use Illuminate\Notifications\Notifiable;
use Illuminate\Foundation\Auth\User as Authenticatable;
use Laravel\Passport\HasApiTokens;
use Spatie\Permission\Traits\HasRoles;
class Device extends Authenticatable
{
use Notifiable, HasRoles, HasApiTokens;
protected $table = "device";
public $timestamps = false;
//用户添加设备
public function adddevice($datadevice = []): string
{
foreach ($datadevice as $k => $value) {
if (is_null($k)) {
return '用户提交表单参数错误';
}
}
$datadevice['deviceaddtime'] = time();
$datadevice['deviceuuid'] = $this->guid();
return $this->insertGetId($datadevice);
}
//生成uid
private function guid() :string
{
if (function_exists('com_create_guid')) {
return com_create_guid();
} else {
mt_srand((double)microtime() * 10000);
$charid = strtoupper(md5(uniqid(rand(), true)));
$hyphen = chr(45);// "-"
$uuid = chr(123)// "{"
. substr($charid, 0, 8) . $hyphen
. substr($charid, 8, 4) . $hyphen
. substr($charid, 12, 4) . $hyphen
. substr($charid, 16, 4) . $hyphen
. substr($charid, 20, 12)
. chr(125);// "}"
return $uuid;
}
}
}
<?php
namespace App\Laravue\Models;
use Illuminate\Notifications\Notifiable;
use Illuminate\Foundation\Auth\User as Authenticatable;
use Laravel\Passport\HasApiTokens;
use Spatie\Permission\Traits\HasRoles;
class Installer extends Authenticatable
{
use Notifiable, HasRoles, HasApiTokens;
protected $table = "installer";
public $timestamps = false;
//添加装维人员
public function addinstall($data = []) : string {
foreach ($data as $k => $value) {
if (is_null($k)) {
return '用户提交表单参数错误';
}
}
$datadevice['addtime'] = time();
return $this->insertGetId($datadevice);
}
}
\ No newline at end of file
......@@ -20,6 +20,7 @@
],
"require": {
"php": "^7.2",
"emadadly/laravel-uuid": "^1.3",
"fideloper/proxy": "^4.0",
"laravel/framework": "^7.0",
"laravel/passport": "^8.4",
......
......@@ -77,7 +77,6 @@ export default {
},
login: {
title: '系统登录',
user: '用户登录',
logIn: '登录',
username: '账号',
password: '密码',
......
<template>
<div class="login-container">
<el-form ref="loginForm" :model="loginForm" :rules="loginRules" class="login-form" auto-complete="on" label-position="left">
<el-tabs v-model="activeName" @tab-click="handleClick">
<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>
<h3 class="title">
{{ $t('login.title') }}
</h3>
<lang-select class="set-language" />
<el-form-item prop="email">
<span class="svg-container">
......@@ -83,7 +73,7 @@ export default {
loading: false,
pwdType: 'password',
redirect: undefined,
activeName: 'second',
activeName: 'second',
};
},
watch: {
......@@ -95,8 +85,8 @@ export default {
},
},
methods: {
handleClick(tab, event) {
console.log(tab, event);
handleClick(tab, event) {
console.log(tab, event);
},
showPwd() {
if (this.pwdType === 'password') {
......@@ -126,11 +116,9 @@ export default {
},
};
</script>
<style rel="stylesheet/scss" lang="scss">
$bg:#2d3a4b;
$light_gray:#eee;
/* reset element-ui css */
.login-container {
.el-input {
......@@ -158,9 +146,7 @@ $light_gray:#eee;
color: #454545;
}
}
</style>
<style rel="stylesheet/scss" lang="scss" scoped>
$bg:#2d3a4b;
$dark_gray:#889aa4;
......@@ -179,16 +165,16 @@ $light_gray:#eee;
padding: 35px 35px 15px 35px;
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;
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 {
......
......@@ -46,6 +46,11 @@ Route::group(['middleware'=>'auth:api'],function (){
Route::match(['get','post'],'device/physicsdelete','DevicesController@physicsdelete')->middleware('permission:' . \App\Laravue\Acl::PERMISSION_PERMISSION_MANAGE);//返回设备列表和更改设备
});
//装维中心
Route::group(['middleware'=>'auth:api'],function (){
Route::get('installer/installerlist','InstallerController@installerlist');//装维人员列表
});
// Fake APIs
Route::get('/table/list', function () {
$rowsNumber = mt_rand(20, 30);
......
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