Commit a0a019b3 authored by Administrator's avatar Administrator

地图模式

parents 94e1ef81 1b901a46
...@@ -71,6 +71,7 @@ class AuthController extends Controller ...@@ -71,6 +71,7 @@ class AuthController extends Controller
$token = $tokenResult->token; $token = $tokenResult->token;
$token->save(); $token->save();
return response()->json(new UserResource($BackgroundUser), Response::HTTP_OK)->header('Authorization', $tokenResult->accessToken); return response()->json(new UserResource($BackgroundUser), Response::HTTP_OK)->header('Authorization', $tokenResult->accessToken);
}else{ }else{
return response()->json(new JsonResponse([], 'login_error'), Response::HTTP_UNAUTHORIZED); return response()->json(new JsonResponse([], 'login_error'), Response::HTTP_UNAUTHORIZED);
} }
......
...@@ -184,8 +184,6 @@ class DevicesController extends Controller ...@@ -184,8 +184,6 @@ 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')//设备不是删除状态
//->where('devicestatus','=','1')//
->leftjoin('device_type as dy', "device.dtype", '=', 'dy.tid') ->leftjoin('device_type as dy', "device.dtype", '=', 'dy.tid')
->leftjoin('gas as g', "device.status", '=', 'g.id') ->leftjoin('gas as g', "device.status", '=', 'g.id')
->leftjoin('status as p', "device.devicepolice", '=', 'p.id') ->leftjoin('status as p', "device.devicepolice", '=', 'p.id')
...@@ -196,8 +194,6 @@ class DevicesController extends Controller ...@@ -196,8 +194,6 @@ class DevicesController extends Controller
->get()->toArray(); ->get()->toArray();
$count = $databadevice $count = $databadevice
->where('dtype', '=', $type) ->where('dtype', '=', $type)
//->where('delete','=','2')//设备不是删除状态
//->where('devicestatus','=','1')//
->count(); ->count();
return ['devicelist' => $devicelist, 'count' => $count]; return ['devicelist' => $devicelist, 'count' => $count];
} }
...@@ -209,8 +205,6 @@ class DevicesController extends Controller ...@@ -209,8 +205,6 @@ class DevicesController extends Controller
$devicelist = $databadevice $devicelist = $databadevice
->where('dtype', '=', $type) ->where('dtype', '=', $type)
->where('uid', '=', Auth::id()) ->where('uid', '=', Auth::id())
//->where('delete','=','2')//设备不是删除状态
//->where('devicestatus','=','1')//
->leftjoin('device_type as dy', "device.dtype", '=', 'dy.tid') ->leftjoin('device_type as dy', "device.dtype", '=', 'dy.tid')
->leftjoin('gas as g', "device.status", '=', 'g.id') ->leftjoin('gas as g', "device.status", '=', 'g.id')
->leftjoin('status as p', "device.devicepolice", '=', 'p.id') ->leftjoin('status as p', "device.devicepolice", '=', 'p.id')
...@@ -222,8 +216,6 @@ class DevicesController extends Controller ...@@ -222,8 +216,6 @@ class DevicesController extends Controller
$count = $databadevice $count = $databadevice
->where('dtype', '=', $type) ->where('dtype', '=', $type)
->where('uid', '=', Auth::id()) ->where('uid', '=', Auth::id())
// ->where('delete','=','2')//设备不是删除状态
//->where('devicestatus','=','1')//
->count(); ->count();
return ['devicelist' => $devicelist, 'count' => $count]; return ['devicelist' => $devicelist, 'count' => $count];
} }
...@@ -233,8 +225,6 @@ class DevicesController extends Controller ...@@ -233,8 +225,6 @@ class DevicesController extends Controller
$databadevice = DB::table('device'); $databadevice = DB::table('device');
$devicelist = $databadevice $devicelist = $databadevice
->where('devicenum', '=', $devicenum) ->where('devicenum', '=', $devicenum)
//->where('delete','=','2')//设备不是删除状态
//->where('devicestatus','=','1')//
->leftjoin('device_type as dy', "device.dtype", '=', 'dy.tid') ->leftjoin('device_type as dy', "device.dtype", '=', 'dy.tid')
->leftjoin('gas as g', "device.status", '=', 'g.id') ->leftjoin('gas as g', "device.status", '=', 'g.id')
->leftjoin('status as p', "device.devicepolice", '=', 'p.id') ->leftjoin('status as p', "device.devicepolice", '=', 'p.id')
...@@ -245,8 +235,6 @@ class DevicesController extends Controller ...@@ -245,8 +235,6 @@ class DevicesController extends Controller
->get()->toArray(); ->get()->toArray();
$count = $databadevice $count = $databadevice
->where('dtype', '=', $devicenum) ->where('dtype', '=', $devicenum)
//->where('delete','=','2')//设备不是删除状态
//->where('devicestatus','=','1')//
->count(); ->count();
return ['devicelist' => $devicelist, 'count' => $count]; return ['devicelist' => $devicelist, 'count' => $count];
} }
...@@ -319,7 +307,6 @@ class DevicesController extends Controller ...@@ -319,7 +307,6 @@ class DevicesController extends Controller
public function police() public function police()
{ {
$data = DB::table('reportpolice as r') $data = DB::table('reportpolice as r')
//->where('r.status', '=', '1')
->join('status as s', 'r.policestatus', '=', 's.id') ->join('status as s', 'r.policestatus', '=', 's.id')
->select('r.*', 's.status_name') ->select('r.*', 's.status_name')
->get(); ->get();
...@@ -369,6 +356,43 @@ class DevicesController extends Controller ...@@ -369,6 +356,43 @@ class DevicesController extends Controller
return $this->jsonSuccessData(DB::table('device_type')->where('tid', '=', $id)->delete()); return $this->jsonSuccessData(DB::table('device_type')->where('tid', '=', $id)->delete());
} }
public function deviceLocation()
{
//返回用户安装位置
return $this->jsonSuccessData(DB::table('device')->select('id','devicenum','devicecoord','devicepolice')->get());
}
//返回消防监测
public function control(Request $request)
{
$pagenNum = $request->input('page') - 1;//页数
$limit = $request->input('limit');
$type = $request->input('type');
if ($pagenNum === '' || $limit == '' || $type === '') {
return $this->jsonErrorData(105, '页数或limit不能为空');
}
if($type ==1){//返回消防监测
$wherein = [1,2,4,7,8,11];
}else{
//返回危化
$wherein = [5,6,9,10];
}
$databadevice = DB::table('device');
$devicelist = $databadevice
->whereIn('dtype', $wherein)
->leftjoin('device_type as dy', "device.dtype", '=', 'dy.tid')
->leftjoin('gas as g', "device.status", '=', 'g.id')
->leftjoin('status as p', "device.devicepolice", '=', 'p.id')
->select('dy.tname', 'g.gas', 'device.*', 'p.status_name')
->orderBy('device.id', 'desc')
->offset($pagenNum)
->limit($limit)
->get()->toArray();
$count = $databadevice
->whereIn('dtype',$wherein)
->count();
return $this->jsonSuccessData(['devicelist' => $devicelist, 'count' => $count]);
}
/** /**
* @param bool $isNew * @param bool $isNew
* @return array * @return array
......
<?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\Device;
use App\Laravue\Models\Users;
use Illuminate\Http\Request;
use Illuminate\Http\Resources\Json\ResourceCollection;
use Illuminate\Support\Arr;
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Hash;
use Illuminate\Support\Facades\Redis;
use Validator;
class HomepageController extends Controller
{
//返回用户数量 设备数量, 报警数量 ,
public function homepagecount()
{
$usercount = Users::count();
$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]);
}
//返回一年当前月份
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])
->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')
->groupBy('date')
->get()
->toArray();
$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)]);
}
private function datamonth($monthdata = []) :array{
$year = date('Y',time());
$month = date('m',time());
$data = [];
foreach ($monthdata as $value) {
$data[$value['date']] = $value['value'];
}
$out = [];
for ($i = 1; $i <= $month; $i++) {
$mont = $i < 10 ? "0{$i}" : $i;
$val = isset($data["{$year}-{$mont}"]) ? $data["{$year}-{$mont}"] : 0;
array_push($out, $val);
}
return $out;
}
}
\ No newline at end of file
...@@ -267,7 +267,6 @@ class UserController extends Controller ...@@ -267,7 +267,6 @@ class UserController extends Controller
return $this->jsonErrorData(105, 'limit不能为空'); return $this->jsonErrorData(105, 'limit不能为空');
} }
$users = DB::table('BackgroundUser as b') $users = DB::table('BackgroundUser as b')
//->where('b.state', '>', '1')
->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')
...@@ -277,10 +276,8 @@ class UserController extends Controller ...@@ -277,10 +276,8 @@ class UserController extends Controller
->limit($limit) ->limit($limit)
->get(); ->get();
$count = DB::table('BackgroundUser') $count = DB::table('BackgroundUser')
//->where('state', '>', '1')
->count(); ->count();
$davicenum = DB::table('BackgroundUser') $davicenum = DB::table('BackgroundUser')
//->where('state', '>', '1')
->select('id') ->select('id')
->get()->toArray(); ->get()->toArray();
$data = []; $data = [];
...@@ -507,6 +504,11 @@ class UserController extends Controller ...@@ -507,6 +504,11 @@ class UserController extends Controller
return $this->jsonSuccessData(DB::table('BackgroundUser')->where('state','=','1')->count()); return $this->jsonSuccessData(DB::table('BackgroundUser')->where('state','=','1')->count());
} }
//返回用户的经纬度
public function userLocation()
{
return $this->jsonSuccessData(DB::table('BackgroundUser')->select('id','nickname','mapcenter','company')->get());
}
/* /*
* 返回废纸篓 和状态 * 返回废纸篓 和状态
......
...@@ -21,13 +21,11 @@ class Authenticate extends Middleware ...@@ -21,13 +21,11 @@ class Authenticate extends Middleware
if (empty($guards)) { if (empty($guards)) {
$guards = [null]; $guards = [null];
} }
foreach ($guards as $guard) { foreach ($guards as $guard) {
if ($this->auth->guard($guard)->check()) { if ($this->auth->guard($guard)->check()) {
return $this->auth->shouldUse($guard); return $this->auth->shouldUse($guard);
} }
} }
return 'authentication_error'; return 'authentication_error';
} }
...@@ -35,7 +33,7 @@ class Authenticate extends Middleware ...@@ -35,7 +33,7 @@ class Authenticate extends Middleware
* Get the path the user should be redirected to when they are not authenticated. * Get the path the user should be redirected to when they are not authenticated.
* *
* @param \Illuminate\Http\Request $request * @param \Illuminate\Http\Request $request
* @return string * @ string
*/ */
protected function redirectTo($request) protected function redirectTo($request)
{ {
......
No preview for this file type
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>地图模式</title>
<link rel="stylesheet" type="text/css" href="npmcss/zzsc.css">
<link rel="stylesheet" type="text/css" href="npmcss/style.css">
<style>
html,
body {
margin: 0;
padding: 0;
overflow: hidden;
height: 100%;
}
#mapContainer {
position: relative;
height: 100%;
width: 100%;
}
</style>
</head>
<script src="npmcss/jquery.js"></script>
<script charset="utf-8" src="https://map.qq.com/api/gljs?v=1.exp&key=OB4BZ-D4W3U-B7VVO-4PJWW-6TKDJ-WPB77"></script>
<body onload="init(1)">
<div id='mapContainer'>
<div class="container" style="z-index: 9999999;position:fixed;left: 1233px;top: -31px;">
<!-- <div class="switch-box is-info">
<input id="info" class="switch-box-input" type="checkbox" checked />
<label for="info" class="switch-box-slider" onclick="init(2)"></label>
<label for="info" class="switch-box-label">切换设备</label>
</div> -->
</div>
</div>
<script>
var map;
function init(id) {
var type = getUrlParams('type');
if(type == '' || type == null){
alert('违规操作');
window.opener = null;
window.open('', '_self');
window.close();
return;
}
if(type != 'permit'){
alert('type值不对重新打开');
window.opener = null;
window.open('', '_self');
window.close();
return;
}
if(id == 1){ //用户设备
$.ajax({
type: "GET",
url: "api/user/userLocation",
data: {},
success: function(data) {
var data = JSON.parse(data);
nmp(data.data,1);
}
});
}else{
$.ajax({
type: "GET",
url: "api/devices/deviceLocation",
data: {},
success: function(data) {
var data = JSON.parse(data);
nmp(data.data,2);
}
});
}
}
function getUrlParams(name) {
var url = window.location.search;
if (url.indexOf('?') == 1) {
return false;
}
url = url.substr(1);
url = url.split('&');
var name = name || '';
var nameres;
// 获取全部参数及其值
for (var i = 0; i < url.length; i++) {
var info = url[i].split('=');
var obj = {};
obj[info[0]] = info[1];
url[i] = obj;
}
// 如果传入一个参数名称,就匹配其值
if (name) {
for (var i = 0; i < url.length; i++) {
for (const key in url[i]) {
if (key == name) {
nameres = url[i][key];
}
}
}
} else {
nameres = url;
}
// 返回结果
return uncompileStr(nameres);
}
function uncompileStr(code) {
code = unescape(code);
var c = String.fromCharCode(code.charCodeAt(0) - code.length);
for (var i = 1; i < code.length; i++) {
c += String.fromCharCode(code.charCodeAt(i) - c.charCodeAt(i - 1));
}
return c;
}
function nmp(data,type) {
var LatLng = [];
if(type == 2){
console.log(LatLng);
data.forEach((item, index, array) => {
if (item.devicecoord != null && item.mapcenter != '') {
console.log(item);
let x = item.devicecoord.split(',')[0];
let y = item.devicecoord.split(',')[1];
if (x > 0 && y > 0) {
let position = new TMap.LatLng(x, y);
let tmpP = {
position: position
};
LatLng.push(tmpP);
}
}
});
}else{
data.forEach((item, index, array) => {
if (item.mapcenter != null && item.mapcenter != '') {
let x = item.mapcenter.split(',')[0];
let y = item.mapcenter.split(',')[1];
if (x > 0 && y > 0) {
let position = new TMap.LatLng(x, y);
let tmpP = {
position: position,
};
LatLng.push(tmpP);
}
}
});
}
var drawContainer = document.getElementById('mapContainer');
var center = new TMap.LatLng(38.230596, 114.216328); //设置中心点坐标
map = new TMap.Map(drawContainer, {
zoom: 12,
pitch: 40,
center: center,
draggable: true,
scrollable: true,
mapStyleId: "style1"
});
// 创建点聚合实例
var markerCluster = new TMap.MarkerCluster({
id: 'cluster',
map: map,
enableDefaultStyle: true, // 启用默认样式
minimumClusterSize: 2, // 形成聚合簇的最小个数
geometries: [{
"id": "1", //点标记唯一标识,后续如果有删除、修改位置等操作,都需要此id
"styleId": 'myStyle', //指定样式id
"position": new TMap.LatLng(39.954104, 116.357503), //点标记坐标位置
"properties": {//自定义属性
"title": "marker1"
}
}, {//第二个点标记
"id": "2",
"styleId": 'marker',
"position": new TMap.LatLng(39.994104, 116.287503),
"properties": {
"title": "marker2"
}
}
],
zoomOnClick: true, // 点击簇时放大至簇内点分离
gridSize: 60, // 聚合算法的可聚合距离
averageCenter: false, // 每个聚和簇的中心是否应该是聚类中所有标记的平均值
maxZoom: true // 采用聚合策略的最大缩放级别
});
}
</script>
</body>
</html>
This diff is collapsed.
.switch-box {
display: block;
margin-top: 24px;
}
.switch-box .switch-box-slider {
position: relative;
display: inline-block;
height: 8px;
width: 32px;
background: #d5d5d5;
border-radius: 8px;
cursor: pointer;
-webkit-transition: all 0.2s ease;
transition: all 0.2s ease;
}
.switch-box .switch-box-slider:after {
position: absolute;
left: -8px;
top: -8px;
display: block;
width: 24px;
height: 24px;
border-radius: 50%;
background: #eeeeee;
box-shadow: 0px 2px 2px rgba(0, 0, 0, 0.2);
content: '';
-webkit-transition: all 0.2s ease;
transition: all 0.2s ease;
}
.switch-box .switch-box-input {
display: none;
}
.switch-box .switch-box-input ~ .switch-box-label {
margin-left: 8px;
}
.switch-box .switch-box-input:checked ~ .switch-box-slider:after {
left: 16px;
}
.switch-box .switch-box-input:disabled ~ .switch-box-slider {
background: #e2e2e2;
cursor: default;
}
.switch-box .switch-box-input:disabled ~ .switch-box-slider:after {
background: #d5d5d5;
}
.switch-box.is-primary .switch-box-input:checked:not(:disabled) ~ .switch-box-slider {
background: #28e1bd;
}
.switch-box.is-primary .switch-box-input:checked:not(:disabled) ~ .switch-box-slider:after {
background: #1abc9c;
}
.switch-box.is-info .switch-box-input:checked:not(:disabled) ~ .switch-box-slider {
background: #5faee3;
}
.switch-box.is-info .switch-box-input:checked:not(:disabled) ~ .switch-box-slider:after {
background: #3498db;
}
.switch-box.is-success .switch-box-input:checked:not(:disabled) ~ .switch-box-slider {
background: #54d98c;
}
.switch-box.is-success .switch-box-input:checked:not(:disabled) ~ .switch-box-slider:after {
background: #2ecc71;
}
.switch-box.is-danger .switch-box-input:checked:not(:disabled) ~ .switch-box-slider {
background: #ed7669;
}
.switch-box.is-danger .switch-box-input:checked:not(:disabled) ~ .switch-box-slider:after {
background: #e74c3c;
}
.switch-box.is-warning .switch-box-input:checked:not(:disabled) ~ .switch-box-slider {
background: #eb9950;
}
.switch-box.is-warning .switch-box-input:checked:not(:disabled) ~ .switch-box-slider:after {
background: #e67e22;
}
.container{
width: 200px;
margin: 30px auto;
}
body{
background: #494A5F;
color: #D5D6E2;
font-weight: 500;
font-size: 1.05em;
font-family: "Microsoft YaHei","宋体","Segoe UI", "Lucida Grande", Helvetica, Arial,sans-serif, FreeSans, Arimo;
}
a{ color: rgba(255, 255, 255, 0.6);outline: none;text-decoration: none;-webkit-transition: 0.2s;transition: 0.2s;}
a:hover,a:focus{color:#74777b;text-decoration: none;}
\ No newline at end of file
...@@ -8,6 +8,14 @@ export function login(data) { ...@@ -8,6 +8,14 @@ export function login(data) {
}); });
} }
export function userlogin(data) {
return request({
url: '/auth/userslogin',
method: 'post',
data: data,
});
}
export function getInfo(token) { export function getInfo(token) {
return request({ return request({
url: '/auth/user', url: '/auth/user',
...@@ -21,3 +29,10 @@ export function logout() { ...@@ -21,3 +29,10 @@ export function logout() {
method: 'post', method: 'post',
}); });
} }
export function userdevicelist(page, limit, id) {
return request({
url: 'devices/userdevicelist?page=' + page + '&limit=' + limit + '&id=' + id,
method: 'get',
});
}
const baseURL = 'ws://127.0.0.1:9502';
const mapkey = '2719fe261fee06a08dcb4980990879da';
const mapurl = 'https://webapi.amap.com/maps?v=1.4.15&key=';
export default {
baseURL,
mapkey,
mapurl,
};
...@@ -92,3 +92,16 @@ export function police(dete) { ...@@ -92,3 +92,16 @@ export function police(dete) {
}); });
} }
export function deviceLocation() {
return request({
url: '/devices/deviceLocation',
method: 'get',
});
}
export function control(page, limit, type) {
return request({
url: 'devices/control?page=' + page + '&limit=' + limit + '&type=' + type,
method: 'get',
});
}
import request from '@/utils/request';
export function homepagecount() { // 设备类型
return request({
url: 'homepagecount/homepagecount',
method: 'get',
});
}
export function getcount() { // 设备类型
return request({
url: 'homepagecount/devicemonthcount',
method: 'get',
});
}
import request from '@/utils/request'; import request from '@/utils/request';
class MapResource { export function devices() {
constructor() {
}
permissions(id) {
return request({ return request({
url: '/' + this.uri + '/' + id + '/permissions', url: '/devices/deviceLocation',
method: 'get', method: 'get',
}); });
} }
fetchArticle(data) {
return request({ export function users() {
url: '/wxuser/seek',
method: 'post',
data,
});
}
updatePermission(id, permissions) {
return request({ return request({
url: '/' + this.uri + '/' + id + '/permissions', url: '/user/userLocation',
method: 'put', method: 'get',
data: permissions,
}); });
}
} }
export { MapResource as default };
...@@ -65,3 +65,11 @@ export function paperBasketList() { ...@@ -65,3 +65,11 @@ export function paperBasketList() {
method: 'get', method: 'get',
}); });
} }
export function userLocation() {
return request({
url: '/user/userLocation',
method: 'get',
});
}
...@@ -7,7 +7,7 @@ import router from '@/router'; ...@@ -7,7 +7,7 @@ import router from '@/router';
import i18n from './lang'; // Internationalization import i18n from './lang'; // Internationalization
import '@/icons'; // icon import '@/icons'; // icon
import '@/permission'; // permission control import '@/permission'; // permission control
import AMap from 'vue-amap';
import * as filters from './filters'; // global filters import * as filters from './filters'; // global filters
Vue.use(ElementUI, { Vue.use(ElementUI, {
...@@ -27,4 +27,5 @@ new Vue({ ...@@ -27,4 +27,5 @@ new Vue({
store, store,
i18n, i18n,
render: h => h(App), render: h => h(App),
AMap,
}); });
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
<script> <script>
import echarts from 'echarts'; import echarts from 'echarts';
import resize from './mixins/resize'; import resize from './mixins/resize';
import { getcount } from '@/api/homepage';
export default { export default {
mixins: [resize], mixins: [resize],
props: { props: {
...@@ -29,10 +29,13 @@ export default { ...@@ -29,10 +29,13 @@ export default {
data() { data() {
return { return {
chart: null, chart: null,
devicemover: [], // 设备数量
policedata: [], // 报警数量
userdata: [], // 用户数量
}; };
}, },
mounted() { created() {
this.initChart(); this.getcount();
}, },
beforeDestroy() { beforeDestroy() {
if (!this.chart) { if (!this.chart) {
...@@ -46,15 +49,16 @@ export default { ...@@ -46,15 +49,16 @@ export default {
this.chart = echarts.init(document.getElementById(this.id)); this.chart = echarts.init(document.getElementById(this.id));
const xData = (function() { const xData = (function() {
const data = []; const data = [];
for (let i = 1; i < 13; i++) { const date = new Date();
data.push(i + 'month'); for (let i = 1; i < date.getMonth() + 1 + 1; i++) {
data.push(i + '月');
} }
return data; return data;
}()); }());
this.chart.setOption({ this.chart.setOption({
backgroundColor: '#344b58', backgroundColor: '#344b58',
title: { title: {
text: 'statistics', text: '统计记录',
x: '20', x: '20',
top: '20', top: '20',
textStyle: { textStyle: {
...@@ -90,7 +94,7 @@ export default { ...@@ -90,7 +94,7 @@ export default {
textStyle: { textStyle: {
color: '#90979c', color: '#90979c',
}, },
data: ['female', 'male', 'average'], data: ['设备数量', '用户数量', '设备报警次数'],
}, },
calculable: true, calculable: true,
xAxis: [{ xAxis: [{
...@@ -160,7 +164,7 @@ export default { ...@@ -160,7 +164,7 @@ export default {
}], }],
series: [ series: [
{ {
name: 'female', name: '设备数量',
type: 'bar', type: 'bar',
stack: 'total', stack: 'total',
barMaxWidth: 35, barMaxWidth: 35,
...@@ -180,23 +184,10 @@ export default { ...@@ -180,23 +184,10 @@ export default {
}, },
}, },
}, },
data: [ data: this.devicemover,
709,
1917,
2455,
2610,
1719,
1433,
1544,
3285,
5208,
3372,
2484,
4078,
],
}, },
{ {
name: 'male', name: '用户数量',
type: 'bar', type: 'bar',
stack: 'total', stack: 'total',
itemStyle: { itemStyle: {
...@@ -212,22 +203,9 @@ export default { ...@@ -212,22 +203,9 @@ export default {
}, },
}, },
}, },
data: [ data: this.userdata,
327,
1776,
507,
1200,
800,
482,
204,
1390,
1001,
951,
381,
220,
],
}, { }, {
name: 'average', name: '设备报警次数',
type: 'line', type: 'line',
stack: 'total', stack: 'total',
symbolSize: 10, symbolSize: 10,
...@@ -245,24 +223,25 @@ export default { ...@@ -245,24 +223,25 @@ export default {
}, },
}, },
}, },
data: [ data: this.policedata,
1036,
3693,
2962,
3810,
2519,
1915,
1748,
4675,
6209,
4323,
2865,
4298,
],
}, },
], ],
}); });
}, },
getcount() {
getcount()
.then(response => {
if (response.code === 200) {
this.devicemover = response.data.devicedata;
this.policedata = response.data.devicepolice;
this.userdata = response.data.policedata;
this.initChart();
}
})
.catch(err => {
console.log(err);
});
},
}, },
}; };
</script> </script>
<!-- <template>
<a href="https://github.com/tuandm/laravue" target="_blank" class="github-corner" aria-label="View source on Github">
<svg
width="80"
height="80"
viewBox="0 0 250 250"
style="fill:#40c9c6; color:#fff;"
aria-hidden="true"
>
<path d="M0,0 L115,115 L130,115 L142,142 L250,250 L250,0 Z" />
<path
d="M128.3,109.0 C113.8,99.7 119.0,89.6 119.0,89.6 C122.0,82.7 120.5,78.6 120.5,78.6 C119.2,72.0 123.4,76.3 123.4,76.3 C127.3,80.9 125.5,87.3 125.5,87.3 C122.9,97.6 130.6,101.9 134.4,103.2"
fill="currentColor"
style="transform-origin: 130px 106px;"
class="octo-arm"
/>
<path
d="M115.0,115.0 C114.9,115.1 118.7,116.5 119.8,115.4 L133.7,101.6 C136.9,99.2 139.9,98.4 142.2,98.6 C133.8,88.0 127.5,74.4 143.8,58.0 C148.5,53.4 154.0,51.2 159.7,51.0 C160.3,49.4 163.2,43.6 171.4,40.1 C171.4,40.1 176.1,42.5 178.8,56.2 C183.1,58.6 187.2,61.8 190.9,65.4 C194.5,69.0 197.7,73.2 200.1,77.6 C213.8,80.2 216.3,84.9 216.3,84.9 C212.7,93.1 206.9,96.0 205.4,96.6 C205.1,102.4 203.0,107.8 198.3,112.5 C181.9,128.9 168.3,122.5 157.7,114.1 C157.9,116.9 156.7,120.9 152.7,124.9 L141.0,136.5 C139.8,137.7 141.6,141.9 141.8,141.8 Z"
fill="currentColor"
class="octo-body"
/>
</svg>
</a>
</template> -->
<style scoped>
.github-corner:hover .octo-arm {
animation: octocat-wave 560ms ease-in-out
}
@keyframes octocat-wave {
0%,
100% {
transform: rotate(0)
}
20%,
60% {
transform: rotate(-25deg)
}
40%,
80% {
transform: rotate(10deg)
}
}
@media (max-width:500px) {
.github-corner:hover .octo-arm {
animation: none
}
.github-corner .octo-arm {
animation: octocat-wave 560ms ease-in-out
}
}
</style>
<?xml version="1.0" standalone="no"?><!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"><svg t="1589854256367" class="icon" viewBox="0 0 1088 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="1990" data-spm-anchor-id="a313x.7781069.0.i1" xmlns:xlink="http://www.w3.org/1999/xlink" width="212.5" height="200"><defs><style type="text/css"></style></defs><path d="M1084.710172 1019.718325h-132.460079c0-2.514635 0-4.893343-0.407778 0a272.532024 272.532024 0 0 0-271.852393-271.852393c-150.130484 0-203.889294 122.809318-203.889294 271.852393-0.543705-4.893343-0.543705-2.514635-0.407779 0H340.174431a462.149067 462.149067 0 0 1 119.139311-314.533218 159.373465 159.373465 0 0 0-156.85883-90.322958C163.878155 609.017323 136.285137 688.058406 136.285137 815.82903c-0.407779-4.213712-0.407779-2.106856 0 0H0.35894v-0.407778-1.291299a319.426561 319.426561 0 0 1 302.028009-334.106591 295.503551 295.503551 0 0 1 252.890688 152.577156 314.397292 314.397292 0 0 1 139.800093-32.690251A391.263556 391.263556 0 0 1 1087.768511 989.746599c0 10.262428-2.242782 19.913188-3.058339 29.971726zM951.842315 1019.718325h0.407778c-0.407779 2.582598-0.407779 5.233159-0.407778 0z m-476.149466 0H476.100628c0 5.233159 0 2.582598-0.407779 0zM340.174431 1019.718325c0 10.262428-0.815557-65.312537 0 0z m-203.889294-203.889295c0 4.485564 0 2.174819 0 0z m-135.926197-0.407778c0 3.126303-0.475742-5.776863 0 0zM689.776608 543.976638a262.473485 262.473485 0 0 1-247.113825-184.247959 171.33497 171.33497 0 0 1-131.780447 63.341607 181.461472 181.461472 0 0 1 0-362.651092 172.898122 172.898122 0 0 1 147.819738 85.361652 260.366629 260.366629 0 0 1 231.074534-145.780846 271.988319 271.988319 0 0 1 0 543.976638zM340.174431 204.161147H272.211333v67.963098h67.963098V204.161147z m339.815491-67.963098a135.926196 135.926196 0 1 0 135.926196 135.926196 135.926196 135.926196 0 0 0-135.926196-135.926196z" p-id="1991" fill="#409EFF" data-spm-anchor-id="a313x.7781069.0.i0" class=""></path></svg>
\ No newline at end of file
...@@ -88,6 +88,8 @@ export default { ...@@ -88,6 +88,8 @@ export default {
thirdparty: 'Or connect with', thirdparty: 'Or connect with',
thirdpartyTips: 'Can not be simulated on local, so please combine you own business simulation! ! !', thirdpartyTips: 'Can not be simulated on local, so please combine you own business simulation! ! !',
email: 'Email', email: 'Email',
adminLogin: 'Administrator login',
userLogin: 'User login',
}, },
documentation: { documentation: {
documentation: 'Documentation', documentation: 'Documentation',
......
...@@ -88,6 +88,8 @@ export default { ...@@ -88,6 +88,8 @@ export default {
thirdparty: 'Или войдите с помощью', thirdparty: 'Или войдите с помощью',
thirdpartyTips: 'Can not be simulated on local, so please combine you own business simulation! ! !', thirdpartyTips: 'Can not be simulated on local, so please combine you own business simulation! ! !',
email: 'Email', email: 'Email',
adminLogin: 'Administrator login',
userLogin: 'User login',
}, },
documentation: { documentation: {
documentation: 'Документация', documentation: 'Документация',
......
...@@ -91,6 +91,8 @@ export default { ...@@ -91,6 +91,8 @@ export default {
any: 'any', any: 'any',
thirdparty: 'Hoặc đăng nhập với', thirdparty: 'Hoặc đăng nhập với',
thirdpartyTips: 'Không thể giả lập, xi vui lòng áp dụng tùy theo tình huống nghiệp vụ của bạn! ! !', thirdpartyTips: 'Không thể giả lập, xi vui lòng áp dụng tùy theo tình huống nghiệp vụ của bạn! ! !',
adminLogin: 'Administrator login',
userLogin: 'User login',
}, },
documentation: { documentation: {
documentation: 'Tài liệu', documentation: 'Tài liệu',
......
...@@ -93,6 +93,8 @@ export default { ...@@ -93,6 +93,8 @@ export default {
any: '随便填', any: '随便填',
thirdparty: '第三方登录', thirdparty: '第三方登录',
thirdpartyTips: '本地不能模拟,请结合自己业务进行模拟!!!', thirdpartyTips: '本地不能模拟,请结合自己业务进行模拟!!!',
adminLogin: '管理者登入',
userLogin: '用户登入',
}, },
documentation: { documentation: {
documentation: '文档', documentation: '文档',
......
...@@ -8,7 +8,7 @@ import getPageTitle from '@/utils/get-page-title'; ...@@ -8,7 +8,7 @@ import getPageTitle from '@/utils/get-page-title';
NProgress.configure({ showSpinner: false }); // NProgress Configuration NProgress.configure({ showSpinner: false }); // NProgress Configuration
const whiteList = ['/login', '/auth-redirect', '/userslogin']; // no redirect whitelist const whiteList = ['/login', '/auth-redirect', '/userlogin']; // no redirect whitelist
router.beforeEach(async(to, from, next) => { router.beforeEach(async(to, from, next) => {
// start progress bar // start progress bar
......
import { login, logout, getInfo } from '@/api/auth'; import { login, logout, getInfo, userlogin } from '@/api/auth';
import { getToken, setToken, removeToken } from '@/utils/auth'; import { getToken, setToken, removeToken } from '@/utils/auth';
import router, { resetRouter } from '@/router'; import router, { resetRouter } from '@/router';
import store from '@/store'; import store from '@/store';
...@@ -53,7 +53,20 @@ const actions = { ...@@ -53,7 +53,20 @@ const actions = {
}); });
}); });
}, },
userlogin({ commit }, userInfo) {
const { email, password } = userInfo;
return new Promise((resolve, reject) => {
userlogin({ email: email.trim(), password: password })
.then(response => {
commit('SET_TOKEN', response.token);
setToken(response.token);
resolve();
})
.catch(error => {
reject(error);
});
});
},
// get user info // get user info
getInfo({ commit, state }) { getInfo({ commit, state }) {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
......
<template> <template>
<div class="dashboard-editor-container"> <div class="dashboard-editor-container">
<github-corner style="position: absolute; top: 0px; border: 0; right: 0;" />
<panel-group @handleSetLineChartData="handleSetLineChartData" /> <panel-group @handleSetLineChartData="handleSetLineChartData" />
<el-row style="background:#fff;padding:16px 16px 0;margin-bottom:32px;"> <el-row style="background:#fff;padding:16px 16px 0;margin-bottom:32px;">
...@@ -41,7 +39,6 @@ ...@@ -41,7 +39,6 @@
</template> </template>
<script> <script>
// import GithubCorner from '@/components/GithubCorner';
import PanelGroup from './components/PanelGroup'; import PanelGroup from './components/PanelGroup';
import LineChart from './components/LineChart'; import LineChart from './components/LineChart';
import RaddarChart from './components/RaddarChart'; import RaddarChart from './components/RaddarChart';
......
...@@ -20,7 +20,6 @@ ...@@ -20,7 +20,6 @@
<script> <script>
import { mapGetters } from 'vuex'; import { mapGetters } from 'vuex';
import PanThumb from '@/components/PanThumb'; import PanThumb from '@/components/PanThumb';
// import GithubCorner from '@/components/GithubCorner';
export default { export default {
name: 'DashboardEditor', name: 'DashboardEditor',
......
<template> <template>
<div class="dashboard-container"> <div class="app-container">
<component :is="currentRole" /> <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>
<!-- 混合统计 -->
<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>
</div> </div>
</template> </template>
<script> <script>
import { mapGetters } from 'vuex'; import Chart from '@/components/Charts/MixChart';
import adminDashboard from './admin'; import { homepagecount } from '@/api/homepage';
import editorDashboard from './editor';
export default { export default {
name: 'Dashboard', name: 'Dashboard',
components: { adminDashboard, editorDashboard }, components: { Chart },
data() { data() {
return { return {
currentRole: 'adminDashboard', reverse: true,
synthesizecount: [],
activities: [{
content: '活动按期开始',
timestamp: '2018-04-15',
}, {
content: '创建成功',
timestamp: '2018-04-11',
}],
}; };
}, },
computed: {
...mapGetters([
'roles',
]),
},
created() { created() {
if (!this.roles.includes('admin')) { this.getList();
this.currentRole = 'editorDashboard'; },
} methods: {
getList() {
homepagecount()
.then(response => {
this.synthesizecount = response.data;
})
.catch(err => {
console.log(err);
});
},
}, },
}; };
</script> </script>
<style rel="stylesheet/scss" lang="scss" scoped>
.app-container{
.chart-container{
position: relative;
width: 100%;
top: 40px;
// height: calc(100vh - 84px);
}
}
</select>
...@@ -79,7 +79,8 @@ ...@@ -79,7 +79,8 @@
</el-table-column> </el-table-column>
<el-table-column align="center" label="状态" width="170"> <el-table-column align="center" label="状态" width="170">
<template slot-scope="scope"> <template slot-scope="scope">
<span :style="{color:( scope.row.devicestatus==1 ? '#67C23A' : '#F56C6C' )}">{{ scope.row.devicestatus==1 ? '正常' : '设备错误' }}</span> <span v-if="scope.row.status_name=='正常' " :style="{color:( scope.row.devicestatus==1 ? '#67C23A' : '#F56C6C' )}">{{ scope.row.devicestatus==1 ? '正常' : '设备错误' }}</span>
<span v-if="scope.row.status_name!='正常' " :style="{color:( scope.row.status_name=='正常' ? '#67C23A' : '#F56C6C' )}">{{ scope.row.status_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">
...@@ -95,7 +96,7 @@ ...@@ -95,7 +96,7 @@
</template> </template>
</el-table-column> </el-table-column>
</el-table> </el-table>
<pagination v-show="total>0" :total="total" :page.sync="page" :limit.sync="limit" @pagination="getList" /> <pagination v-show="total>0" :total="total" :page.sync="page" :limit.sync="limit" @pagination="devicelist" />
<el-dialog :visible.sync="dialogPvVisible" title="设备详情信息" width="50%"> <el-dialog :visible.sync="dialogPvVisible" title="设备详情信息" width="50%">
<el-table :data="devicefistr"> <el-table :data="devicefistr">
......
This diff is collapsed.
...@@ -9,27 +9,31 @@ ...@@ -9,27 +9,31 @@
:events="events" :events="events"
class="amap-demo" class="amap-demo"
> >
<!-- 用户标记 -->
<el-amap-marker <el-amap-marker
v-for="(marker, index) in markers" v-for="(marker, index) in markers"
:key="marker.id" :key="marker.id"
:position="marker.position" :position="marker.mapcenter | rebuildUserCenter(marker.mapcenter)"
:visible="markerVisible" :visible="markerVisible"
:content="marker.content" :content="marker.company | rebuildContent(100, 3)"
:vid="index" :vid="index"
:clickable="true" :clickable="true"
:events="marker.events" :events="rebuildEvent(marker.mapcenter)"
:z-index="markerUserZIndex"
></el-amap-marker> ></el-amap-marker>
<el-amap-circle-marker <el-amap-circle-marker
v-for="marker in markersDevice" v-for="marker in markersDevice"
:key="marker.id" :key="marker.id"
:visible="markersDeviceVisible" :visible="markersDeviceVisible"
:center="marker.center" :center="marker.devicecoord | deviceLocationFilter(marker.devicecoord)"
:radius="marker.radius" :radius="13"
:fill-color="marker.fillColor" :fill-color="marker.devicepolice | deviceStatusFilter('color')"
:fill-opacity="marker.fillOpacity" :fill-opacity="1"
:stroke-color="'#ccc'" :stroke-color="'#ccc'"
:stroke-opacity="0.9" :stroke-opacity="0.9"
:events="markerClickEvent(marker)"
></el-amap-circle-marker> ></el-amap-circle-marker>
<!-- 右上角设备和用户切换按钮 -->
<div class="toolbar"> <div class="toolbar">
<el-switch <el-switch
v-model="markersDeviceVisible" v-model="markersDeviceVisible"
...@@ -43,6 +47,39 @@ ...@@ -43,6 +47,39 @@
</el-switch> </el-switch>
</div> </div>
</el-amap> </el-amap>
<!-- 点击地图标记打开的信息窗 -->
<el-dialog
:title="dialogTitle"
:visible.sync="dialogTableVisible"
width="20%"
:modal="false"
custom-class="zero-dialog"
>
<el-table :data="gridData" :show-header="false">
<el-table-column property="title"></el-table-column>
<el-table-column property="content"></el-table-column>
</el-table>
</el-dialog>
<!-- 用户的设备列表 -->
<div v-if="deviceListVisible" class="zero-user-devices">
<el-collapse v-model="activeNames">
<el-collapse-item name="1">
<template slot="title">
设备列表<i class="header-icon el-icon-info"></i>
</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="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> </div>
</template> </template>
...@@ -50,6 +87,7 @@ ...@@ -50,6 +87,7 @@
import Vue from 'vue'; import Vue from 'vue';
import VueAMap from 'vue-amap'; import VueAMap from 'vue-amap';
import { AMapManager } from 'vue-amap'; import { AMapManager } from 'vue-amap';
import { devices, users } from '@/api/map';
Vue.use(VueAMap); Vue.use(VueAMap);
...@@ -74,6 +112,46 @@ VueAMap.initAMapApiLoader({ ...@@ -74,6 +112,46 @@ VueAMap.initAMapApiLoader({
}); });
export default { export default {
filters: {
rebuildContent(company, deviceCount, alarmCount) {
let mcontent = '<div class="mapIcon"><span class="mapIcon_title">%name</span><span class="mapIcon_num_all">%num</span><span class="mapIcon_num">%alarm</span></div>';
mcontent = mcontent.replace(/%name/, company).replace(/%num/, deviceCount).replace(/%alarm/, alarmCount);
return mcontent;
},
rebuildUserCenter(mapcenter) {
mapcenter = mapcenter.replace(/\s*/g, '');
// console.log(mapcenter.split(','));
return mapcenter.split(',');
},
deviceLocationFilter(center) {
center = center.replace(/\s*/g, '');
return center.split(',');
},
deviceStatusFilter(status, cate) {
var statuses = [];
statuses[1] = { color: '#1c7a17', name: '正常' };
statuses[2] = { color: '#f6e032', name: '错误' };
statuses[3] = { color: '#f6e032', name: '传感器故障' };
statuses[4] = { color: '#f30016', name: '报警' };
statuses[5] = { color: '#f42f18', name: '低报' };
statuses[6] = { color: '#97000b', name: '高报' };
statuses[7] = { color: '#f6e032', name: '通信故障' };
statuses[8] = { color: '#f6e032', name: '超量程' };
statuses[9] = { color: '#747677', name: '离线' };
statuses[10] = { color: '#f6e032', name: '电量低' };
statuses[11] = { color: '#f6e032', name: '主电故障' };
statuses[12] = { color: '#f6e032', name: '备电故障' };
statuses[13] = { color: '#f6e032', name: '无此节点' };
statuses[14] = { color: '#f6e032', name: '低电压' };
statuses[15] = { color: '#f6e032', name: '故障' };
statuses[16] = { color: '#97000b', name: '报警联动' };
if (cate === 'color') {
return statuses[status].color;
} else if (cate === 'status') {
return statuses[status].name;
}
},
},
data(){ data(){
const _this = this; const _this = this;
return { return {
...@@ -84,21 +162,21 @@ export default { ...@@ -84,21 +162,21 @@ export default {
events: { events: {
init: (o) => { init: (o) => {
o.setMapStyle('amap://styles/normal'); o.setMapStyle('amap://styles/normal');
console.log(o.getCenter()); // console.log(o.getCenter());
// console.log(this.$refs.map.$$getInstance()); // console.log(this.$refs.map.$$getInstance());
o.getCity(result => { o.getCity(result => {
console.log(result); // console.log(result);
}); });
}, },
'moveend': () => { 'moveend': () => {
}, },
'zoomchange': () => { 'zoomchange': () => {
console.log('zoom:', _this.$refs.map); // console.log('zoom:', _this.$refs.map);
_this.zoom = this.$refs.map.$$getInstance().getZoom(); _this.zoom = this.$refs.map.$$getInstance().getZoom();
console.log(_this.zoom); console.log(_this.zoom);
}, },
'click': (e) => { 'click': (e) => {
alert('map clicked'); // alert('map clicked');
}, },
}, },
plugin: ['ToolBar', { plugin: ['ToolBar', {
...@@ -110,11 +188,16 @@ export default { ...@@ -110,11 +188,16 @@ export default {
}, },
}, },
}], }],
markerContent: '<div class="mapIcon"><span class="mapIcon_title">%name</span><span class="mapIcon_num_all">%num</span><span class="mapIcon_num">%alarm</span></div>',
markers: [], markers: [],
markerVisible: true, markerVisible: true,
markersDevice: [], markersDevice: [],
markersDeviceVisible: false, markersDeviceVisible: false,
gridData: {}, // 设备信息
dialogTitle: '设备信息', // 设备信息标题
dialogTableVisible: false, // 设备信息是否显示
deviceListVisible: true, // 用户设备列表是否显示
activeNames: ['1'], // 左侧设备列表默认打开
markerUserZIndex: 100,
}; };
}, },
watch: { watch: {
...@@ -122,68 +205,65 @@ export default { ...@@ -122,68 +205,65 @@ export default {
mounted() { mounted() {
}, },
created() { created() {
const that = this; this.$store.dispatch('app/toggleSideBar');
this.markers = [ // const users = devices.users();
{ users()
position: [114.505208, 38.045474], .then(res => {
content: this.rebuildContent('赢得企图', 10, 5), console.log(res.data);
userid: 1, this.markers = res.data;
events: { });
click() { devices()
// alert(1); .then(res => {
that.getUserDevices([114.505208, 38.045474]); console.log(res.data);
this.markersDevice = res.data;
});
}, },
methods: {
getUserDevices(center) {
// alert(userid);
this.zoom = 12;
this.center = center;
this.markerVisible = true;
this.markersDeviceVisible = true;
}, },
getDeviceInfo(device) {
console.log(device);
alert('deviceInfo');
}, },
{ rebuildEvent(mapcenter) {
position: [113.505208, 38.015474], mapcenter = mapcenter.replace(/\s*/g, '');
content: this.rebuildContent('正元化肥', 15, 0), // console.log(mapcenter);
userid: 2, const that = this;
events: { const position = mapcenter.split(',');
return {
click(e) { click(e) {
// alert(2); // alert(that.zoom);
that.getUserDevices([113.505208, 38.015474]); that.getUserDevices(position);
}, that.deviceListVisible = true;
}, that.markerUserZIndex = 1000;
}, },
]; };
this.markersDevice = [
{
center: [114.505208, 37.045474],
radius: 13,
fillColor: '#777',
fillOpacity: 0.8,
}, },
markerClickEvent(marker) {
const that = this;
return {
click(e) {
console.log(marker);
// const position = marker.devicecoord.replace(/\s*/g, '');
// console.log(position.split(','));
that.gridData = [
{ {
center: [112.505208, 37.045474], title: '设备编号',
radius: 13, content: marker.devicenum,
fillColor: '#750b17',
fillOpacity: 0.8,
}, },
{ {
center: [113.505208, 37.045474], title: '坐标',
radius: 13, content: marker.devicecoord,
fillColor: '#1c7a17',
fillOpacity: 0.8,
}, },
]; ];
that.dialogTableVisible = true;
}, },
methods: { };
rebuildContent(content, deviceCount, alarmCount) {
let mcontent = this.markerContent;
mcontent = mcontent.replace(/%name/, content).replace(/%num/, deviceCount).replace(/%alarm/, alarmCount);
console.log(mcontent);
return mcontent;
},
getUserDevices(center) {
// alert(userid);
this.zoom = 13;
this.center = center;
this.markerVisible = false;
this.markersDeviceVisible = true;
},
getDeviceInfo(deviceId) {
alert(deviceId);
}, },
}, },
}; };
...@@ -251,4 +331,10 @@ export default { ...@@ -251,4 +331,10 @@ export default {
top: 120px; top: 120px;
right: 40px; right: 40px;
} }
.zero-user-devices{
position: fixed;
top: 100px;
padding: 0px 10px 0px 10px;
background-color: #ffffff;
}
</style> </style>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Hello world!</title>
<style type="text/css">
#container{
/*地图(容器)显示大小*/
width:1200px;
height:400px;
}
</style>
<!--引入Javascript API GL,参数说明参见下文-->
<script src="https://map.qq.com/api/gljs?v=1.exp&key=JW7BZ-NN2KD-ODD4Y-PCH4X-J76HQ-EEF2Q"></script>
<script>
//地图初始化函数,本例取名为init,开发者可根据实际情况定义
function initMap() {
//定义地图中心点坐标
var center = new TMap.LatLng(39.984120, 116.307484)
//定义map变量,调用 TMap.Map() 构造函数创建地图
var map = new TMap.Map(document.getElementById('container'), {
center: center,//设置地图中心点坐标
zoom: 17.2, //设置地图缩放级别
pitch: 43.5, //设置俯仰角
rotation: 45 //设置地图旋转角度
});
}
</script>
</head>
<!-- 页面载入后,调用init函数 -->
<body onload="initMap()">
<!-- 定义地图显示容器 -->
<div id="container"></div>
</body>
</html>
<template> <template>
<div>危化监测</div> <div class="app-container">
<el-table :key="tableKey" v-loading="loading" :data="device" border fit highlight-current-rows>
<el-table-column align="center" label="id" width="80">
<template slot-scope="scope">
<span>{{ scope.row.id }}</span>
</template>
</el-table-column>
<el-table-column align="center" label="设备编号" width="150">
<template slot-scope="scope">
<span @click="handleCopy(scope.row.devicenum,$event)">{{ scope.row.devicenum }}</span>
</template>
</el-table-column>
<el-table-column align="center" label="设备类型" width="150">
<template slot-scope="scope">
<span>{{ scope.row.tname }}</span>
</template>
</el-table-column>
<el-table-column align="center" label="介质状态" width="170">
<template slot-scope="scope">
<span>{{ scope.row.gas }}</span>
</template>
</el-table-column>
<el-table-column align="center" label="设备名称" width="170">
<template slot-scope="scope">
<span>{{ scope.row.username }}</span>
</template>
</el-table-column>
<el-table-column align="center" label="浓度" width="170">
<template slot-scope="scope">
<span>{{ scope.row.nd }}</span>
</template>
</el-table-column>
<el-table-column align="center" label="是否已删除设备" width="170">
<template slot-scope="scope">
<span :style="{color:( scope.row.delete==1 ? '#F56C6C' : '#67C23A' )}">{{ scope.row.delete ==1 ? '设备已被丢弃废纸篓' : '设备正常' }}</span>
</template>
</el-table-column>
<el-table-column align="center" label="设备备注" width="170">
<template slot-scope="scope">
<span>{{ scope.row.deviceremark }}</span>
</template>
</el-table-column>
<el-table-column align="center" label="设备详情" width="170">
<template slot-scope="scope">
<span>{{ scope.row.deviceinfo }}</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>
</template>
</el-table-column>
<el-table-column align="center" label="设备实时状态" width="170">
<template slot-scope="scope">
<span>
<el-tag :type=" scope.row.status_name=='正常' ? 'success' : 'warning' " effect="dark">{{ scope.row.status_name }}</el-tag>
</span>
</template>
</el-table-column>
<el-table-column align="center" label="状态" width="170">
<template slot-scope="scope">
<span v-if="scope.row.status_name=='正常' " :style="{color:( scope.row.devicestatus==1 ? '#67C23A' : '#F56C6C' )}">{{ scope.row.devicestatus==1 ? '正常' : '设备错误' }}</span>
<span v-if="scope.row.status_name!='正常' " :style="{color:( scope.row.status_name=='正常' ? '#67C23A' : '#F56C6C' )}">{{ scope.row.status_name=='正常' ? '正常' : '设备异常' }}</span>
</template>
</el-table-column>
</el-table>
<pagination v-show="total>0" :total="total" :page.sync="page" :limit.sync="limit" @pagination="devicelist" />
</div>
</template> </template>
<script> <script>
import { control } from '@/api/device';
import Pagination from '@/components/Pagination'; // 分页
import clip from '@/utils/clipboard';
export default {
name: 'Devicetype',
components: { Pagination },
data() {
return {
tableKey: 0,
loading: true,
device: [],
page: 1,
limit: 10,
type: 2,
total: 0,
paper: undefined,
};
},
created() {
this.devicelist(); // 设备状态
},
methods: {
devicelist() {
const limit = this.limit;
const page = this.page;
this.loading = true;
control(page, limit, this.type)
.then(response => {
var devicetype = response.data['devicelist'];
this.device = devicetype;
this.device.forEach((element, index) => {
element['index'] = (page - 1) * limit + index + 1;
});
this.total = response.data.count;
this.loading = false;
})
.catch(err => {
console.log(err);
});
},
handleClick(tab) {
this.type = tab.$attrs.tid;
this.devicelist();
},
handleCopy(text, event) {
clip(text, event);
},
handleCopyphone(text, event){
clip(text, event);
},
},
};
</script> </script>
<style> <style>
......
<template> <template>
<div>消防监测</div> <div class="app-container">
<el-table :key="tableKey" v-loading="loading" :data="device" border fit highlight-current-rows>
<el-table-column align="center" label="id" width="80">
<template slot-scope="scope">
<span>{{ scope.row.id }}</span>
</template>
</el-table-column>
<el-table-column align="center" label="设备编号" width="150">
<template slot-scope="scope">
<span @click="handleCopy(scope.row.devicenum,$event)">{{ scope.row.devicenum }}</span>
</template>
</el-table-column>
<el-table-column align="center" label="设备类型" width="150">
<template slot-scope="scope">
<span>{{ scope.row.tname }}</span>
</template>
</el-table-column>
<el-table-column align="center" label="介质状态" width="170">
<template slot-scope="scope">
<span>{{ scope.row.gas }}</span>
</template>
</el-table-column>
<el-table-column align="center" label="设备名称" width="170">
<template slot-scope="scope">
<span>{{ scope.row.username }}</span>
</template>
</el-table-column>
<el-table-column align="center" label="浓度" width="170">
<template slot-scope="scope">
<span>{{ scope.row.nd }}</span>
</template>
</el-table-column>
<el-table-column align="center" label="是否已删除设备" width="170">
<template slot-scope="scope">
<span :style="{color:( scope.row.delete==1 ? '#F56C6C' : '#67C23A' )}">{{ scope.row.delete ==1 ? '设备已被丢弃废纸篓' : '设备正常' }}</span>
</template>
</el-table-column>
<el-table-column align="center" label="设备备注" width="170">
<template slot-scope="scope">
<span>{{ scope.row.deviceremark }}</span>
</template>
</el-table-column>
<el-table-column align="center" label="设备详情" width="170">
<template slot-scope="scope">
<span>{{ scope.row.deviceinfo }}</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>
</template>
</el-table-column>
<el-table-column align="center" label="设备实时状态" width="170">
<template slot-scope="scope">
<span>
<el-tag :type=" scope.row.status_name=='正常' ? 'success' : 'warning' " effect="dark">{{ scope.row.status_name }}</el-tag>
</span>
</template>
</el-table-column>
<el-table-column align="center" label="状态" width="170">
<template slot-scope="scope">
<span v-if="scope.row.status_name=='正常' " :style="{color:( scope.row.devicestatus==1 ? '#67C23A' : '#F56C6C' )}">{{ scope.row.devicestatus==1 ? '正常' : '设备错误' }}</span>
<span v-if="scope.row.status_name!='正常' " :style="{color:( scope.row.status_name=='正常' ? '#67C23A' : '#F56C6C' )}">{{ scope.row.status_name=='正常' ? '正常' : '设备异常' }}</span>
</template>
</el-table-column>
</el-table>
<pagination v-show="total>0" :total="total" :page.sync="page" :limit.sync="limit" @pagination="devicelist" />
</div>
</template> </template>
<script> <script>
import { control } from '@/api/device';
import Pagination from '@/components/Pagination'; // 分页
import clip from '@/utils/clipboard';
export default {
name: 'Devicetype',
components: { Pagination },
data() {
return {
tableKey: 0,
loading: true,
device: [],
page: 1,
limit: 10,
type: 1,
total: 0,
paper: undefined,
};
},
created() {
this.devicelist(); // 设备状态
},
methods: {
devicelist() {
const limit = this.limit;
const page = this.page;
this.loading = true;
control(page, limit, this.type)
.then(response => {
var devicetype = response.data['devicelist'];
this.device = devicetype;
this.device.forEach((element, index) => {
element['index'] = (page - 1) * limit + index + 1;
});
this.total = response.data.count;
this.loading = false;
})
.catch(err => {
console.log(err);
});
},
handleClick(tab) {
this.type = tab.$attrs.tid;
this.devicelist();
},
handleCopy(text, event) {
clip(text, event);
},
handleCopyphone(text, event){
clip(text, event);
},
},
};
</script> </script>
<style> <style>
......
...@@ -71,6 +71,7 @@ ...@@ -71,6 +71,7 @@
<script> <script>
import { deviceTypeList } from '@/api/device'; import { deviceTypeList } from '@/api/device';
import websocketurl from '@/api/configurl';
import BackToTop from '@/components/BackToTop'; import BackToTop from '@/components/BackToTop';
export default { export default {
components: { BackToTop }, components: { BackToTop },
...@@ -115,7 +116,7 @@ export default { ...@@ -115,7 +116,7 @@ export default {
}); });
}, },
initWebSocket(){ // 初始化weosocket initWebSocket(){ // 初始化weosocket
const wsuri = 'ws://127.0.0.1:9502'; const wsuri = websocketurl.baseURL;
this.websock = new WebSocket(wsuri); this.websock = new WebSocket(wsuri);
this.websock.onmessage = this.websocketonmessage; this.websock.onmessage = this.websocketonmessage;
this.websock.onopen = this.websocketonopen; this.websock.onopen = this.websocketonopen;
......
<template>
<div></div>
</template>
<script>
</script>
<style>
</style>
...@@ -29,7 +29,6 @@ ...@@ -29,7 +29,6 @@
<div id="app"> <div id="app">
<app></app> <app></app>
</div> </div>
<script src=/static/tinymce4.7.5/tinymce.min.js></script> <script src=/static/tinymce4.7.5/tinymce.min.js></script>
<script src="{{ mix('js/vendor.js') }}"></script> <script src="{{ mix('js/vendor.js') }}"></script>
<script src="{{ mix('js/manifest.js') }}"></script> <script src="{{ mix('js/manifest.js') }}"></script>
......
...@@ -29,7 +29,6 @@ ...@@ -29,7 +29,6 @@
<div id="app"> <div id="app">
<app></app> <app></app>
</div> </div>
<script src=/static/tinymce4.7.5/tinymce.min.js></script> <script src=/static/tinymce4.7.5/tinymce.min.js></script>
<script src="{{ mix('js/app.js') }}"></script> <script src="{{ mix('js/app.js') }}"></script>
</body> </body>
......
...@@ -41,10 +41,11 @@ Route::group(['middleware' => 'auth:api'], function () { ...@@ -41,10 +41,11 @@ Route::group(['middleware' => 'auth:api'], function () {
Route::get('user/UpPaperBasket/{id}','UserController@UpPaperBasket');//更新废纸篓和禁用用户 Route::get('user/UpPaperBasket/{id}','UserController@UpPaperBasket');//更新废纸篓和禁用用户
Route::get('user/UpuserForbidden/{id}','UserController@UpuserForbidden');//禁用此用户 Route::get('user/UpuserForbidden/{id}','UserController@UpuserForbidden');//禁用此用户
Route::get('user/paperBasket','UserController@paperBasket');//返回废纸篓数量 Route::get('user/paperBasket','UserController@paperBasket');//返回废纸篓数量
Route::get('user/paperBasketList','UserController@paperBasketList');//返回废纸篓和用户状态 Route::get('user/paperBasketList','UserController@paperBasketList');//返回废纸篓和用户状态
Route::get('user/userLocation','UserController@userLocation');//返回用户安装位置
Route::get('user/textcountuser','UserController@textcountuser');//用户测试接口
Route::get('user/textcountuser','UserController@textcountuser');//返回废纸篓和用户状态
}); });
//上传图片路由 //上传图片路由
...@@ -61,6 +62,12 @@ Route::group(['middleware'=>'auth:api'],function (){ ...@@ -61,6 +62,12 @@ Route::group(['middleware'=>'auth:api'],function (){
Route::post('SwooleCommand/SwooleCommand','SwooleCommandController@index'); Route::post('SwooleCommand/SwooleCommand','SwooleCommandController@index');
}); });
//首页路由
Route::group(['middleware'=>'auth:api'],function (){
Route::get('homepagecount/homepagecount','HomepageController@homepagecount');//删除图片
Route::get('homepagecount/devicemonthcount','HomepageController@devicemonthcount');//删除图片
});
//设备路由 //设备路由
Route::group(['middleware'=>'auth:api'],function (){ Route::group(['middleware'=>'auth:api'],function (){
Route::get('devices/devicelist', 'DevicesController@devicelist');//设备列表 Route::get('devices/devicelist', 'DevicesController@devicelist');//设备列表
...@@ -81,6 +88,8 @@ Route::group(['middleware'=>'auth:api'],function (){ ...@@ -81,6 +88,8 @@ Route::group(['middleware'=>'auth:api'],function (){
Route::get('devices/addClassify/{data}','DevicesController@addClassify');//添加分类 Route::get('devices/addClassify/{data}','DevicesController@addClassify');//添加分类
Route::get('devices/delteClassify/{id}','DevicesController@delteClassify');//删除分类 Route::get('devices/delteClassify/{id}','DevicesController@delteClassify');//删除分类
Route::get('devices/detedevice','DevicesController@detedevice');//查看历史数据 Route::get('devices/detedevice','DevicesController@detedevice');//查看历史数据
Route::get('devices/control','DevicesController@control');//返回消防监测
Route::get('devices/deviceLocation','DevicesController@deviceLocation');//返回设备安装位置
}); });
//装维中心 //装维中心
......
...@@ -39,5 +39,10 @@ module.exports = { ...@@ -39,5 +39,10 @@ module.exports = {
}, },
], ],
}, },
externals: {
'AMap': 'AMap',
'Loca': 'Loca',
'AMapUI': 'AMapUI',
},
plugins: plugins, plugins: plugins,
}; };
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