Browse Source

增加设备查看数据页tab

master
wanghongjun 2 years ago
parent
commit
0cf9ed3c16
  1. 2
      application/api/controller/Information.php
  2. 40
      application/index/controller/Device.php
  3. 26
      application/index/view/device/index.html
  4. 103
      application/index/view/device/receiving_information.html

2
application/api/controller/Information.php

@ -5,6 +5,7 @@ namespace app\api\controller;
use think\Db;
use think\exception\ValidateException;
use think\Loader;
use think\Log;
use think\Request;
use think\db\exception\DataNotFoundException;
use think\db\exception\ModelNotFoundException;
@ -28,6 +29,7 @@ class Information extends Base
try {
Log::info('xiaowangbeizhu'.json_encode($param));
$InformationValidate = Loader::validate('InformationValidate');
if(!$InformationValidate->check($param)){
throw new ValidateException($InformationValidate->getError());

40
application/index/controller/Device.php

@ -65,4 +65,44 @@ class Device extends Base
return json($list);
}
/**
* 设备接收信息页面
* @return mixed
*/
public function receivingInformation()
{
$receive = Request::instance()->get();
$this->assign('deviceId',$receive['deviceId']);
return $this->fetch();
}
/**
* 设备接收信息页面数据接口
* @return Json
* @throws DataNotFoundException
* @throws DbException
* @throws Exception
* @throws ModelNotFoundException
*/
public function receivingInformationList() {
$receive = Request::instance()->get();
$page = input("get.page") ? input("get.page") : 1;
$page = intval($page);
$limit = input("get.limit") ? input("get.limit") : 1;
$limit = intval($limit);
$start = $limit * ($page - 1);
$where['deviceId'] = $receive['deviceId'] ?: 0;
$result = Db::table("bs_device_receiving_information")->where($where)->order('id desc')->limit($start, $limit)->select();
$num = Db::table("bs_device_receiving_information")->where($where)->count();
foreach ($result as &$item) {
if ($item['timestamp']) $item['timestamp'] = date("Y-m-d H:i:s",substr($item['timestamp'],0,10));
}
$list["msg"] = "";
$list["code"] = 0;
$list["count"] = $num;
$list["data"] = $result;
return json($list);
}
}

26
application/index/view/device/index.html

@ -76,6 +76,12 @@
</div>
</div>
<script type="text/html" id="barDemo">
<a class="layui-btn layui-btn-danger layui-icon layui-icon-delete layui-btn-xs" value="{{d.deviceId}}" lay-event="queryInfo">
查看
</a>
</script>
<script>
@ -232,6 +238,26 @@
return false;
});
//监听单个删除按钮
table.on('tool(demo)', function (obj) {
var data = obj.data;
if (obj.event === 'queryInfo') {
layer.open({
type: 2
, title: '查看接收信息'
, shadeClose: true
, shade: 0.8
, area: ['80%', '90%']
, content: '/index/device/receivingInformation?deviceId=' + data.deviceId
, btn: ['关闭']
, end: function () {
layer.closeAll()
}
})
}
});
function get_cols() {
return [ //表头,style: 'background-color: #bee4ca ; color: #2c2525 ' ,style: 'background-color: #acd3ed;color: #2c2525;' ,style: 'background-color: #bda9c5'
{

103
application/index/view/device/receiving_information.html

@ -0,0 +1,103 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>设备信息总览</title>
<meta name="renderer" content="webkit">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<link rel="stylesheet" href="/css/font.css">
<link rel="stylesheet" href="/css/xadmin.css">
<script src="/lib/layui/layui.js" charset="utf-8"></script>
<script type="text/javascript" src="/js/xadmin.js"></script>
<!-- 让IE8/9支持媒体查询,从而兼容栅格 -->
<!--[if lt IE 9]>
<script src="https://cdn.staticfile.org/html5shiv/r29/html5.min.js"></script>
<script src="https://cdn.staticfile.org/respond.js/1.4.2/respond.min.js"></script>
<![endif]-->
<style>
.layui-table thead span {
/*background-color: #acd3ed;*/
font-size: 15px;
}
.layui-table tbody tr td div {
font-size: 14px;
}
.layui-table tbody tr:hover {
background-color: #f7e8df;
}
</style>
</head>
<body class="layui-anim layui-anim-scale flag"><br/>
<div class="layui-card-body">
<table id="demoInformation" lay-filter="demoInformation"></table>
</div>
<input type="hidden" name="deviceId" id="deviceId" value="{$deviceId}">
<script>
layui.use(['table', 'jquery'], function () {
var table = layui.table;
var $ = layui.jquery;
let deviceId = $("#deviceId").val();
//生成数据表格
var tableIns = table.render({
elem: '#demoInformation'
, url: '/index/Device/receivingInformationList?deviceId=' + deviceId//数据接口
, loading: true
, size: 'lg'
, page: {
layout: ['prev', 'page', 'next', 'count', 'limit']//自定义布局顺序
, groups: 10 //最多几个跳页按钮
, first: false //不显示首页
, last: false //不显示尾页
}
, cols: [
[
{
field: 'taskId',
title: '任务id',
minWidth: 100,
align: 'center'
}
, {
field: 'productId',
title: '产品id',
minWidth: 100,
align: 'center'
}
, {
field: 'deviceId',
title: '设备id',
minWidth: 100,
align: 'center'
}
, {
field: 'tenantId',
title: '租户id',
minWidth: 100,
align: 'center'
}
, {
field: 'protocol',
title: '协议',
minWidth: 100,
align: 'center'
}
, {
field: 'timestamp',
title: '接收时间',
minWidth: 100,
align: 'center'
}
]
]
});
});
</script>
</body>
</html>
Loading…
Cancel
Save