12345市长热线标准版-前端

NewsList.html 17KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <meta charset="UTF-8">
  5. <script src="../Script/Common/huayi.load.js"></script>
  6. <script src="../Script/Common/huayi.config.js"></script>
  7. <link rel="stylesheet" href="../css/init.css" />
  8. <title>新闻发布</title>
  9. <style>
  10. .toolBar {
  11. padding: 15px 0;
  12. border-bottom: 1px solid #ccc;
  13. }
  14. .boxCon table th {
  15. width: 20%;
  16. }
  17. .boxCon table td textarea {
  18. width: 100%;
  19. }
  20. .inpBox {
  21. border: 1px solid #a9a9a9;
  22. height: 27px;
  23. width: 55%;
  24. display: inline-block;
  25. position: relative;
  26. vertical-align: middle;
  27. }
  28. .inps1,
  29. .inps4 {
  30. width: 100%;
  31. height: 24px;
  32. outline: none;
  33. border: 0;
  34. border-image-width: 0;
  35. padding: 0;
  36. padding-left: 3px;
  37. }
  38. .changeTitle,
  39. .changeKey,
  40. .addTitle,
  41. .addKey {
  42. width: 55%;
  43. }
  44. .xl {
  45. display: inline-block;
  46. background: url(../img/dropDown.png) no-repeat;
  47. height: 100%;
  48. background-position: center center;
  49. width: 20px;
  50. position: absolute;
  51. right: 0;
  52. top: 0px;
  53. background-color: #f7bc8b;
  54. cursor: pointer;
  55. }
  56. .xl:hover {
  57. background-color: #e6d523;
  58. }
  59. .addTree {
  60. background: #fff;
  61. position: absolute;
  62. width: 100%;
  63. border: 1px solid darkgrey;
  64. right: 0;
  65. top: 26px;
  66. display: none;
  67. height: 220px;
  68. overflow-y: auto;
  69. }
  70. .treeTable {
  71. /*overflow-y: auto;*/
  72. }
  73. .tree {
  74. height: 100%;
  75. }
  76. .trTitle {
  77. width: 100%;
  78. height: 34px;
  79. line-height: 34px;
  80. border-bottom: 1px solid #ebebeb;
  81. color: red;
  82. font-weight: 700;
  83. margin-bottom: 15px;
  84. }
  85. .treeCon {
  86. border: 1px solid #ebebeb;
  87. overflow-y: auto;
  88. padding: 10px;
  89. }
  90. .ztree li {
  91. width: 100%;
  92. overflow: hidden;
  93. white-space: nowrap;
  94. text-overflow: ellipsis;
  95. margin-top: 10px;
  96. }
  97. .content {
  98. width: 270px;
  99. height: 25px;
  100. overflow: hidden;
  101. white-space: nowrap;
  102. text-overflow: ellipsis;
  103. text-align: left;
  104. }
  105. .inputs {
  106. width: 200px;
  107. padding: 6px 10PX;
  108. border: 1px solid #ccc;
  109. outline: none;
  110. vertical-align: middle;
  111. }
  112. </style>
  113. </head>
  114. <body class="gray-bg">
  115. <div class="container-fluid wrapper-content animated fadeInRight">
  116. <div class="daoHang clearfix">
  117. <div class="dhLeft">
  118. <sapn>
  119. <i class="syIcon"></i>位置:
  120. <a id="ReIndex">首页</a>&gt;
  121. <a href="javaScript:;">网站后台</a>&gt;
  122. <a href="" class="nowPosition">新闻发布</a>
  123. </sapn>
  124. </div>
  125. <div class="dhRight"><a href="" title="刷新"><i class="fa fa-refresh"></i></a></div>
  126. </div>
  127. <div class="clearfix" style="float: right; margin-bottom: 20px;">
  128. <div class="toolRight">
  129. <span>标题:<input type="text" id="Bt" class="inputs" /></span>
  130. <span>
  131. 栏目类型:
  132. <select name="" id="lmlx" class="inputs">
  133. <option value="0">全部</option>
  134. <option value="1">工作动态</option>
  135. <option value="2">民情速递</option>
  136. <option value="3">曝光台</option>
  137. <option value="4">政策法规</option>
  138. <option value="5">工作掠影</option>
  139. <option value="6">公告</option>
  140. <option value="7">答疑释惑</option>
  141. <option value="8">服务承诺</option>
  142. <option value="9">效能建设</option>
  143. <option value="10">集萃园地</option>>
  144. </select>
  145. </span>
  146. <button class="btns searchGo">搜索</button>
  147. <button class="btns add">添加</button>
  148. </div>
  149. </div>
  150. <div class="treeTable clearfix">
  151. <div class="tableCon col-md-12">
  152. <table id="table1" data-row-style="rowStyle" data-query-params="queryParams" data-pagination="true">
  153. <thead>
  154. <tr>
  155. <th data-field="bt">标题</th>
  156. <th data-field="UserCode">添加人</th>
  157. <th data-field="sj">添加时间</th>
  158. <th data-align="left" data-formatter="Dispose">操作</th>
  159. </tr>
  160. </thead>
  161. <tbody id="tbody"></tbody>
  162. </table>
  163. </div>
  164. </div>
  165. </div>
  166. <!--添加弹出内容-->
  167. <div class="model addModel">
  168. <div class="box">
  169. <div class="btop clearfix">
  170. <p class="btl">新闻操作</p>
  171. <p class="btr addBtr" title="关闭">X</p>
  172. </div>
  173. <div class="boxCon">
  174. <table>
  175. <tbody>
  176. <tr>
  177. <th>选择栏目:</th>
  178. <td colspan="3">
  179. <select name="" id="lmlxs" class="inputs">
  180. <option value="1">工作动态</option>
  181. <option value="2">民情速递</option>
  182. <option value="3">曝光台</option>
  183. <option value="4">政策法规</option>
  184. <option value="5">工作掠影</option>
  185. <option value="6">公告</option>
  186. <option value="7">答疑释惑</option>
  187. <option value="8">服务承诺</option>
  188. <option value="9">效能建设</option>
  189. <option value="10">集萃园地</option>>
  190. </select>
  191. </td>
  192. </tr>
  193. <tr>
  194. <th>排序:</th>
  195. <td colspan="3"><input type="text" class="px" /></td>
  196. </tr>
  197. <tr class="tp" style="display:none;">
  198. <th>图片:</th>
  199. <td colspan="3">
  200. <span class="tpname"></span>
  201. <input type="button" value="上传图片" class="sctp" />
  202. <input type="file" name="upFile" id="upFile" accept="image/jpeg,image/jpg,image/png" style="display: none;">
  203. </td>
  204. </tr>
  205. <tr class="xw">
  206. <th>标题:</th>
  207. <td colspan="3"><input type="text" class="bt" /></td>
  208. </tr>
  209. <tr class="xw">
  210. <th>内容:</th>
  211. <td colspan="3"><textarea data-adaptheight id="addEditor" name="content" style="width: 100%;height: 100px;"></textarea></td>
  212. </tr>
  213. </tbody>
  214. </table>
  215. <div style="text-align: center;">
  216. <button class="btns addCun1">保存</button>
  217. <button class="btns addCun">保存</button>
  218. </div>
  219. </div>
  220. <input type="hidden" id="Ids" /> ]
  221. <input type="hidden" id="Id" />
  222. </div>
  223. <input type="hidden" id="Pages" />
  224. </div>
  225. <script src="../css/layer/layer.js"></script>
  226. <script src="../js/kindeditor/kindeditor-all-min.js"></script>
  227. <script src="../js/kindeditor/lang/zh-CN.js"></script>
  228. <script src="../js/adjustHeight.js"></script>
  229. <script>
  230. //返回首页
  231. $('#ReIndex').click(function(){
  232. top.home_index();
  233. })
  234. var table = $('#table1');
  235. var token = $.cookie("token");
  236. $(document).ready(function () {
  237. initTable();
  238. //添加
  239. $(".add").click(function () {
  240. $(".addModel").show();
  241. $(".addCun").hide();
  242. $(".addCun1").show();
  243. Clean();
  244. });
  245. //关闭
  246. $(".addBtr").click(function () {
  247. $(".addModel").hide();
  248. })
  249. //
  250. $('.addCun').click(function () {
  251. AddNew();
  252. });
  253. $('.addCun1').click(function () {
  254. AddNews();
  255. Clean();
  256. });
  257. //搜索
  258. $('.searchGo').click(function () {
  259. initTable();
  260. })
  261. $("#lmlxs").change(function () {
  262. if ($("#lmlxs").val() == '5') {
  263. $(".tp").show();
  264. $(".xw").hide();
  265. } else {
  266. $(".tp").hide();
  267. $(".xw").show();
  268. }
  269. })
  270. //编辑器配置
  271. KindEditor.ready(function (K) {
  272. window.editor = K.create('#addEditor', {
  273. uploadJson: '../../js/kindeditor/asp.net/upload_json.ashx',
  274. fileManagerJson: '../../js/kindeditor/asp.net/file_manager_json.ashx',
  275. allowFileManager: true
  276. }); //添加弹出框编辑器
  277. window.changeEditor = K.create('#changeEditor', {
  278. uploadJson: '../../js/kindeditor/asp.net/upload_json.ashx',
  279. fileManagerJson: '../../js/kindeditor/asp.net/file_manager_json.ashx',
  280. allowFileManager: true
  281. }); //修改弹出框编辑器
  282. });
  283. //上传图片
  284. $(".sctp").click(function () {
  285. $("#upFile").trigger("click");
  286. })
  287. $("#upFile").change(function () {
  288. uploadtp();
  289. });
  290. });
  291. //右边展示
  292. function initTable() {
  293. //先销毁表格
  294. table.bootstrapTable('destroy');
  295. //初始化表格,动态从服务器加载数据
  296. table.bootstrapTable({
  297. method: "get", //使用get请求到服务器获取数据
  298. url: huayi.config.callcenter_url + "Web/GetNewsList", //获取数据的Servlet地址
  299. // url: "kehu.json", //获取数据的Servlet地址
  300. contentType: "application/x-www-form-urlencoded",
  301. striped: true, //表格显示条纹
  302. pagination: true, //启动分页
  303. pageSize: 10, //每页显示的记录数
  304. pageNumber: 1, //当前第几页
  305. pageList: [10, 20, 50, 100], //记录数可选列表
  306. search: false, //是否启用查询
  307. showColumns: false, //显示下拉框勾选要显示的列
  308. showRefresh: false, //显示刷新按钮
  309. sidePagination: "server", //表示服务端请求r
  310. queryParamsType: "undefined",
  311. queryParams: function queryParams(params) { //设置查询参数
  312. var param = {
  313. page: params.pageNumber,
  314. pagesize: params.pageSize,
  315. token: token,
  316. name: $('#Bt').val(), //操作人名称
  317. type: $('#lmlx').val() //登录时间
  318. };
  319. return param;
  320. },
  321. onLoadSuccess: function () { //加载成功时执行
  322. //layer.msg("加载成功");
  323. },
  324. onLoadError: function () { //加载失败时执行
  325. //layer.msg("加载数据失败", { time: 1500, icon: 2 });
  326. }
  327. });
  328. }
  329. //操作
  330. function Dispose(val, row) {
  331. return '<div class="imgs" >' +
  332. '<a class="xg" onclick="ckxq(' + row.id + ')"> 修改</a>' +
  333. '<a class="xg" onclick="Move(' + row.id + ')"> 删除 </a>' +
  334. '</div>';
  335. }
  336. //删除工单
  337. function Move(str) {
  338. layer.confirm('确定删除当前记录?', {
  339. btn: ['是', '否'] //按钮
  340. }, function () {
  341. var arr = [];
  342. arr.push(str);
  343. $.post(huayi.config.callcenter_url + "Web/DelNews?", {
  344. ids: arr,
  345. token: $.cookie("token")
  346. }, function (data) {
  347. data = JSON.parse(data);
  348. /*验证请求*/
  349. if (data.state == "success") {
  350. layer.msg("删除成功");
  351. //重新加载
  352. initTable();
  353. }
  354. });
  355. });
  356. }
  357. //详情
  358. function ckxq(ids) {
  359. Clean();
  360. $(".addModel").show();
  361. $(".addCun").show();
  362. $(".addCun1").hide();
  363. $.getJSON(huayi.config.callcenter_url + "Web/GetNews", {
  364. id: ids,
  365. token: token
  366. }, function (data) {
  367. if (data.state == "success") {
  368. $(".bt").val(data.data.bt);
  369. $(".px").val(data.data.ordernum);
  370. $("#Id").val(data.data.id);
  371. $(".tpname").text(data.data.img)
  372. $('#lmlxs').val(data.data.ClassId)
  373. $('#lmlxs').trigger("change");
  374. editor.html(data.data.nr);
  375. }
  376. });
  377. }
  378. //新增编辑新闻
  379. function AddNews() {
  380. $.post(huayi.config.callcenter_url + "Web/AddNews", {
  381. id: $("#Ids").val(),
  382. type: $('#lmlxs').val(),
  383. title: $('.bt').val(),
  384. cont: encodeURIComponent(editor.html()),
  385. img: $(".tpname").text(),
  386. sort: $('.px').val(),
  387. token: token
  388. }, function (data) {
  389. data = JSON.parse(data);
  390. if (data.state == "success") {
  391. $(".addModel").hide();
  392. initTable();
  393. }
  394. });
  395. }
  396. function AddNew() {
  397. $.post(huayi.config.callcenter_url + "Web/AddNews", {
  398. id: $("#Id").val(),
  399. type: $('#lmlxs').val(),
  400. title: $('.bt').val(),
  401. cont: encodeURIComponent(editor.html()),
  402. sort: $('.px').val(),
  403. img: $(".tpname").text(),
  404. token: token
  405. }, function (data) {
  406. data = JSON.parse(data);
  407. if (data.state == "success") {
  408. $(".addModel").hide();
  409. initTable();
  410. }
  411. });
  412. }
  413. //清除
  414. function Clean() {
  415. $("#Ids").val('');
  416. $('.lmlxs').val('');
  417. $('.bt').val('');
  418. $('.px').val('');
  419. $(".tpname").text('');
  420. editor.html('');
  421. }
  422. //上传图片
  423. function uploadtp() {
  424. if (document.getElementById("upFile").files.length > 0) {
  425. var formData = new FormData();
  426. formData.append("upFile", document.getElementById("upFile").files[0]);
  427. formData.append("token", $.cookie("token"));
  428. $.ajax({
  429. url: huayi.config.callcenter_url + "WorkOrder/UploadFile",
  430. type: "POST",
  431. data: formData,
  432. /**
  433. *必须false才会自动加上正确的Content-Type
  434. */
  435. contentType: false,
  436. /**
  437. * 必须false才会避开jQuery对 formdata 的默认处理
  438. * XMLHttpRequest会对 formdata 进行正确的处理
  439. */
  440. processData: false,
  441. success: function (result) {
  442. document.getElementById("upFile").outerHTML = document.getElementById("upFile").outerHTML;
  443. $("#upFile").change(function () {
  444. uploadtp();
  445. });
  446. var r = $.parseJSON(result);
  447. if (r.state.toLowerCase() == "success") {
  448. $(".tpname").text(r.data);
  449. layer.msg("上传成功");
  450. }
  451. }
  452. });
  453. } else {
  454. layer.confirm('请上传图片!', {
  455. btn: ['确定']
  456. });
  457. }
  458. }
  459. </script>
  460. </body>
  461. </html>