BulletinInfoList.cshtml 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508
  1. 
  2. @{
  3. Layout = null;
  4. }
  5. <!DOCTYPE html>
  6. <html>
  7. <head>
  8. <meta name="viewport" content="width=device-width" />
  9. <title>BulletinInfo</title>
  10. <link href="~/easyui/themes/bootstrap/easyui.css" rel="stylesheet" />
  11. <link href="~/easyui/themes/icon.css" rel="stylesheet" />
  12. <link href="~/Content/css/bootstrap.min.css" rel="stylesheet" />
  13. <link href="~/Content/js/plugins/layer/skin/layer.css" rel="stylesheet" />
  14. <script src="~/Content/js/jquery.min.js"></script>
  15. <script src="~/Content/js/bootstrap.min.js"></script>
  16. <script src="~/easyui/jquery.easyui.min.js"></script>
  17. <script src="~/easyui/jquery.easyui.mobile.js"></script>
  18. <script src="~/easyui/locale/easyui-lang-zh_CN.js"></script>
  19. <script src="~/Content/js/plugins/layer/laydate/laydate.js"></script>
  20. <script src="~/Content/js/plugins/layer/layer.min.js"></script>
  21. <script src="~/Content/plugins/ajaxFileUpload/ajaxFileUpload-M.js"></script>
  22. <script src="~/js/Utils.js"></script>
  23. <link href="~/Content/css/Style/Markets.css" rel="stylesheet" />
  24. <link href="~/Content/kindeditor-master/themes/default/default.css" rel="stylesheet" />
  25. <script src="~/Content/kindeditor-master/kindeditor-all.js"></script>
  26. <script src="~/Content/kindeditor-master/kindeditor-all-min.js"></script>
  27. <script src="~/Content/kindeditor-master/lang/zh-CN.js"></script>
  28. <style>
  29. .td_1 {
  30. padding-bottom: 5px;
  31. padding-left: 5px;
  32. }
  33. </style>
  34. </head>
  35. <body>
  36. <section class="hidden">
  37. <input id="hid_Type" name="hid_Type" type="hidden" value="0" />
  38. <input id="hid_RuleType" name="hid_RuleType" type="hidden" value="@ViewBag.RuleType" />
  39. <input id="hid_IsAdd" name="hid_RuleType" type="hidden" value="@ViewBag.IsAdd" />
  40. <input id="hid_IsUpdate" name="hid_RuleType" type="hidden" value="@ViewBag.IsUpdate" />
  41. <input id="hid_IsDelete" name="hid_RuleType" type="hidden" value="@ViewBag.IsDelete" />
  42. <input id="hid_IsAudit" name="hid_RuleType" type="hidden" value="@ViewBag.IsAudit" />
  43. </section>
  44. @*<section class="text-center title">
  45. <h2>市场信息</h2>
  46. </section>*@
  47. <section class="container-fluid" style="height: 95vh; padding-top: 5px;">
  48. <div class="row tbToolBar" id="tbToolBar">
  49. <div class="toolbar" id="CurdTool" style="float:left">
  50. <a href="#" class="easyui-linkbutton" id="btn_Add" iconCls="icon-add" plain="true" onclick="btn_Add()" >添加</a>
  51. &nbsp;
  52. <a href="#" class="easyui-linkbutton" id="btn_Update" iconCls="icon-edit" plain="true" onclick="btn_Edit()" >修改</a>
  53. &nbsp;
  54. <a href="#" class="easyui-linkbutton" id="btn_Delete" iconCls="icon-remove" plain="true" onclick="btn_Del()" >删除</a>
  55. &nbsp;
  56. <a href="#" class="easyui-linkbutton" id="btn_Audit" iconCls="icon-edit" plain="true" onclick="btn_Aud()" >审核</a>
  57. </div>
  58. </div>
  59. <table id="dgTable" class="easyui-datagrid" style="height: 100%;"
  60. data-options="singleSelect: true,
  61. method: 'post',
  62. multiSort: false,
  63. toolbar: '#tbToolBar',
  64. fitColumns: true,
  65. rownumbers: true,
  66. remoteSort: false,
  67. loadFilter: pagerFilter,
  68. pagination: true,
  69. pageSize: 25,
  70. pageList: [15, 25, 50, 100]
  71. ">
  72. <thead>
  73. <tr>
  74. @*hid_IsLock<th data-options="field:'TradeTypeID'" class="hidden">行业类型</th>*@
  75. <th data-options="field:'Title',width:80,align:'center'">标题</th>
  76. <th data-options="field:'BulletinTypeID',width:80,align:'center'">公告类型</th>
  77. <th data-options="field:'AuditFlagName',width:80,align:'center'">是否审核</th>
  78. <th data-options="field:'UpdateTime',width:80,align:'center'">日期</th>
  79. </tr>
  80. </thead>
  81. </table>
  82. </section>
  83. <section>
  84. <div id="winModal" class="easyui-window winModal" title="公告栏信息维护" style="width: 650px; height:450px;padding:5px;"
  85. iconCls="icon-save" data-options="modal:true,closed:true">
  86. <div class="easyui-layout" data-options="fit:true" style="height:400px">
  87. <div data-options="region:'center'" style="padding:5px 5px 1px; height:385px">
  88. <table cellpadding="10" cellspacing="0" style="margin-left:10px">
  89. <tr>
  90. <td class="td_1">公告类型</td>
  91. <td class="td_1">
  92. <select class="easyui-combobox" id="BulletinTypeID" name="BulletinTypeID" style="width:400px;height:20px">
  93. @Html.Raw(ViewBag.SelBulletinType)
  94. </select>
  95. </td>
  96. </tr>
  97. <tr>
  98. <td class="td_1">标题</td>
  99. <td class="td_1">
  100. <input class="easyui-textbox" type="text" id="Title" name="Title" data-options="required:true" style="width:400px;height:20px" />
  101. </td>
  102. </tr>
  103. <tr>
  104. <td class="td_1">发布日期</td>
  105. <td class="td_1">
  106. <input class="laydate-icon" type="text" id="UpdateTime" name="UpdateTime" data-options="required:true" style="width:400px;height:20px" />
  107. </td>
  108. </tr>
  109. <tr>
  110. <td class="td_1">上传附件</td>
  111. <td class="td_1">
  112. <input class="easyui-filebox" id="UploadedFile" name="UploadedFile" data-options="prompt:'Choose a file...'" style="width:300px;height:20px" />
  113. </td>
  114. </tr>
  115. <tr>
  116. <td align="left" colspan="2" >
  117. <label id="DownUrl"></label>
  118. </td>
  119. </tr>
  120. <tr style="color:cornflowerblue">
  121. <td align="center" colspan="2" style="background-color:lightgray">
  122. <span><strong>内容</strong></span>
  123. </td>
  124. </tr>
  125. <tr>
  126. <td class="td_1" colspan="2">
  127. <textarea id="content" name="content" class="easyui-validatebox" data-options="required:true" style="width: 550px; height: 150px;" placeholder="请输入内容"></textarea>
  128. </td>
  129. </tr>
  130. <tr></tr>
  131. </table>
  132. </div>
  133. <div data-options="region:'south',border:false" style="text-align:right; padding: 12px 20px ;height:52px;">
  134. <a class="easyui-linkbutton" id="Save" data-options="iconCls:'icon-ok'" href="javascript:void(0)" onclick="Save()" style="width:80px">确认</a>
  135. <a class="easyui-linkbutton" data-options="iconCls:'icon-cancel'" href="javascript:void(0)" onclick="$('#winModal').window('close');" style="width:80px">取消</a>
  136. </div>
  137. </div>
  138. </div>
  139. </section>
  140. <script>
  141. function btn_Add() {
  142. $("#hid_Type").val("Add");
  143. $("#Title").textbox("setValue", "");
  144. $('#UploadedFile').filebox('setValue', '');
  145. $("#DownUrl").html("未上传附件");
  146. KindEditor.html('#content', "");
  147. $('#winModal').window('open');
  148. }
  149. //修改
  150. function btn_Edit() {
  151. $("#hid_Type").val("Edit");
  152. //ClearFile(getFileElement());
  153. $("#UploadedFile").filebox("setValue", "");
  154. var row = $('#dgTable').datagrid('getSelected');
  155. if (row) {
  156. $("#BulletinTypeID").combobox("setValue", row.BulletinTypeID);
  157. $("#Title").textbox("setValue", row.Title)
  158. $("#UpdateTime").val(row.UpdateTime);
  159. $.ajax({
  160. url: "/BulletinInfo/GetBulletinInfoAttachFileInfo?ran=" + Math.random(),
  161. type: "POST",
  162. dataType: "json",
  163. data: { ID: row.ID },
  164. success: function (data) {
  165. if (CheckAajxData(data) == false) {
  166. return;
  167. }
  168. var msg = data.FileName;
  169. if (!msg || msg.length <= 0) {
  170. $("#DownUrl").html("未上传附件");
  171. } else {
  172. $("#DownUrl").html(msg);
  173. }
  174. }
  175. })
  176. KindEditor.html('#content', row.content);
  177. $('#winModal').window('open');
  178. } else {
  179. layer.alert('请选择一条记录进行查看', {icon:0, title: '提示信息' });
  180. }
  181. }
  182. @*function Save(type) {
  183. type = type || $("#hid_Type").val();
  184. var ID = (type === "Edit") ? $('#dgTable').datagrid('getSelections')[0].ID : "";
  185. $.ajaxFileUpload({
  186. url: "@Url.Action("BulletinInfoListOper", "BulletinInfo")",
  187. secureuri: false, //一般设置为false
  188. fileElementId: getfileelement(),//$("#UploadedFile").filebox('getValue'),
  189. type: "post",
  190. dataType: "json",
  191. data: {
  192. Type: type,
  193. UploadFile: "true",
  194. ID: ID,
  195. BulletinTypeID: $("#BulletinTypeID").combobox("getValue"),
  196. Title: $("#Title").textbox("getValue"),
  197. UpdateTime: $("#UpdateTime").val(),
  198. content: $("#content").val()
  199. },
  200. success: function (data) {
  201. if (CheckAajxData(data) === false) return;
  202. //$("#UploadedFile").filebox("setValue", "");
  203. $('#UploadedFile').filebox({
  204. buttonText: '选择文件...',
  205. buttonAlign: 'right'
  206. })
  207. var msg = data.ErrorInfo;
  208. if (data.Success === true) {
  209. LoadTable();
  210. $("#winModal").window("close");
  211. layer.alert(msg, { icon: 1, title: '提示信息' });
  212. } else {
  213. layer.alert(msg, { icon: 7, title: '提示信息' });
  214. }
  215. }
  216. });
  217. }*@
  218. function Save(type) {
  219. type = type || $("#hid_Type").val();
  220. var ID = (type === "Edit") ? $('#dgTable').datagrid('getSelections')[0].ID : "";
  221. var formdata = new FormData();
  222. formdata.append("Type", type);
  223. formdata.append("ID", ID);
  224. formdata.append("BulletinTypeID", $("#BulletinTypeID").combobox("getValue"));
  225. formdata.append("Title", $("#Title").textbox("getValue"));
  226. formdata.append("UpdateTime", $("#UpdateTime").val());
  227. //formdata.append("content", encodeURI(encodeURI($("#content").val())));
  228. var b64 = new Base64();
  229. formdata.append("content", b64.encode($("#content").val()));
  230. formdata.append("file", $("#" + getfileelement())[0].files[0]);
  231. $.ajax({ // $.post,告辞
  232. type: 'post',
  233. contentType: false, // 关关关!必须得 false
  234. // 这个不关会扔一个默认值 application/x-www-form-urlencoded 过去,后端拿不到数据的!
  235. // 而且你甚至不能传个字符串 'multipart/form-data',后端一样拿不到数据!
  236. processData: false, // 关关关!重点
  237. url: "@Url.Action("BulletinInfoListOper", "BulletinInfo")",
  238. data: formdata,
  239. success: function (data) {
  240. if (CheckAajxData(data) === false) return;
  241. //$("#UploadedFile").filebox("setValue", "");
  242. $('#UploadedFile').filebox({
  243. buttonText: '选择文件...',
  244. buttonAlign: 'right'
  245. });
  246. data = JSON.parse(data);
  247. var msg = data.ErrorInfo;
  248. //console.log(msg, data.Success);
  249. if (data.Success === true) {
  250. LoadTable();
  251. $("#winModal").window("close");
  252. layer.alert(msg, { icon: 1, title: '提示信息' });
  253. } else {
  254. layer.alert(msg, { icon: 7, title: '提示信息' });
  255. }
  256. }
  257. });
  258. }
  259. function btn_Aud() {
  260. $("#hid_Type").val("Aud");
  261. var row = $('#dgTable').datagrid('getSelected');
  262. if (row) {
  263. layer.confirm('确认审核这条记录?', {
  264. btn: ['确认审核', '取消'] //按钮
  265. }, function () {
  266. if (row) {
  267. $.ajax({
  268. url: "/BulletinInfo/BulletinInfoListOper?ran=" + Math.random(),
  269. type: "POST",
  270. dataType: "json",
  271. data: { ID: row.ID, Type: 'Aud' },
  272. success: function (data) {
  273. if (CheckAajxData(data) == false) {
  274. return;
  275. }
  276. var msg = data.ErrorInfo;
  277. if (data != null && data.Success == true) {
  278. LoadTable();
  279. //$('#winSetSysStatusInfo').window('close');
  280. layer.alert("操作成功!", { icon: 1, title: '提示信息' });
  281. } else {
  282. layer.alert(msg, { icon: 2, title: '提示信息' });
  283. }
  284. }
  285. })
  286. }
  287. })
  288. } else {
  289. layer.alert('请选择一条记录进行查看', { icon: 0, title: '提示信息' });
  290. }
  291. }
  292. function btn_Del() {
  293. $("#hid_Type").val("Del");
  294. var row = $('#dgTable').datagrid('getSelected');
  295. if (row) {
  296. layer.confirm('确认删除这条记录?', {
  297. btn: ['确认删除', '取消'] //按钮
  298. }, function () {
  299. if (row) {
  300. $.ajax({
  301. url: "/BulletinInfo/BulletinInfoListOper?ran=" + Math.random(),
  302. type: "POST",
  303. dataType: "json",
  304. data: { ID: row.ID, Type: 'Del'},
  305. success: function (data) {
  306. if (CheckAajxData(data) == false) {
  307. return;
  308. }
  309. var msg = data.ErrorInfo;
  310. if (data != null && data.Success == true) {
  311. LoadTable();
  312. //$('#winSetSysStatusInfo').window('close');
  313. layer.alert("操作成功!", {icon: 1, title: '提示信息' });
  314. } else {
  315. layer.alert(msg, { icon: 2, title: '提示信息' });
  316. }
  317. }
  318. })
  319. }
  320. })
  321. } else {
  322. layer.alert('请选择一条记录进行查看', { icon: 0, title: '提示信息' });
  323. }
  324. }
  325. //加载表格数据
  326. function LoadTable() {
  327. $('#dgTable').datagrid({
  328. url: '@Url.Action("GetBulletinInfoList", "BulletinInfo")',
  329. onDblClickRow: function () {
  330. btn_Edit();
  331. }
  332. });
  333. }
  334. var editor;
  335. $(function () {
  336. //加载表格数据
  337. window.LoadTable();
  338. editor = KindEditor.create('textarea[name="content"]', {
  339. resizeType: 1, width: "100%", height: "500px", afterChange: function () {
  340. this.sync();
  341. }, afterBlur: function () {
  342. this.sync();
  343. }, allowUpload: true, uploadJson: '/SystemModule/UploadImage'
  344. });
  345. laydate({
  346. elem: '#UpdateTime',
  347. format: "YYYY-MM-DD",
  348. min: "2000-01-01",
  349. event: "focus"
  350. });
  351. $('#UploadedFile').filebox({
  352. buttonText: '选择文件...',
  353. buttonAlign: 'right'
  354. })
  355. if($('#hid_IsAdd').val()=="N"){
  356. $("#btn_Add").hide();
  357. }
  358. if($('#hid_IsUpdate').val()=="N"){
  359. $("#btn_Update").hide();
  360. }
  361. if($('#hid_IsDelete').val()=="N"){
  362. $("#btn_Delete").hide();
  363. }
  364. if($('#hid_IsAudit').val()=="N"){
  365. $("#btn_Audit").hide();
  366. }
  367. });
  368. //function ClearFile(idStr) {
  369. // var file = $(idStr);
  370. // file.after(file.clone().val(""));
  371. // file.remove();
  372. //}
  373. function getfileelement(uploadedfile) {
  374. uploadedfile = uploadedfile || "UploadedFile";
  375. return $('#' + uploadedfile).next().find("input[type='file']").attr("id")
  376. }
  377. function Base64() {
  378. // private property
  379. _keyStr = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";
  380. // public method for encoding
  381. this.encode = function (input) {
  382. var output = "";
  383. var chr1, chr2, chr3, enc1, enc2, enc3, enc4;
  384. var i = 0;
  385. input = _utf8_encode(input);
  386. while (i < input.length) {
  387. chr1 = input.charCodeAt(i++);
  388. chr2 = input.charCodeAt(i++);
  389. chr3 = input.charCodeAt(i++);
  390. enc1 = chr1 >> 2;
  391. enc2 = ((chr1 & 3) << 4) | (chr2 >> 4);
  392. enc3 = ((chr2 & 15) << 2) | (chr3 >> 6);
  393. enc4 = chr3 & 63;
  394. if (isNaN(chr2)) {
  395. enc3 = enc4 = 64;
  396. } else if (isNaN(chr3)) {
  397. enc4 = 64;
  398. }
  399. output = output +
  400. _keyStr.charAt(enc1) + _keyStr.charAt(enc2) +
  401. _keyStr.charAt(enc3) + _keyStr.charAt(enc4);
  402. }
  403. return output;
  404. }
  405. // public method for decoding
  406. this.decode = function (input) {
  407. var output = "";
  408. var chr1, chr2, chr3;
  409. var enc1, enc2, enc3, enc4;
  410. var i = 0;
  411. input = input.replace(/[^A-Za-z0-9\+\/\=]/g, "");
  412. while (i < input.length) {
  413. enc1 = _keyStr.indexOf(input.charAt(i++));
  414. enc2 = _keyStr.indexOf(input.charAt(i++));
  415. enc3 = _keyStr.indexOf(input.charAt(i++));
  416. enc4 = _keyStr.indexOf(input.charAt(i++));
  417. chr1 = (enc1 << 2) | (enc2 >> 4);
  418. chr2 = ((enc2 & 15) << 4) | (enc3 >> 2);
  419. chr3 = ((enc3 & 3) << 6) | enc4;
  420. output = output + String.fromCharCode(chr1);
  421. if (enc3 != 64) {
  422. output = output + String.fromCharCode(chr2);
  423. }
  424. if (enc4 != 64) {
  425. output = output + String.fromCharCode(chr3);
  426. }
  427. }
  428. output = _utf8_decode(output);
  429. return output;
  430. }
  431. // private method for UTF-8 encoding
  432. _utf8_encode = function (string) {
  433. string = string.replace(/\r\n/g, "\n");
  434. var utftext = "";
  435. for (var n = 0; n < string.length; n++) {
  436. var c = string.charCodeAt(n);
  437. if (c < 128) {
  438. utftext += String.fromCharCode(c);
  439. } else if ((c > 127) && (c < 2048)) {
  440. utftext += String.fromCharCode((c >> 6) | 192);
  441. utftext += String.fromCharCode((c & 63) | 128);
  442. } else {
  443. utftext += String.fromCharCode((c >> 12) | 224);
  444. utftext += String.fromCharCode(((c >> 6) & 63) | 128);
  445. utftext += String.fromCharCode((c & 63) | 128);
  446. }
  447. }
  448. return utftext;
  449. }
  450. // private method for UTF-8 decoding
  451. _utf8_decode = function (utftext) {
  452. var string = "";
  453. var i = 0;
  454. var c = c1 = c2 = 0;
  455. while (i < utftext.length) {
  456. c = utftext.charCodeAt(i);
  457. if (c < 128) {
  458. string += String.fromCharCode(c);
  459. i++;
  460. } else if ((c > 191) && (c < 224)) {
  461. c2 = utftext.charCodeAt(i + 1);
  462. string += String.fromCharCode(((c & 31) << 6) | (c2 & 63));
  463. i += 2;
  464. } else {
  465. c2 = utftext.charCodeAt(i + 1);
  466. c3 = utftext.charCodeAt(i + 2);
  467. string += String.fromCharCode(((c & 15) << 12) | ((c2 & 63) << 6) | (c3 & 63));
  468. i += 3;
  469. }
  470. }
  471. return string;
  472. }
  473. }
  474. </script>
  475. </body>
  476. </html>