2021-05-27 16:58:40 +08:00
|
|
|
|
@page
|
|
|
|
|
|
@model Waste.Web.Entry.Pages.Device.IndexModel
|
|
|
|
|
|
@{
|
|
|
|
|
|
ViewData["Title"] = "设备管理";
|
|
|
|
|
|
}
|
|
|
|
|
|
<div class="layui-card">
|
|
|
|
|
|
<div class="layui-form layui-card-header layuiadmin-card-header-auto">
|
|
|
|
|
|
<div class="layui-form-item">
|
2022-01-20 13:51:01 +08:00
|
|
|
|
<div class="layui-inline">
|
|
|
|
|
|
<div class="layui-input-inline">
|
|
|
|
|
|
<select id="BusinessId" lay-search>
|
2022-06-15 11:40:34 +08:00
|
|
|
|
<option value="">请选择商户</option>
|
2022-01-20 13:51:01 +08:00
|
|
|
|
@foreach (var item in Model.blist)
|
|
|
|
|
|
{
|
|
|
|
|
|
<option value="@item.Id">@item.Name</option>
|
|
|
|
|
|
}
|
|
|
|
|
|
</select>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</div>
|
2021-09-15 11:10:54 +08:00
|
|
|
|
<div class="layui-inline">
|
|
|
|
|
|
<div class="layui-input-inline">
|
|
|
|
|
|
<input type="text" class="layui-input" name="Ecode" id="Ecode" placeholder="请输入机器码" />
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</div>
|
2021-05-27 16:58:40 +08:00
|
|
|
|
<div class="layui-inline">
|
|
|
|
|
|
<div class="layui-input-inline">
|
|
|
|
|
|
<input type="text" class="layui-input" name="FacEcode" id="FacEcode" placeholder="请输入设备编号" />
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
<div class="layui-inline">
|
|
|
|
|
|
<div class="layui-input-inline">
|
|
|
|
|
|
<input type="text" class="layui-input" name="Name" id="Name" placeholder="请输入设备名称" />
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</div>
|
2022-06-15 11:40:34 +08:00
|
|
|
|
<div class="layui-inline">
|
|
|
|
|
|
<div class="layui-input-inline">
|
|
|
|
|
|
<input type="text" class="layui-input" data-time="ysdatetime" name="lasthearttime" id="lasthearttime" placeholder="请选择最近上报时间" />
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</div>
|
2021-05-27 16:58:40 +08:00
|
|
|
|
<div class="layui-inline">
|
|
|
|
|
|
<button class="btn btn-primary btn-lg js-search" type="button">查询</button>
|
|
|
|
|
|
<button class="btn btn-primary btn-lg js-add" type="button">添加</button>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
<div class="layui-card-body">
|
|
|
|
|
|
<table class="layui-table" id="list" lay-filter="list">
|
|
|
|
|
|
</table>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
<script type="text/html" id="optpl">
|
|
|
|
|
|
<a href="#" class="js-edit" title="编辑" data-id="{{d.id}}">编辑</a>
|
2021-10-12 15:26:06 +08:00
|
|
|
|
@*<a href="#" class="js-detail" title="详情" data-id="{{d.id}}">详情</a> *@
|
|
|
|
|
|
{{#if (d.status == 1){ }}
|
2022-05-14 18:02:50 +08:00
|
|
|
|
<a href="#" class="js-stop" title="设备停用" data-id="{{d.id}}">停用</a>
|
2021-10-12 15:26:06 +08:00
|
|
|
|
{{# } else if (d.status == 0){ }}
|
2022-05-14 18:02:50 +08:00
|
|
|
|
<a href="#" class="js-start" title="设备启用" data-id="{{d.id}}">启用</a>
|
2021-10-12 15:26:06 +08:00
|
|
|
|
{{#} }}
|
2022-05-14 18:02:50 +08:00
|
|
|
|
<a href="#" class="js-config" title="配置" data-id="{{d.id}}">配置</a>
|
2021-05-27 16:58:40 +08:00
|
|
|
|
</script>
|
|
|
|
|
|
<script type="text/html" id="lefttoolbar">
|
|
|
|
|
|
<button class="btn btn-primary btn-lg" lay-event="js-fenpei">分配</button>
|
|
|
|
|
|
<button class="btn btn-primary btn-lg" lay-event="reback">回收</button>
|
|
|
|
|
|
</script>
|
|
|
|
|
|
<script type="text/html" id="netstatustpl">
|
|
|
|
|
|
{{#if (d.netstatus == 0){ }}
|
|
|
|
|
|
<span style="color:red;">离线</span>
|
|
|
|
|
|
{{# } else { }}
|
|
|
|
|
|
<span style="color: #19be6b;">在线</span>
|
|
|
|
|
|
{{#} }}
|
|
|
|
|
|
</script>
|
|
|
|
|
|
<script type="text/html" id="signtpl">
|
|
|
|
|
|
<ul class="signlist">
|
|
|
|
|
|
<li class="{{d.sign >0 && d.netstatus ==1?"active":""}}"></li>
|
|
|
|
|
|
<li class="{{d.sign >1 &&d.netstatus ==1?"active":""}}"></li>
|
|
|
|
|
|
<li class="{{d.sign >2 &&d.netstatus ==1?"active":""}}"></li>
|
|
|
|
|
|
<li class="{{d.sign >3 &&d.netstatus ==1?"active":""}}"></li>
|
|
|
|
|
|
<li class="{{d.sign >4 &&d.netstatus ==1?"active":""}}"></li>
|
|
|
|
|
|
</ul>
|
|
|
|
|
|
</script>
|
|
|
|
|
|
@section Scripts
|
|
|
|
|
|
{
|
2022-01-20 13:51:01 +08:00
|
|
|
|
<script type="text/javascript">
|
2021-05-27 16:58:40 +08:00
|
|
|
|
layui.use(['common', 'table', 'layer'], function () {
|
|
|
|
|
|
var common = layui.common, table = layui.table, layer = layui.layer;
|
|
|
|
|
|
common.initTable({
|
|
|
|
|
|
url: '/api/device/getlist',
|
|
|
|
|
|
toolbar:"#lefttoolbar"
|
|
|
|
|
|
, method: 'post',
|
|
|
|
|
|
ontoolbarevent: function (obj) {
|
|
|
|
|
|
if (obj.event == "js-fenpei" || obj.event == "reback") {
|
|
|
|
|
|
var checkStatus = table.checkStatus(obj.config.id);
|
|
|
|
|
|
if (checkStatus.data.length == 0) {
|
|
|
|
|
|
common.alert("请选择设备");
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
var ids = [];
|
|
|
|
|
|
$.each(checkStatus.data, function () {
|
|
|
|
|
|
ids.push(this.id);
|
|
|
|
|
|
});
|
|
|
|
|
|
switch (obj.event) {
|
|
|
|
|
|
case "js-fenpei":
|
|
|
|
|
|
common.normaldialog({
|
|
|
|
|
|
title: '选择服务商',
|
|
|
|
|
|
area: ['70%', '70%'],
|
|
|
|
|
|
content: '/Business/List',
|
|
|
|
|
|
btn: ['确认', '取消'],
|
|
|
|
|
|
yes: function (index, layero) {
|
|
|
|
|
|
var body = layer.getChildFrame('body', index);
|
|
|
|
|
|
var iframeWin = window[layero.find('iframe')[0]['name']]; //得到iframe页的窗口对象,执行iframe页的方法:
|
|
|
|
|
|
var values = iframeWin.getselect(table);
|
|
|
|
|
|
if (values.length == 0) {
|
|
|
|
|
|
common.alert("请选择商户");
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
common.uajax({
|
|
|
|
|
|
url: "/api/device/batchset",
|
|
|
|
|
|
type: "post",
|
|
|
|
|
|
data: {
|
|
|
|
|
|
businessid: values[0].id,
|
|
|
|
|
|
codes: ids,
|
|
|
|
|
|
type: 1
|
|
|
|
|
|
},
|
|
|
|
|
|
success: function (res) {
|
|
|
|
|
|
if (res.succeeded) {
|
|
|
|
|
|
var newres = res.data;
|
|
|
|
|
|
if (newres.code === 0) {
|
|
|
|
|
|
common.info(res.message, function () {
|
|
|
|
|
|
/*$(".js-search").trigger("click");*/
|
|
|
|
|
|
layer.close(index);
|
|
|
|
|
|
});
|
|
|
|
|
|
} else {
|
|
|
|
|
|
common.alert(newres.message);
|
|
|
|
|
|
}
|
|
|
|
|
|
} else {
|
|
|
|
|
|
var msg = "状态码:" + res.statuscode + ",时间戳:" + res.timestamp + ",描述:" + res.errors;
|
|
|
|
|
|
that.alert(msg);
|
|
|
|
|
|
}
|
|
|
|
|
|
},
|
|
|
|
|
|
});
|
|
|
|
|
|
}, btn2: function (index, layero) {
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
});
|
|
|
|
|
|
break;
|
|
|
|
|
|
case "reback":
|
|
|
|
|
|
common.confirm("确定回收?", function () {
|
|
|
|
|
|
common.uajax({
|
|
|
|
|
|
url: "/api/device/batchset",
|
|
|
|
|
|
type: "post",
|
|
|
|
|
|
data: {
|
|
|
|
|
|
businessid: '@Model.emptyBusinessid',
|
|
|
|
|
|
codes: ids,
|
|
|
|
|
|
type: 2
|
|
|
|
|
|
}
|
|
|
|
|
|
});
|
|
|
|
|
|
});
|
|
|
|
|
|
break;
|
|
|
|
|
|
default:
|
|
|
|
|
|
break;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
, cols: [[
|
|
|
|
|
|
{ type: "checkbox" },
|
|
|
|
|
|
{
|
|
|
|
|
|
field: 'businessname', title: '所属商户'
|
|
|
|
|
|
},
|
|
|
|
|
|
{
|
2021-08-23 10:49:35 +08:00
|
|
|
|
field: 'facecode', title: '编号'
|
|
|
|
|
|
},
|
|
|
|
|
|
{
|
|
|
|
|
|
field: 'ecode', title: '机器码'
|
2021-05-27 16:58:40 +08:00
|
|
|
|
},
|
|
|
|
|
|
{
|
|
|
|
|
|
field: 'name', title: '设备名称'
|
|
|
|
|
|
}
|
|
|
|
|
|
,
|
|
|
|
|
|
{
|
|
|
|
|
|
field: 'todaycount', title: '今日/累计称重', templet: function (d) {
|
|
|
|
|
|
return d.todaycount + "/" + d.totalcount;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
,
|
|
|
|
|
|
{
|
|
|
|
|
|
field: 'todayweight', title: '今日/累计重量(KG)', templet: function (d) {
|
|
|
|
|
|
return d.todayweight + "/" + d.totalweight;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
,
|
|
|
|
|
|
{
|
|
|
|
|
|
field: 'nettype', title: '联网方式', templet: function (d) {
|
|
|
|
|
|
return DeviceNetType[d.nettype];
|
|
|
|
|
|
}, hide: true
|
|
|
|
|
|
}
|
|
|
|
|
|
,
|
|
|
|
|
|
{
|
|
|
|
|
|
field: 'status', title: '设备状态', templet: function (d) {
|
|
|
|
|
|
return DeviceStatus[d.status];
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
,
|
|
|
|
|
|
{
|
|
|
|
|
|
field: 'netstatus', title: '网络状态', templet:"#netstatustpl"
|
|
|
|
|
|
}
|
|
|
|
|
|
,
|
|
|
|
|
|
{
|
2021-09-30 09:27:59 +08:00
|
|
|
|
field: 'sign', title: '信号强度', templet: "#signtpl", hide: true
|
2021-05-27 16:58:40 +08:00
|
|
|
|
}
|
|
|
|
|
|
,
|
|
|
|
|
|
{
|
|
|
|
|
|
field: 'iccid', title: 'ICCID', hide: true
|
|
|
|
|
|
}
|
|
|
|
|
|
,
|
2022-06-15 11:40:34 +08:00
|
|
|
|
{
|
|
|
|
|
|
field: 'lasthearttime', title: '最近上报时间',sort:true
|
|
|
|
|
|
}
|
|
|
|
|
|
,
|
|
|
|
|
|
,
|
2021-05-27 16:58:40 +08:00
|
|
|
|
{
|
|
|
|
|
|
field: 'lastbeattime', title: '心跳时间'
|
|
|
|
|
|
}
|
|
|
|
|
|
,
|
2021-08-17 10:21:47 +08:00
|
|
|
|
{
|
|
|
|
|
|
field: 'longitude', title: '经度',hide:true
|
|
|
|
|
|
}
|
|
|
|
|
|
,
|
|
|
|
|
|
{
|
|
|
|
|
|
field: 'latitude', title: '纬度', hide: true
|
|
|
|
|
|
}
|
|
|
|
|
|
,
|
2021-05-27 16:58:40 +08:00
|
|
|
|
{
|
|
|
|
|
|
field: 'address', title: '地址'
|
|
|
|
|
|
}
|
|
|
|
|
|
,
|
|
|
|
|
|
{
|
|
|
|
|
|
field: 'remark', title: '备注', hide: true
|
|
|
|
|
|
}
|
2022-01-20 13:51:01 +08:00
|
|
|
|
,
|
2021-05-27 16:58:40 +08:00
|
|
|
|
{
|
|
|
|
|
|
title: '操作', templet: "#optpl"
|
|
|
|
|
|
}
|
|
|
|
|
|
]]
|
|
|
|
|
|
});
|
|
|
|
|
|
$(".js-search").on("click", function () {
|
2022-06-15 11:40:34 +08:00
|
|
|
|
var queryParam = [{
|
|
|
|
|
|
"Name": 'FacEcode',
|
|
|
|
|
|
"Type": QueryCond.Like,
|
|
|
|
|
|
"Value": $("#FacEcode").val()
|
|
|
|
|
|
}, {
|
|
|
|
|
|
"Name": 'Ecode',
|
|
|
|
|
|
"Type": QueryCond.Like,
|
|
|
|
|
|
"Value": $("#Ecode").val()
|
|
|
|
|
|
}, {
|
|
|
|
|
|
"Name": 'Name',
|
|
|
|
|
|
"Type": QueryCond.Like,
|
|
|
|
|
|
"Value": $("#Name").val()
|
|
|
|
|
|
}, {
|
|
|
|
|
|
"Name": 'BusinessId',
|
|
|
|
|
|
"Type": QueryCond.Equal,
|
|
|
|
|
|
"Value": $("#BusinessId").val()
|
|
|
|
|
|
}];
|
|
|
|
|
|
var starttime = $("#lasthearttime").val();
|
|
|
|
|
|
if (starttime != "") {
|
|
|
|
|
|
var times = starttime.split('~');
|
|
|
|
|
|
queryParam.push({
|
|
|
|
|
|
"Name": 'lasthearttime',
|
|
|
|
|
|
"Type": QueryCond.GreaterThanOrEqual,
|
|
|
|
|
|
"Value": times[0].trim()
|
|
|
|
|
|
});
|
|
|
|
|
|
queryParam.push({
|
|
|
|
|
|
"Name": 'lasthearttime',
|
|
|
|
|
|
"Type": QueryCond.LessThanOrEqual,
|
|
|
|
|
|
"Value": times[1].trim()
|
|
|
|
|
|
});
|
|
|
|
|
|
}
|
2021-05-27 16:58:40 +08:00
|
|
|
|
common.reloadtable("list", {
|
|
|
|
|
|
where: {
|
2022-06-15 11:40:34 +08:00
|
|
|
|
queryParam: queryParam
|
2021-05-27 16:58:40 +08:00
|
|
|
|
}
|
|
|
|
|
|
});
|
|
|
|
|
|
});
|
|
|
|
|
|
$(".js-add").on("click", function () {
|
|
|
|
|
|
common.dialog({
|
|
|
|
|
|
title: '添加设备',
|
|
|
|
|
|
content: '/Device/Edit'
|
|
|
|
|
|
});
|
|
|
|
|
|
});
|
|
|
|
|
|
$("body").on("click", ".js-edit", function () {
|
|
|
|
|
|
var id = $(this).data('id');
|
|
|
|
|
|
common.dialog({
|
|
|
|
|
|
title: '编辑设备',
|
|
|
|
|
|
content: '/Device/Edit?id=' + id
|
|
|
|
|
|
});
|
2022-05-14 18:02:50 +08:00
|
|
|
|
});
|
|
|
|
|
|
$("body").on("click", ".js-config", function () {
|
|
|
|
|
|
var id = $(this).data('id');
|
|
|
|
|
|
common.dialog({
|
|
|
|
|
|
title: '推送配置',
|
|
|
|
|
|
content: '/Device/Config?id=' + id
|
|
|
|
|
|
});
|
2021-05-27 16:58:40 +08:00
|
|
|
|
});
|
|
|
|
|
|
$("body").on("click", ".js-delete", function () {
|
|
|
|
|
|
var id = $(this).data('id');
|
|
|
|
|
|
common.confirm("确定删除?", function () {
|
|
|
|
|
|
common.ajax({
|
|
|
|
|
|
url: "Del?id=" + id
|
|
|
|
|
|
});
|
|
|
|
|
|
});
|
|
|
|
|
|
});
|
2021-09-30 13:53:10 +08:00
|
|
|
|
$("body").on("click", ".js-detail", function () {
|
|
|
|
|
|
var id = $(this).data('id');
|
|
|
|
|
|
common.dialog({
|
|
|
|
|
|
content:"/Device/Detail?id="+id
|
|
|
|
|
|
});
|
|
|
|
|
|
});
|
2021-10-12 15:26:06 +08:00
|
|
|
|
$("body").on("click", ".js-stop", function () {
|
|
|
|
|
|
var id = $(this).data('id');
|
|
|
|
|
|
common.confirm("确定停用?", function () {
|
|
|
|
|
|
common.uajax({
|
|
|
|
|
|
url: "/api/device/setstatus?id=" + id+"&status=0"
|
|
|
|
|
|
});
|
|
|
|
|
|
});
|
|
|
|
|
|
});
|
|
|
|
|
|
$("body").on("click", ".js-start", function () {
|
|
|
|
|
|
var id = $(this).data('id');
|
|
|
|
|
|
common.confirm("确定启用?", function () {
|
|
|
|
|
|
common.uajax({
|
|
|
|
|
|
url: "/api/device/setstatus?id=" + id + "&status=1"
|
|
|
|
|
|
});
|
|
|
|
|
|
});
|
|
|
|
|
|
});
|
2021-05-27 16:58:40 +08:00
|
|
|
|
});
|
2022-01-20 13:51:01 +08:00
|
|
|
|
</script>
|
2021-05-27 16:58:40 +08:00
|
|
|
|
}
|