219 lines
11 KiB
HTML
219 lines
11 KiB
HTML
<!DOCTYPE html>
|
|
<html lang="zh-cn">
|
|
<head>
|
|
<meta charset="utf-8">
|
|
<title>报警规则列表</title>
|
|
<link rel="stylesheet" href="/app/admin/component/pear/css/pear.css" />
|
|
<link rel="stylesheet" href="/app/admin/admin/css/reset.css" />
|
|
</head>
|
|
<body class="pear-container">
|
|
|
|
<div class="layui-card">
|
|
<div class="layui-card-body">
|
|
<form class="layui-form top-search-from">
|
|
|
|
<div class="layui-form-item">
|
|
<label class="layui-form-label">所属医院</label>
|
|
<div class="layui-input-block">
|
|
<div id="hospitalSelect"></div>
|
|
</div>
|
|
</div>
|
|
<div class="layui-form-item">
|
|
<label class="layui-form-label">预警类型</label>
|
|
<div class="layui-input-block">
|
|
<select name="type">
|
|
<option value="">全部</option>
|
|
<option value="1">温度</option>
|
|
<option value="2">压力</option>
|
|
<option value="3">时间</option>
|
|
</select>
|
|
</div>
|
|
</div>
|
|
<div class="layui-form-item">
|
|
<label class="layui-form-label">预警等级</label>
|
|
<div class="layui-input-block">
|
|
<select name="level">
|
|
<option value="">全部</option>
|
|
<option value="1">初级</option>
|
|
<option value="2">中级</option>
|
|
<option value="3">高级</option>
|
|
</select>
|
|
</div>
|
|
</div>
|
|
<div class="layui-form-item">
|
|
<label class="layui-form-label">状态</label>
|
|
<div class="layui-input-block">
|
|
<select name="is_open">
|
|
<option value="">全部</option>
|
|
<option value="1">开启</option>
|
|
<option value="2">关闭</option>
|
|
</select>
|
|
</div>
|
|
</div>
|
|
<div class="layui-form-item layui-inline">
|
|
<label class="layui-form-label"></label>
|
|
<button class="pear-btn pear-btn-md pear-btn-primary" lay-submit lay-filter="table-query">
|
|
<i class="layui-icon layui-icon-search"></i>查询
|
|
</button>
|
|
<button type="reset" class="pear-btn pear-btn-md" lay-submit lay-filter="table-reset">
|
|
<i class="layui-icon layui-icon-refresh"></i>重置
|
|
</button>
|
|
</div>
|
|
<div class="toggle-btn">
|
|
<a class="layui-hide">展开<i class="layui-icon layui-icon-down"></i></a>
|
|
<a class="layui-hide">收起<i class="layui-icon layui-icon-up"></i></a>
|
|
</div>
|
|
</form>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="layui-card">
|
|
<div class="layui-card-body">
|
|
<table id="data-table" lay-filter="data-table"></table>
|
|
</div>
|
|
</div>
|
|
|
|
<script type="text/html" id="table-toolbar">
|
|
<button class="pear-btn pear-btn-primary pear-btn-md" lay-event="add">
|
|
<i class="layui-icon layui-icon-add-1"></i>新增
|
|
</button>
|
|
<button class="pear-btn pear-btn-danger pear-btn-md" lay-event="batchRemove">
|
|
<i class="layui-icon layui-icon-delete"></i>删除
|
|
</button>
|
|
</script>
|
|
|
|
<script type="text/html" id="table-bar">
|
|
<button class="pear-btn pear-btn-xs tool-btn" lay-event="edit">编辑</button>
|
|
<button class="pear-btn pear-btn-xs tool-btn" lay-event="remove">删除</button>
|
|
</script>
|
|
|
|
<!-- 状态模板 -->
|
|
<script type="text/html" id="statusTpl">
|
|
{{# if(d.is_open === 1){ }}
|
|
<span style="color:green">{{ d.is_open_text }}</span>
|
|
{{# } else { }}
|
|
<span style="color:red">{{ d.is_open_text }}</span>
|
|
{{# } }}
|
|
</script>
|
|
|
|
<script src="/app/admin/component/layui/layui.js?v=2.8.12"></script>
|
|
<script src="/app/admin/component/pear/pear.js"></script>
|
|
<script src="/app/admin/admin/js/permission.js"></script>
|
|
<script src="/app/admin/admin/js/common.js"></script>
|
|
|
|
<script>
|
|
const PRIMARY_KEY = "id";
|
|
const SELECT_API = "/app/admin/warn-rule/select";
|
|
const DELETE_API = "/app/admin/warn-rule/delete";
|
|
const INSERT_URL = "/app/admin/warn-rule/insert";
|
|
const UPDATE_URL = "/app/admin/warn-rule/update";
|
|
const HOSPITAL_OPTIONS_API = "/app/admin/hospital/options";
|
|
|
|
layui.use(["table", "form", "common", "popup", "xmSelect"], function() {
|
|
let table = layui.table, form = layui.form, $ = layui.$, common = layui.common;
|
|
|
|
// 医院多选下拉
|
|
let hospitalSelect = null;
|
|
$.ajax({
|
|
url: HOSPITAL_OPTIONS_API, dataType: "json", type: "get",
|
|
success: function(res) {
|
|
hospitalSelect = layui.xmSelect.render({
|
|
el: "#hospitalSelect",
|
|
name: "hospital_id",
|
|
tips: "全部医院",
|
|
filterable: true,
|
|
searchTips: "搜索医院",
|
|
data: res.data || []
|
|
});
|
|
}
|
|
});
|
|
|
|
let cols = [
|
|
{ type: "checkbox", align: "center" },
|
|
{ title: "ID", field: "id", align: "center", width: 80, sort: true },
|
|
{ title: "所属医院", field: "hospital_name", align: "center", minWidth: 160 },
|
|
{ title: "设备名称", field: "device_name", align: "center", minWidth: 120 },
|
|
{ title: "预警类型", field: "type_text", align: "center", width: 90 },
|
|
{ title: "预警等级", field: "level_text", align: "center", width: 90 },
|
|
{ title: "上限值", field: "warn_upper_limit", align: "center", width: 100 },
|
|
{ title: "下限值", field: "warn_lower_limit", align: "center", width: 100 },
|
|
{ title: "联系人", field: "contact", align: "center", width: 100 },
|
|
{ title: "联系电话", field: "mobile", align: "center", width: 130 },
|
|
{ title: "通知方式", field: "notice_type_text", align: "center", width: 90 },
|
|
{ title: "状态", field: "is_open_text", align: "center", width: 80, templet: "#statusTpl" },
|
|
{ title: "创建时间", field: "created_at", align: "center", width: 170, sort: true },
|
|
{ title: "操作", toolbar: "#table-bar", align: "center", fixed: "right", width: 150 }
|
|
];
|
|
|
|
table.render({
|
|
elem: "#data-table", url: SELECT_API, page: true, cols: [cols],
|
|
skin: "line", size: "lg", toolbar: "#table-toolbar", autoSort: false,
|
|
defaultToolbar: [{ title: "刷新", layEvent: "refresh", icon: "layui-icon-refresh" }, "filter", "print", "exports"]
|
|
});
|
|
|
|
table.on("tool(data-table)", function(obj) {
|
|
if (obj.event === "remove") doRemove(obj.data[PRIMARY_KEY]);
|
|
else if (obj.event === "edit") edit(obj);
|
|
});
|
|
table.on("toolbar(data-table)", function(obj) {
|
|
if (obj.event === "add") add();
|
|
else if (obj.event === "refresh") refreshTable();
|
|
else if (obj.event === "batchRemove") batchRemove(obj);
|
|
});
|
|
|
|
form.on("submit(table-query)", function(data) {
|
|
let where = data.field;
|
|
if (hospitalSelect) {
|
|
let vals = hospitalSelect.getValue("value");
|
|
if (vals.length > 0) {
|
|
where["hospital_id[0]"] = "in";
|
|
where["hospital_id[1]"] = vals.join(",");
|
|
}
|
|
}
|
|
delete where.hospital_id;
|
|
table.reload("data-table", { page: { curr: 1 }, where: where });
|
|
return false;
|
|
});
|
|
|
|
form.on("submit(table-reset)", function() {
|
|
if (hospitalSelect) hospitalSelect.setValue([]);
|
|
table.reload("data-table", { where: [] });
|
|
});
|
|
|
|
table.on("sort(data-table)", function(obj) {
|
|
table.reload("data-table", { initSort: obj, scrollPos: "fixed", where: { field: obj.field, order: obj.type } });
|
|
});
|
|
|
|
let add = function() {
|
|
layer.open({ type: 2, title: "新增报警规则", shade: 0.1, maxmin: true,
|
|
area: [common.isModile()?"100%":"550px", common.isModile()?"100%":"550px"], content: INSERT_URL });
|
|
}
|
|
let edit = function(obj) {
|
|
layer.open({ type: 2, title: "编辑报警规则", shade: 0.1, maxmin: true,
|
|
area: [common.isModile()?"100%":"550px", common.isModile()?"100%":"550px"],
|
|
content: UPDATE_URL + "?" + PRIMARY_KEY + "=" + obj.data[PRIMARY_KEY] });
|
|
}
|
|
let batchRemove = function(obj) {
|
|
let ids = common.checkField(obj, PRIMARY_KEY);
|
|
if (!ids) { layui.popup.warning("未选中数据"); return; }
|
|
doRemove(ids.split(","));
|
|
}
|
|
let doRemove = function(ids) {
|
|
let data = {}; data[PRIMARY_KEY] = ids;
|
|
layer.confirm("确定删除?", { icon: 3, title: "提示" }, function(index) {
|
|
layer.close(index); let loading = layer.load();
|
|
$.ajax({ url: DELETE_API, data: data, dataType: "json", type: "post",
|
|
success: function(res) { layer.close(loading); if (res.code) return layui.popup.failure(res.msg); layui.popup.success("操作成功", refreshTable); }
|
|
});
|
|
});
|
|
}
|
|
window.refreshTable = function() {
|
|
table.reloadData("data-table", { scrollPos: "fixed", done: function(res, curr) {
|
|
if (curr > 1 && res.data && !res.data.length) table.reloadData("data-table", { page: { curr: curr - 1 } });
|
|
}});
|
|
}
|
|
});
|
|
</script>
|
|
</body>
|
|
</html>
|