Commit 3fc3a241 authored by 冯超鹏's avatar 冯超鹏

添加用户模块和修改登入模块,修改权限

parent 3781ff76
......@@ -82,10 +82,11 @@ class swooleMqtt extends Command
});
$this->mqtt->on('receive', function ($server, $fd, $from_id, $data) {
$header = $this->mqttGetHeader($data);
print_r($data);
if ($header['type'] == 1) {
$resp = chr(32) . chr(2) . chr(0) . chr(0);
$this->eventConnect($header, substr($data, 2));
print_r($resp);
// print_r($resp);
$this->mqtt->send($fd, $resp);
} elseif ($header['type'] == 3) {
$resp = chr(32) . chr(2) . chr(0) . chr(0);
......
......@@ -13,12 +13,12 @@ class SwooleCommandController extends Controller
public function userslist(): string
{
//查询用户数量
$usercount = DB::table('BackgroundUser')->count();//获取用户数量
$usercount = DB::table('users')->count();//获取用户数量
//查询设备类型
$count = DB::table('BackgroundUser as b')
$count = DB::table('users as b')
->leftjoin('device as d','b.id','=','d.uid')
->leftjoin('device_type as t','d.dtype','=','t.tid')
->selectRaw('b.username,count(IF(d.dtype=1,true,null)) AS type_1, COUNT(IF(t.tid=2, true, null)) AS type_2,COUNT(IF(t.tid=4, true, null)) AS type_4,COUNT(IF(t.tid=5, true, null)) AS type_5,COUNT(IF(t.tid=6, true, null)) AS type_6,COUNT(IF(t.tid=7, true, null)) AS type_7,COUNT(IF(t.tid=8, true, null)) AS type_8,COUNT(IF(t.tid=9, true, null)) AS type_9,COUNT(IF(t.tid=10, true, null)) AS type_10,COUNT(IF(t.tid=11, true, null)) AS type_11')
->selectRaw('b.name,count(IF(d.dtype=1,true,null)) AS type_1, COUNT(IF(t.tid=2, true, null)) AS type_2,COUNT(IF(t.tid=4, true, null)) AS type_4,COUNT(IF(t.tid=5, true, null)) AS type_5,COUNT(IF(t.tid=6, true, null)) AS type_6,COUNT(IF(t.tid=7, true, null)) AS type_7,COUNT(IF(t.tid=8, true, null)) AS type_8,COUNT(IF(t.tid=9, true, null)) AS type_9,COUNT(IF(t.tid=10, true, null)) AS type_10,COUNT(IF(t.tid=11, true, null)) AS type_11')
->groupBy('b.id')
->get();
$countdata = ['usercount' => $usercount, 'userdata' => $count];
......
......@@ -27,40 +27,50 @@ class AuthController extends Controller
* @return \Illuminate\Http\JsonResponse
* @ 管理员登入
*/
//
public function login(Request $request , Users $users)
{
$userOrAdmin= $request->input('userOrAdmin');
$credentials = $request->only('email', 'password');
if($userOrAdmin == 1 ){ //用户
$BackgroundUser = $users->where([['email','=',$credentials['email']],['password','=',sha1($credentials['password'])],['state','=','2']])->first();
if (Auth::attempt($credentials)) {
$BackgroundUser = $users->where([['email','=',$credentials['email']],['isadmin','=','1']])->first();
if (!Auth::attempt($credentials)) {
return response()->json(new JsonResponse([], 'login_error'), Response::HTTP_UNAUTHORIZED);
}
if($BackgroundUser){
$BackgroundUser = $request->user();
print_r($BackgroundUser);
die();
$tokenResult = $BackgroundUser->createToken('Personal Access Token');
if($BackgroundUser != null){
$BackgroundUser = $users->where([['email','=',$credentials['email']],['isadmin','=','1']])->first()->toArray();
if($BackgroundUser['email'] != $credentials['email']){
$user = $request->user();
$tokenResult = $user->createToken('Personal Access Token');
$token = $tokenResult->token;
$token->save();
return response()->json(new UserResource($user), Response::HTTP_OK)->header('Authorization', $tokenResult->accessToken);
}else{
return response()->json(new JsonResponse([], '请用管理员窗口登入'), Response::HTTP_UNAUTHORIZED);
}
}else{
$user = $request->user();
$tokenResult = $user->createToken('Personal Access Token');
$token = $tokenResult->token;
$token->save();
return response()->json(new UserResource($BackgroundUser), Response::HTTP_OK)->header('Authorization', $tokenResult->accessToken);
return response()->json(new UserResource($user), Response::HTTP_OK)->header('Authorization', $tokenResult->accessToken);
}
}else{
$isadmin = $users->where([['email','=',$credentials['email']],['isadmin','=','2']])->first();
if ($isadmin) {
return response()->json(new JsonResponse([], '请用用户窗口登入'), Response::HTTP_UNAUTHORIZED);
}
if (!Auth::attempt($credentials)) {
return response()->json(new JsonResponse([], 'login_error'), Response::HTTP_UNAUTHORIZED);
}
$user = $request->user();
$tokenResult = $user->createToken('Personal Access Token');
$token = $tokenResult->token;
$token->save();
return response()->json(new UserResource($user), Response::HTTP_OK)->header('Authorization', $tokenResult->accessToken);
}
}
public function logout(Request $request)
{
$request->user()->token()->revoke();
......@@ -71,26 +81,4 @@ class AuthController extends Controller
{
return new UserResource(Auth::user());
}
// 用户登入接口
public function userslogin(Request $request , Users $users){
$email = $request->input('email');
$password = $request->input('password');
// if (!Auth::attempt($credentials)) {
// return response()->json(new JsonResponse([], 'login_error'), Response::HTTP_UNAUTHORIZED);
// }
if(is_null($email) || is_null($password)){
return $this->jsonErrorData(105,'用户名或密码不能为空');
}
$BackgroundUser = $users->where([['email','=',$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);
}
}
}
......@@ -76,8 +76,12 @@ class Controller extends BaseController
{
$user = Auth::user();//获取当前用户信息
$isadmin = DB::table('users')->where([['name', '=', $user['name']], ['email', '=', $user['email']]])->first();
return $isadmin;
return get_object_vars($isadmin)['isadmin'] == 1 ? '1' : null;
}
public function timeline($instructions)
{
return DB::table('timeline')->insertGetId(['instructions'=>$instructions,'operationip'=>$_SERVER["REMOTE_ADDR"],'timestamp'=>date("Y-m-d H:i:s",time())]);
}
}
This diff is collapsed.
......@@ -8,6 +8,7 @@ use App\Http\Resources\UserResource;
use App\Laravue\JsonResponse;
use App\Laravue\Models\Device;
use App\Laravue\Models\Users;
use App\Laravue\Models\Homepage;
use Illuminate\Http\Request;
use Illuminate\Http\Resources\Json\ResourceCollection;
use Illuminate\Support\Arr;
......@@ -16,6 +17,7 @@ use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Hash;
use Illuminate\Support\Facades\Redis;
use Validator;
class HomepageController extends Controller
{
//返回用户数量 设备数量, 报警数量 ,
......@@ -25,39 +27,97 @@ class HomepageController extends Controller
$devicecount = Device::count();
$devicepolice = Device::where('devicepolice', '>', '1')->count();
$t = time();//当前时间
$start = mktime(0,0,0,date("m",$t),date("d",$t),date("Y",$t));//今天的开始
$end = mktime(23,59,59,date("m",$t),date("d",$t),date("Y",$t));//今天的结束
$timedevicepolice = DB::table('reportpolice')->where('status', '=', '1')->whereBetween('starttime',[$start,$end])->count();
return $this->jsonSuccessData(['usercount' => $usercount, 'devicecount' => $devicecount, 'devicepolice' => $devicepolice,'timedevicepolice'=>$timedevicepolice]);
$start = mktime(0, 0, 0, date("m", $t), date("d", $t), date("Y", $t));//今天的开始
$end = mktime(23, 59, 59, date("m", $t), date("d", $t), date("Y", $t));//今天的结束
$timedevicepolice = DB::table('reportpolice')->where('status', '=', '1')->whereBetween('starttime', [$start, $end])->count();
return $this->jsonSuccessData(['usercount' => $usercount, 'devicecount' => $devicecount, 'devicepolice' => $devicepolice, 'timedevicepolice' => $timedevicepolice]);
}
public function gettimeline()
{
return $this->jsonSuccessData(DB::table('timeline')->orderByDesc('id')->get());
}
//返回一年当前月份
public function devicemonthcount(){
$year_start=strtotime(date("Y")."-01-01"); // 获取当前的1月份的时间戳
public function devicemonthcount()
{
$year_start = strtotime(date("Y") . "-01-01"); // 获取当前的1月份的时间戳
$endThismonth = mktime(23, 59, 59, date('m'), date('t'), date('Y')); //获取当月的时间戳
$devicedata = Device::whereBetween('deviceaddtime',[$year_start,$endThismonth])
$devicedata = Device::whereBetween('deviceaddtime', [$year_start, $endThismonth])
->selectRaw('from_unixtime(deviceaddtime,"%Y-%m") as date,COUNT(id) as value')
->groupBy('date')
->get()
->toArray();
$policedata = Users::whereBetween('add_time',[$year_start,$endThismonth])
->selectRaw('from_unixtime(add_time,"%Y-%m") as date,COUNT(id) as value')
$policedata = Users::whereBetween('created_at', [$year_start, $endThismonth])
->selectRaw('from_unixtime(created_at,"%Y-%m") as date,COUNT(id) as value')
->groupBy('date')
->get()
->toArray();
$devicepolice = Device::whereBetween('deviceaddtime',[$year_start,$endThismonth])
->where('devicepolice','>',1)
$devicepolice = Device::whereBetween('deviceaddtime', [$year_start, $endThismonth])
->where('devicepolice', '>', 1)
->selectRaw('from_unixtime(deviceaddtime,"%Y-%m") as date,COUNT(id) as value')
->groupBy('date')
->get()
->toArray();
return $this->jsonSuccessData(['devicedata'=>$this->datamonth($devicedata),'policedata'=>$this->datamonth($policedata),'devicepolice'=>$this->datamonth($devicepolice)]);
return $this->jsonSuccessData(['devicedata' => $this->datamonth($devicedata), 'policedata' => $this->datamonth($policedata), 'devicepolice' => $this->datamonth($devicepolice)]);
}
private function datamonth($monthdata = []) :array{
$year = date('Y',time());
$month = date('m',time());
//用户统计
public function UserStatistics (){
$devicecount = Device::where('uid','=',Auth::id())->count();
$devicepolice = Device::where('devicepolice', '>', '1')->where('uid','=',Auth::id())->count();
$t = time();//当前时间
$start = mktime(0, 0, 0, date("m", $t), date("d", $t), date("Y", $t));//今天的开始
$end = mktime(23, 59, 59, date("m", $t), date("d", $t), date("Y", $t));//今天的结束
$timedevicepolice = DB::table('reportpolice as r')
->join('device as d','d.devicenum','=','r.devicenumber')
->where('d.uid','=',Auth::id())
->where('r.status', '=', '1')
->whereBetween('r.starttime', [$start, $end])
->count();
return $this->jsonSuccessData(['devicecount' => $devicecount, 'devicepolice' => $devicepolice, 'timedevicepolice' => $timedevicepolice]);
}
//返回一年当前月份
public function userdevicemonthcount()
{
$year_start = strtotime(date("Y") . "-01-01"); // 获取当前的1月份的时间戳
$endThismonth = mktime(23, 59, 59, date('m'), date('t'), date('Y')); //获取当月的时间戳
$devicedata = Device::where('uid','=',Auth::id())->whereBetween('deviceaddtime', [$year_start, $endThismonth])
->selectRaw('from_unixtime(deviceaddtime,"%Y-%m") as date,COUNT(id) as value')
->groupBy('date')
->get()
->toArray();
$devicepolice = Device::where('uid','=',Auth::id())->whereBetween('deviceaddtime', [$year_start, $endThismonth])
->where('devicepolice', '>', 1)
->selectRaw('from_unixtime(deviceaddtime,"%Y-%m") as date,COUNT(id) as value')
->groupBy('date')
->get()
->toArray();
return $this->jsonSuccessData(['devicedata' => $this->datamonth($devicedata), 'devicepolice' => $this->datamonth($devicepolice)]);
}
// 项目统计
public function Project_statistics()
{
$start_time = microtime(true);
$memory = (!function_exists('memory_get_usage')) ? '0' : round(memory_get_usage() / 1024 / 1024, 2);
$unit = array('B', 'KB', 'MB', 'GB', 'TB', 'PD');
$phay = base_path();
$size = $this->getDirSize($phay);
$base_path = @round($size / pow(1024, ($i = floor(log($size, 1024)))), 2);
$end_time = microtime(true);
return $this->jsonSuccessData(['memory' => round($memory), 'base_path' => round($base_path) / 10, 'end_time' => round($end_time - $start_time), 'dabatime' => ceil($this->dabadas()),'rand'=>rand(1,100)]);
}
//获取接口访问时间
private function datamonth($monthdata = []): array
{
$year = date('Y', time());
$month = date('m', time());
$data = [];
foreach ($monthdata as $value) {
$data[$value['date']] = $value['value'];
......@@ -70,4 +130,33 @@ class HomepageController extends Controller
}
return $out;
}
private function getDirSize($dir)
{
@$dh = opendir($dir);
$size = 0;
while ($file = @readdir($dh)) {
if ($file != "." and $file != "..") {
$path = $dir . "/" . $file;
if (is_dir($path)) {
$size += $this->getDirSize($path);
} elseif (is_file($path)) {
$size += filesize($path);
}
}
}
@closedir($dh);
return $size;
}
private function dabadas()
{
$start_time = microtime(true);
DB::table('device')->select();
DB::table('timeline')->select();
DB::table('BackgroundUser')->select();
$end_time = microtime(true);
return $end_time - $start_time;
}
}
\ No newline at end of file
......@@ -38,6 +38,7 @@ class InstallerController extends Controller
unset($keys[$key]);
}
}
$this->timeline('新增了装维人员');
return $this->jsonSuccessData($type->addinstall($keys));
}
// 用户搜索
......@@ -104,8 +105,10 @@ class InstallerController extends Controller
return $this->jsonErrorData(105,'uid不能为空');
}
if ($type == 1){//物理删除
$this->timeline('装维人员放置废纸篓');
return $this->jsonSuccessData(Installer::where('id','=',$uid)->delete());
}elseif($type == 2){//逻辑删除
$this->timeline('删除了废纸篓');
return $this->jsonSuccessData(Installer::where('id','=',$uid)->update(['delete'=>2,'status'=>2]));
}
......
......@@ -58,6 +58,7 @@ class UploadimgController extends Controller
unset($data[$k]);
}
}
$this->timeline('新增了新的图片');
$add = DB::table('userimage')
->insert($data);
return $this->jsonSuccessData($add);
......@@ -79,8 +80,10 @@ class UploadimgController extends Controller
return $this->jsonErrorData(105,'参数不能为空');
}
if($type == 1){//逻辑删除
$this->timeline('将图片放置废纸篓');
return $this->jsonSuccessData($userimage->where('id','=',$imgid)->update(['delete'=>'2']));
}else if ($type == 2){//物理删除
$this->timeline('删除了图片');
return $this->jsonSuccessData($userimage->where('id','=',$imgid)->delete());
}
}
......
This diff is collapsed.
On Error Resume Next
Set objProc = GetObject("winmgmts:\\.\root\cimv2:win32_processor='cpu0'")
WScript.Echo(objProc.LoadPercentage)
\ No newline at end of file
......@@ -30,7 +30,7 @@ class User extends Authenticatable
* @var array
*/
protected $fillable = [
'name', 'email', 'password'
'name', 'email', 'password','username','title','company','mapcenter','province','cityid','areaid','provinceid','isadmin'
];
/**
......
......@@ -22,7 +22,7 @@ class Users extends Authenticatable
{
use Notifiable, HasRoles, HasApiTokens;
protected $table = "BackgroundUser";
protected $table = "users";
public $timestamps = false;
public function getTypeAllToArray($userdata = []) {
......
......@@ -62,7 +62,19 @@ return [
PDO::MYSQL_ATTR_SSL_CA => env('MYSQL_ATTR_SSL_CA'),
]) : [],
],
'mysql_center' => [
'driver' => 'mysql',
'host' => env('DB_HOST_CENTER', 'localhost'),
'port' => env('DB_PORT_CENTER', '3306'),
'database' => env('DB_DATABASE_CENTER', 'forge'),
'username' => env('DB_USERNAME_CENTER', 'forge'),
'password' => env('DB_PASSWORD_CENTER', ''),
'charset' => 'utf8',
'collation' => 'utf8mb4_unicode_ci',
'prefix' => '',
'strict' => false,
'engine' => null,
],
'pgsql' => [
'driver' => 'pgsql',
'url' => env('DATABASE_URL'),
......
No preview for this file type
[{"devicenum":"ZHGAS000131031","username":"123214","deviceremark":null,"devicelinkman":"1","devicephone":"16631150870","deviceinfo":null,"tname":"\u5bb6\u7528\u62a5\u8b66\u5668(IOT)","gas":"\u7532\u70f7","danwei":"%LEL","status_name":"\u62a5\u8b66"}]
[{"devicenum":"ZHGAS000131031","username":"123214","deviceremark":null,"devicelinkman":"1","devicephone":"16631150870","deviceinfo":null,"tname":"\u5bb6\u7528\u62a5\u8b66\u5668(IOT)","gas":"\u7532\u70f7","danwei":"%LEL","status_name":"\u4f20\u611f\u5668\u6545\u969c"}]
[{"devicenum":"ZHGAS000131031","username":"123214","deviceremark":null,"devicelinkman":"1","devicephone":"16631150870","deviceinfo":null,"tname":"\u5bb6\u7528\u62a5\u8b66\u5668(IOT)","gas":"\u7532\u70f7","danwei":"%LEL","status_name":"\u9ad8\u62a5"}]
[{"devicenum":"A202005062000","username":"\u4eca\u5929\u516d\u4e00","deviceremark":"**","devicelinkman":"\u8427\u5c71","devicephone":"15634500000","deviceinfo":"\u5357\u5bab\u6c7d\u8f66\u7ad9","tname":"\u538b\u529b\u76d1\u6d4b\u8bbe\u5907","gas":"\u786b\u5316\u6c22","danwei":"%VOL","status_name":"\u6b63\u5e38"}]
......@@ -128,3 +128,11 @@ export function addcontactsuser(data) {
data,
});
}
export function userdeviceList(data) {
return request({
url: '/devices/userdevicelist',
method: 'post',
data,
});
}
......@@ -14,3 +14,32 @@ export function getcount() { // 设备类型
});
}
export function timeline() { // 时间线
return request({
url: 'homepagecount/timeline',
method: 'get',
});
}
export function Project_statistics() { // 统计
return request({
url: 'homepagecount/Project_statistics',
method: 'get',
});
}
// 用户统计
export function UserStatistics() { // 统计
return request({
url: 'homepagecount/UserStatistics',
method: 'get',
});
}
// 用户统计
export function userdevicemonthcount() { // 统计
return request({
url: 'homepagecount/userdevicemonthcount',
method: 'get',
});
}
......@@ -73,3 +73,17 @@ export function userLocation() {
});
}
export function areachina() {
return request({
url: '/user/areachina',
method: 'get',
});
}
export function areachinapost(data) {
return request({
url: '/user/areachina',
method: 'post',
data,
});
}
......@@ -5,7 +5,7 @@
<script>
import echarts from 'echarts';
import resize from './mixins/resize';
import { userdevicemonthcount } from '@/api/homepage';
export default {
mixins: [resize],
props: {
......@@ -29,10 +29,12 @@ export default {
data() {
return {
chart: null,
userdevicepolice: [],
userdevicecount: [],
};
},
mounted() {
this.initChart();
created() {
this.UserStatistics();
},
beforeDestroy() {
if (!this.chart) {
......@@ -43,13 +45,20 @@ export default {
},
methods: {
initChart() {
const xData = (function() {
const data = [];
const date = new Date();
for (let i = 1; i < date.getMonth() + 1 + 1; i++) {
data.push(i + '月');
}
return data;
}());
this.chart = echarts.init(document.getElementById(this.id));
this.chart.setOption({
backgroundColor: '#394056',
title: {
top: 20,
text: 'Requests',
text: '设备统计',
textStyle: {
fontWeight: 'normal',
fontSize: 16,
......@@ -71,7 +80,7 @@ export default {
itemWidth: 14,
itemHeight: 5,
itemGap: 13,
data: ['API', 'Search', 'Log'],
data: ['设备数量', '报警数量'],
right: '4%',
textStyle: {
fontSize: 12,
......@@ -93,7 +102,7 @@ export default {
color: '#57617B',
},
},
data: ['13:00', '13:05', '13:10', '13:15', '13:20', '13:25', '13:30', '13:35', '13:40', '13:45', '13:50', '13:55'],
data: xData,
}],
yAxis: [{
type: 'value',
......@@ -119,40 +128,7 @@ export default {
},
}],
series: [{
name: 'API',
type: 'line',
smooth: true,
symbol: 'circle',
symbolSize: 5,
showSymbol: false,
lineStyle: {
normal: {
width: 1,
},
},
areaStyle: {
normal: {
color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [{
offset: 0,
color: 'rgba(137, 189, 27, 0.3)',
}, {
offset: 0.8,
color: 'rgba(137, 189, 27, 0)',
}], false),
shadowColor: 'rgba(0, 0, 0, 0.1)',
shadowBlur: 10,
},
},
itemStyle: {
normal: {
color: 'rgb(137,189,27)',
borderColor: 'rgba(137,189,2,0.27)',
borderWidth: 12,
},
},
data: [220, 182, 191, 134, 150, 120, 110, 125, 145, 122, 165, 122],
}, {
name: 'Search',
name: '设备数量',
type: 'line',
smooth: true,
symbol: 'circle',
......@@ -183,9 +159,9 @@ export default {
borderWidth: 12,
},
},
data: [120, 110, 125, 145, 122, 165, 122, 220, 182, 191, 134, 150],
data: this.userdevicecount,
}, {
name: 'Log',
name: '报警数量',
type: 'line',
smooth: true,
symbol: 'circle',
......@@ -216,10 +192,23 @@ export default {
borderWidth: 12,
},
},
data: [220, 182, 125, 145, 122, 191, 134, 150, 120, 110, 165, 122],
data: this.userdevicepolice,
}],
});
},
UserStatistics() {
userdevicemonthcount()
.then(response => {
if (response.code === 200) {
this.userdevicecount = response.data.devicedata;
this.userdevicepolice = response.data.devicepolice;
this.initChart();
}
})
.catch(err => {
console.log(err);
});
},
},
};
</script>
......@@ -73,7 +73,7 @@ export default {
if (item.hidden) {
return false;
} else {
// Temp set(will be used if only has one showing child)
console.log(item);
this.onlyOneChild = item;
return true;
}
......
......@@ -24,6 +24,7 @@ import usersRoutes from './modules/users';
// import permissionRoutes from './modules/permission';
import historyRoutes from './modules/history.js';
import monitorRoutes from './modules/monitor.js';
import userdeviceRoutes from './modules/userdevice';
/**
* Sub-menu only appear when children.length>=1
......@@ -37,7 +38,7 @@ import monitorRoutes from './modules/monitor.js';
* it will becomes nested mode, otherwise not show the root menu
* redirect: noredirect if `redirect:noredirect` will no redirect in the breadcrumb
* name:'router-name' the name is used by <keep-alive> (must set!!!)
* meta : {
* me
roles: ['admin', 'editor'] Visible for these roles only
permissions: ['view menu zip', 'manage user'] Visible for these permissions only
title: 'title' the name show in sub-menu and breadcrumb (recommend set)
......@@ -53,6 +54,8 @@ export const constantRoutes = [
path: '/redirect',
component: Layout,
hidden: true,
meta: { roles: ['admin'] },
permissions: ['admin'],
children: [
{
path: '/redirect/:path*',
......@@ -95,28 +98,10 @@ export const constantRoutes = [
path: 'dashboard',
component: () => import('@/views/dashboard/index'),
name: 'Dashboard',
meta: { title: 'dashboard', icon: 'dashboard', noCache: false },
meta: { title: 'dashboard', icon: 'dashboard', noCache: false, permissions: ['view menu dashboard'] },
},
],
},
{
path: '/map',
component: Layout,
redirect: '/map',
children: [
{
path: 'map',
component: () => import('@/views/map/index'),
name: 'Map',
meta: { title: 'map', icon: 'international', noCache: false },
},
],
},
monitorRoutes,
historyRoutes,
deviceRoutes,
usersRoutes,
adminRoutes,
// {
// path: '/documentation',
// component: Layout,
......@@ -164,69 +149,41 @@ export const asyncRoutes = [
// },
// ],
// },
monitorRoutes,
historyRoutes,
deviceRoutes,
usersRoutes,
adminRoutes,
userdeviceRoutes,
// {
// path: '/clipboard',
// path: '/userdevice',
// component: Layout,
// redirect: 'noredirect',
// meta: { permissions: ['view menu clipboard'] },
// hidden: false,
// meta: { permissions: ['view menu userdevice'], roles: ['user'] },
// children: [
// {
// path: 'index',
// component: () => import('@/views/clipboard/index'),
// name: 'ClipboardDemo',
// meta: { title: 'clipboardDemo', icon: 'clipboard', roles: ['admin', 'manager', 'editor', 'user'] },
// component: () => import('@/views/userdevice/index'),
// name: 'userdevice',
// meta: { title: '设备列表', icon: 'tree-table' },
// },
// ],
// },
// errorRoutes,
// {
// path: '/zip',
// component: Layout,
// redirect: '/zip/download',
// alwaysShow: true,
// meta: { title: 'zip', icon: 'zip', permissions: ['view menu zip'] },
// children: [
// {
// path: 'download',
// component: () => import('@/views/zip'),
// name: 'ExportZip',
// meta: { title: 'exportZip' },
// },
// ],
// },
// {
// path: '/pdf',
// component: Layout,
// redirect: '/pdf/index',
// meta: { title: 'pdf', icon: 'pdf', permissions: ['view menu pdf'] },
// children: [
// {
// path: 'index',
// component: () => import('@/views/pdf'),
// name: 'Pdf',
// meta: { title: 'pdf' },
// },
// ],
// },
// {
// path: '/pdf/download',
// component: () => import('@/views/pdf/Download'),
// hidden: true,
// },
// {
// path: '/i18n',
// component: Layout,
// meta: { permissions: ['view menu i18n'] },
// children: [
// {
// path: 'index',
// component: () => import('@/views/i18n'),
// name: 'I18n',
// meta: { title: 'i18n', icon: 'international' },
// },
// ],
// },
{ path: '*', redirect: '/404', hidden: true },
{
path: '/map',
component: Layout,
redirect: '/map',
children: [
{
path: 'map',
component: () => import('@/views/map/index'),
name: 'Map',
meta: { title: 'map', icon: 'international', noCache: false },
},
],
},
{ path: '/', redirect: '/error/404', hidden: true },
];
const createRouter = () => new Router({
......
......@@ -48,12 +48,12 @@ const adminRoutes = {
meta: { title: 'editArticle', noCache: true, permissions: ['manage article'] },
hidden: true,
},
{
path: 'articles',
component: () => import('@/views/articles/List'),
name: 'ArticleList',
meta: { title: 'articleList', icon: 'list', permissions: ['manage article'] },
},
// {
// path: 'articles',
// component: () => import('@/views/articles/List'),
// name: 'ArticleList',
// meta: { title: 'articleList', icon: 'list', permissions: ['manage article'] },
// },
],
};
......
......@@ -9,7 +9,7 @@ const deviceRoutes = {
meta: {
title: '设备管理',
icon: 'device',
permissions: ['view menu administrator'],
permissions: ['view menu admindevice'],
},
children: [
{
......
......@@ -8,7 +8,7 @@ const historyRoutes = {
meta: {
title: 'history',
icon: 'nested',
permissions: ['view menu history alarms'],
permissions: ['view menu history'],
},
children: [
{
......
import Layout from '@/layout';
const userdeviceRoutes = {
path: '/userdevice',
component: Layout,
redirect: '/userdevice/index',
name: 'Devices',
alwaysShow: true,
meta: {
title: '用户设备管理',
icon: 'device',
},
children: [
{
path: 'device',
component: () => import('@/views/userdevice/index'),
name: 'Device',
meta: { title: '设备列表', icon: 'devicelist' },
},
// {
// path: 'categories',
// component: () => import('@/views/device/categories'),
// name: 'Categories',
// meta: { title: '设备分类', icon: 'tree-table', permissions: ['manage categories'] },
// },
{
path: 'DeviceStutus',
component: () => import('@/views/device/devicedtutus'),
name: 'DeviceStutus',
meta: { title: '设备废纸篓', icon: 'devicestutus' },
},
{
path: 'addDevice',
component: () => import('@/views/device/addDevice'),
name: 'addDevice',
meta: { title: '添加设备', icon: 'deviceadd' },
},
],
};
export default userdeviceRoutes;
......@@ -9,7 +9,7 @@ const usersRoutes = {
meta: {
title: '用户管理',
icon: 'peoples',
permissions: ['view menu administrator'],
permissions: ['view menu user'],
},
children: [
{
......
<template>
<div class="app-container">
<el-row :gutter="20">
<el-col :span="20">
<!-- 用户操作 -->
<div>
<el-row :gutter="20">
<el-col :span="6"><el-card shadow="always">用户数量<span style="margin-left: 12px;color: #606266;">{{ synthesizecount.usercount }}</span></el-card></el-col>
<el-col :span="6"><el-card shadow="always">设备数量<span style="margin-left: 12px;color: #409EFF;">{{ synthesizecount.devicecount }}</span></el-card></el-col>
<el-col :span="6"><el-card shadow="always">报警数量<span style="margin-left: 12px;color: #E6A23C;">{{ synthesizecount.devicepolice }}</span></el-card></el-col>
<el-col :span="6"><el-card shadow="always">今天报警次数<span style="margin-left: 12px;color: #F56C6C;">{{ synthesizecount.timedevicepolice }}</span></el-card></el-col>
</el-row>
<div v-if="checkPermission(['manage isadmin'])">
<el-row :gutter="20">
<el-col :span="20">
<!-- 用户操作 -->
<div>
<el-row :gutter="20">
<el-col :span="6"><el-card shadow="always">用户数量<span style="margin-left: 12px;color: #606266;">{{ synthesizecount.usercount }}</span></el-card></el-col>
<el-col :span="6"><el-card shadow="always">设备数量<span style="margin-left: 12px;color: #409EFF;">{{ synthesizecount.devicecount }}</span></el-card></el-col>
<el-col :span="6"><el-card shadow="always">报警数量<span style="margin-left: 12px;color: #E6A23C;">{{ synthesizecount.devicepolice }}</span></el-card></el-col>
<el-col :span="6"><el-card shadow="always">今天报警次数<span style="margin-left: 12px;color: #F56C6C;">{{ synthesizecount.timedevicepolice }}</span></el-card></el-col>
</el-row>
</div>
<!-- 混合统计 -->
<el-card class="box-card" style="margin-top:12px;padding-bottom:24px">
<div class="chart-container" style="position: relative; top: 2px; height: 560px;">
<chart height="100%" width="100%" />
</div>
</el-card>
<!-- 统计 -->
<el-card class="box-card" style="margin-top:12px;height: 200px;">
<div style="display: inline-block;">
<el-progress type="dashboard" :percentage="memory" :color="colors"></el-progress>
<el-tooltip class="item" effect="dark" :content="memory + 'MB'" placement="top-start">
<span style="position: relative;left: -115px;top: 12px;">项目运行速度</span>
</el-tooltip>
</div>
<div style="display: inline-block;">
<el-progress type="dashboard" :percentage="base_path" :color="colors"></el-progress>
<el-tooltip class="item" effect="dark" :content="base_path * 10 + 'MB'" placement="top-start">
<span style="position: relative;left: -108px;top: 12px;">项目容量</span>
</el-tooltip>
</div>
<div style="display: inline-block;">
<el-progress type="dashboard" :percentage="end_time" :color="colors"></el-progress>
<el-tooltip class="item" effect="dark" :content="end_time + 'S'" placement="top-start">
<span style="position: relative;left: -112px;top: 12px;">访问接口速度</span>
</el-tooltip>
</div>
<div style="display: inline-block; position: relative;left: -36px;">
<el-progress type="dashboard" :percentage="databas" :color="colors"></el-progress>
<el-tooltip class="item" effect="dark" :content="databas + 'S'" placement="top-start">
<span style="position: relative;left: -122px;top: 12px;">访问数据库速度</span>
</el-tooltip>
</div>
<div style="display: inline-block;position: relative;right: -808px;bottom: 127px;">
<el-progress type="dashboard" :percentage="rand" :color="colors"></el-progress>
<el-tooltip class="item" effect="dark" :content="rand + 'MB'" placement="top-start">
<span style="position: relative;left: -112px;top: 12px;">进程占用情况</span>
</el-tooltip>
</div>
</el-card>
</el-col>
<el-col :span="4">
<!-- 时间线 -->
<el-card class="box-card" style="width: 210px;position: relative;left: -13px;height: 908px;overflow:scroll">
<div style="position: relative;left: -55px;">
<el-timeline :reverse="reverse">
<el-timeline-item v-for="(activity, index) in activities" :key="index" :timestamp="activity.timestamp" style="width: 202px;">{{ activity.instructions }}<div style="padding-top: 7px;">ip:{{ activity.operationip }}</div></el-timeline-item>
</el-timeline>
</div>
</el-card>
</el-col>
</el-row>
</div>
<div v-if="checkPermission(['manage device'])">
<!-- 用户首页 -->
<el-row :gutter="20">
<el-col :span="6"><el-card shadow="always">设备数量<span style="margin-left: 12px;color: #1426fe;">{{ uerscount.devicecount }}</span></el-card></el-col>
<el-col v-if="uerscount.devicepolice != 0" :span="6"><el-card shadow="always">今日正常设备<span style="margin-left: 12px;color: #409EFF;">{{ uerscount.devicepolice }}</span></el-card></el-col>
<el-col v-if="uerscount.devicepolice == 0" :span="6"><el-card shadow="always">今日正常设备<span style="margin-left: 12px;color: #409EFF;">{{ uerscount.devicecount }}</span></el-card></el-col>
<el-col :span="6"><el-card shadow="always">今天报警数量<span style="margin-left: 12px;color: #E6A23C;">{{ uerscount.timedevicepolice }}</span></el-card></el-col>
<el-col :span="6"><el-card shadow="always">设备服务分析<span :style="{color: uerscount.timedevicepolice === 0 ? '#67C23A' : (uerscount.timedevicepolice > 10 ? '#909399': (uerscount.timedevicepolice > 20 ? '#E6A23C' : '#F56C6C'))}" style="margin-left: 12px;">{{ uerscount.timedevicepolice === 0 ? '正常' : (uerscount.timedevicepolice > 10 ? '良好': (uerscount.timedevicepolice > 20 ? '较差' : '极差')) }}</span></el-card></el-col>
</el-row>
<el-card class="box-card" style="margin-top:12px;padding-bottom:24px">
<div class="chart-container" style="position: relative; top: 2px; height: 560px;">
<LineChart height="100%" width="100%" />
</div>
<!-- 混合统计 -->
<div class="chart-container" style="position: relative; top: 20px; height: 500px;">
<chart height="100%" width="100%" />
</div>
</el-col>
<el-col :span="4">
<!-- 时间线 -->
<div>
<el-timeline :reverse="reverse">
<el-timeline-item v-for="(activity, index) in activities" :key="index" :timestamp="activity.timestamp">{{ activity.content }}</el-timeline-item>
</el-timeline>
</div>
</el-col>
</el-row>
</el-card>
</div>
</div>
</template>
<script>
import Chart from '@/components/Charts/MixChart';
import { homepagecount } from '@/api/homepage';
import LineChart from '@/components/Charts/lineMarker';
import checkPermission from '@/utils/permission';
import { homepagecount, timeline, Project_statistics, UserStatistics } from '@/api/homepage';
export default {
name: 'Dashboard',
components: { Chart },
components: { Chart, LineChart },
data() {
return {
reverse: true,
reverse: false,
synthesizecount: [],
activities: [{
content: '活动按期开始',
timestamp: '2018-04-15',
}, {
content: '创建成功',
timestamp: '2018-04-11',
}],
uerscount: [],
activities: [],
memory: 0,
base_path: 0,
end_time: 0,
databas: 0,
rand: 0,
colors: [
{ color: '#f56c6c', memory: 20 },
{ color: '#e6a23c', memory: 40 },
{ color: '#5cb87a', memory: 60 },
{ color: '#1989fa', memory: 80 },
{ color: '#6f7ad3', memory: 100 },
],
};
},
created() {
this.getList();
this.timeline();
this.Project();
this.UserStatistics();
},
methods: {
checkPermission,
getList() {
homepagecount()
.then(response => {
......@@ -60,6 +127,39 @@ export default {
console.log(err);
});
},
timeline() {
timeline()
.then(response => {
this.activities = response.data;
})
.catch(err => {
console.log(err);
});
},
Project() {
Project_statistics()
.then(response => {
this.base_path = response.data.base_path;
this.memory = response.data.memory;
this.end_time = response.data.end_time;
this.databas = response.data.dabatime;
this.rand = response.data.rand;
})
.catch(err => {
console.log(err);
});
},
UserStatistics() {
UserStatistics()
.then(response => {
if (response.code === 200) {
this.uerscount = response.data;
}
})
.catch(err => {
console.log(err);
});
},
},
};
</script>
......
......@@ -22,9 +22,9 @@
<el-option v-for="item in danwei" :key="item.id" :label="item.danwei" :value="item.id"></el-option>
</el-select>
</el-form-item>
<el-form-item label="选择用户" prop="uid">
<el-form-item v-if="checkPermission(['manage isadmin'])" label="选择用户" prop="uid">
<el-select v-model="form.uid" placeholder="请选择用户">
<el-option v-for="item in addUserDevice" :key="item.id" :label="item.nickname" :value="item.id"></el-option>
<el-option v-for="item in addUserDevice" :key="item.id" :label="item.name" :value="item.id"></el-option>
</el-select>
</el-form-item>
<el-form-item label="设备联系人" prop="devicelinkman" label-width="92px">
......@@ -35,7 +35,7 @@
</el-form-item>
<el-form-item label="设备坐标" prop="devicecoord">
<el-input v-model="form.devicecoord" style="width: 50%;"></el-input>
<el-button type="primary" style="position: relative;left: 51px;top: 57px;z-index: 999;" @click="drawer = true">拾取坐标</el-button>
<el-button type="primary" style="position: relative;left: 18px;z-index: 999;" @click="drawer = true">拾取坐标</el-button>
</el-form-item>
<el-form-item label="设备详情,设备安装位置" prop="deviceinfo" label-width="167px">
<el-input v-model="form.deviceinfo" style="width: 50%;"></el-input>
......@@ -59,6 +59,7 @@
<script>
import CoordinateMap from '@/components/coordinateMap';
import { deviceTypeList, addUserDevice, adddevice } from '@/api/device';
import checkPermission from '@/utils/permission';
export default {
components: { CoordinateMap },
data() {
......@@ -126,13 +127,14 @@ export default {
this.addUserDevices();
},
methods: {
checkPermission,
onSubmit(formName) {
this.$refs[formName].validate((valid) => {
if (valid) {
adddevice(this.form)
.then(response => {
if (response.code === 200) {
this.$router.push({ path: '/device/device' });
this.$router.push({ path: '/userdevice/device' });
}
})
.catch(err => {
......
......@@ -18,6 +18,11 @@
<span>{{ scope.row.deviceremark }}</span>
</template>
</el-table-column>
<el-table-column v-if="checkPermission(['manage isadmin'])" prop="email" label="设备删除记入" width="180">
<template slot-scope="scope">
<span>{{ scope.row.devicedeleteinfo }}</span>
</template>
</el-table-column>
<el-table-column align="center" label="创建时间" width="170">
<template slot-scope="scope">
<span>{{ scope.row.deviceaddtime | parseTime('{y}-{m}-{d} {h}:{i}') }}</span>
......@@ -37,6 +42,7 @@
<script>
import { deviceBasketList, UpPaperBasket } from '@/api/device';
import checkPermission from '@/utils/permission';
export default {
data() {
return {
......@@ -50,6 +56,7 @@ export default {
this.deviceBasketList();
},
methods: {
checkPermission,
deviceBasketList() {
deviceBasketList()
.then(response => {
......
......@@ -9,7 +9,7 @@
<span @click="handleCopy(scope.row.devicenum,$event)">{{ scope.row.devicenum }}</span>
</template>
</el-table-column>
<el-table-column label="用户姓名" width="140">
<el-table-column label="设备名称" width="140">
<template slot-scope="scope">
<span>{{ scope.row.username }}</span>
</template>
......@@ -70,6 +70,7 @@ export default {
data() {
return {
equipment: [],
timer: null,
tableKey: 0,
value2: undefined,
pickerOptions: {
......@@ -117,11 +118,18 @@ export default {
.then(response => {
if (response.code === 200) {
this.equipment = response.data;
this.timers();
} else if (response.code === 105) {
this.$message({
message: response.msg,
type: 'warning',
});
} else {
this.$notify({
title: '警告',
message: 'TCP链接失败',
type: 'warning',
});
}
})
.catch(err => {
......@@ -148,6 +156,16 @@ export default {
console.log(err);
});
},
timers() {
// this.timer = setInterval(() => {
// this.equipmentlist();
// }, 10000);
},
destroyed() {
this.$once('hook:beforeDestroy', () => {
clearInterval(this.timer);
});
},
},
};
</script>
......
......@@ -15,10 +15,10 @@
:key="marker.id"
:position="marker.mapcenter | rebuildUserCenter(marker.mapcenter)"
:visible="markerVisible"
:content="marker.nickname | rebuildContent(marker.UserDaviceNum, marker.police)"
:content="marker.name | rebuildContent(marker.UserDaviceNum, marker.police)"
:vid="index"
:clickable="true"
:events="rebuildEvent(marker)"
:events="checkPermission(['manage isadmin']) ? rebuildEvent(marker) : ''"
:z-index="markerUserZIndex"
></el-amap-marker>
<el-amap-circle-marker
......@@ -35,7 +35,8 @@
></el-amap-circle-marker>
<!-- 右上角设备和用户切换按钮 -->
<div class="toolbar">
<el-button type="primary" size="mini" round @click="allDevices">全部设备</el-button>
<el-button v-if="leftDeviceName != '全部设备' " type="primary" size="mini" round @click="allDevices">全部设备</el-button>
<!-- <el-button v-if="checkPermission(['manage device'])" type="primary" size="mini" round @click="allDevices">全部设备</el-button> -->
<el-switch
v-model="markersDeviceVisible"
active-text="设备"
......@@ -63,7 +64,7 @@
</el-dialog>
<!-- 用户的设备列表 -->
<div v-if="deviceListVisible" class="zero-user-devices">
<el-collapse v-model="activeNames">
<el-collapse v-if="checkPermission(['manage isadmin'])" v-model="activeNames">
<el-collapse-item name="1">
<template slot="title">
设备列表 - {{ leftDeviceName }}
......@@ -82,6 +83,25 @@
</el-table>
</el-collapse-item>
</el-collapse>
<el-collapse v-if="checkPermission(['manage device'])" v-model="activeNames">
<el-collapse-item name="1">
<template slot="title">
{{ leftDeviceName }}
</template>
<el-table :data="markersDevice" style="100%" max-height="700">
<el-table-column property="devicenum" label="设备编号" width="200px"></el-table-column>
<el-table-column property="deviceinfo" label="位置" width="200px"></el-table-column>
<el-table-column property="nd" label="值" width="40px"></el-table-column>
<el-table-column property="devicepolice" label="状态">
<template slot-scope="scope">
<el-tag effect="dark" :hit="false" style="border-color: #ffffff;" :color="scope.row.devicepolice | deviceStatusFilter('color')" size="mini">
{{ scope.row.devicepolice | deviceStatusFilter('status') }}
</el-tag>
</template>
</el-table-column>
</el-table>
</el-collapse-item>
</el-collapse>
</div>
</div>
</template>
......@@ -91,7 +111,7 @@ import Vue from 'vue';
import VueAMap from 'vue-amap';
import { AMapManager } from 'vue-amap';
import { devices, users, deviceinfo } from '@/api/map';
import checkPermission from '@/utils/permission';
Vue.use(VueAMap);
// 初始化vue-amap
......@@ -225,6 +245,7 @@ export default {
});
},
methods: {
checkPermission,
allDevices() {
devices()
.then(res => {
......@@ -247,7 +268,7 @@ export default {
return {
click(e) {
// alert(that.zoom);
that.leftDeviceName = marker.nickname;
that.leftDeviceName = marker.name;
that.getUserDevices(position);
that.deviceListVisible = true;
that.markerUserZIndex = 1000;
......
......@@ -2,7 +2,7 @@
<div class="app-container">
<div class="filter-container">
<el-form ref="query" :model="userdata" style="display: inline-block;">
<el-input v-model="userdata.nickname" placeholder="用户名称" clearable style="width: 200px;" class="filter-item" name="userskk" @input="changeValue" />
<el-input v-model="userdata.name" placeholder="用户名称" clearable style="width: 200px;" class="filter-item" name="userskk" @input="changeValue" />
<el-select v-model="userdata.state" placeholder="状态" clearable class="filter-item" style="width: 130px" @change="selectOne">
<el-option v-for="item in calendarTypeOptions" :key="item" :label="item" :value="item" />
</el-select>
......@@ -32,10 +32,10 @@
</el-table-column>
<el-table-column align="center" label="用户名称" width="150">
<template slot-scope="scope">
<span>{{ scope.row.nickname }}</span>
<span>{{ scope.row.name }}</span>
</template>
</el-table-column>
<el-table-column align="center" label="用户邮箱" width="170">
<el-table-column align="center" label="用户邮箱" width="180">
<template slot-scope="scope">
<span @click="handleCopy(scope.row.email,$event)">{{ scope.row.email }}</span>
</template>
......@@ -45,19 +45,19 @@
<span v-for="item in userDaviceNum" :key="item.index">{{ scope.row.id==item.id ? item.count : '' }}</span>
</template>
</el-table-column>
<el-table-column align="center" label="用户地址" width="170">
<el-table-column align="center" label="用户地址" width="340">
<template slot-scope="scope">
<span>{{ scope.row.province }}-{{ scope.row.area }}-{{ scope.row.city }}</span>
</template>
</el-table-column>
<el-table-column align="center" label="创建时间" width="170">
<template slot-scope="scope">
<span>{{ scope.row.add_time | parseTime('{y}-{m}-{d} {h}:{i}') }}</span>
<span>{{ scope.row.created_at | parseTime('{y}-{m}-{d} {h}:{i}') }}</span>
</template>
</el-table-column>
<el-table-column align="center" label="状态" width="400">
<el-table-column align="center" label="状态" width="250">
<template slot-scope="scope">
<span :style="{color:( scope.row.state==1 ? '#F56C6C' : ( scope.row.state==3 ? '#909399' : '#67C23A' ) )}">{{ scope.row.state==1 ? '用户已被丢弃废纸篓' : ( scope.row.state==3 ? '禁用' : '正常' ) }}</span>
<span :style="{color:( scope.row.state==1 ? '#F56C6C' : ( scope.row.state==3 ? '#909399' : '#67C23A' ) )}">{{ scope.row.state==1 ? '禁用' : ( scope.row.state==3 ? '用户已被丢弃废纸篓' : '正常' ) }}</span>
</template>
</el-table-column>
<el-table-column label="操作" align="center" width="230" class-name="small-padding fixed-width">
......@@ -66,7 +66,7 @@
<el-popover width="160" trigger="click" placement="top">
<p>此删除,分丢弃废纸篓,和删除</p>
<div style="text-align: right; margin: 0">
<el-button v-if="scope.row.state>1" size="mini" type="text" @click="userDelete(scope.row.id, 1)">丢弃废纸篓</el-button>
<el-button v-if="scope.row.state<3" size="mini" type="text" @click="userDelete(scope.row.id, 1)">丢弃废纸篓</el-button>
<el-button type="text" size="mini" @click="userDelete(scope.row.id, 2)">删除</el-button>
</div>
<el-button slot="reference" size="mini" type="danger">删除</el-button>
......@@ -82,7 +82,7 @@
<el-input v-model.number="upUserData.username"></el-input>
</el-form-item>
<el-form-item label="用户名称" prop="nickname">
<el-input v-model.number="upUserData.nickname"></el-input>
<el-input v-model.number="upUserData.name"></el-input>
</el-form-item>
<el-form-item label="邮箱" prop="email">
<el-input v-model.number="upUserData.email"></el-input>
......@@ -128,7 +128,7 @@ export default {
},
upUserData: {
username: undefined,
nickname: undefined,
name: undefined,
title: undefined,
email: undefined,
company: undefined,
......
......@@ -9,7 +9,7 @@
<el-table :data="countdata" stripe style="width: 100%">
<el-table-column prop="date" label="姓名" width="180">
<template slot-scope="scope">
<span>{{ scope.row.username }}</span>
<span>{{ scope.row.name }}</span>
</template>
</el-table-column>
<el-table-column prop="name" label="工业探测器" width="170">
......
......@@ -10,7 +10,7 @@
</el-table-column>
<el-table-column prop="nickname" label="用户名称" width="180">
<template slot-scope="scope">
<span>{{ scope.row.nickname }}</span>
<span>{{ scope.row.name }}</span>
</template>
</el-table-column>
<el-table-column prop="email" label="用户邮箱" width="180">
......@@ -20,7 +20,7 @@
</el-table-column>
<el-table-column align="center" label="创建时间" width="170">
<template slot-scope="scope">
<span>{{ scope.row.add_time | parseTime('{y}-{m}-{d} {h}:{i}') }}</span>
<span>{{ scope.row.created_at | parseTime('{y}-{m}-{d} {h}:{i}') }}</span>
</template>
</el-table-column>
<el-table-column prop="state" label="状态">
......@@ -40,7 +40,7 @@
</el-table-column>
<el-table-column prop="nickname" label="用户名称" width="180">
<template slot-scope="scope">
<span>{{ scope.row.nickname }}</span>
<span>{{ scope.row.name }}</span>
</template>
</el-table-column>
<el-table-column prop="email" label="用户邮箱" width="180">
......@@ -50,7 +50,7 @@
</el-table-column>
<el-table-column align="center" label="创建时间" width="170">
<template slot-scope="scope">
<span>{{ scope.row.add_time | parseTime('{y}-{m}-{d} {h}:{i}') }}</span>
<span>{{ scope.row.created_at | parseTime('{y}-{m}-{d} {h}:{i}') }}</span>
</template>
</el-table-column>
<el-table-column prop="state" label="状态">
......
This diff is collapsed.
<template>
<div class="app-container">
<div class="filter-container">
<el-input v-model="query.keyword" :placeholder="$t('table.keyword')" style="width: 200px;" class="filter-item" @keyup.enter.native="handleFilter" />
<el-select v-model="query.role" :placeholder="$t('table.role')" clearable style="width: 90px" class="filter-item" @change="handleFilter">
<el-input v-model="query.keyword" placeholder="关键词" style="width: 200px;" class="filter-item" @keyup.enter.native="handleFilter" />
<el-select v-model="query.role" placeholder="权限" clearable style="width: 90px" class="filter-item" @change="handleFilter">
<el-option v-for="item in roles" :key="item" :label="item | uppercaseFirst" :value="item" />
</el-select>
<el-button v-waves class="filter-item" type="primary" icon="el-icon-search" @click="handleFilter">
......@@ -89,42 +89,70 @@
</div>
</div>
</el-dialog>
<el-dialog :title="'Create new user'" :visible.sync="dialogFormVisible">
<div v-loading="userCreating" class="form-container">
<el-form ref="userForm" :rules="rules" :model="newUser" label-position="left" label-width="150px" style="max-width: 500px;">
<el-form-item :label="$t('user.role')" prop="role">
<el-select v-model="newUser.role" class="filter-item" placeholder="Please select role">
<el-option v-for="item in nonAdminRoles" :key="item" :label="item | uppercaseFirst" :value="item" />
</el-select>
</el-form-item>
<el-form-item :label="$t('user.name')" prop="name">
<el-input v-model="newUser.name" />
</el-form-item>
<el-form-item :label="$t('user.email')" prop="email">
<el-input v-model="newUser.email" />
</el-form-item>
<el-form-item :label="$t('user.password')" prop="password">
<el-input v-model="newUser.password" show-password />
</el-form-item>
<el-form-item :label="$t('user.confirmPassword')" prop="confirmPassword">
<el-input v-model="newUser.confirmPassword" show-password />
</el-form-item>
</el-form>
<div slot="footer" class="dialog-footer">
<el-button @click="dialogFormVisible = false">
{{ $t('table.cancel') }}
</el-button>
<el-button type="primary" @click="createUser()">
{{ $t('table.confirm') }}
</el-button>
<el-drawer title="添加用户" :visible.sync="drawer" :direction="direction" :before-close="handleClose">
<el-card class="box-card" style="height: 20000px;">
<div v-loading="userCreating" class="form-container">
<el-form ref="userForm" :rules="rules" :model="newUser" label-position="left" label-width="150px" style="max-width: 500px;">
<el-form-item label="选择权限" prop="role">
<el-select v-model="newUser.role" class="filter-item" placeholder="Please select role">
<el-option v-for="item in nonAdminRoles" :key="item" :label="item | uppercaseFirst" :value="item" />
</el-select>
</el-form-item>
<el-form-item label="用户名" prop="name">
<el-input v-model="newUser.name" />
</el-form-item>
<el-form-item label="账号名称" prop="username">
<el-input v-model="newUser.username" />
</el-form-item>
<el-form-item label="邮箱" prop="email">
<el-input v-model="newUser.email" />
</el-form-item>
<el-form-item label="自定义标题" prop="title">
<el-input v-model="newUser.title" />
</el-form-item>
<el-form-item label="自定义公司名称" prop="company">
<el-input v-model="newUser.company" />
</el-form-item>
<el-form-item label="坐标" prop="mapcenter">
<el-input v-model="newUser.mapcenter" style="width:155px" />
<el-button type="primary" size="small" plain @click="positionUrl">拾取坐标</el-button>
</el-form-item>
<el-form-item label="选择地址" prop="role">
<el-select v-model="newUser.province" class="filter-item" placeholder="省" @change="postcity">
<el-option v-for="item in province" :key="item.areaid" :label="item.area_name" :value="item.areaid" />
</el-select>
<div style="margin-top: 12px;"></div>
<el-select v-model="newUser.city" class="filter-item" placeholder="市" @change="postarea">
<el-option v-for="item in city" :key="item.areaid" :label="item.area_name" :value="item.areaid" />
</el-select>
<div style="margin-top: 12px;"></div>
<el-select v-model="newUser.area" class="filter-item" placeholder="区">
<el-option v-for="item in area" :key="item.areaid" :label="item.area_name" :value="item.areaid" />
</el-select>
</el-form-item>
<el-form-item label="密码" prop="password">
<el-input v-model="newUser.password" show-password />
</el-form-item>
<el-form-item label="确认密码" prop="confirmPassword">
<el-input v-model="newUser.confirmPassword" show-password />
</el-form-item>
</el-form>
<div slot="footer" class="dialog-footer">
<el-button @click="drawer = false">
{{ $t('table.cancel') }}
</el-button>
<el-button type="primary" @click="createUser()">
{{ $t('table.confirm') }}
</el-button>
</div>
</div>
</div>
</el-dialog>
</el-card>
</el-drawer>
</div>
</template>
<script>
import { areachina, areachinapost } from '@/api/users';
import Pagination from '@/components/Pagination'; // Secondary package based on el-pagination
import UserResource from '@/api/user';
import Resource from '@/api/resource';
......@@ -150,6 +178,8 @@ export default {
return {
list: null,
total: 0,
drawer: false,
direction: 'rtl',
loading: true,
downloading: false,
userCreating: false,
......@@ -159,10 +189,13 @@ export default {
keyword: '',
role: '',
},
province: [],
city: [],
area: [],
roles: ['admin', 'manager', 'editor', 'user', 'visitor'],
nonAdminRoles: ['editor', 'user', 'visitor'],
newUser: {},
dialogFormVisible: false,
// drawer: false,
dialogPermissionVisible: false,
dialogPermissionLoading: false,
currentUserId: 0,
......@@ -174,6 +207,13 @@ export default {
rules: {
role: [{ required: true, message: 'Role is required', trigger: 'change' }],
name: [{ required: true, message: 'Name is required', trigger: 'blur' }],
username: [{ required: true, message: 'username is required', trigger: 'blur' }],
title: [{ required: true, message: 'title is required', trigger: 'blur' }],
company: [{ required: true, message: 'company is required', trigger: 'blur' }],
mapcenter: [{ required: true, message: 'mapcenter is required', trigger: 'blur' }],
province: [{ required: true, message: 'province is required', trigger: 'blur' }],
city: [{ required: true, message: 'city is required', trigger: 'blur' }],
area: [{ required: true, message: 'area is required', trigger: 'blur' }],
email: [
{ required: true, message: 'Email is required', trigger: 'blur' },
{ type: 'email', message: 'Please input correct email address', trigger: ['blur', 'change'] },
......@@ -288,11 +328,57 @@ export default {
},
handleCreate() {
this.resetNewUser();
this.dialogFormVisible = true;
this.areachinas();
this.drawer = true;
this.$nextTick(() => {
this.$refs['userForm'].clearValidate();
});
},
// 获取地址
areachinas() {
areachina()
.then(response => {
this.province = response.data;
})
.catch(err => {
console.log(err);
});
},
postcity(id) {
var data = {
areaid: id,
};
areachinapost(data)
.then(response => {
this.city = response.data;
})
.catch(err => {
console.log(err);
});
},
positionUrl() {
window.open('latlge.html');
},
postarea(id) {
var data = {
areaid: id,
};
areachinapost(data)
.then(response => {
this.area = response.data;
})
.catch(err => {
console.log(err);
});
},
handleClose(done) {
this.$confirm('确认关闭?')
.then(_ => {
done();
})
.catch(_ => {
});
},
handleDelete(id, name) {
this.$confirm('This will permanently delete user ' + name + '. Continue?', 'Warning', {
confirmButtonText: 'OK',
......@@ -346,7 +432,7 @@ export default {
duration: 5 * 1000,
});
this.resetNewUser();
this.dialogFormVisible = false;
this.drawer = false;
this.handleFilter();
})
.catch(error => {
......
......@@ -36,7 +36,7 @@ Route::group(['middleware' => 'auth:api'], function () {
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/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::post('user/addcontactsuser','UserController@addcontactsuser');//添加联系人
Route::get('user/contactslist','UserController@contactslist');//返回当前登入的联系人列表
Route::get('user/UpPaperBasket/{id}','UserController@UpPaperBasket');//更新废纸篓和禁用用户
Route::get('user/UpuserForbidden/{id}','UserController@UpuserForbidden');//禁用此用户
......@@ -69,19 +69,24 @@ Route::group(['middleware'=>'auth:api'],function (){
//首页路由
Route::group(['middleware'=>'auth:api'],function (){
Route::get('homepagecount/homepagecount','HomepageController@homepagecount');//删除图片
Route::get('homepagecount/devicemonthcount','HomepageController@devicemonthcount');//删除图片
Route::get('homepagecount/homepagecount','HomepageController@homepagecount');
Route::get('homepagecount/devicemonthcount','HomepageController@devicemonthcount');
Route::get('homepagecount/timeline','HomepageController@gettimeline');
Route::get('homepagecount/Project_statistics','HomepageController@Project_statistics');
Route::get('homepagecount/UserStatistics','HomepageController@UserStatistics');
Route::get('homepagecount/userdevicemonthcount','HomepageController@userdevicemonthcount');
});
//设备路由
Route::group(['middleware'=>'auth:api'],function (){
Route::get('devices/devicelist', 'DevicesController@devicelist');//设备列表
Route::get('devices/userdevicelist', 'DevicesController@userdevicelist');//用户设备列表
Route::post('devices/userdevicelist', 'DevicesController@userdevicelist');//用户设备列表
Route::get('devices/deviceDataInfo/{id}', 'DevicesController@deviceDataInfo');//设备详情
Route::post('devices/deviceDataSearch', 'DevicesController@deviceDataSearch');//设备搜索列表
Route::get('devices/devicetype','DevicesController@devicetype');//设备类型
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');//新增设备
Route::match(['get','post'],'devices/physicsdelete','DevicesController@physicsdelete')->middleware('permission:' . \App\Laravue\Acl::PERMISSION_PERMISSION_MANAGE);//返回设备列表和更改设备
Route::match(['get','post'],'devices/updatedevice','DevicesController@updatedevice')->middleware('permission:' . \App\Laravue\Acl::PERMISSION_PERMISSION_MANAGE);//更新设备
Route::get('devices/equipment','DevicesController@equipment');//获取设备监测列表
......
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