NoticeManager.js 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323
  1. /// <reference path="E:\ZLSoft\109-中联开发管理系统\ZLPMS\PMS.WebUI\Content/Scripts/jquery.min.js" />
  2. /// <reference path="E:\ZLSoft\109-中联开发管理系统\ZLPMS\PMS.WebUI\Content/Scripts/plugins/easyui/jquery.easyui.min.js" />
  3. /// <reference path="E:\ZLSoft\109-中联开发管理系统\ZLPMS\PMS.WebUI\Content/Scripts/zlpms.js" />
  4. var appOBJ = {
  5. noticeID: undefined,
  6. count: 0,
  7. index: undefined,
  8. index2: undefined,
  9. ID:undefined,
  10. }
  11. function viewModel() {
  12. //公告初始化
  13. this.Init = function () {
  14. $("#notice").datagrid({
  15. url: "/Notice/DataBind?query",
  16. method: 'Get',
  17. pagination:true,
  18. singleSelect: true,
  19. toolbar: '#btn_func',
  20. fit:true,
  21. rownumbers: true,
  22. frozenColumns:[[
  23. { field: '编号', title: '编号', width: 40, align: 'center' },
  24. {
  25. field: '类型', title: '类型', width: 60, align: 'center', styler(val) {
  26. if (val == "公告")
  27. { return 'color:#0c7f86;font-weight:bold'; }
  28. else (val == "通知")
  29. { return 'color:#e85f47;font-weight:bold'; }
  30. }
  31. },
  32. {
  33. field: '是否启用', title: '状态', width: 60, align: 'center', formatter: function (value, row, index) {
  34. if (value=="启用") {
  35. return "✔";
  36. } else {
  37. return "✘";
  38. }
  39. }
  40. },
  41. { field: '优先级', title: '优先级', width: 60, align: 'center', align: 'center' },]],
  42. columns: [[
  43. { field: '标题', title: '标题', width: 400, halign: 'center' },
  44. { field: '发布时间', title: '发布时间', width: 160, align: 'center' },
  45. { field: '添加人', title: '添加人', width: 100, align: 'center' },
  46. {
  47. field: '通知对象', title: '通知对象', width: 300, halign: 'center', formatter: function (val, row, index) {
  48. var nature = "";
  49. var data = val.split(',');
  50. for(var i=0;i<data.length;i++)
  51. {
  52. nature += data[i] == 1 ? "本部人员" : (data[i] == 2 ? "渠道人员" : (data[i] == 3 ? "用户" : (data[i] == 4 ? "机构管理员" : "卫计委管理员")));
  53. nature+=","
  54. }
  55. return nature = nature.substring(0, nature.length - 1);
  56. }
  57. },
  58. { field: '渠道', title: '渠道', width: 180, align: 'center' },
  59. ]],
  60. })
  61. }
  62. //添加初始化
  63. this.Add_Init = function () {
  64. $(function () {
  65. var um = UM.getEditor('Deatil', {
  66. toolbar: [
  67. ' undo redo | forecolor backcolor | removeformat |',
  68. 'insertorderedlist insertunorderedlist | selectall cleardoc paragraph | fontsize',
  69. '| justifyleft justifycenter justifyright justifyjustify |',
  70. '| horizontal print preview']
  71. });
  72. //通知类型
  73. $("#Type").combobox({
  74. url: "/Notice/NoticeType",
  75. valueField: '代码',
  76. textField: '显示名'
  77. })
  78. //通知对象
  79. $("#NotifyTagert").combobox({
  80. url: "/Notice/NoticePerson",
  81. valueField: '代码',
  82. textField: '显示名',
  83. })
  84. //优先级
  85. $("#Property").combobox({
  86. url: "/Notice/NoticeOrder",
  87. valueField: '代码',
  88. textField: '显示名'
  89. })
  90. })
  91. }
  92. //修改初始化
  93. this.Edit_Init = function (id) {
  94. $(function () {
  95. var um = UM.getEditor('Deatil', {
  96. toolbar: [
  97. ' undo redo | forecolor backcolor | removeformat |',
  98. 'insertorderedlist insertunorderedlist | selectall cleardoc paragraph | fontsize',
  99. '| justifyleft justifycenter justifyright justifyjustify |',
  100. '| horizontal print preview']
  101. });
  102. //通知类型
  103. $("#Type").combobox({
  104. url: "/Notice/NoticeType",
  105. valueField: '代码',
  106. textField: '显示名'
  107. })
  108. //通知对象
  109. $("#NotifyTagert").combobox({
  110. url: "/Notice/NoticePerson",
  111. valueField: '代码',
  112. textField: '显示名',
  113. })
  114. //优先级
  115. $("#Property").combobox({
  116. url: "/Notice/NoticeOrder",
  117. valueField: '代码',
  118. textField: '显示名'
  119. })
  120. })
  121. $.get("/Notice/GetNoticeByID?id=" + id, function (data) {
  122. if(data!=null)
  123. {
  124. var um = UM.getEditor('Deatil');
  125. $("#Title").textbox("setValue", data[0].标题)
  126. $("#Type").combobox("setValue", data[0].通知类型)
  127. $("#NotifyTagert").combobox("setValue", data[0].通知对象.split(","))
  128. $("#Property").combobox("setValue", data[0].优先级)
  129. um.setContent(data[0].内容);
  130. $("#IsShow").val(data[0].首页显示);
  131. if(data[0].首页显示==1)
  132. {
  133. $('#Show').checkbox('check');
  134. $("#EndDate").datetimebox("setValue", data[0].截止日期)
  135. }
  136. //附件
  137. if (data[0].附件ID != null && data.length > 0) {
  138. $("#attchment").html();
  139. var html = "";
  140. for (var i = 0; i < data.length; i++) {
  141. 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>";
  142. }
  143. $("#attchment").html(html);
  144. }
  145. }
  146. })
  147. }
  148. //APP推送初始化
  149. this.APPInit = function () {
  150. $("#AppPush").datagrid({
  151. url: "/Notice/APPDataBind",
  152. method: 'Get',
  153. pagination: true,
  154. singleSelect: true,
  155. toolbar: '#btn_func',
  156. fit: true,
  157. rownumbers: true,
  158. frozenColumns: [[
  159. {
  160. field: '状态', title: '状态', width: 60, align: 'center', formatter: function (value, row, index) {
  161. if (value == "启用") {
  162. return "✔";
  163. } else {
  164. return "✘";
  165. }
  166. },
  167. styler(val) {
  168. if (val == "启用")
  169. { return 'color:#0c7f86;font-weight:bold'; }
  170. else
  171. { return 'color:#e85f47;font-weight:bold'; }
  172. }
  173. }, ]],
  174. columns: [[
  175. { field: '标题', title: '标题', width: 200, halign: 'center' },
  176. { field: '描述', title: '描述', width: 600, align: 'center' },
  177. { field: '添加人', title: '添加人', width: 80, align: 'center' },
  178. { field: '添加时间', title: '添加时间', width: 160, align: 'center' },
  179. { field: '图片ID', title: '图片ID', width: 80, align: 'center' },
  180. ]],
  181. })
  182. }
  183. }
  184. //添加通知公告
  185. function Add_Notice() {
  186. var r = ZLPMS.FormToObject('insert_notice');
  187. if (!r.Title || !r.Deatil || !r.Type || !r.NotifyTagert || !r.Property) {
  188. top.ZLPMS.Msg("请将内容填写完整!", 2)
  189. return;
  190. }
  191. if ($('#Show').checkbox('options').checked) {
  192. if ($("#EndDate").datetimebox("getValue") == "") {
  193. top.ZLPMS.Msg("请填写截止日期!", 2)
  194. return;
  195. }
  196. }
  197. if (appOBJ.count > 1) {
  198. top.ZLPMS.Msg("只能上传一个文件!", 2)
  199. return;
  200. }
  201. r = $('#insert_notice').form('validate');
  202. if (r) {//post到后台
  203. if ($('#Show').checkbox('options').checked) {
  204. $("#IsShow").val(1)
  205. }
  206. else {
  207. $("#IsShow").val(0)
  208. }
  209. var t = ZLPMS.FormToObject('insert_notice');
  210. var param = escape(JSON.stringify(t));
  211. $.post("/Notice/Add_Notice", { text: param }, function (data) {
  212. if (data == 1) {
  213. top.ZLPMS.Msg("添加成功!", 1);
  214. ZLPMS.CloseTopWindow(true)
  215. }
  216. else {
  217. top.ZLPMS.Msg("数据异常请重新填写!", 2)
  218. ZLPMS.CloseTopWindow(true)
  219. }
  220. });
  221. }
  222. }
  223. //修改公告
  224. function Save_Notice() {
  225. var r = ZLPMS.FormToObject('edit_notice')
  226. if (!r.Title || !r.Deatil || !r.Type || !r.NotifyTagert || !r.Property) {
  227. top.ZLPMS.Msg("请将内容填写完整!", 2)
  228. return;
  229. }
  230. if ($('#Show').checkbox('options').checked) {
  231. if ($("#EndDate").datetimebox("getValue") == "") {
  232. top.ZLPMS.Msg("请填写截止日期!", 2)
  233. return;
  234. }
  235. }
  236. $.get("/Notice/GetNoticeByID?id=" + $("#ID").val(), function (data) {
  237. if (appOBJ.count > 0&&data[0].附件ID!=null) {
  238. top.ZLPMS.Msg("只能有一个附件!", 2)
  239. }
  240. else
  241. {
  242. r = $('#edit_notice').form('validate');
  243. if (r) {//post到后台
  244. if ($('#Show').checkbox('options').checked) {
  245. $("#IsShow").val(1)
  246. } else {
  247. $("#IsShow").val(0)
  248. }
  249. var param = escape(JSON.stringify(ZLPMS.FormToObject('edit_notice')));
  250. $.post("/Notice/Edit_Notice", { text: param }, function (data) {
  251. if (data==1)
  252. {
  253. top.ZLPMS.Msg("修改成功!", 1);
  254. ZLPMS.CloseTopWindow(true)
  255. }
  256. else
  257. {
  258. top.ZLPMS.Msg("数据异常请重新填写!", 2)
  259. ZLPMS.CloseTopWindow(true)
  260. }
  261. });
  262. }
  263. }
  264. })
  265. }
  266. //关闭
  267. function Close() {
  268. ClearImg();
  269. ZLPMS.CloseTopWindow();
  270. }
  271. //清空图片ID
  272. function ClearImg() {
  273. $.ajax({
  274. url: '/Notice/ClearTempData',
  275. method: 'post',
  276. success: function () {
  277. }
  278. });
  279. }
  280. //删除附件
  281. function Delete_img(data) {
  282. top.ZLPMS.Confirm('删除后无法恢复,您确定要删除该附件吗?', 3, function (idx) {
  283. $.post("/Notice/DeleteFJ", { id: data }, function (d) {
  284. if (d == 1) {
  285. top.ZLPMS.Msg("删除成功", 1);
  286. var classname = "#attchment";
  287. var icon = "#icon";
  288. $(classname).attr("style", "display:none;")
  289. }
  290. else {
  291. top.ZLPMS.Msg("删除失败", 2)
  292. }
  293. })
  294. });
  295. }
  296. //下载附件文件
  297. function downloadfile(id) {
  298. window.open('/Problem/ViewProblemImage?id=' + id);
  299. }