layui.use(['form', 'layer', 'table', 'laytpl'], function () {
var form = layui.form,
layer = layui.layer,
$ = layui.jquery,
laytpl = layui.laytpl,
table = layui.table;
var UserId = JSON.parse(window.sessionStorage.getItem("userInfo")).UserCode
//系统列表
var tableIns = table.render({
elem: '#leaveList',
url: '../../ashx/ZYCarApplyHandler.ashx',
where: { Action: 'List', random: new Date().getTime(), userId: UserId },
cellMinWidth: 95,
page: true,
height: "full-125",
limits: [10, 15, 20, 25],
limit: 20,
id: "ListTable",
cols: [[
{ field: 'CARNUM', title: '车牌号', minWidth: 60, align: "center" },
{ field: 'USERNAME', title: '申请人', minWidth: 60, align: "center" },
{ field: 'STA_NAME', title: '用车部门', minWidth: 60, align: "center" },
{ field: 'STATE', title: '状态', align: 'center', minWidth: 60, templet: function (d) {
if (d.STATE == "0") {
return '申请中';
} else if (d.STATE == "1") {
return '通过';
} else if (d.STATE == "2") {
return ' 未通过';
}
}
},
{ title: '操作', width: 180, templet: '#oaleaveListBar', fixed: "right", align: "center" }
]]
});
//table重新加载
function reload() {
table.reload("ListTable", {
page: { curr: 1 },
where: {
Action: 'List',
keywords: $(".searchVal").val(), //搜索的关键字
random: new Date().getTime(), //随机参数
userId: UserId
}
})
}
//搜索【此功能需要后台配合,所以暂时没有动态效果演示】
$(".search_btn").on("click", function () {
if ($(".searchVal").val() != '') {
table.reload("ListTable", {
page: {
curr: 1 //重新从第 1 页开始
},
where: {
Action: 'List',
keywords: $(".searchVal").val(), //搜索的关键字
random: new Date().getTime(), //随机参数
userId: UserId
}
});
} else {
layer.msg("请输入搜索的内容");
}
});
$(".addNews_btn").click(function () {
var clientWidth = parseInt(document.body.clientWidth * 0.7) + 'px';
var clientHeight = parseInt(document.body.clientHeight * 0.9) + 'px';
var index = layui.layer.open({
title: "请假申请单",
type: 2,
area: [clientWidth, clientHeight],
maxmin: true,
content: "applyItem.html"
})
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.9) + 'px';
var clientHeight = parseInt(document.body.clientHeight * 0.9) + 'px';
var index = layui.layer.open({
title: "查看申请单处理进度",
type: 2,
area: [clientWidth, clientHeight],
maxmin: true,
content: "carAudit.html?applyId=" + edit.ID,// + "&waitId=20583a98-5647-48ac-a99f-48becfc0470e",
success: function (layero, index) {
var body = layui.layer.getChildFrame('body', index);
var iframe = window['layui-layer-iframe' + index];
body.find(".ID").val(edit.ID)//ID与action是一个隐藏的元素
body.find(".Action").val("view");
}
})
window.sessionStorage.setItem("index", index);
//改变窗口大小时,重置弹窗的宽高,防止超出可视区域(如F12调出debug的操作)
$(window).on("resize", function () {
layui.layer.full(window.sessionStorage.getItem("index"));
})
}
//列表操作
table.on('tool(leaveList)', function (obj) {
var layEvent = obj.event;
data = obj.data;
if (layEvent == 'edit') {//查看
view(data);
}
})
})