///
///
///
var appOBJ = {
noticeID: undefined,
count: 0,
index: undefined,
index2: undefined,
ID:undefined,
}
function viewModel() {
//公告初始化
this.Init = function () {
$("#notice").datagrid({
url: "/Notice/DataBind?query",
method: 'Get',
pagination:true,
singleSelect: true,
toolbar: '#btn_func',
fit:true,
rownumbers: true,
frozenColumns:[[
{ field: '编号', title: '编号', width: 40, align: 'center' },
{
field: '类型', title: '类型', width: 60, align: 'center', styler(val) {
if (val == "公告")
{ return 'color:#0c7f86;font-weight:bold'; }
else (val == "通知")
{ return 'color:#e85f47;font-weight:bold'; }
}
},
{
field: '是否启用', title: '状态', width: 60, align: 'center', formatter: function (value, row, index) {
if (value=="启用") {
return "✔";
} else {
return "✘";
}
}
},
{ field: '优先级', title: '优先级', width: 60, align: 'center', align: 'center' },]],
columns: [[
{ field: '标题', title: '标题', width: 400, halign: 'center' },
{ field: '发布时间', title: '发布时间', width: 160, align: 'center' },
{ field: '添加人', title: '添加人', width: 100, align: 'center' },
{
field: '通知对象', title: '通知对象', width: 300, halign: 'center', formatter: function (val, row, index) {
var nature = "";
var data = val.split(',');
for(var i=0;i 0) {
$("#attchment").html();
var html = "";
for (var i = 0; i < data.length; i++) {
html += "";
}
$("#attchment").html(html);
}
}
})
}
//APP推送初始化
this.APPInit = function () {
$("#AppPush").datagrid({
url: "/Notice/APPDataBind",
method: 'Get',
pagination: true,
singleSelect: true,
toolbar: '#btn_func',
fit: true,
rownumbers: true,
frozenColumns: [[
{
field: '状态', title: '状态', width: 60, align: 'center', formatter: function (value, row, index) {
if (value == "启用") {
return "✔";
} else {
return "✘";
}
},
styler(val) {
if (val == "启用")
{ return 'color:#0c7f86;font-weight:bold'; }
else
{ return 'color:#e85f47;font-weight:bold'; }
}
}, ]],
columns: [[
{ field: '标题', title: '标题', width: 200, halign: 'center' },
{ field: '描述', title: '描述', width: 600, align: 'center' },
{ field: '添加人', title: '添加人', width: 80, align: 'center' },
{ field: '添加时间', title: '添加时间', width: 160, align: 'center' },
{ field: '图片ID', title: '图片ID', width: 80, align: 'center' },
]],
})
}
}
//添加通知公告
function Add_Notice() {
var r = ZLPMS.FormToObject('insert_notice');
if (!r.Title || !r.Deatil || !r.Type || !r.NotifyTagert || !r.Property) {
top.ZLPMS.Msg("请将内容填写完整!", 2)
return;
}
if ($('#Show').checkbox('options').checked) {
if ($("#EndDate").datetimebox("getValue") == "") {
top.ZLPMS.Msg("请填写截止日期!", 2)
return;
}
}
if (appOBJ.count > 1) {
top.ZLPMS.Msg("只能上传一个文件!", 2)
return;
}
r = $('#insert_notice').form('validate');
if (r) {//post到后台
if ($('#Show').checkbox('options').checked) {
$("#IsShow").val(1)
}
else {
$("#IsShow").val(0)
}
var t = ZLPMS.FormToObject('insert_notice');
var param = escape(JSON.stringify(t));
$.post("/Notice/Add_Notice", { text: param }, function (data) {
if (data == 1) {
top.ZLPMS.Msg("添加成功!", 1);
ZLPMS.CloseTopWindow(true)
}
else {
top.ZLPMS.Msg("数据异常请重新填写!", 2)
ZLPMS.CloseTopWindow(true)
}
});
}
}
//修改公告
function Save_Notice() {
var r = ZLPMS.FormToObject('edit_notice')
if (!r.Title || !r.Deatil || !r.Type || !r.NotifyTagert || !r.Property) {
top.ZLPMS.Msg("请将内容填写完整!", 2)
return;
}
if ($('#Show').checkbox('options').checked) {
if ($("#EndDate").datetimebox("getValue") == "") {
top.ZLPMS.Msg("请填写截止日期!", 2)
return;
}
}
$.get("/Notice/GetNoticeByID?id=" + $("#ID").val(), function (data) {
if (appOBJ.count > 0&&data[0].附件ID!=null) {
top.ZLPMS.Msg("只能有一个附件!", 2)
}
else
{
r = $('#edit_notice').form('validate');
if (r) {//post到后台
if ($('#Show').checkbox('options').checked) {
$("#IsShow").val(1)
} else {
$("#IsShow").val(0)
}
var param = escape(JSON.stringify(ZLPMS.FormToObject('edit_notice')));
$.post("/Notice/Edit_Notice", { text: param }, function (data) {
if (data==1)
{
top.ZLPMS.Msg("修改成功!", 1);
ZLPMS.CloseTopWindow(true)
}
else
{
top.ZLPMS.Msg("数据异常请重新填写!", 2)
ZLPMS.CloseTopWindow(true)
}
});
}
}
})
}
//关闭
function Close() {
ClearImg();
ZLPMS.CloseTopWindow();
}
//清空图片ID
function ClearImg() {
$.ajax({
url: '/Notice/ClearTempData',
method: 'post',
success: function () {
}
});
}
//删除附件
function Delete_img(data) {
top.ZLPMS.Confirm('删除后无法恢复,您确定要删除该附件吗?', 3, function (idx) {
$.post("/Notice/DeleteFJ", { id: data }, function (d) {
if (d == 1) {
top.ZLPMS.Msg("删除成功", 1);
var classname = "#attchment";
var icon = "#icon";
$(classname).attr("style", "display:none;")
}
else {
top.ZLPMS.Msg("删除失败", 2)
}
})
});
}
//下载附件文件
function downloadfile(id) {
window.open('/Problem/ViewProblemImage?id=' + id);
}