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.
333 lines
12 KiB
333 lines
12 KiB
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 OrgId = JSON.parse(window.sessionStorage.getItem("userInfo")).OrgID;
|
|
//OrgId = "fc21743dcaad4225b8be141dd47d8a2f";
|
|
|
|
//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) {
|
|
// search(treeNode.ID, treeNode.TYPE);
|
|
// }
|
|
// }
|
|
//};
|
|
////初始化树
|
|
//$.ajax({
|
|
// type: "post",
|
|
// url: "../../ashx/ZYSysEmpHandler.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);
|
|
// }
|
|
// }
|
|
//});
|
|
|
|
//初始化下拉菜单,绑定通知公告类型ANN_TYPE
|
|
$.ajax({
|
|
type: "post",
|
|
url: "../../ashx/ZYOaKnolageHandler.ashx",
|
|
data: { Action: "getDicdetail", mod_code: "XFJY_BType", dic_fid: "" },
|
|
dataType: "json",
|
|
success: function (res) {
|
|
if (res.code == 0) {
|
|
var arr = res.data;
|
|
var optionhtml = '<option value="">--请选择模块--</option>';
|
|
arr.forEach(function (item) {
|
|
optionhtml += '<option data-idx="' + item.ID + '" value="' + item.DIC_VALUE + '">' + item.DIC_TEXT + '</option>';
|
|
});
|
|
$("#searchCls").html(optionhtml);
|
|
form.render();
|
|
}
|
|
}
|
|
});
|
|
|
|
form.on('select(searchCls)', function (data) {
|
|
var dic_fid = "";
|
|
dic_fid = data.elem[data.elem.selectedIndex].dataset.idx
|
|
if (data.value == "") {
|
|
$("#searchNtype").html("");
|
|
form.render();
|
|
}
|
|
|
|
//初始化下拉菜单,绑定通知公告类型ANN_TYPE
|
|
$.ajax({
|
|
type: "post",
|
|
url: "../../ashx/ZYOaKnolageHandler.ashx",
|
|
data: { Action: "getDicdetail", mod_code: "XFJY_BType", dic_fid: dic_fid },
|
|
dataType: "json",
|
|
success: function (res) {
|
|
if (res.code == 0) {
|
|
var arr = res.data;
|
|
var optionhtml = '<option value="">--请选择类型--</option>';
|
|
arr.forEach(function (item) {
|
|
optionhtml += '<option value="' + item.DIC_VALUE + '">' + item.DIC_TEXT + '</option>';
|
|
});
|
|
$("#searchNtype").html(optionhtml);
|
|
form.render();
|
|
}
|
|
}
|
|
});
|
|
|
|
});
|
|
|
|
var is_content = "";
|
|
$("input:checkbox[name='is_content']:checked").each(function (i) {
|
|
is_content = $(this).val();
|
|
});
|
|
var searchCls = $("#searchCls").val();
|
|
var searchNtype = $("#searchNtype").val();
|
|
//系统列表
|
|
var tableIns = table.render({
|
|
elem: '#List',
|
|
url: '../../ashx/ZYOaKnolageHandler.ashx',
|
|
where: { Action: 'List', cls: searchCls, ntype: searchNtype, OrgId: OrgId, 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: "ListTable",
|
|
cols: [[
|
|
{ type: "checkbox", fixed: "left", width: 50 },
|
|
{ field: 'ART_TITLE', title: '标题', minWidth: 60, align: "center" },
|
|
{ field: 'CLSNAME', title: '模块', minWidth: 60, align: "center" },
|
|
{ field: 'NTYPENAME', title: '类型', minWidth: 60, align: "center" },
|
|
{ field: 'ORG_NAME', title: '发布单位', minWidth: 60, align: "center" },
|
|
{
|
|
title: '操作', width: 160, fixed: "right", align: "center", templet: function (d) {
|
|
if (d.ORG_ID == OrgId) {//本机构
|
|
return $('#sysappListBar').html();
|
|
}
|
|
else {//其他机构
|
|
return $('#sysappListBarOther').html();
|
|
}
|
|
}
|
|
}
|
|
]]
|
|
});
|
|
//搜索【此功能需要后台配合,所以暂时没有动态效果演示】
|
|
$(".search_btn").on("click", function () {
|
|
var is_content = "";
|
|
$("input:checkbox[name='is_content']:checked").each(function (i) {
|
|
is_content = $(this).val();
|
|
});
|
|
table.reload("ListTable", {
|
|
page: {
|
|
curr: 1 //重新从第 1 页开始
|
|
},
|
|
where: {
|
|
Action: 'List',
|
|
keyword: $(".searchVal").val(), //搜索的关键字
|
|
cls: $("#searchCls").val(),
|
|
ntype: $("#searchNtype").val(),
|
|
OrgId: OrgId,
|
|
is_content: is_content,
|
|
random: new Date().getTime() //随机参数
|
|
}
|
|
});
|
|
});
|
|
|
|
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("ListTable", {
|
|
page: {
|
|
curr: 1 //重新从第 1 页开始
|
|
},
|
|
where: {
|
|
Action: 'List',
|
|
keyword: $(".searchVal").val(), //搜索的关键字
|
|
//treeID: treeid, //
|
|
cls: $("#searchCls").val(),
|
|
ntype: $("#searchNtype").val(),
|
|
OrgId: OrgId,
|
|
is_content: is_content,
|
|
random: new Date().getTime() //随机参数
|
|
}
|
|
});
|
|
}
|
|
reload = function () {
|
|
var is_content = "";
|
|
$("input:checkbox[name='is_content']:checked").each(function (i) {
|
|
is_content = $(this).val();
|
|
});
|
|
table.reload("ListTable", {
|
|
page: {
|
|
curr: 1 //重新从第 1 页开始
|
|
},
|
|
where: {
|
|
Action: 'List',
|
|
keyword: $(".searchVal").val(), //搜索的关键字
|
|
cls: $("#searchCls").val(),
|
|
ntype: $("#searchNtype").val(),
|
|
OrgId: OrgId,
|
|
is_content: is_content,
|
|
random: new Date().getTime() //随机参数
|
|
}
|
|
});
|
|
}
|
|
//添加编辑
|
|
function AddEdit(edit) {
|
|
var clientWidth = parseInt(document.body.clientWidth * 0.65) + 'px';
|
|
var clientHeight = parseInt(document.body.clientHeight * 0.85) + 'px';
|
|
var title = "", content = "";
|
|
if (edit) { title = "编辑"; content = "edit.html?id=" + edit.ID } else { title = "添加"; content = "edit.html" }
|
|
var index = layui.layer.open({
|
|
title: title,
|
|
type: 2,
|
|
area: [clientWidth, clientHeight],
|
|
maxmin: false,
|
|
content: content,
|
|
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("#cls").val(edit.CLS);
|
|
body.find("#art_title").val(edit.ART_TITLE);
|
|
body.find("#art_come").val(edit.ART_COME);
|
|
body.find("#R_PHOTO").attr("src", "../../" + edit.ART_PIC);
|
|
body.find("#art_path").val(edit.ART_PIC);
|
|
body.find("#art_short").val(edit.ART_SHORT);
|
|
body.find("#art_cont").val(edit.ART_CONT);
|
|
setTimeout(function () {
|
|
body.find("#cls").siblings("div.layui-form-select").find('dl').find("dd[lay-value='" + edit.CLS + "']").click();
|
|
setTimeout(function () {
|
|
body.find("#ntype").val(edit.NTYPE);
|
|
body.find("#ntype").siblings("div.layui-form-select").find('dl').find("dd[lay-value='" + edit.NTYPE + "']").click();
|
|
}, 500)
|
|
}, 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"));
|
|
});
|
|
}
|
|
|
|
$(".add_btn").click(function () {
|
|
AddEdit();
|
|
});
|
|
|
|
//删除
|
|
function Del(data) {
|
|
|
|
layui.layer.confirm('确定删除选中的?', { icon: 3, title: '提示信息' }, function (index) {
|
|
//提交信息
|
|
$.post("../../ashx/ZYOaKnolageHandler.ashx", {
|
|
Action: "Del",
|
|
id: data.ID,
|
|
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);
|
|
}
|
|
layui.layer.close(index);
|
|
});
|
|
});
|
|
}
|
|
|
|
//查看
|
|
function View(data) {
|
|
var clientWidth = parseInt(document.body.clientWidth * 0.65) + 'px';
|
|
var clientHeight = parseInt(document.body.clientHeight * 0.85) + 'px';
|
|
var index = layui.layer.open({
|
|
title: "查看",
|
|
type: 2,
|
|
area: [clientWidth, clientHeight],
|
|
maxmin: false,
|
|
content: "view.html?id=" + data.ID,
|
|
success: function (layero, index) {
|
|
var body = layui.layer.getChildFrame('body', index);
|
|
body.find(".newstitle").html(data.ART_TITLE);
|
|
body.find(".newsdate").html("时间:" + data.CREATE_TIME + " 来源:" + data.ART_COME);
|
|
body.find(".summary").html("<font color='#c8f1ff'><span style='font-size:16px;white-space:nowrap'>摘要:</span></font>" + data.ART_SHORT);
|
|
body.find("#newscont").html(data.ART_CONT);
|
|
form.render();
|
|
}
|
|
})
|
|
window.sessionStorage.setItem("index", index);
|
|
//改变窗口大小时,重置弹窗的宽高,防止超出可视区域(如F12调出debug的操作)
|
|
$(window).on("resize", function () {
|
|
layui.layer.full(window.sessionStorage.getItem("index"));
|
|
})
|
|
}
|
|
|
|
|
|
//列表操作
|
|
table.on('tool(List)', function (obj) {
|
|
var layEvent = obj.event;
|
|
data = obj.data;
|
|
if (layEvent == 'edit') {//修改
|
|
AddEdit(data);
|
|
}
|
|
else if (layEvent == 'del') {//删除
|
|
Del(data);
|
|
}
|
|
else if (layEvent == 'view') { //查看
|
|
View(data);
|
|
}
|
|
})
|
|
|
|
form.on('checkbox(bellow)', function (data) {
|
|
if (data.elem.checked == true) {
|
|
reload();
|
|
} else {
|
|
reload();
|
|
}
|
|
});
|
|
})
|
|
|