layui .config({ base: "../../js/", }) .use(["ztree", "form", "layer", "table", "laytpl"], function () { var form = layui.form, layer = parent.layer === undefined ? layui.layer : top.layer, laytpl = layui.laytpl, table = layui.table; var userInfo = JSON.parse(window.sessionStorage.getItem("userInfo")); var OrgId = JSON.parse(window.sessionStorage.getItem("userInfo")).OrgID; var vehicleType = ""; // 选中部门ID var selDeptId = ""; var selTreeID = ""; form.on("select(searchClass)", function (data) { vehicleType = data.value; if (vehicleType == "0") { $("#vehicleAcc_btn").show(); } else { $("#vehicleAcc_btn").hide(); } table.reload("carListTableAboutEqupt", { page: { curr: 1, //重新从第 1 页开始 }, where: { Action: "CarList", keywords: $(".searchVal").val(), //搜索的关键字 class: vehicleType, //车辆类别 random: new Date().getTime(), //随机参数 }, }); }); var AREA_PID = ""; var $zTree, OrgList = []; var setting = { view: { selectedMulti: false, }, data: { key: { name: "NAME", }, simpleData: { enable: true, type: "TYPE", idKey: "ID", pIdKey: "PID", }, }, edit: { enable: false, }, callback: { onClick: function (e, treeId, treeNode) { // search(treeNode.ID, treeNode.TYPE); selTreeID = treeNode.ID; //判断选中标签是否部门 if (treeNode.TYPE == "dept") { //选中节点是部门 selDeptId = treeNode.ID; selTreeID = treeNode.PID; } else { //选中节点是机构 selDeptId = ""; } search(selTreeID, treeNode.TYPE); }, }, }; //初始化树 $(function () { //判断当前是否管理员 var IsAdmin = JSON.parse(window.sessionStorage.getItem("userInfo")).IsAdmin; if (IsAdmin === "1") { //管理员 } else { //非管理员 $("#divOrgDept").hide(); $("#divEmpBody").css("left", "0px"); } $.ajax({ type: "post", url: "../../ashx/SysEmpHandler.ashx", data: { Action: "OrgDeptTree", OrgId: OrgId }, dataType: "json", success: function (result) { var data = result.data; var zNodes = []; if (data.length > 0) { for (var i in data) { //if (data[i].TYPE == "org") { OrgList.push(data[i].ID); zNodes.push(data[i]); //} } } $zTree = $.fn.zTree.init($("#ztree"), setting, zNodes); //延迟展开根节点 var nodes = $zTree.getNodes(); for (var i = 0; i < nodes.length; i++) { $zTree.expandNode($zTree.getNodes()[i], true, false, false); } }, }); }); //每次加载节点触发的方法 function onAsyncSuccess(event, treeId, treeNode, msg) { //递归展开子节点 if (treeNode != undefined) { expandNodes(treeNode.children, "ztree"); } } //递归展开子节点 function expandNodes(nodes, treeId) { if (!nodes) return; var zTree = $.fn.zTree.getZTreeObj(treeId); for (var i = 0, l = nodes.length; i < l; i++) { zTree.expandNode(nodes[i], true, false, false); if (nodes[i].isParent && nodes[i].zAsync) { expandNodes(nodes[i].children, treeId); } } } //获取父级行政区ID var orgStr = ""; $.ajax({ type: "post", url: "../../ashx/FireOrgHandler.ashx", data: { Action: "AreaPID", ORG_ID: OrgId }, dataType: "json", success: function (result) { AREA_PID = result.data.CITY; }, }); setTimeout(function () { var is_content = ""; $("input:checkbox[name='is_content']:checked").each(function (i) { is_content = $(this).val(); }); //系统列表 var tableIns = table.render({ elem: "#carListTableAboutEqupt", url: "../../ashx/CarHandler.ashx", where: { Action: "CarList", class: "1", OrgId: OrgId, is_content: is_content, DeptID: userInfo.DeptID, selDeptId: selDeptId,//选中部门ID IsAdmin: userInfo.IsAdmin, random: new Date().getTime(), }, // OrgId: OrgId, //where: { Action: 'CarList', class: vehicleType, OrgId: OrgId, OrgList: OrgList.join(","), is_content: is_content, random: new Date().getTime() }, // OrgId: OrgId, cellMinWidth: 95, page: true, height: "full-125", limits: [10, 15, 20, 25], limit: 15, id: "carListTableAboutEqupt", cols: [ [ { type: "checkbox", fixed: "left", width: 50 }, { field: "CAR_NUM", title: "车辆号牌", minWidth: 60, align: "center", }, { field: "CAR_NAME", title: "车辆名称", minWidth: 60, align: "center", }, { field: "CLASS", title: "车辆类别", minWidth: 60, align: "center", templet: function (d) { if (d.CLASS == "0") { return '执勤车'; //return '公务车'; } else if (d.CLASS == "1") { return '执勤车'; } else if (d.CLASS == "2") { //return '地方车'; return '执勤车'; } else { //return '无类型'; return '执勤车'; } //return 'ID:' + d.id + ',标题:' + d.title + '' }, }, { field: "ORG_NAME", title: "所属消防单位", minWidth: 60, align: "center", }, { //field: 'ISRUN', title: '是否可用', minWidth: 60, align: "center", templet: function (d) { // if (d.ISRUN == "0") { //是否运行 0可用1在用2故障 // return ' 可用'; // } else if (d.ISRUN == "1") { // return ' 在用'; // } else if (d.ISRUN == "2") { // return ' 故障'; // } else { // return ' 未知'; // } //} field: "LIABLEMAN", title: "责任人", minWidth: 60, align: "center", }, { field: "TELNUM", title: "责任人电话", minWidth: 60, align: "center", }, //{ // field: 'ISSTART', title: '是否启动', minWidth: 60, align: "center", templet: function (d) { // if (d.ISSTART == "0") { // return ' 未启动'; // } else if (d.ISSTART == "1") { // return ' 已启动'; // } else { // return ' 未知'; // } // } //}, { field: "ISAPPLY", title: "申请状态", minWidth: 60, align: "center", templet: function (d) { if (d.ISAPPLY == "0") { return ' 在岗'; } else if (d.ISAPPLY == "1") { return ' 申请中'; } else if (d.ISAPPLY == "2") { return ' 离岗'; } else { return ' 未知'; } }, }, { title: "操作", width: 220, templet: "#sysappListBar", fixed: "right", align: "center", }, ], ], }); }, 500); //搜索【此功能需要后台配合,所以暂时没有动态效果演示】 $(".search_btn").on("click", function () { var is_content = ""; $("input:checkbox[name='is_content']:checked").each(function (i) { is_content = $(this).val(); }); table.reload("carListTableAboutEqupt", { page: { curr: 1, //重新从第 1 页开始 }, where: { Action: "CarList", keywords: $(".searchVal").val(), //搜索的关键字 class: $("#searchClass").val(), //车辆类别 is_content: is_content, selDeptId: selDeptId,//选中部门ID random: new Date().getTime(), //随机参数 }, }); }); //导出 $(".exp_btn").click(function () { var is_content = ""; $("input:checkbox[name='is_content']:checked").each(function (i) { is_content = $(this).val(); }); layer.confirm( "若需导出数据较多,或导致导出时间较长,请耐心等候,点击确认开始导出!", { icon: 3, title: "提示" }, function (index) { var data = { Action: "expList", class: $("#searchClass").val(), //车辆类别 OrgId: OrgId, is_content: is_content, keywords: $(".searchVal").val(), //搜索的关键字 random: new Date().getTime(), }; var url = "../../ashx/CarHandler.ashx"; var method = "POST"; $.downLoadFile(url, data, method, false); layer.close(index); } ); }); function search(treeid, type) { //console.log(treeid + "," + type); var is_content = ""; $("input:checkbox[name='is_content']:checked").each(function (i) { is_content = $(this).val(); }); table.reload("carListTableAboutEqupt", { page: { curr: 1, //重新从第 1 页开始 }, where: { Action: "CarList", keywords: $(".searchVal").val(), //搜索的关键字 treeID: treeid, //所属目录 type: type, //所属目录 class: $("#searchClass").val(), //车辆类别 is_content: is_content, selDeptId: selDeptId,//选中部门ID random: new Date().getTime(), //随机参数 }, }); } reload = function () { var is_content = ""; $("input:checkbox[name='is_content']:checked").each(function (i) { is_content = $(this).val(); }); table.reload("carListTableAboutEqupt", { page: { curr: 1, //重新从第 1 页开始 }, where: { Action: "CarList", keywords: $(".searchVal").val(), //搜索的关键字 class: $("#searchClass").val(), //车辆类别 is_content: is_content, random: new Date().getTime(), //随机参数 }, }); }; //添加编辑 function AddEdit(edit) { console.log(edit); var clientWidth = parseInt(document.body.clientWidth * 0.8) + "px"; var clientHeight = parseInt(document.body.clientHeight * 0.85) + "px"; var title = ""; title = "车载装备维护"; var index = layui.layer.open({ title: title, type: 2, area: [clientWidth, clientHeight], maxmin: true, content: 'CarEquipFileEdit.html?id=' + edit.ID //content: // "edit.html?AREA_PID=" + // AREA_PID + // "&ID=" + // edit.ID + // "&vehicleType=" + // "1" + // "&CarNUM=" + // edit.CAR_NUM, }); window.sessionStorage.setItem("index", index); //改变窗口大小时,重置弹窗的宽高,防止超出可视区域(如F12调出debug的操作) $(window).on("resize", function () { layui.layer.full(window.sessionStorage.getItem("index")); }); } //查看 function View(edit) { var clientWidth = parseInt(document.body.clientWidth * 0.8) + "px"; var clientHeight = parseInt(document.body.clientHeight * 0.9) + "px"; var title = ""; title = "车载装备详情"; if (edit.CarEquipFileUrl.length < 1) { layer.open({ title: '信息提示' , content: '没有上传数据!' }); return; } var fireUrl = "http://xzcamp.xfzn365.com" + edit.CarEquipFileUrl; fireUrl = encodeURIComponent(btoa(fireUrl)); var index = layui.layer.open({ title: title, type: 2, area: [clientWidth, clientHeight], maxmin: true, //content: "https://view.officeapps.live.com/op/view.aspx?src=http://xzcamp.xfzn365.com" + edit.CarEquipFileUrl content: "http://221.13.83.52:28012/onlinePreview?url=" + fireUrl //content: // "view.html?AREA_PID=" + // AREA_PID + // "&ID=" + // edit.ID + // "&vehicleType=" + // "1", }); window.sessionStorage.setItem("index", index); //改变窗口大小时,重置弹窗的宽高,防止超出可视区域(如F12调出debug的操作) $(window).on("resize", function () { layui.layer.full(window.sessionStorage.getItem("index")); }); } // 记录查看 function Recard(edit) { var clientWidth = parseInt(document.body.clientWidth * 0.5) + "px"; var clientHeight = parseInt(document.body.clientHeight * 0.7) + "px"; var title = ""; title = "交接记录"; var index = layui.layer.open({ title: title, type: 2, area: [clientWidth, clientHeight], maxmin: true, //content: "view.html?AREA_PID=" + AREA_PID + "&ID=" + edit.ID + "&vehicleType=" + vehicleType content: "record.html?AREA_PID=" + AREA_PID + "&ID=" + edit.ID + "&vehicleType=" + "1", }); window.sessionStorage.setItem("index", index); //改变窗口大小时,重置弹窗的宽高,防止超出可视区域(如F12调出debug的操作) $(window).on("resize", function () { layui.layer.full(window.sessionStorage.getItem("index")); }); } $(".add_btn").click(function () { AddEdit(); }); //批量删除 $(".delAll_btn").click(function () { var checkStatus = table.checkStatus("carListTableAboutEqupt"), data = checkStatus.data, carList = []; if (data.length > 0) { for (var i in data) { carList.push(data[i].ID); } layer.confirm( "确定删除选中的车辆?", { icon: 3, title: "提示信息" }, function (index) { //提交信息 $.post( "../../ashx/CarHandler.ashx", { Action: "Del", carList: carList.join(","), random: new Date().getTime(), //随机参数 }, function (res) { res = $.parseJSON(res); if (res.code == 1) { top.layer.msg(res.msg); reload(); } else { top.layer.msg(res.msg); } } ); } ); } else { layer.msg("请选择需要删除的车辆"); } }); //列表操作 table.on("tool(carListTableAboutEqupt)", function (obj) { var layEvent = obj.event; data = obj.data; //console.log(obj) //console.log(data) if (layEvent == "equipEdit") { //修改 AddEdit(data); } else if (layEvent == "audit") { //查看 View(data); } else if (layEvent == "recard") { //记录 Recard(data); } else if (layEvent == "playVideo") { //车载视频 playVideo(data); } }); function playVideo(data) { if (!data.IMEI) { layer.msg("暂未获取到视频信息,请稍后再试"); } else { var l = (screen.availWidth - 500) / 2; var t = (screen.availHeight - 300) / 2; if (data.FACTORY == "1") { window.open( "../../Fire/Map/LTTMapVideoRealPlay.html?carNum=" + data.IMEI, "实时视频", "height=300, width=550, top=" + t + ", left=" + l + ", toolbar=no, menubar=no, scrollbars=no, resizable=no, location=no, status=no" ); } else { window.open( "../../Fire/Map/MapVideoRealPlay.html?imei=" + data.IMEI, "实时视频", "height=300, width=550, top=" + t + ", left=" + l + ", toolbar=no, menubar=no, scrollbars=no, resizable=no, location=no, status=no" ); } } } //申请表单 $(".apply_btn").click(function () { var clientWidth = parseInt(document.body.clientWidth * 0.7) + "px"; var clientHeight = parseInt(document.body.clientHeight * 0.9) + "px"; var title = "申请表单"; var index = layui.layer.open({ title: title, type: 2, area: [clientWidth, clientHeight], maxmin: true, content: "apply.html", success: function (layero, index) { }, }); window.sessionStorage.setItem("index", index); //改变窗口大小时,重置弹窗的宽高,防止超出可视区域(如F12调出debug的操作) $(window).on("resize", function () { layui.layer.full(window.sessionStorage.getItem("index")); }); }); form.on("checkbox(bellow)", function (data) { if (data.elem.checked == true) { reload(); } else { reload(); } }); });