123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323 |
- /// <reference path="E:\ZLSoft\109-中联开发管理系统\ZLPMS\PMS.WebUI\Content/Scripts/jquery.min.js" />
- /// <reference path="E:\ZLSoft\109-中联开发管理系统\ZLPMS\PMS.WebUI\Content/Scripts/plugins/easyui/jquery.easyui.min.js" />
- /// <reference path="E:\ZLSoft\109-中联开发管理系统\ZLPMS\PMS.WebUI\Content/Scripts/zlpms.js" />
- 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<data.length;i++)
- {
- nature += data[i] == 1 ? "本部人员" : (data[i] == 2 ? "渠道人员" : (data[i] == 3 ? "用户" : (data[i] == 4 ? "机构管理员" : "卫计委管理员")));
- nature+=","
- }
- return nature = nature.substring(0, nature.length - 1);
- }
- },
- { field: '渠道', title: '渠道', width: 180, align: 'center' },
- ]],
- })
- }
- //添加初始化
- this.Add_Init = function () {
- $(function () {
- var um = UM.getEditor('Deatil', {
- toolbar: [
- ' undo redo | forecolor backcolor | removeformat |',
- 'insertorderedlist insertunorderedlist | selectall cleardoc paragraph | fontsize',
- '| justifyleft justifycenter justifyright justifyjustify |',
- '| horizontal print preview']
- });
- //通知类型
- $("#Type").combobox({
- url: "/Notice/NoticeType",
- valueField: '代码',
- textField: '显示名'
- })
- //通知对象
- $("#NotifyTagert").combobox({
- url: "/Notice/NoticePerson",
- valueField: '代码',
- textField: '显示名',
- })
- //优先级
- $("#Property").combobox({
- url: "/Notice/NoticeOrder",
- valueField: '代码',
- textField: '显示名'
- })
-
- })
- }
- //修改初始化
- this.Edit_Init = function (id) {
- $(function () {
- var um = UM.getEditor('Deatil', {
- toolbar: [
- ' undo redo | forecolor backcolor | removeformat |',
- 'insertorderedlist insertunorderedlist | selectall cleardoc paragraph | fontsize',
- '| justifyleft justifycenter justifyright justifyjustify |',
- '| horizontal print preview']
- });
- //通知类型
- $("#Type").combobox({
- url: "/Notice/NoticeType",
- valueField: '代码',
- textField: '显示名'
- })
- //通知对象
- $("#NotifyTagert").combobox({
- url: "/Notice/NoticePerson",
- valueField: '代码',
- textField: '显示名',
- })
- //优先级
- $("#Property").combobox({
- url: "/Notice/NoticeOrder",
- valueField: '代码',
- textField: '显示名'
- })
- })
- $.get("/Notice/GetNoticeByID?id=" + id, function (data) {
- if(data!=null)
- {
- var um = UM.getEditor('Deatil');
- $("#Title").textbox("setValue", data[0].标题)
- $("#Type").combobox("setValue", data[0].通知类型)
- $("#NotifyTagert").combobox("setValue", data[0].通知对象.split(","))
- $("#Property").combobox("setValue", data[0].优先级)
- um.setContent(data[0].内容);
- $("#IsShow").val(data[0].首页显示);
-
- if(data[0].首页显示==1)
- {
- $('#Show').checkbox('check');
- $("#EndDate").datetimebox("setValue", data[0].截止日期)
- }
- //附件
- if (data[0].附件ID != null && data.length > 0) {
- $("#attchment").html();
- var html = "";
- for (var i = 0; i < data.length; i++) {
- html += "<div><a href='#' onclick='downloadfile(" + data[i].附件ID + ")'>下载附件</a><i class='fa fa-times' aria-hidden='true' onclick='Delete_img("+'"'+data[i].ID+'"'+")'></i></div>";
- }
- $("#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);
- }
|