Commit 36278252 authored by Administrator's avatar Administrator

实时监测

parent d58ff614
Pipeline #106 failed with stages
...@@ -26,73 +26,137 @@ class SwooleCommandController extends Controller ...@@ -26,73 +26,137 @@ class SwooleCommandController extends Controller
return $this->jsonSuccessData($countdata); return $this->jsonSuccessData($countdata);
} }
public function chemicals($id) /**
* 危化监测
* @param $data
* @return false|string
*/
public function chemicals($data)
{ {
$searchData = json_decode($data, true);
$id = $searchData['userId'];
$uid = $this->parseAbilityAndArgumentsadmin($id); $uid = $this->parseAbilityAndArgumentsadmin($id);
$databadevice = DB::table('device');
$where = [];
$whereIn = [1, 5, 10];
if(!empty($searchData['deviceNum'])) {
$where[] = ['devicenum', 'like', "%{$searchData['deviceNum']}%"];
}
if(!empty($searchData['deviceName'])) {
$where[] = ['username', 'like', "%{$searchData['deviceName']}%"];
}
if($searchData['deviceType'] != 0) {
$whereIn = [$searchData['deviceType']];
}
if($searchData['deviceStatus'] != 0) {
$where[] = ['device.devicepolice', '=', $searchData['deviceStatus']];
}
$limit = $searchData['limit'];
$pagenNum = $limit * ($searchData['page'] - 1);//页数
if($uid == 1){ if($uid == 1){
$devicelist = $databadevice $devicelist = DB::table('device')
->whereIn('dtype', [1, 5, 10]) ->whereIn('dtype', $whereIn)
->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')
->leftjoin('danwei as dw', 'device.devicemonad', '=', 'dw.id') ->leftjoin('danwei as dw', 'device.devicemonad', '=', 'dw.id')
->select('dy.tname', 'g.gas', 'device.*', 'p.status_name', 'dw.danwei') ->select('dy.tname', 'g.gas', 'device.*', 'p.status_name', 'dw.danwei')
->where($where)
->offset($pagenNum)
->limit($limit)
->orderBy('device.id', 'desc') ->orderBy('device.id', 'desc')
->get()->toArray(); ->get()->toArray();
$count = $databadevice $count = DB::table('device')
->whereIn('dtype', [1, 5, 10]) ->whereIn('dtype', $whereIn)
->where($where)
->count(); ->count();
}else{ }else{
$devicelist = $databadevice $devicelist = DB::table('device')
->whereIn('dtype', [1, 5, 10]) ->whereIn('dtype', $whereIn)
->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')
->leftjoin('danwei as dw', 'device.devicemonad', '=', 'dw.id') ->leftjoin('danwei as dw', 'device.devicemonad', '=', 'dw.id')
->where('device.uid','=',$id) ->where('device.uid','=',$id)
->where($where)
->select('dy.tname', 'g.gas', 'device.*', 'p.status_name', 'dw.danwei') ->select('dy.tname', 'g.gas', 'device.*', 'p.status_name', 'dw.danwei')
->offset($pagenNum)
->limit($limit)
->orderBy('device.id', 'desc') ->orderBy('device.id', 'desc')
->get()->toArray(); ->get()->toArray();
$count = $databadevice $count = DB::table('device')
->where('device.uid','=',$id) ->where('device.uid','=',$id)
->whereIn('dtype', [1, 5, 10]) ->whereIn('dtype', $whereIn)
->where($where)
->count(); ->count();
} }
return $this->jsonSuccessData(['devicelist' => $devicelist, 'count' => $count]); return $this->jsonSuccessData(['devicelist' => $devicelist, 'count' => $count]);
} }
public function fire($id) /**
* 消防监测
* @param $data
* @return false|string
*/
public function fire($data)
{ {
$searchData = json_decode($data, true);
$id = $searchData['userId'];
$uid = $this->parseAbilityAndArgumentsadmin($id); $uid = $this->parseAbilityAndArgumentsadmin($id);
$databadevice = DB::table('device');
$where = [];
$whereIn = [2, 4, 6, 7, 8, 9, 11];
if(!empty($searchData['deviceNum'])) {
$where[] = ['devicenum', 'like', "%{$searchData['deviceNum']}%"];
}
if(!empty($searchData['deviceName'])) {
$where[] = ['username', 'like', "%{$searchData['deviceName']}%"];
}
if($searchData['deviceType'] != 0) {
$whereIn = [$searchData['deviceType']];
}
if($searchData['deviceStatus'] != 0) {
$where[] = ['device.devicepolice', '=', $searchData['deviceStatus']];
}
$limit = $searchData['limit'];
$pagenNum = $limit * ($searchData['page'] - 1);//页数
if($uid == 1){ if($uid == 1){
$devicelist = $databadevice $devicelist = DB::table('device')
->whereIn('dtype', [2, 4, 6, 7, 8, 9, 11]) ->whereIn('dtype', $whereIn)
->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')
->leftjoin('danwei as dw', 'device.devicemonad', '=', 'dw.id') ->leftjoin('danwei as dw', 'device.devicemonad', '=', 'dw.id')
->select('dy.tname', 'g.gas', 'device.*', 'p.status_name', 'dw.danwei') ->select('dy.tname', 'g.gas', 'device.*', 'p.status_name', 'dw.danwei')
->where($where)
->offset($pagenNum)
->limit($limit)
->orderBy('device.id', 'desc') ->orderBy('device.id', 'desc')
->get()->toArray(); ->get()->toArray();
$count = $databadevice $count = DB::table('device')
->whereIn('dtype', [2, 4, 6, 7, 8, 9, 11]) ->whereIn('dtype', $whereIn)
->where($where)
->count(); ->count();
}else{ }else{
$devicelist = $databadevice $devicelist = DB::table('device')
->whereIn('dtype', [2, 4, 6, 7, 8, 9, 11]) ->whereIn('dtype', $whereIn)
->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')
->leftjoin('danwei as dw', 'device.devicemonad', '=', 'dw.id') ->leftjoin('danwei as dw', 'device.devicemonad', '=', 'dw.id')
->where('device.uid','=',$id) ->where('device.uid','=',$id)
->where($where)
->select('dy.tname', 'g.gas', 'device.*', 'p.status_name', 'dw.danwei') ->select('dy.tname', 'g.gas', 'device.*', 'p.status_name', 'dw.danwei')
->offset($pagenNum)
->limit($limit)
->orderBy('device.id', 'desc') ->orderBy('device.id', 'desc')
->get()->toArray(); ->get()->toArray();
$count = $databadevice $count = DB::table('device')
->where('device.uid','=',$id) ->where('device.uid','=',$id)
->whereIn('dtype', [2, 4, 6, 7, 8, 9, 11]) ->whereIn('dtype', $whereIn)
->where($where)
->count(); ->count();
} }
return $this->jsonSuccessData(['devicelist' => $devicelist, 'count' => $count]); return $this->jsonSuccessData(['devicelist' => $devicelist, 'count' => $count]);
......
...@@ -482,8 +482,9 @@ class DevicesController extends Controller ...@@ -482,8 +482,9 @@ class DevicesController extends Controller
//返回消防监测 //返回消防监测
public function control(Request $request) public function control(Request $request)
{ {
$pagenNum = $request->input('page') - 1;//页数 $pagenNum = $request->input('page');//页数
$limit = $request->input('limit'); $limit = $request->input('limit');
$offset = $limit * ($pagenNum - 1);
$type = $request->input('type'); $type = $request->input('type');
if ($pagenNum === '' || $limit == '' || $type === '') { if ($pagenNum === '' || $limit == '' || $type === '') {
return $this->jsonErrorData(105, '页数或limit不能为空'); return $this->jsonErrorData(105, '页数或limit不能为空');
...@@ -494,24 +495,40 @@ class DevicesController extends Controller ...@@ -494,24 +495,40 @@ class DevicesController extends Controller
//返回危化 //返回危化
$wherein = [1, 5, 10]; $wherein = [1, 5, 10];
} }
$databadevice = DB::table('device'); $search = json_decode($request->input('search'), true);
$where = [];
if(!empty($search['deviceNum'])) {
$where[] = ['devicenum', 'like', "%{$search['deviceNum']}%"];
}
if(!empty($search['deviceName'])) {
$where[] = ['username', 'like', "%{$search['deviceName']}%"];
}
if($search['deviceType'] != 0) {
$wherein = [$search['deviceType']];
}
if($search['deviceStatus'] != 0) {
$where[] = ['device.devicepolice', '=', $search['deviceStatus']];
}
if (!is_null($this->isadmin())) { if (!is_null($this->isadmin())) {
$devicelist = $databadevice $devicelist = DB::table('device')
->whereIn('dtype', $wherein) ->whereIn('dtype', $wherein)
->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')
->leftjoin('danwei as dw', 'device.devicemonad', '=', 'dw.id') ->leftjoin('danwei as dw', 'device.devicemonad', '=', 'dw.id')
->select('dy.tname', 'g.gas', 'device.*', 'p.status_name', 'dw.danwei') ->select('dy.tname', 'g.gas', 'device.*', 'p.status_name', 'dw.danwei')
->where($where)
->orderBy('device.id', 'desc') ->orderBy('device.id', 'desc')
->offset($pagenNum) ->offset($offset)
->limit($limit) ->limit($limit)
->get()->toArray(); ->get()->toArray();
$count = $databadevice $count = DB::table('device')
->whereIn('dtype', $wherein) ->whereIn('dtype', $wherein)
->where($where)
->count(); ->count();
}else{ }else{
$devicelist = $databadevice $devicelist = DB::table('device')
->whereIn('dtype', $wherein) ->whereIn('dtype', $wherein)
->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')
...@@ -519,13 +536,15 @@ class DevicesController extends Controller ...@@ -519,13 +536,15 @@ class DevicesController extends Controller
->leftjoin('danwei as dw', 'device.devicemonad', '=', 'dw.id') ->leftjoin('danwei as dw', 'device.devicemonad', '=', 'dw.id')
->where('device.uid','=',Auth::id()) ->where('device.uid','=',Auth::id())
->select('dy.tname', 'g.gas', 'device.*', 'p.status_name', 'dw.danwei') ->select('dy.tname', 'g.gas', 'device.*', 'p.status_name', 'dw.danwei')
->where($where)
->orderBy('device.id', 'desc') ->orderBy('device.id', 'desc')
->offset($pagenNum) ->offset($offset)
->limit($limit) ->limit($limit)
->get()->toArray(); ->get()->toArray();
$count = $databadevice $count = DB::table('device')
->whereIn('dtype', $wherein) ->whereIn('dtype', $wherein)
->where('uid','=',Auth::id()) ->where('uid','=',Auth::id())
->where($where)
->count(); ->count();
} }
return $this->jsonSuccessData(['devicelist' => $devicelist, 'count' => $count]); return $this->jsonSuccessData(['devicelist' => $devicelist, 'count' => $count]);
......
<?php
use Illuminate\Database\Seeder;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Hash;
use Illuminate\Support\Str;
use Ramsey\Uuid\Uuid;
class DeviceSeeder extends Seeder
{
/**
* Run the database seeds.
*
* @return void
*/
public function run()
{
for ($i= 0; $i < 100; $i++) {
$dtype = random_int(1, 11);
if($dtype === 3) $dtype = 2;
DB::table('device')->insert([
'uid' => 1,
'contactsid' => random_int(1, 7),
'devicenum' => Str::random(22),
'dtype' => $dtype,
'status' => 1,
'devicemonad' => random_int(1, 8),
'devicepolice' => random_int(1, 8),
'deviceuuid' => Uuid::uuid1()->toString(),
'username' => "河北泽宏" . random_int(1, 1000) . "号测试设备",
'nd' => random_int(0, 1000),
'deviceremark' => '河北泽宏' . $i,
'devicelinkman' => Str::random(10),
'devicephone' => '1883011' . random_int(1000, 9999),
'deviceinfo' => Str::random(10),
'devicecoord' => '114.'. random_int(100000, 999999) .',38.'. random_int(100000, 999999),
'deviceaddtime' => time(),
'update_time' => time(),
]);
}
}
}
...@@ -107,9 +107,9 @@ export function addUserDevice() { ...@@ -107,9 +107,9 @@ export function addUserDevice() {
}); });
} }
export function control(page, limit, type) { export function control(page, limit, type, formData) {
return request({ return request({
url: 'devices/control?page=' + page + '&limit=' + limit + '&type=' + type, url: 'devices/control?page=' + page + '&limit=' + limit + '&type=' + type + '&search=' + JSON.stringify(formData),
method: 'get', method: 'get',
}); });
} }
......
...@@ -3,7 +3,7 @@ import Clipboard from 'clipboard'; ...@@ -3,7 +3,7 @@ import Clipboard from 'clipboard';
function clipboardSuccess() { function clipboardSuccess() {
Vue.prototype.$message({ Vue.prototype.$message({
message: 'Copy successfully', message: '复制成功',
type: 'success', type: 'success',
duration: 1500, duration: 1500,
}); });
...@@ -11,7 +11,7 @@ function clipboardSuccess() { ...@@ -11,7 +11,7 @@ function clipboardSuccess() {
function clipboardError() { function clipboardError() {
Vue.prototype.$message({ Vue.prototype.$message({
message: 'Copy failed', message: '复制失败',
type: 'error', type: 'error',
}); });
} }
......
<template> <template>
<div class="app-container"> <div class="app-container">
<el-form :inline="true" :model="formSearch" class="demo-form-inline">
<el-form-item label="设备编号">
<el-input v-model="formSearch.deviceNum" placeholder="输入完整设备编号"></el-input>
</el-form-item>
<el-form-item label="设备名称">
<el-input v-model="formSearch.deviceName" placeholder="设备名称"></el-input>
</el-form-item>
<el-form-item label="设备类型">
<el-select
v-model="formSearch.deviceType"
style="margin-left: 20px;"
placeholder="请选择"
>
<el-option
v-for="item in optionTypes"
:key="item.value"
:label="item.label"
:value="item.value"
>
</el-option>
</el-select>
</el-form-item>
<el-form-item label="状态">
<el-select
v-model="formSearch.deviceStatus"
style="margin-left: 20px;"
placeholder="请选择"
>
<el-option
v-for="item in optionStatus"
:key="item.value"
:label="item.label"
:value="item.value"
>
</el-option>
</el-select>
</el-form-item>
<el-form-item>
<el-button type="primary" @click="onSubmit">查询</el-button>
</el-form-item>
</el-form>
<el-table :key="tableKey" v-loading="loading" :data="device" border fit highlight-current-rows> <el-table :key="tableKey" v-loading="loading" :data="device" border fit highlight-current-rows>
<el-table-column align="center" label="ID" width="80"> <el-table-column align="center" label="ID" width="80">
<template slot-scope="scope"> <template slot-scope="scope">
...@@ -11,7 +52,7 @@ ...@@ -11,7 +52,7 @@
<span @click="handleCopy(scope.row.devicenum,$event)">{{ scope.row.devicenum }}</span> <span @click="handleCopy(scope.row.devicenum,$event)">{{ scope.row.devicenum }}</span>
</template> </template>
</el-table-column> </el-table-column>
<el-table-column align="center" label="设备名称" width="170"> <el-table-column align="center" label="设备名称" width="200">
<template slot-scope="scope"> <template slot-scope="scope">
<span>{{ scope.row.username }}</span> <span>{{ scope.row.username }}</span>
</template> </template>
...@@ -31,7 +72,7 @@ ...@@ -31,7 +72,7 @@
<span>{{ scope.row.gas }}</span> <span>{{ scope.row.gas }}</span>
</template> </template>
</el-table-column> </el-table-column>
<el-table-column align="center" label="检测值" width="170"> <el-table-column align="center" label="检测值" width="100">
<template slot-scope="scope"> <template slot-scope="scope">
<span>{{ scope.row.nd }}</span> <span>{{ scope.row.nd }}</span>
</template> </template>
...@@ -41,26 +82,33 @@ ...@@ -41,26 +82,33 @@
<span>{{ scope.row.danwei }}</span> <span>{{ scope.row.danwei }}</span>
</template> </template>
</el-table-column> </el-table-column>
<el-table-column align="center" label="设备实时状态" width="170"> <el-table-column align="center" label="实时状态" width="120">
<template slot-scope="scope"> <template slot-scope="scope">
<span> <span>
<el-tag :type=" scope.row.status_name=='正常' ? 'success' : 'warning' " effect="dark">{{ scope.row.status_name }}</el-tag> <el-tag :type=" scope.row.status_name=='正常' ? 'success' : 'warning' " effect="dark">{{ scope.row.status_name }}</el-tag>
</span> </span>
</template> </template>
</el-table-column> </el-table-column>
<el-table-column align="center" label="状态" width="170"> <el-table-column align="center" label="状态" width="70">
<template slot-scope="scope"> <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.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> <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">
<template slot-scope="scope"> <template slot-scope="scope">
<span>{{ scope.row.update_time | parseTime('{y}-{m}-{d} {h}:{i}') }}</span> <span v-if="scope.row.update_time > 0">{{ scope.row.update_time | parseTime('{y}-{m}-{d} {h}:{i}:{s}') }}</span>
</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="devicelist" /> <pagination
v-show="total>0"
:total="total"
:page.sync="formSearch.page"
:limit.sync="formSearch.limit"
:page-sizes="[10,30,80]"
@pagination="devicelist"
/>
</div> </div>
</template> </template>
...@@ -77,12 +125,84 @@ export default { ...@@ -77,12 +125,84 @@ export default {
tableKey: 0, tableKey: 0,
loading: true, loading: true,
device: [], device: [],
page: 1,
limit: 10,
type: 2, type: 2,
total: 0, total: 0,
paper: undefined, paper: undefined,
timer: '', timer: '',
formSearch: {
deviceNum: '',
deviceName: '',
deviceType: 0,
deviceStatus: 0,
userId: 0,
page: 1,
limit: 10,
},
optionStatus: [{
value: 0,
label: '全部',
}, {
value: 1,
label: '正常',
}, {
value: 2,
label: '错误',
}, {
value: 3,
label: '传感器故障',
}, {
value: 4,
label: '报警',
}, {
value: 5,
label: '低报',
}, {
value: 6,
label: '高报',
}, {
value: 7,
label: '通信故障',
}, {
value: 8,
label: '超量程',
}, {
value: 9,
label: '离线',
}, {
value: 10,
label: '电量低',
}, {
value: 11,
label: '主电故障',
}, {
value: 12,
label: '备电故障',
}, {
value: 13,
label: '无此节点',
}, {
value: 14,
label: '低电压',
}, {
value: 15,
label: '故障',
}, {
value: 16,
label: '报警联动',
}],
optionTypes: [{
value: 0,
label: '全部',
}, {
value: 1,
label: '工业探测器',
}, {
value: 5,
label: '压力监测设备',
}, {
value: 10,
label: '温度变送器',
}],
}; };
}, },
created() { created() {
...@@ -91,11 +211,15 @@ export default { ...@@ -91,11 +211,15 @@ export default {
}, },
methods: { methods: {
onSubmit() {
this.formSearch.page = 1;
this.devicelist();
},
devicelist() { devicelist() {
const limit = this.limit; const limit = this.formSearch.limit;
const page = this.page; const page = this.formSearch.page;
this.loading = true; this.loading = true;
control(page, limit, this.type) control(page, limit, this.type, this.formSearch)
.then(response => { .then(response => {
var devicetype = response.data['devicelist']; var devicetype = response.data['devicelist'];
this.device = devicetype; this.device = devicetype;
...@@ -136,7 +260,8 @@ export default { ...@@ -136,7 +260,8 @@ export default {
this.total = redata.data.count; this.total = redata.data.count;
}, },
websocketsend(){ // 数据发送 websocketsend(){ // 数据发送
this.websock.send(localStorage.getItem('userinfoid')); this.formSearch.userId = localStorage.getItem('userinfoid');
this.websock.send(JSON.stringify(this.formSearch));
}, },
websocketclose(e){ // 关闭 websocketclose(e){ // 关闭
console.log('断开连接', e); console.log('断开连接', e);
......
<template> <template>
<div class="app-container"> <div class="app-container">
<el-form :inline="true" :model="formSearch" class="demo-form-inline">
<el-form-item label="设备编号">
<el-input v-model="formSearch.deviceNum" placeholder="输入完整设备编号"></el-input>
</el-form-item>
<el-form-item label="设备名称">
<el-input v-model="formSearch.deviceName" placeholder="设备名称"></el-input>
</el-form-item>
<el-form-item label="设备类型">
<el-select
v-model="formSearch.deviceType"
style="margin-left: 20px;"
placeholder="请选择"
>
<el-option
v-for="item in optionTypes"
:key="item.value"
:label="item.label"
:value="item.value"
>
</el-option>
</el-select>
</el-form-item>
<el-form-item label="状态">
<el-select
v-model="formSearch.deviceStatus"
style="margin-left: 20px;"
placeholder="请选择"
>
<el-option
v-for="item in optionStatus"
:key="item.value"
:label="item.label"
:value="item.value"
>
</el-option>
</el-select>
</el-form-item>
<el-form-item>
<el-button type="primary" @click="onSubmit">查询</el-button>
</el-form-item>
</el-form>
<el-table :key="tableKey" v-loading="loading" :data="device" border fit highlight-current-rows> <el-table :key="tableKey" v-loading="loading" :data="device" border fit highlight-current-rows>
<el-table-column align="center" label="ID" width="80"> <el-table-column align="center" label="ID" width="80">
<template slot-scope="scope"> <template slot-scope="scope">
...@@ -11,7 +52,7 @@ ...@@ -11,7 +52,7 @@
<span @click="handleCopy(scope.row.devicenum,$event)">{{ scope.row.devicenum }}</span> <span @click="handleCopy(scope.row.devicenum,$event)">{{ scope.row.devicenum }}</span>
</template> </template>
</el-table-column> </el-table-column>
<el-table-column align="center" label="设备名称" width="170"> <el-table-column align="center" label="设备名称" width="200">
<template slot-scope="scope"> <template slot-scope="scope">
<span>{{ scope.row.username }}</span> <span>{{ scope.row.username }}</span>
</template> </template>
...@@ -31,7 +72,7 @@ ...@@ -31,7 +72,7 @@
<span>{{ scope.row.gas }}</span> <span>{{ scope.row.gas }}</span>
</template> </template>
</el-table-column> </el-table-column>
<el-table-column align="center" label="检测值" width="170"> <el-table-column align="center" label="检测值" width="100">
<template slot-scope="scope"> <template slot-scope="scope">
<span>{{ scope.row.nd }}</span> <span>{{ scope.row.nd }}</span>
</template> </template>
...@@ -41,26 +82,33 @@ ...@@ -41,26 +82,33 @@
<span>{{ scope.row.danwei }}</span> <span>{{ scope.row.danwei }}</span>
</template> </template>
</el-table-column> </el-table-column>
<el-table-column align="center" label="设备实时状态" width="170"> <el-table-column align="center" label="实时状态" width="120">
<template slot-scope="scope"> <template slot-scope="scope">
<span> <span>
<el-tag :type=" scope.row.status_name=='正常' ? 'success' : 'warning' " effect="dark">{{ scope.row.status_name }}</el-tag> <el-tag :type=" scope.row.status_name=='正常' ? 'success' : 'warning' " effect="dark">{{ scope.row.status_name }}</el-tag>
</span> </span>
</template> </template>
</el-table-column> </el-table-column>
<el-table-column align="center" label="状态" width="170"> <el-table-column align="center" label="状态" width="70">
<template slot-scope="scope"> <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.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> <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">
<template slot-scope="scope"> <template slot-scope="scope">
<span>{{ scope.row.update_time | parseTime('{y}-{m}-{d} {h}:{i}') }}</span> <span v-if="scope.row.update_time > 0">{{ scope.row.update_time | parseTime('{y}-{m}-{d} {h}:{i}:{s}') }}</span>
</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="devicelist" /> <pagination
v-show="total>0"
:total="total"
:page.sync="formSearch.page"
:limit.sync="formSearch.limit"
:page-sizes="[10,30,80]"
@pagination="devicelist"
/>
</div> </div>
</template> </template>
...@@ -77,12 +125,96 @@ export default { ...@@ -77,12 +125,96 @@ export default {
tableKey: 0, tableKey: 0,
loading: true, loading: true,
device: [], device: [],
page: 1,
limit: 10,
type: 1, type: 1,
total: 0, total: 0,
paper: undefined, paper: undefined,
timer: '', timer: '',
formSearch: {
deviceNum: '',
deviceName: '',
deviceType: 0,
deviceStatus: 0,
userId: 0,
page: 1,
limit: 10,
},
optionStatus: [{
value: 0,
label: '全部',
}, {
value: 1,
label: '正常',
}, {
value: 2,
label: '错误',
}, {
value: 3,
label: '传感器故障',
}, {
value: 4,
label: '报警',
}, {
value: 5,
label: '低报',
}, {
value: 6,
label: '高报',
}, {
value: 7,
label: '通信故障',
}, {
value: 8,
label: '超量程',
}, {
value: 9,
label: '离线',
}, {
value: 10,
label: '电量低',
}, {
value: 11,
label: '主电故障',
}, {
value: 12,
label: '备电故障',
}, {
value: 13,
label: '无此节点',
}, {
value: 14,
label: '低电压',
}, {
value: 15,
label: '故障',
}, {
value: 16,
label: '报警联动',
}],
optionTypes: [{
value: 0,
label: '全部',
}, {
value: 2,
label: '家用报警器',
}, {
value: 4,
label: '家用报警器(IOT)',
}, {
value: 6,
label: '烟雾感应设备',
}, {
value: 7,
label: '烟雾感应设备(联通)',
}, {
value: 8,
label: '家用报警器(RTU)',
}, {
value: 9,
label: '液位探测器',
}, {
value: 11,
label: '消防报警及联动设备',
}],
}; };
}, },
created() { created() {
...@@ -91,11 +223,15 @@ export default { ...@@ -91,11 +223,15 @@ export default {
}, },
methods: { methods: {
onSubmit() {
this.formSearch.page = 1;
this.devicelist();
},
devicelist() { devicelist() {
const limit = this.limit; const limit = this.formSearch.limit;
const page = this.page; const page = this.formSearch.page;
this.loading = true; this.loading = true;
control(page, limit, this.type) control(page, limit, this.type, this.formSearch)
.then(response => { .then(response => {
var devicetype = response.data['devicelist']; var devicetype = response.data['devicelist'];
this.device = devicetype; this.device = devicetype;
...@@ -136,13 +272,14 @@ export default { ...@@ -136,13 +272,14 @@ export default {
this.total = redata.data.count; this.total = redata.data.count;
}, },
websocketsend(){ // 数据发送 websocketsend(){ // 数据发送
this.websock.send(localStorage.getItem('userinfoid')); this.formSearch.userId = localStorage.getItem('userinfoid');
this.websock.send(JSON.stringify(this.formSearch));
}, },
websocketclose(e){ // 关闭 websocketclose(e){ // 关闭
console.log('断开连接', e); console.log('断开连接', e);
this.$notify({ this.$notify({
title: '警告', title: '警告',
message: '消防监测长连接已断开', message: '危化监测长连接已断开',
type: 'warning', type: 'warning',
}); });
clearInterval(this.timer); clearInterval(this.timer);
......
...@@ -89,7 +89,7 @@ ...@@ -89,7 +89,7 @@
</div> </div>
</div> </div>
</el-dialog> </el-dialog>
<el-drawer title="添加用户" :visible.sync="drawer" :direction="direction" :before-close="handleClose"> <el-drawer title="添加用户" :visible.sync="drawer" :direction="direction" :before-close="handleClose" custom-class="zl-drawer">
<el-card class="box-card" style="height: 20000px;"> <el-card class="box-card" style="height: 20000px;">
<div v-loading="userCreating" class="form-container"> <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 ref="userForm" :rules="rules" :model="newUser" label-position="left" label-width="150px" style="max-width: 500px;">
...@@ -565,5 +565,8 @@ export default { ...@@ -565,5 +565,8 @@ export default {
.clear-left { .clear-left {
clear: left; clear: left;
} }
.zl-drawer .el-drawer__body {
overflow-y: auto !important;
}
} }
</style> </style>
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