永城市12345 (县级市)- 来源于虞城县12345 - 所有县级统一API

NewsList.html 19KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745
  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. <link href="../css/plugins/cropper/cropper.min.css" rel="stylesheet">
  9. <title>新闻发布</title>
  10. <style>
  11. .toolBar {
  12. padding: 15px 0;
  13. border-bottom: 1px solid #ccc;
  14. }
  15. .boxCon {
  16. height: 450px !important;
  17. }
  18. .boxCon table th {
  19. width: 20%;
  20. }
  21. .boxCon table td textarea {
  22. width: 100%;
  23. }
  24. .inpBox {
  25. border: 1px solid #a9a9a9;
  26. height: 27px;
  27. width: 55%;
  28. display: inline-block;
  29. position: relative;
  30. vertical-align: middle;
  31. }
  32. .inps1,
  33. .inps4 {
  34. width: 100%;
  35. height: 24px;
  36. outline: none;
  37. border: 0;
  38. border-image-width: 0;
  39. padding: 0;
  40. padding-left: 3px;
  41. }
  42. .changeTitle,
  43. .changeKey,
  44. .addTitle,
  45. .addKey {
  46. width: 55%;
  47. }
  48. .xl {
  49. display: inline-block;
  50. background: url(../img/dropDown.png) no-repeat;
  51. height: 100%;
  52. background-position: center center;
  53. width: 20px;
  54. position: absolute;
  55. right: 0;
  56. top: 0px;
  57. background-color: #f7bc8b;
  58. cursor: pointer;
  59. }
  60. .xl:hover {
  61. background-color: #e6d523;
  62. }
  63. .addTree {
  64. background: #fff;
  65. position: absolute;
  66. width: 100%;
  67. border: 1px solid darkgrey;
  68. right: 0;
  69. top: 26px;
  70. display: none;
  71. height: 220px;
  72. overflow-y: auto;
  73. }
  74. .treeTable {
  75. /*overflow-y: auto;*/
  76. }
  77. .tree {
  78. height: 100%;
  79. }
  80. .trTitle {
  81. width: 100%;
  82. height: 34px;
  83. line-height: 34px;
  84. border-bottom: 1px solid #ebebeb;
  85. color: red;
  86. font-weight: 700;
  87. margin-bottom: 15px;
  88. }
  89. .treeCon {
  90. border: 1px solid #ebebeb;
  91. overflow-y: auto;
  92. padding: 10px;
  93. }
  94. .ztree li {
  95. width: 100%;
  96. overflow: hidden;
  97. white-space: nowrap;
  98. text-overflow: ellipsis;
  99. margin-top: 10px;
  100. }
  101. .content {
  102. width: 270px;
  103. height: 25px;
  104. overflow: hidden;
  105. white-space: nowrap;
  106. text-overflow: ellipsis;
  107. text-align: left;
  108. }
  109. .inputs {
  110. width: 200px;
  111. padding: 6px 10PX;
  112. border: 1px solid #ccc;
  113. outline: none;
  114. vertical-align: middle;
  115. }
  116. .clearFix:after {
  117. content: "";
  118. display: block;
  119. clear: both;
  120. }
  121. .crop_left {
  122. width: 40%;
  123. height: 10px;
  124. float: left;
  125. }
  126. .crop_right {
  127. width: 30%;
  128. float: right;
  129. margin-right: 25px;
  130. }
  131. .btnn {
  132. background: #2f4050;
  133. color: #fff;
  134. padding: 3px 10px;
  135. border: 0;
  136. border-radius: 3px;
  137. cursor: pointer;
  138. }
  139. </style>
  140. </head>
  141. <body>
  142. <div class="container-fluid">
  143. <div class="daoHang clearfix">
  144. <div class="dhLeft">
  145. <sapn>
  146. <i class="syIcon"></i>位置:
  147. <a id="ReIndex">首页</a>&gt;
  148. <a href="javaScript:;">系统后台</a>&gt;
  149. <a href="" class="nowPosition">新闻发布</a>
  150. </sapn>
  151. </div>
  152. </div>
  153. <div class="clearfix" style="float: right; margin-bottom: 20px;">
  154. <div class="toolRight">
  155. <span>标题:<input type="text" id="Bt" class="inputs" /></span>
  156. <span>
  157. 栏目类型:
  158. <select name="" id="lmlx" class="inputs">
  159. <option value="0">全部</option>
  160. <option value="1">工作动态</option>
  161. <option value="2">民情速递</option>
  162. <option value="3">曝光台</option>
  163. <option value="4">政策法规</option>
  164. <option value="6">公告</option>
  165. <!--<option value="7">答疑释惑</option>
  166. <option value="8">服务承诺</option>
  167. <option value="9">效能建设</option>
  168. <option value="10">集萃园地</option>>-->
  169. </select>
  170. </span>
  171. <span>
  172. 图文:
  173. <select name="" id="istw" class="inputs">
  174. <option value="">全部</option>
  175. <option value="1">是</option>
  176. <option value="0">否</option>
  177. </select>
  178. </span>
  179. <button class="btns searchGo">搜索</button>
  180. <button class="btns add">添加</button>
  181. </div>
  182. </div>
  183. <div class="treeTable clearfix">
  184. <div class="tableCon col-md-12">
  185. <table id="table1" data-row-style="rowStyle" data-query-params="queryParams" data-pagination="true">
  186. <thead>
  187. <tr>
  188. <th data-field="ClassId" data-formatter="getType">栏目</th>
  189. <th data-field="urlname" data-formatter="img">图片</th>
  190. <th data-field="bt">标题</th>
  191. <th data-field="iszd" data-formatter="iszd">图文</th>
  192. <th data-field="UserCode">添加人</th>
  193. <th data-field="sj">添加时间</th>
  194. <th data-align="left" data-formatter="Dispose">操作</th>
  195. </tr>
  196. </thead>
  197. <tbody id="tbody"></tbody>
  198. </table>
  199. </div>
  200. </div>
  201. </div>
  202. <!--添加弹出内容-->
  203. <div class="model addModel">
  204. <div class="box">
  205. <div class="btop clearfix">
  206. <p class="btl">新闻操作</p>
  207. <p class="btr addBtr" title="关闭">X</p>
  208. </div>
  209. <div class="boxCon">
  210. <table>
  211. <tbody>
  212. <tr>
  213. <th>选择栏目:</th>
  214. <td>
  215. <select name="" id="lmlxs" class="inputs">
  216. <option value="1">工作动态</option>
  217. <option value="2">民情速递</option>
  218. <option value="3">曝光台</option>
  219. <option value="4">政策法规</option>
  220. <option value="6">公告</option>
  221. <!--<option value="7">答疑释惑</option>
  222. <option value="8">服务承诺</option>
  223. <option value="9">效能建设</option>
  224. <option value="10">集萃园地</option>>-->
  225. </select>
  226. </td>
  227. </tr>
  228. <tr>
  229. <th>排序:</th>
  230. <td><input type="text" class="px inputs" /></td>
  231. </tr>
  232. <tr>
  233. <th>图片:</th>
  234. <td>
  235. <!--<span class="tpname"></span>
  236. <input type="button" value="上传图片" class="sctp" />
  237. <input type="file" name="upFile" id="upFile" accept="image/jpeg,image/jpg,image/png" style="display: none;">
  238. -->
  239. <div class="uploadTP">
  240. <div class="clearFix">
  241. <div class="crop_left">
  242. <div class="image-crop" style="height: 210px;">
  243. <!--<img src="">-->
  244. <img src="../img/gaga.jpg" style="width: 280px;">
  245. </div>
  246. <div class="progress">
  247. <div class="progress-bar" role="progressbar" aria-valuenow="0" aria-valuemin="0" aria-valuemax="100">
  248. 0%
  249. </div>
  250. </div>
  251. </div>
  252. <div class="crop_right">
  253. <h4>图片预览:</h4>
  254. <div class="img-preview img-preview-sm"></div>
  255. </div>
  256. </div>
  257. <div class="anniu" style="margin-top: 60px;text-align: left;">
  258. <label title="上传图片" for="inputImage" class="btnn" style="margin-right: 100px;">
  259. <input type="file" accept="image/jpeg,image/jpg,image/png" name="file" id="inputImage" class="hide"> 本地图片
  260. </label>
  261. <button class="btnn" id="zoomIn" type="button">放大</button>
  262. <button class="btnn" id="zoomOut" type="button">缩小</button>
  263. <button class="btnn" id="rotateLeft" type="button">左旋转</button>
  264. <button class="btnn" id="rotateRight" type="button">右旋转</button>
  265. <button class="btnn" id="setDrag" type="button">上传图片</button>
  266. </div>
  267. </div>
  268. </td>
  269. </tr>
  270. <tr class="xw">
  271. <th>标题:</th>
  272. <td><input type="text" class="bt inputs" /></td>
  273. </tr>
  274. <tr class="xw">
  275. <th>内容:</th>
  276. <td><textarea id="addEditor" name="content" style="width: 100%;height: 100px;"></textarea></td>
  277. </tr>
  278. <tr class="xw">
  279. <th>来源:</th>
  280. <td><input type="text" class="sourceText inputs" value="本站"/></td>
  281. </tr>
  282. <tr class="xw">
  283. <th>是否展示在公示栏:</th>
  284. <td>
  285. <input type="checkbox" class="iszd" />
  286. </td>
  287. </tr>
  288. </tbody>
  289. </table>
  290. <div style="text-align: center;">
  291. <button class="btns addCun1">保存</button>
  292. <button class="btns addCun">保存</button>
  293. </div>
  294. </div>
  295. <input type="hidden" id="Ids" />
  296. <input type="hidden" id="Id" />
  297. </div>
  298. <input type="hidden" id="Pages" />
  299. <input type="hidden" id="berImg" />
  300. <input type="hidden" id="aftImg" />
  301. </div>
  302. <script src="../css/layer/layer.js"></script>
  303. <script src="../js/kindeditor/kindeditor-all-min.js"></script>
  304. <script src="../js/kindeditor/lang/zh-CN.js"></script>
  305. <script src="../js/plugins/cropper/cropper.min.js"></script>
  306. <script>
  307. var table = $('#table1');
  308. var token = $.cookie("token");
  309. $(document).ready(function() {
  310. initTable();
  311. //添加
  312. $(".add").click(function() {
  313. $(".addModel").show();
  314. $(".addCun").hide();
  315. $(".addCun1").show();
  316. Clean();
  317. });
  318. //关闭
  319. $(".addBtr").click(function() {
  320. $(".addModel").hide();
  321. })
  322. //
  323. $('.addCun').click(function() {
  324. AddNew();
  325. });
  326. $('.addCun1').click(function() {
  327. AddNews();
  328. });
  329. //搜索
  330. $('.searchGo').click(function() {
  331. initTable();
  332. })
  333. $("#lmlxs").change(function() {
  334. if($("#lmlxs").val() == '5') {
  335. $(".xw").hide();
  336. } else {
  337. $(".xw").show();
  338. }
  339. })
  340. //编辑器配置
  341. KindEditor.ready(function(K) {
  342. window.editor = K.create('#addEditor', {
  343. //urlType: 'domain',
  344. imgMaxSize: 10 * 1024 * 1024,
  345. uploadJson: '../../js/kindeditor/asp.net/upload_json.ashx',
  346. fileManagerJson: '../../js/kindeditor/asp.net/file_manager_json.ashx',
  347. allowFileManager: true
  348. }); //添加弹出框编辑器
  349. });
  350. // //上传图片
  351. // $(".sctp").click(function() {
  352. // $("#upFile").trigger("click");
  353. // })
  354. // $("#upFile").change(function() {
  355. // uploadtp();
  356. // });
  357. });
  358. //右边展示
  359. function initTable() {
  360. //先销毁表格
  361. table.bootstrapTable('destroy');
  362. //初始化表格,动态从服务器加载数据
  363. table.bootstrapTable({
  364. method: "get", //使用get请求到服务器获取数据
  365. url: huayi.config.callcenter_url + "Web/GetNewsList", //获取数据的Servlet地址
  366. // url: "kehu.json", //获取数据的Servlet地址
  367. contentType: "application/x-www-form-urlencoded",
  368. striped: true, //表格显示条纹
  369. pagination: true, //启动分页
  370. pageSize: 10, //每页显示的记录数
  371. pageNumber: 1, //当前第几页
  372. pageList: [10, 20, 50, 100], //记录数可选列表
  373. search: false, //是否启用查询
  374. showColumns: false, //显示下拉框勾选要显示的列
  375. showRefresh: false, //显示刷新按钮
  376. sidePagination: "server", //表示服务端请求r
  377. queryParamsType: "undefined",
  378. queryParams: function queryParams(params) { //设置查询参数
  379. var param = {
  380. page: params.pageNumber,
  381. pagesize: params.pageSize,
  382. token: token,
  383. name: $('#Bt').val(), //标题
  384. type: $('#lmlx').val(), //栏目
  385. iszd: $('#istw').val() //图文
  386. };
  387. return param;
  388. },
  389. onLoadSuccess: function() { //加载成功时执行
  390. //layer.msg("加载成功");
  391. },
  392. onLoadError: function() { //加载失败时执行
  393. //layer.msg("加载数据失败", { time: 1500, icon: 2 });
  394. }
  395. });
  396. }
  397. function iszd(val) {
  398. var str = '否';
  399. if(val == '1') {
  400. str = '是';
  401. }
  402. return str;
  403. }
  404. function getType(val) {
  405. if(val) {
  406. switch(val + '') {
  407. case '1':
  408. val = "工作动态";
  409. break;
  410. case '2':
  411. val = "民情速递";
  412. break;
  413. case '3':
  414. val = "曝光台";
  415. break;
  416. case '4':
  417. val = "政策法规";
  418. break;
  419. case '5':
  420. val = "工作掠影";
  421. break;
  422. case '6':
  423. val = "公告";
  424. break;
  425. //case '7':
  426. // val = "答疑释惑";
  427. // break;
  428. //case '8':
  429. // val = "服务承诺";
  430. // break;
  431. //case '9':
  432. // val = "效能建设";
  433. // break;
  434. //case '10':
  435. // val = "集萃园地";
  436. // break;
  437. }
  438. return val;
  439. } else {
  440. return '';
  441. }
  442. }
  443. //操作
  444. function Dispose(val, row) {
  445. return '<div class="imgs" >' +
  446. '<a class="xg" onclick="ckxq(' + row.id + ')"> 修改</a>' +
  447. '<a class="xg" onclick="Move(' + row.id + ')"> 删除 </a>' +
  448. '</div>';
  449. }
  450. //图片
  451. function img(val) {
  452. console.log(val)
  453. if(val) {
  454. return '<div class="imgs" >' +
  455. '<img src="' + val + '" style="width:100px;height:50px;"/>' +
  456. '</div>';
  457. } else {
  458. return '';
  459. }
  460. }
  461. //删除工单
  462. function Move(str) {
  463. layer.confirm('确定删除当前记录?', {
  464. btn: ['是', '否'] //按钮
  465. }, function() {
  466. var arr = [];
  467. arr.push(str);
  468. $.post(huayi.config.callcenter_url + "Web/DelNews", {
  469. ids: arr,
  470. token: $.cookie("token")
  471. }, function(data) {
  472. data = JSON.parse(data);
  473. /*验证请求*/
  474. if(data.state == "success") {
  475. layer.msg("删除成功");
  476. //重新加载
  477. initTable();
  478. }
  479. });
  480. });
  481. }
  482. //详情
  483. function ckxq(ids) {
  484. Clean();
  485. $(".addModel").show();
  486. $(".addCun").show();
  487. $(".addCun1").hide();
  488. $.getJSON(huayi.config.callcenter_url + "Web/GetNews", {
  489. id: ids,
  490. token: token
  491. }, function(data) {
  492. if(data.state == "success") {
  493. $(".bt").val(data.data.bt);
  494. $(".sourceText").val(data.data.source);
  495. $(".px").val(data.data.ordernum);
  496. $("#Id").val(data.data.id);
  497. var img = data.data.img;
  498. var urlname = data.data.urlname;
  499. if(img) {
  500. $('.crop_left img').attr('src', data.data.ym + img);
  501. $('.crop_right img').attr('src', data.data.ym + urlname);
  502. $("#berImg").val(img);
  503. $("#aftImg").val(urlname);
  504. }
  505. if(data.data.iszd) {
  506. $(".iszd").prop("checked", true);
  507. }
  508. $('#lmlxs').val(data.data.ClassId)
  509. $('#lmlxs').trigger("change");
  510. editor.html(data.data.nr);
  511. }
  512. });
  513. }
  514. //新增编辑新闻
  515. function AddNews() {
  516. if($("#lmlxs").val() == '5') {
  517. if(!$("#aftImg").val()) {
  518. layer.confirm('请上传图片!', {
  519. btn: ['确定']
  520. });
  521. return;
  522. }
  523. $('.bt').val("");
  524. editor.html('');
  525. } else {
  526. if(!$('.bt').val()) {
  527. layer.confirm('请输入标题!', {
  528. btn: ['确定']
  529. });
  530. return;
  531. }
  532. if(!editor.html()) {
  533. layer.confirm('请输入内容!', {
  534. btn: ['确定']
  535. });
  536. return;
  537. }
  538. }
  539. var iszd = 0;
  540. if($('.iszd').is(':checked')) {
  541. iszd = 1;
  542. //console.log($(".tpname").text());
  543. //debugger;
  544. if(!$("#aftImg").val()) {
  545. layer.confirm('图文新闻必须上传图片!', {
  546. btn: ['确定']
  547. });
  548. return;
  549. }
  550. }
  551. $.post(huayi.config.callcenter_url + "Web/AddNews", {
  552. id: $("#Ids").val(),
  553. type: $('#lmlxs').val(),
  554. title: $('.bt').val(),
  555. cont: encodeURIComponent(editor.html()),
  556. img: $("#berImg").val(), //原图
  557. smallimg: $("#aftImg").val(), //裁剪后的图
  558. sort: $('.px').val(),
  559. source:$('.sourceText').val(),
  560. iszd: iszd,
  561. token: token
  562. }, function(data) {
  563. data = JSON.parse(data);
  564. if(data.state == "success") {
  565. debugger
  566. $(".addModel").hide();
  567. Clean();
  568. initTable();
  569. }
  570. });
  571. }
  572. function AddNew() {
  573. if($("#lmlxs").val() == '5') {
  574. if(!$("#aftImg").val()) {
  575. layer.confirm('请上传图片!', {
  576. btn: ['确定']
  577. });
  578. return;
  579. }
  580. $('.bt').val("");
  581. editor.html('');
  582. } else {
  583. if(!$('.bt').val()) {
  584. layer.confirm('请输入标题!', {
  585. btn: ['确定']
  586. });
  587. return;
  588. }
  589. if(!editor.html()) {
  590. layer.confirm('请输入内容!', {
  591. btn: ['确定']
  592. });
  593. return;
  594. }
  595. }
  596. var iszd = 0;
  597. if($('.iszd').is(':checked')) {
  598. iszd = 1;
  599. if(!$("#aftImg").val()) {
  600. layer.confirm('图文新闻必须上传图片!', {
  601. btn: ['确定']
  602. });
  603. return;
  604. }
  605. }
  606. $.post(huayi.config.callcenter_url + "Web/AddNews", {
  607. id: $("#Id").val(),
  608. type: $('#lmlxs').val(),
  609. title: $('.bt').val(),
  610. cont: encodeURIComponent(editor.html()),
  611. sort: $('.px').val(),
  612. img: $("#berImg").val(), //原图
  613. smallimg: $("#aftImg").val(), //裁剪后的图
  614. source:$('.sourceText').val(),
  615. iszd: iszd,
  616. token: token
  617. }, function(data) {
  618. data = JSON.parse(data);
  619. if(data.state == "success") {
  620. debugger
  621. $(".addModel").hide();
  622. Clean();
  623. initTable();
  624. }
  625. });
  626. }
  627. //清除
  628. function Clean() {
  629. $("#Ids").val('');
  630. $('.lmlxs').val('');
  631. $('.bt').val('');
  632. $('.sourceText').val(),
  633. $('.px').val('');
  634. $("#berImg").val('');
  635. $("#aftImg").val('');
  636. $(".iszd").prop("checked", false);
  637. editor.html('');
  638. }
  639. //图片裁剪
  640. var o = $(".image-crop > img");
  641. $(o).cropper({
  642. aspectRatio: 4 / 3,
  643. resizable: true,
  644. dragCrop: true,
  645. preview: ".img-preview",
  646. done: function() {}
  647. });
  648. var r = $("#inputImage");
  649. if(window.FileReader) {
  650. r.change(function() {
  651. $('.progress-bar').css('width', '0%');
  652. $('.progress-bar').text('0%');
  653. var e, i = new FileReader,
  654. t = this.files;
  655. if(t.length && (e = t[0], /^image\/\w+$/.test(e.type))) {
  656. i.readAsDataURL(e);
  657. i.onload = function() {
  658. r.val("");
  659. o.cropper("reset", !0).cropper("replace", this.result);
  660. }
  661. } else {
  662. layer.msg("请选择图片文件");
  663. }
  664. });
  665. $("#setDrag").click(function() {
  666. o.cropper("setDragMode", "crop");
  667. var img = o.cropper("getCroppedCanvas").toDataURL('image/png');
  668. $.post(huayi.config.callcenter_url + "web/UploadImage", {
  669. dataurl: encodeURIComponent(img),
  670. "token": $.cookie("token")
  671. }, function(result) {
  672. result = $.parseJSON(result);
  673. if(result.state.toLowerCase() == "success") {
  674. //$(".yhtx").attr("src",result.data);
  675. $("#berImg").val(result.data.imgurl);
  676. $("#aftImg").val(result.data.smallimgurl);
  677. layer.msg("上传成功");
  678. }
  679. })
  680. });
  681. $("#zoomIn").click(function() {
  682. o.cropper("zoom", .1)
  683. });
  684. $("#zoomOut").click(function() {
  685. o.cropper("zoom", -.1)
  686. });
  687. $("#rotateLeft").click(function() {
  688. o.cropper("rotate", 45)
  689. });
  690. $("#rotateRight").click(function() {
  691. o.cropper("rotate", -45)
  692. });
  693. } else {
  694. r.addClass("hide");
  695. }
  696. </script>
  697. </body>
  698. </html>