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.
150 lines
4.9 KiB
150 lines
4.9 KiB
layui.config({
|
|
base: '../../js/'
|
|
}).use(['ztree', 'form', 'layer', 'table', 'laytpl','laydate'], function () {
|
|
var form = layui.form,
|
|
layer = parent.layer === undefined ? layui.layer : top.layer,
|
|
$ = layui.jquery,
|
|
laytpl = layui.laytpl,
|
|
table = layui.table,
|
|
laydate =layui.laydate;
|
|
|
|
laydate.render({
|
|
elem: '#searchTime', //指定元素
|
|
format: 'yyyy-MM-dd', //指定时间格式
|
|
type: 'year',
|
|
trigger: 'click', //采用click弹出
|
|
value: new Date()
|
|
});
|
|
|
|
//系统列表
|
|
table.render({
|
|
elem: '#holidayList',
|
|
url: '../../ashx/OaHolidayHandler.ashx',
|
|
where: { Action: 'List', random: new Date().getTime() },
|
|
cellMinWidth: 95,
|
|
page: false,
|
|
height: "full-125",
|
|
id: "holidayListTable",
|
|
cols: [[
|
|
{
|
|
field: 'HDATE', title: '日期', minWidth: 120, event: 'collapse', align: "center"
|
|
},
|
|
{ field: 'NAME', title: '名称', minWidth: 80, align: "center" },
|
|
{
|
|
field: 'REST', title: '类型', minWidth: 80, align: "center", templet: function (d) {
|
|
if (d.REST == "0") {
|
|
return "周末";
|
|
}
|
|
else if (d.REST == "1") {
|
|
return '<span style="color: red;">节假日</span>';
|
|
}
|
|
}
|
|
},
|
|
{fixed: 'right', title: '操作', align: 'center', toolbar: '#toolBar'
|
|
}
|
|
]]
|
|
});
|
|
|
|
//监听工具条
|
|
table.on('tool(holidayList)', function (obj) {
|
|
var data = obj.data;
|
|
console.log("holidayList");
|
|
var layEvent = obj.event;
|
|
if (layEvent == 'edit') {//修改
|
|
AddEdit(data);
|
|
} else if (layEvent == 'del') {//删除
|
|
Del(data);
|
|
}
|
|
});
|
|
|
|
//table重新加载
|
|
function reload() {
|
|
table.reload("holidayListTable", {
|
|
page: { curr: 1 },
|
|
where: {
|
|
Action: 'List',
|
|
random: new Date().getTime() //随机参数
|
|
}
|
|
})
|
|
}
|
|
|
|
$(".search_btn").click(function () {
|
|
var searchTime = $("#searchTime").val();
|
|
var searchRest = $("#searchRest").val();
|
|
table.reload("holidayListTable", {
|
|
page: { curr: 1 },
|
|
where: {
|
|
Action: 'List',
|
|
searchTime: searchTime,
|
|
searchRest: searchRest,
|
|
random: new Date().getTime() //随机参数
|
|
}
|
|
})
|
|
});
|
|
|
|
//添加编辑
|
|
function AddEdit(edit) {
|
|
var clientWidth = parseInt(document.body.clientWidth * 0.5) + 'px';
|
|
var clientHeight = parseInt(document.body.clientHeight * 0.5) + '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",
|
|
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("#hdate").val(edit.HDATE);
|
|
body.find("#name").val(edit.NAME);
|
|
body.find("#rest").val(edit.REST);
|
|
if (edit.REST != null && edit.REST != "") {
|
|
body.find("#rest").siblings("div.layui-form-select").find('dl').find("dd[lay-value='" + edit.REST + "']").click();
|
|
}
|
|
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"));
|
|
})
|
|
}
|
|
$(".add_btn").click(function () {
|
|
AddEdit();
|
|
});
|
|
|
|
|
|
|
|
function Del(edit) {
|
|
layer.confirm('确定删除该条信息么?', { icon: 3, title: '提示信息' }, function (index) {
|
|
//提交信息
|
|
$.post("../../ashx/OaHolidayHandler.ashx", {
|
|
Action: "Del",
|
|
ID: edit.ID,
|
|
random: new Date().getTime() //随机参数
|
|
}, function (res) {
|
|
res = $.parseJSON(res);
|
|
console.log(res);
|
|
if (res.code == 1) {
|
|
top.layer.msg(res.msg);
|
|
reload();
|
|
} else {
|
|
top.layer.msg(res.msg);
|
|
}
|
|
});
|
|
});
|
|
}
|
|
|
|
|
|
|
|
|
|
})
|