虞城12345_前端

NewsList.html 26KB

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