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.
385 lines
16 KiB
385 lines
16 KiB
layui.config({
|
|
base: '../../js/'
|
|
}).use(['ztree', 'form', 'layer', 'table', 'laytpl'], function () {
|
|
var form = layui.form,
|
|
layer = parent.layer === undefined ? layui.layer : top.layer,
|
|
$ = layui.jquery,
|
|
laytpl = layui.laytpl,
|
|
table = layui.table;
|
|
|
|
var OrgId = JSON.parse(window.sessionStorage.getItem("userInfo")).OrgID;
|
|
var AREA_PID = "";
|
|
var $zTree, OrgList = [];
|
|
var setting = {
|
|
view: {
|
|
selectedMulti: false
|
|
},
|
|
check: {
|
|
enable: true
|
|
},
|
|
data: {
|
|
key: {
|
|
name: "NAME"
|
|
},
|
|
simpleData: {
|
|
enable: true,
|
|
type: "TYPE",
|
|
idKey: "ID",
|
|
pIdKey: "PID"
|
|
}
|
|
},
|
|
edit: {
|
|
enable: false
|
|
},
|
|
callback: {
|
|
onClick: function (e, treeId, treeNode) {
|
|
console.log(treeNode.ID + " == " + treeNode.TYPE);
|
|
search(treeNode.ID, treeNode.TYPE);
|
|
}
|
|
}
|
|
};
|
|
//初始化树
|
|
$(function () {
|
|
$.ajax({
|
|
type: "post",
|
|
url: "../../ashx/SysEmpHandler.ashx",
|
|
data: { Action: "OrgDeptTree", OrgId: OrgId },
|
|
dataType: "json",
|
|
success: function (result) {
|
|
var zNodes = result.data;
|
|
if (zNodes.length > 0) {
|
|
for (var i in zNodes) {
|
|
OrgList.push(zNodes[i].ID);
|
|
}
|
|
}
|
|
$zTree = $.fn.zTree.init($("#ztree"), setting, zNodes);
|
|
}
|
|
});
|
|
});
|
|
|
|
//延迟展开根节点
|
|
setTimeout(function () {
|
|
var nodes = $zTree.getNodes();
|
|
for (var i = 0; i < nodes.length; i++) {
|
|
$zTree.expandNode($zTree.getNodes()[i], true, false, false);
|
|
}
|
|
}, 500);
|
|
|
|
|
|
//每次加载节点触发的方法
|
|
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 tableIns = table.render({
|
|
elem: '#carList',
|
|
url: '../../ashx/CarHandler.ashx',
|
|
where: { Action: 'CarList', class: 1, OrgId: OrgId, OrgList: OrgList.join(","), random: new Date().getTime() }, //
|
|
cellMinWidth: 95,
|
|
page: true,
|
|
height: "full-125",
|
|
limits: [10, 15, 20, 25],
|
|
limit: 10,
|
|
id: "carListTable",
|
|
cols: [[
|
|
{ type: "checkbox", fixed: "left", width: 50 },
|
|
{
|
|
field: 'CLASS', title: '类型', minWidth: 60, align: "center", templet: function (d) {
|
|
if (d.CLASS == "0") {
|
|
return '<span class="layui-badge layui-bg-blue">公务车</span>';
|
|
}
|
|
else if (d.CLASS == "1") {
|
|
return '<span class="layui-badge layui-bg-blue">执勤车</span>';
|
|
}
|
|
else if (d.CLASS == "2") {
|
|
return '<span class="layui-badge layui-bg-blue">地方车</span>';
|
|
}
|
|
else {
|
|
return '<span class="layui-badge layui-bg-blue">无类型</span>';
|
|
}
|
|
//return 'ID:' + d.id + ',标题:<span style="color: #c00;">' + d.title + '</span>'
|
|
}
|
|
},
|
|
{ field: 'CAR_NAME', title: '车辆名称', minWidth: 120, align: "center" },
|
|
{ field: 'CAR_NUM', title: '车辆号牌', minWidth: 120, align: "center" },
|
|
{ field: 'LIABLEMAN', title: '责任人名称', minWidth: 120, align: "center" },
|
|
// { field: 'CLASS', title: '车辆类别', minWidth: 60, align: "center", templet: function (d) {
|
|
// if (d.CLASS == "0") { //车辆大类型 0公务用车1执勤
|
|
// return '公务用车';
|
|
// } else if (d.CLASS == "1") {
|
|
// return '执勤车辆';
|
|
// }
|
|
// else if (d.CLASS == "2") {
|
|
// return '社会车辆';
|
|
// }
|
|
// }
|
|
// },
|
|
{field: 'TRADEMARK', title: '车辆标志', minWidth: 120, align: "center" },
|
|
{ field: 'ISRUN', title: '是否可用', minWidth: 120, align: "center", templet: function (d) {
|
|
if (d.ISRUN == "0") { //是否运行 0可用1在用2故障
|
|
return ' <span class="layui-badge layui-bg-blue">可用</span>';
|
|
} else if (d.ISRUN == "1") {
|
|
return ' <span class="layui-badge layui-bg-danger">在用</span>';
|
|
} else if (d.ISRUN == "2") {
|
|
return ' <span class="layui-badge layui-bg-gray">故障</span>';
|
|
}
|
|
}
|
|
},
|
|
{ field: 'ISSTART', title: '是否启动', minWidth: 60, align: "center", templet: function (d) {
|
|
if (d.ISSTART == "0") {
|
|
return ' <span class="layui-badge layui-bg-blue">未启动</span>';
|
|
} else if (d.ISSTART == "1") {
|
|
return ' <span class="layui-badge layui-bg-danger">已启动</span>';
|
|
}
|
|
}
|
|
},
|
|
{ field: 'WATERNUM', title: '载水量(t)', minWidth: 120, align: "center" },
|
|
{ field: 'DRYPOWDER', title: '载干粉量(kg)', minWidth: 120, align: "center" },
|
|
{ field: 'HEIGHTBOARDINGCAR', title: '登高车工作高度(m)', minWidth: 120, align: "center" },
|
|
{ field: 'FROTHAMOUNT', title: '泡沫量', minWidth: 120, align: "center" },
|
|
{ field: 'FROTHAMOUNTA', title: 'a类泡沫量', minWidth: 120, align: "center" },
|
|
{ field: 'FROTHAMOUNTB', title: 'b类泡沫量', minWidth: 120, align: "center" },
|
|
{ field: 'FROTHAMOUNTMULTI', title: '多功能泡沫量', minWidth: 120, align: "center" },
|
|
{ field: 'LIQUIDLEVEL', title: '液位', minWidth: 120, align: "center" },
|
|
{ field: 'PRESSURE', title: '压力', minWidth: 120, align: "center" },
|
|
|
|
|
|
{ title: '操作', width: 120, templet: '#sysappListBar', fixed: "right", align: "center" }
|
|
]]
|
|
});
|
|
}, 500);
|
|
|
|
//搜索【此功能需要后台配合,所以暂时没有动态效果演示】
|
|
$(".search_btn").on("click", function () {
|
|
table.reload("carListTable", {
|
|
page: {
|
|
curr: 1 //重新从第 1 页开始
|
|
},
|
|
where: {
|
|
Action: 'CarList',
|
|
keywords: $(".searchVal").val(), //搜索的关键字
|
|
class: 1,
|
|
OrgId: OrgId,
|
|
random: new Date().getTime() //随机参数
|
|
}
|
|
});
|
|
});
|
|
function search(treeid, type) {
|
|
console.log(treeid + "," + type);
|
|
table.reload("carListTable", {
|
|
page: {
|
|
curr: 1 //重新从第 1 页开始
|
|
},
|
|
where: {
|
|
Action: 'CarList',
|
|
keywords: $(".searchVal").val(), //搜索的关键字
|
|
treeID: treeid, //所属目录
|
|
type: type, //所属目录
|
|
class: 1,
|
|
OrgId: OrgId,
|
|
random: new Date().getTime() //随机参数
|
|
}
|
|
});
|
|
}
|
|
function reload() {
|
|
table.reload("carListTable", {
|
|
page: {
|
|
curr: 1 //重新从第 1 页开始
|
|
},
|
|
where: {
|
|
Action: 'CarList',
|
|
keywords: $(".searchVal").val(), //搜索的关键字
|
|
class: 1,
|
|
OrgId: OrgId,
|
|
random: new Date().getTime() //随机参数
|
|
}
|
|
});
|
|
}
|
|
//添加编辑
|
|
function AddEdit(edit) {
|
|
var clientWidth = parseInt(document.body.clientWidth * 0.7) + 'px';
|
|
var clientHeight = parseInt(document.body.clientHeight * 0.9) + 'px';
|
|
var title = "";
|
|
if (edit) { title = "编辑车辆"; } else { title = "添加车辆"; }
|
|
var index = layui.layer.open({
|
|
title: title,
|
|
type: 2,
|
|
area: [clientWidth, clientHeight],
|
|
maxmin: true,
|
|
content: "edit.html?AREA_PID=" + AREA_PID,
|
|
success: function (layero, index) {
|
|
var body = layui.layer.getChildFrame('body', index);
|
|
if (edit) {
|
|
body.find(".ID").val(edit.ID);
|
|
body.find(".Action").val("Edit");
|
|
|
|
body.find("#car_name").val(edit.CAR_NAME), //车辆名称
|
|
body.find("#car_no").val(edit.CAR_NO), //车辆编号
|
|
body.find("#org_id").val(edit.ORG_ID); //队
|
|
body.find("#dept_id").val(edit.DEPT_ID); //消防站
|
|
body.find("#car_num").val(edit.CAR_NUM), //车辆号牌
|
|
body.find("#car_code").val(edit.CAR_CODE), //车辆登记代号
|
|
body.find("#frame_num").val(edit.FRAME_NUM), //车架号
|
|
body.find("#engine_no").val(edit.ENGINE_NO), //发动机号
|
|
body.find("#trademark").val(edit.TRADEMARK), //商标
|
|
body.find("#gbcode").val(edit.GB_CODE), //国标代码
|
|
body.find("#factory").val(edit.FACTORY), //出厂厂家
|
|
body.find("#liableman").val(edit.LIABLEMAN), //责任人名称
|
|
body.find("#region").val(edit.REGION), //所属辖区
|
|
body.find("#isrun").val(edit.ISRUN), //是否运行
|
|
body.find("#class").val(edit.CLASS), //大类型
|
|
body.find("#type").val(edit.TYPE), //小类型
|
|
body.find("#waternum").val(edit.WATERNUM), //载水量
|
|
body.find("#drypowder").val(edit.DRYPOWDER), //载干粉量
|
|
body.find("#heightboardingcar").val(edit.HEIGHTBOARDINGCAR), //登高车工作高度
|
|
body.find("#frothamount").val(edit.FROTHAMOUNT), //泡沫量
|
|
body.find("#frothamounta").val(edit.FROTHAMOUNTA), //A类泡沫量
|
|
body.find("#frothamountb").val(edit.FROTHAMOUNTB), //B类泡沫量
|
|
body.find("#frothamountmulti").val(edit.FROTHAMOUNTMULTI), //多功能泡沫量
|
|
body.find("#liquidlevel").val(edit.LIQUIDLEVEL), //液位
|
|
body.find("#pressure").val(edit.PRESSURE), //压力
|
|
body.find("#isstart").val(edit.ISSTART); //是否运行
|
|
body.find("#PHOTO").attr('src', "../../" + edit.PHOTO);
|
|
body.find("#PHOTO_PATH").val(edit.PHOTO);
|
|
setTimeout(function () {
|
|
|
|
body.find("#org_id").siblings("div.layui-form-select").find('dl').find("dd[lay-value='" + edit.ORG_ID + "']").click();
|
|
body.find("#dept_id").siblings("div.layui-form-select").find('dl').find("dd[lay-value='" + edit.DEPT_ID + "']").click();
|
|
body.find("#isstart").siblings("div.layui-form-select").find('dl').find("dd[lay-value='" + edit.ISSTART + "']").click();
|
|
body.find("#region").siblings("div.layui-form-select").find('dl').find("dd[lay-value='" + edit.REGION + "']").click();
|
|
}, 500)
|
|
form.render();
|
|
} else {
|
|
body.find(".Action").val("Add");
|
|
form.render();
|
|
}
|
|
}
|
|
})
|
|
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.7) + 'px';
|
|
var clientHeight = parseInt(document.body.clientHeight * 0.9) + '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
|
|
|
|
})
|
|
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('carListTable'),
|
|
data = checkStatus.data,
|
|
carList = [];
|
|
if (data.length > 0) {
|
|
for (var i in data) {
|
|
carList.push(data[i].ID);
|
|
}
|
|
console.log(carList.join(","));
|
|
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(carList)', function (obj) {
|
|
var layEvent = obj.event;
|
|
data = obj.data;
|
|
console.log(data);
|
|
if (layEvent == 'edit') {//修改
|
|
AddEdit(data);
|
|
}
|
|
else if (layEvent == 'audit') {//查看
|
|
View(data);
|
|
}
|
|
})
|
|
|
|
//申请表单
|
|
$(".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"));
|
|
})
|
|
})
|
|
})
|
|
|