You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

307 lines
10 KiB

{% extends 'baseBZP.html' %}
{% block content %}
{% load static %}
<link href="{% static 'css/plugins/iCheck/custom.css' %}" rel="stylesheet" />
<style type="text/css">
.dataTables_filter {
display: none;
}
.i-checks {
float: left !important;
margin: 0px !important;
padding: 0px !important;
}
</style>
<div class="layui-fluid">
<div class="layui-card">
<div class="layui-form layui-card-header layuiadmin-card-header-auto">
<div class="layui-form-item">
<div class="layui-inline">
<label class="layui-form-label">起始时间</label>
<div class="layui-input-block">
<input type="text" class="layui-input" id="startDate" ReserveSearch='' value="{{ last_year }}" name="searchValue" placeholder="起始时间">
</div>
</div>
<div class="layui-inline">
<label class="layui-form-label">结束时间</label>
<div class="layui-input-block">
<input type="text" class="layui-input" id="endDate" ReserveSearch='' value="{{ today }}" name="searchValue" placeholder="结束时间">
</div>
</div>
<div class="layui-inline">
<label class="layui-form-label">预警对象</label>
<div class="layui-input-block">
<input type="text" class="layui-input" id="searchValue" ReserveSearch='' value="{{ searchValue }}" name="searchValue" placeholder="搜索预警对象">
</div>
</div>
<div class="layui-inline" style="height: 42px;">
<button type="button" class="layui-btn layuiadmin-btn-useradmin" data-type="btnTableSearch">
<i class="layui-icon layui-icon-search layuiadmin-button-btn"></i>
</button>
</div>
</div>
</div>
<div class="layui-card-body">
<div style="padding-bottom: 10px;">
<button type="button" class="layui-btn layuiadmin-btn-useradmin" data-type="btnTableReload" style="margin-right:3px;" data-toggle="tooltip" data-placement="left" title="刷新药剂列表"><i class="fa fa-refresh" aria-hidden="true"></i>刷新</button>
<button type="button" class="layui-btn layuiadmin-btn-useradmin" data-type="btnTableEdit" style="margin-right:3px;" data-toggle="tooltip" data-placement="left" title="解决选中预警"><i class="fa fa-info" aria-hidden="true"></i>预警详情</button>
</div>
<table id="demo" lay-filter="test" lay-data="{id: 'idTest'}"></table>
</div>
</div>
</div>
{% load static %}
<script src="{% static 'js/plugins/iCheck/icheck.min.js' %}"></script>
<script src="{% static 'js/plugins/datapicker/bootstrap-datepicker.js' %}"></script>
<script src="{% static 'js/fileDownload.js' %}"></script>
<script src="{% static 'js/utils.js' %}"></script>
<script src="{% static 'js/warning.js' %}"></script>
<script type="text/javascript">
var today = "{{today}}"
var last_year = "{{last_year}}"
//年月选择器
var laydate = layui.laydate;
//年月选择器
laydate.render({
elem: '#startDate',
type: 'datetime',
format: "yyyy-MM-dd HH:mm:ss"
});
laydate.render({
elem: '#endDate',
type: 'datetime',
format: "yyyy-MM-dd HH:mm:ss",
});
var table = layui.table;
let dataTable = []
//执行渲染
table.render({
elem: '#demo', //指定原始表格元素选择器推荐id选择器
// height: 312, //容器高度
cols: [
[{type: 'checkbox', fixed: 'left'},
{ field: 'ObjectType', title: '预警类型', width: 240, sort: true, templet:function (d) {
switch (d.ObjectType) {
case '1':
return '药剂保质期预警';
case '2':
return '药剂过期报警';
case '3':
return '药剂余量预警';
case '4':
return '药柜温湿度预警';
case '5':
return '药柜滤芯保质期预警';
case '6':
return '药剂出库超期预警';
case '7':
return '药剂违规领用预警';
}
}},
{ field: 'ObjectName', title: '预警对象', width: 280, sort: true },
{ field: 'WarningContent', title: '预警内容', width: 900, sort: true },
{ field: 'WarningDate', title: '预警时间', width: 220, sort: true, templet: function(d){
return String(d.WarningDate).replace("T", " ")
}},
]
], //设置表头
url:"{% url 'warning:getWarningListJson' %}",
id: "test",
page: {
layout: [ 'count', 'prev', 'page', 'next',], //自定义分页布局
prev:'上一页',
next:'下一页'
},
where: {last_year:last_year, today:today},
limit: 15,
limits: [10, 15, 20, 25, 30],
height: 'full-160',
size:'lg',
done: function (res, curr, count) {
},
});
var active = {
btnTableSearch: function () {
table.reload('test', {
where: { //设定异步数据接口的额外参数,任意设
searchValue: $("#searchValue").val(),
startDate: $('#startDate').val(),
endDate: $('#endDate').val()
//…
},page: {
curr: 1 //重新从第 1 页开始
}
}) //只重载数据
},
btnTableReload: function(){
location.reload();
},
btnTableEdit: function(){
var checkStatus = table.checkStatus('test'), selectRow = checkStatus.data; //得到选中的数据
if (selectRow.length === 0) {
return layer.msg('请选择要解决/查看的预警!');
}
selectRow = selectRow[0]
quiteTime = Infinity;
parent.layer.open({
title: "预警详情",
shift: 2,
type: 2,
area: ['860px', '550px'],
skin: 'layui-layer-rim', //加上边框
content: ["/warning/form/?warning_id=" + selectRow.WarningId, 'no'],
end: function () {
currentTime = 0;
quiteTime = 600;
tableModel.ajax.reload();
}
});
}
};
$('.layui-btn.layuiadmin-btn-useradmin').on('click', function () {
var type = $(this).data('type');
active[type] ? active[type].call(this) : '';
});
$(function () {
$('#navTitle', window.parent.document).text('预警管理');
$('.i-checks').iCheck({
checkboxClass: 'icheckbox_square-green',
radioClass: 'iradio_square-green',
});
var searchValue = $("#searchValue").val();
$("#searchValue").text(searchValue);
var tableModel = $('#dataTableModel').DataTable({
//searching: false,
lengthChange: false,
select: true,
ordering: false,
bPaginate:true,
ajax: {
url: "{% url 'warning:getWarningListJson' %}",
data: { searchValue: searchValue },
dataSrc: 'data'
},
columns: [
{ data: 'CustomerId' },
{ data: 'ObjectId' },
{ data: 'WarningId' },
{ data: 'ObjectType' },
{ data: 'ObjectName' },
{ data: 'WarningContent' },
{ data: 'WarningDate' },
// { data: 'IsSolve' }
],
createdRow: function (row, data, dataIndex) {
$(row).children('td').eq(0).html(replace_objectType(data.ObjectType));
$(row).children('td').eq(3).html(replace_WarningDate(data.WarningDate));
// $(row).children('td').eq(4).html(data.IsSolve == 1 ? "<span class='label label-warning'>已解决</span>" : "<span class='label label-default'>未解决</span>");
// $(row).children('td').eq(4).attr('style', 'text-align: center;');
},
columnDefs: [
{
"targets": [0, 1, 2],
"visible": false
}
]
});
tag = '{{ tag }}';
if(tag==1){
$('.iCheck-helper').trigger('click');
var value = $(".OperaType").find(".checked input:radio[name=OperaType]").val();
tableModel.column(7).search(value).draw();
}
$(".OperaType,.iCheck-helper").click(function () {
var value = $(".OperaType").find(".checked input:radio[name=OperaType]").val();
tableModel.column(7).search(value).draw();
});
$('#startDate, #endDate').change(function () {
tableModel.draw();
});
$("#btnTableExport").click(function () {
var index = '';
var url = '{% url 'dataReport:exportWarningData' %}';
$.fileDownload(url, {
prepareCallback: function (url) {
index = parent.layer.load(2,{time: 3*1000});
},
successCallback: function (url) {
parent.layer.close(index)
},
failCallback: function (url) {
msg('数据异常, 下载失败');
parent.layer.close(index)
}
})
});
$("#tablePre").click(function () {
$("#dataTableModel_previous").click();
});
$("#tableNext").click(function () {
$("#dataTableModel_next").click();
});
// 替换预警类型
function replace_objectType(params) {
switch (params) {
case '1':
return '药剂保质期预警';
case '2':
return '药剂过期报警';
case '3':
return '药剂余量预警';
case '4':
return '药柜温湿度预警';
case '5':
return '药柜滤芯保质期预警';
case '6':
return '药剂出库超期预警';
case '7':
return '药剂违规领用预警';
}
}
function replace_WarningDate(params) {
if(params){
return params.replace('T', ' ')
}
}
});
</script>
<iframe width=0 height=0 frameborder=0 id="export" />
{% endblock %}