软测单独项目
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.
 
 
 
 
 
 

308 lines
13 KiB

<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<title></title>
<meta charset="utf-8" />
<link rel="stylesheet" href="layui/css/layui.css" media="all" />
<link rel="stylesheet" href="../../css/ztree/metro/ztree.css">
<style>
dl dd {
text-align: left;
}
.layui-form{
width: 100%
}
.select_1{
width: 80px;
margin: 0 5px;
}
.select_2{
width: 160px;
margin: 0 5px;
}
#dataTime_1 {
width: 260px;
margin: 0 5px;
}
a {
color: #0af949;
text-decoration: underline;
}
</style>
</head>
<body>
<div style="margin:0 auto;text-align: center;">
<form class="layui-form" style="float: right;width: 100%">
<div class="layui-input-inline select_2">
<select id="select_2" lay-filter="select_2" lay-search=""></select>
</div>
<div class="layui-input-inline">
<input type="text" class="layui-input" id="dataTime_1" placeholder="请选择查询的时间段">
</div>
<div class="layui-input-inline">
<span id="span_1" style="float: left;line-height: 40px;font-size: 22px;font-weight: bold;">车辆出入报表</span>
</div>
<div class="layui-input-inline">
<input type="checkbox" id="is_content" name='is_content' lay-filter="is_content" value="1" title="包含下级所属单位">
</div>
<div style="float: right;margin-right: 20px;">
<button id="exportWord" type="button" class="layui-btn">导出</button>
</div>
</form>
</div>
<div style="width: 90%;height: 500px;float: left;margin-left: 5%;">
<table id="carAccList" lay-filter="carAccList"></table>
</div>
<script type="text/javascript" src="layui/layui.js"></script>
<script src="../../js/echarts.min.js"></script>
<script>
var userInfo = JSON.parse(window.sessionStorage.getItem("userInfo"));
var OrgId = "";
var OrgName = "";
if (userInfo != null) {
OrgId = userInfo.OrgID;
OrgName = userInfo.OrgName;
}
//获取当前日期
var myDate = new Date();
var nowY = myDate.getFullYear();
var nowM = myDate.getMonth() + 1;
var lastY = nowY;
var lastM = nowM + 1;
if (nowM == "12") {
lastY = nowY + 1;
lastM = "1";
}
layui.use(['form', 'layer', 'table', 'laydate'], function () {
$ = layui.jquery,
form = layui.form,
layer = layui.layer,
table = layui.table,
laydate = layui.laydate;
//日期选择初始化
laydate.render({
elem: '#dataTime_1',
type: 'month',
//value: nowY + '-' + (nowM < 10 ? '0' + nowM : nowM) + ' - ' + lastY + '-' + (lastM < 10 ? "0" + lastM : lastM),
value: nowY + '-01 - ' + lastY + '-' + (lastM < 10 ? "0" + lastM : lastM),
isInitValue: true,
range: true,
done: function (value) {
if (value.indexOf(" - ") != -1 && $("#select_2").val() != null) {
var startDate = value.split(" - ")[0]
var endDate = value.split(" - ")[1];
work_obj.getStatisticsTra2($("#select_2").val(), startDate, endDate);
}
}
});
//监听车辆下拉框
form.on('select(select_2)', function (data) {
var value = $("#dataTime_1").val();
if (value.indexOf(" - ") != -1 && $("#select_2").val() != null) {
var startDate = value.split(" - ")[0]
var endDate = value.split(" - ")[1];
work_obj.getStatisticsTra2($("#select_2").val(), startDate, endDate);
}
})
//监听包含下级复选框
form.on('checkbox(is_content)', function (data) {
work_obj.getCarList();
var value = $("#dataTime_1").val();
if (value.indexOf(" - ") != -1 && $("#select_2").val() != null) {
var startDate = value.split(" - ")[0]
var endDate = value.split(" - ")[1];
work_obj.getStatisticsTra2($("#select_2").val(), startDate, endDate);
}
});
$("#exportWord").click(function () {
//load提交
var index = layer.msg('正在导出...请稍候', { icon: 16, time: false, shade: 0.2 });
var startDate = nowY + "-01";
var endDate = lastY + "-" + (lastM < 10 ? "0" + lastM : lastM);
var value = $("#dataTime_1").val();
var carNum = $("#select_2").val();
if (value.indexOf(" - ") != -1 && carNum != null) {
startDate = value.split(" - ")[0]
endDate = value.split(" - ")[1];
}
var is_content = "";
$("input:checkbox[name='is_content']:checked").each(function (i) {
is_content = $(this).val();
});
$.ajax({
type: "post",
url: "../../ashx/CarHandler.ashx",
data: {
Action: "htmlToWord2",
by1: encodeURIComponent(getFullCanvasDataURL("echarts_1")),
carNum: carNum,
orgId: OrgId,
startDate: startDate,
endDate: endDate,
is_content: is_content
},
dataType: "json",
success: function (data) {
layer.close(index);
if (data != null && data != "") {
if (data.code == "0") {
window.location.href = "../../" + data.url;
} else {
layer.msg(data.msg);
}
} else {
layer.msg("导出失败请联系管理员");
}
}, error: function (e) {
console.log(e)
layer.close(index);
layer.msg(e.msg);
}
});
})
work_obj.getCarList();
//初始化表格数据
table.render({
elem: '#carAccList',
url: '../../ashx/CarHandler.ashx',
where: {
Action: 'getCarAccListByTime2',
carNum: "",
orgId: OrgId,
startDate: nowY + "-01",
endDate: lastY + "-" + (lastM < 10 ? "0" + lastM : lastM),
is_content: ""
},
cellMinWidth: 95,
id: "carAccListTable",
cols: [[
{ field: 'ORG_NAME', title: '所属消防机构', minWidth: 60, align: "center" },
{ field: 'CAR_PLATE', title: '车牌号', minWidth: 60, align: "center" },
{ field: 'CLASS_NAME', title: '车辆类别', minWidth: 60, align: "center" },
{
field: 'COUNTNUM', title: '出入次数', minWidth: 60, align: "center", templet: function (d) {
return "<div title=\"点击查看【" + d.CAR_PLATE + "】出入记录\" style=\"width:100%;height:100%;cursor:pointer;\" onclick=\"goCarAccItem('" + d.CAR_PLATE + "')\"><a href=\"#\">" + d.COUNTNUM + "</a>";
}
}
]]
});
});
var work_obj = {
getCarList: function () {
$(function () {
//获取机构下所有车辆
var is_content = "";
$("input:checkbox[name='is_content']:checked").each(function (i) {
is_content = $(this).val();
});
$.ajax({
type: "post",
url: "../../ashx/CarHandler.ashx",
data: {
Action: "CarList",
OrgId: OrgId,
page: 1,
limit: 99999,
is_content: is_content
},
dataType: "json",
success: function (result) {
$("#select_2").empty();
var orgStr = "<option value=''>---所有车辆---</option>";
result.data.forEach(function (obj, index, arr) {
if (obj.CLASS == "0" || obj.CLASS == "1") {
orgStr += "<option value='" + obj.CAR_NUM + "'>" + obj.CAR_NUM + "</option>";
}
});
$("#select_2").append(orgStr);
form.render('select');
}
});
})
},
getStatisticsTra2: function (carNum, startDate, endDate) {
var is_content = "";
$("input:checkbox[name='is_content']:checked").each(function (i) {
is_content = $(this).val();
});
table.reload("carAccListTable", {
where: {
Action: 'getCarAccListByTime2',
carNum: carNum,
orgId: OrgId,
startDate: startDate,
endDate: endDate,
is_content: is_content
},
});
}
};
//将图形转成base64的图片
function getFullCanvasDataURL(divId) {
//将第一个画布作为基准。
var baseCanvas = $("#" + divId).find("canvas").first()[0];
if (!baseCanvas) {
return false;
};
var width = baseCanvas.width;
var height = baseCanvas.height;
var ctx = baseCanvas.getContext("2d");
//遍历,将后续的画布添加到在第一个上
$("#" + divId).find("canvas").each(function (i, canvasObj) {
if (i > 0) {
var canvasTmp = $(canvasObj)[0];
ctx.drawImage(canvasTmp, 0, 0, width, height);
}
});
//获取base64位的url
return baseCanvas.toDataURL();
}
function goCarAccItem(carNum) {
var clientWidth = parseInt(document.body.clientWidth * 0.7) + 'px';
var index = layer.open({
title: "【" + carNum + "】出入记录",
type: 2,
area: [clientWidth, '600px'],
maxmin: true,
content: "carAccessSta2Item.html",
success: function (layero, index) {
var body = layui.layer.getChildFrame('body', index);
body.find(".orgId").val(OrgId);
body.find(".carNum").val(carNum);
var startDate = nowY + "-01";
var endDate = lastY + "-" + (lastM < 10 ? "0" + lastM : lastM);
var value = $("#dataTime_1").val();
if (value.indexOf(" - ") != -1 && $("#select_2").val() != null) {
startDate = value.split(" - ")[0]
endDate = value.split(" - ")[1];
}
body.find(".startDate").val(startDate);
body.find(".endDate").val(endDate);
var is_content = "";
$("input:checkbox[name='is_content']:checked").each(function (i) {
is_content = $(this).val();
});
body.find(".isContent").val(is_content);
}
})
window.sessionStorage.setItem("index", index);
}
</script>
<link rel="stylesheet" href="../../css/right-list.css" media="all" />
<link rel="stylesheet" href="../../css/bulletframebg.css" media="all" />
</body>
</html>