334 lines
15 KiB
Plaintext
334 lines
15 KiB
Plaintext
|
|
@page "{handler?}"
|
|||
|
|
@model YBDevice.NWeb.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">
|
|||
|
|
<div class="layui-inline">
|
|||
|
|
<div class="layui-input-inline">
|
|||
|
|
<select id="BusinessId" lay-search>
|
|||
|
|
<option value="">选择客户</option>
|
|||
|
|
@foreach (var item in Model.buss)
|
|||
|
|
{
|
|||
|
|
<option value="@item.Id">@item.Name</option>
|
|||
|
|
}
|
|||
|
|
</select>
|
|||
|
|
</div>
|
|||
|
|
</div>
|
|||
|
|
<div class="layui-inline">
|
|||
|
|
<div class="layui-input-inline">
|
|||
|
|
<select id="type" lay-search>
|
|||
|
|
<option value="">设备类型</option>
|
|||
|
|
@foreach (var item in Model.types)
|
|||
|
|
{
|
|||
|
|
<option value="@item.Code">@item.Name</option>
|
|||
|
|
}
|
|||
|
|
</select>
|
|||
|
|
</div>
|
|||
|
|
</div>
|
|||
|
|
<div class="layui-inline">
|
|||
|
|
<div class="layui-input-inline">
|
|||
|
|
<select id="status">
|
|||
|
|
<option value="">设备状态</option>
|
|||
|
|
@foreach (var item in Model.statuss)
|
|||
|
|
{
|
|||
|
|
<option value="@item.Value">@item.Text</option>
|
|||
|
|
}
|
|||
|
|
</select>
|
|||
|
|
</div>
|
|||
|
|
</div>
|
|||
|
|
<div class="layui-inline">
|
|||
|
|
<div class="layui-input-inline">
|
|||
|
|
<input type="text" class="layui-input" placeholder="请输入设备名称" id="name" />
|
|||
|
|
</div>
|
|||
|
|
</div>
|
|||
|
|
<div class="layui-inline">
|
|||
|
|
<div class="layui-input-inline">
|
|||
|
|
<input type="text" class="layui-input" placeholder="请输入设备序列号" id="faccode" />
|
|||
|
|
</div>
|
|||
|
|
</div>
|
|||
|
|
<div class="layui-inline">
|
|||
|
|
<div class="layui-input-inline">
|
|||
|
|
<input type="text" class="layui-input" placeholder="请输入机器码" id="ecode" />
|
|||
|
|
</div>
|
|||
|
|
</div>
|
|||
|
|
<div class="layui-inline">
|
|||
|
|
<button class="btn btn-primary btn-lg js-search" type="button">查询</button>
|
|||
|
|
@Html.Raw(Model.viewdata.Top)
|
|||
|
|
</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">
|
|||
|
|
@Html.Raw(Model.viewdata.Table)
|
|||
|
|
</script>
|
|||
|
|
<script type="text/html" id="lefttoolbar">
|
|||
|
|
@Html.Raw(Model.viewdata.TableTop)
|
|||
|
|
</script>
|
|||
|
|
@section Scripts
|
|||
|
|
{
|
|||
|
|
<script type="text/javascript">
|
|||
|
|
layui.use(['common', 'table', 'layer'], function () {
|
|||
|
|
var common = layui.common, table = layui.table, layer = layui.layer;
|
|||
|
|
common.initTable({
|
|||
|
|
url: '/api/device/getlist',
|
|||
|
|
where: {
|
|||
|
|
sort: "lasthearttime",
|
|||
|
|
order:"desc"
|
|||
|
|
}
|
|||
|
|
, method: 'post'
|
|||
|
|
, toolbar: "#lefttoolbar",
|
|||
|
|
ontoolbarevent: function (obj) {
|
|||
|
|
if (obj.event == "js-fenpei" || obj.event == "js-fenpei1" || obj.event == "js-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.code === 0) {
|
|||
|
|
common.info(res.message, function () {
|
|||
|
|
/*$(".js-search").trigger("click");*/
|
|||
|
|
layer.close(index);
|
|||
|
|
});
|
|||
|
|
} else {
|
|||
|
|
common.alert(res.message);
|
|||
|
|
}
|
|||
|
|
},
|
|||
|
|
});
|
|||
|
|
}, btn2: function (index, layero) {
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
});
|
|||
|
|
break;
|
|||
|
|
case "js-fenpei1":
|
|||
|
|
console.log("")
|
|||
|
|
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,
|
|||
|
|
isactive:0
|
|||
|
|
},
|
|||
|
|
success: function (res) {
|
|||
|
|
if (res.code === 0) {
|
|||
|
|
common.info(res.message, function () {
|
|||
|
|
/*$(".js-search").trigger("click");*/
|
|||
|
|
layer.close(index);
|
|||
|
|
});
|
|||
|
|
} else {
|
|||
|
|
common.alert(res.message);
|
|||
|
|
}
|
|||
|
|
},
|
|||
|
|
});
|
|||
|
|
}, btn2: function (index, layero) {
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
});
|
|||
|
|
break;
|
|||
|
|
case "js-reback":
|
|||
|
|
common.confirm("确定回收?", function () {
|
|||
|
|
common.uajax({
|
|||
|
|
url: "/api/device/batchset",
|
|||
|
|
type: "post",
|
|||
|
|
data: {
|
|||
|
|
businessid: 0,
|
|||
|
|
codes: ids,
|
|||
|
|
type: 2
|
|||
|
|
}
|
|||
|
|
});
|
|||
|
|
});
|
|||
|
|
break;
|
|||
|
|
default:
|
|||
|
|
break;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
, cols: [[
|
|||
|
|
{ type: "checkbox" },
|
|||
|
|
{
|
|||
|
|
field: 'businessname', title: '客户'
|
|||
|
|
},
|
|||
|
|
{
|
|||
|
|
field: 'name', title: '名称'
|
|||
|
|
},
|
|||
|
|
{
|
|||
|
|
field: 'typename', title: '型号'
|
|||
|
|
},
|
|||
|
|
{
|
|||
|
|
field: 'faccode', title: '序列号'
|
|||
|
|
},
|
|||
|
|
{
|
|||
|
|
field: 'ecode', title: '机器码', hide: true
|
|||
|
|
},
|
|||
|
|
{
|
|||
|
|
field: 'todayresultcnt', title: '今日/累计次数', templet: function (d) {
|
|||
|
|
return d.todayresultcnt + '/' + d.totalresultcnt;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
,
|
|||
|
|
{
|
|||
|
|
field: 'status', title: '状态', templet: function (d) {
|
|||
|
|
var html = "";
|
|||
|
|
if (d.status == 2) {
|
|||
|
|
html = "<span class='text-grey'>";
|
|||
|
|
}
|
|||
|
|
if (d.status == 0) {
|
|||
|
|
html = "<span class='text-red'>";
|
|||
|
|
}
|
|||
|
|
if (d.status == 1) {
|
|||
|
|
html = "<span class='text-green'>";
|
|||
|
|
}
|
|||
|
|
return html + DeviceStatus[d.status] + "</span>";
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
,
|
|||
|
|
{
|
|||
|
|
field: 'lasthearttime', title: '最近测量时间', templet: function (d) {
|
|||
|
|
return d.time;
|
|||
|
|
}
|
|||
|
|
},
|
|||
|
|
{
|
|||
|
|
title: '操作', templet: "#optpl", fixed:'right'
|
|||
|
|
}
|
|||
|
|
]]
|
|||
|
|
});
|
|||
|
|
$(".js-search").on("click", function () {
|
|||
|
|
common.reloadtable("list", {
|
|||
|
|
where: {
|
|||
|
|
queryParam: [{
|
|||
|
|
"Name": 'BusinessId',
|
|||
|
|
"Type": QueryCond.Equal,
|
|||
|
|
"Value": $("#BusinessId").val()
|
|||
|
|
}, {
|
|||
|
|
"Name": 'Type',
|
|||
|
|
"Type": QueryCond.Equal,
|
|||
|
|
"Value": $("#type").val()
|
|||
|
|
}, {
|
|||
|
|
"Name": 'faccode',
|
|||
|
|
"Type": QueryCond.Like,
|
|||
|
|
"Value": $("#faccode").val()
|
|||
|
|
}, {
|
|||
|
|
"Name": 'name',
|
|||
|
|
"Type": QueryCond.Like,
|
|||
|
|
"Value": $("#name").val()
|
|||
|
|
}, {
|
|||
|
|
"Name": 'ecode',
|
|||
|
|
"Type": QueryCond.Like,
|
|||
|
|
"Value": $("#ecode").val()
|
|||
|
|
}, {
|
|||
|
|
"Name": 'status',
|
|||
|
|
"Type": QueryCond.Equal,
|
|||
|
|
"Value": $("#status").val()
|
|||
|
|
}]
|
|||
|
|
}
|
|||
|
|
});
|
|||
|
|
});
|
|||
|
|
$(".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
|
|||
|
|
});
|
|||
|
|
});
|
|||
|
|
$("body").on("click", ".js-delete", function () {
|
|||
|
|
var id = $(this).data('id');
|
|||
|
|
common.confirm("确定删除?", function () {
|
|||
|
|
common.ajax({
|
|||
|
|
url: "Del?id=" + id,
|
|||
|
|
success: function (res) {
|
|||
|
|
if (res.code == 0) {
|
|||
|
|
common.info(res.message, function () {
|
|||
|
|
$(".js-search").trigger("click");
|
|||
|
|
});
|
|||
|
|
} else {
|
|||
|
|
common.alert(res.message);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
});
|
|||
|
|
});
|
|||
|
|
});
|
|||
|
|
$("body").on("click", ".js-detail", function () {
|
|||
|
|
var id = $(this).data("id");
|
|||
|
|
common.dialog({
|
|||
|
|
title: '设备详情',
|
|||
|
|
content: 'detail?id=' + id
|
|||
|
|
});
|
|||
|
|
});
|
|||
|
|
$("body").on("click", ".js-Set", function () {
|
|||
|
|
var id = $(this).data('id');
|
|||
|
|
var status = $(this).data('status');
|
|||
|
|
var msg = "确定启用?";
|
|||
|
|
if (status == 0) {
|
|||
|
|
msg = "确定停用?";
|
|||
|
|
}
|
|||
|
|
common.confirm(msg, function () {
|
|||
|
|
common.uajax({
|
|||
|
|
url: '/api/device/stopdev/?id=' + id + '&status=' + status,
|
|||
|
|
});
|
|||
|
|
});
|
|||
|
|
});
|
|||
|
|
$("body").on("click", ".js-record", function () {
|
|||
|
|
var id = $(this).data('id');
|
|||
|
|
common.dialog({
|
|||
|
|
title: '分配记录',
|
|||
|
|
content: 'alloc?id=' + id
|
|||
|
|
});
|
|||
|
|
});
|
|||
|
|
});
|
|||
|
|
</script>
|
|||
|
|
}
|