| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631 |
- <!DOCTYPE html>
- <html>
- <head>
- <meta charset="UTF-8">
- <script src="../Script/Common/huayi.load.js"></script>
- <script src="../Script/Common/huayi.config.js"></script>
- <link rel="stylesheet" href="../css/init.css" />
- <title>新闻发布</title>
- <style>
- .toolBar {
- padding: 15px 0;
- border-bottom: 1px solid #ccc;
- }
- .boxCon table th {
- width: 20%;
- }
- .boxCon table td textarea {
- width: 100%;
- }
- .inpBox {
- border: 1px solid #a9a9a9;
- height: 27px;
- width: 55%;
- display: inline-block;
- position: relative;
- vertical-align: middle;
- }
- .inps1,
- .inps4 {
- width: 100%;
- height: 24px;
- outline: none;
- border: 0;
- border-image-width: 0;
- padding: 0;
- padding-left: 3px;
- }
- .changeTitle,
- .changeKey,
- .addTitle,
- .addKey {
- width: 55%;
- }
- .xl {
- display: inline-block;
- background: url(../img/dropDown.png) no-repeat;
- height: 100%;
- background-position: center center;
- width: 20px;
- position: absolute;
- right: 0;
- top: 0px;
- background-color: #f7bc8b;
- cursor: pointer;
- }
- .xl:hover {
- background-color: #e6d523;
- }
- .addTree {
- background: #fff;
- position: absolute;
- width: 100%;
- border: 1px solid darkgrey;
- right: 0;
- top: 26px;
- display: none;
- height: 220px;
- overflow-y: auto;
- }
- .treeTable {
- /*overflow-y: auto;*/
- }
- .tree {
- height: 100%;
- }
- .trTitle {
- width: 100%;
- height: 34px;
- line-height: 34px;
- border-bottom: 1px solid #ebebeb;
- color: red;
- font-weight: 700;
- margin-bottom: 15px;
- }
- .treeCon {
- border: 1px solid #ebebeb;
- overflow-y: auto;
- padding: 10px;
- }
- .ztree li {
- width: 100%;
- overflow: hidden;
- white-space: nowrap;
- text-overflow: ellipsis;
- margin-top: 10px;
- }
- .content {
- width: 270px;
- height: 25px;
- overflow: hidden;
- white-space: nowrap;
- text-overflow: ellipsis;
- text-align: left;
- }
- .inputs {
- width: 200px;
- padding: 6px 10PX;
- border: 1px solid #ccc;
- outline: none;
- vertical-align: middle;
- }
- </style>
- </head>
- <body>
- <div class="container-fluid">
- <div class="daoHang clearfix">
- <div class="dhLeft">
- <sapn>
- <i class="syIcon"></i>位置:
- <a href="javaScript:;">首页</a>>
- <a href="javaScript:;">网站后台</a>>
- <a href="" style="color: #000;">新闻发布</a>
- </sapn>
- </div>
- </div>
- <div class="clearfix" style="float: right; margin-bottom: 20px;">
- <div class="toolRight">
- <span>标题:<input type="text" id="Bt" class="inputs" /></span>
- <span>
- 栏目类型:
- <select name="" id="lmlx" class="inputs">
- <option value="0">全部</option>
- <option value="1">工作动态</option>
- <option value="2">民情速递</option>
- <option value="3">曝光台</option>
- <option value="4">政策法规</option>
- <option value="5">工作掠影</option>
- <option value="6">公告</option>
- <option value="7">答疑释惑</option>
- <option value="8">服务承诺</option>
- <option value="9">效能建设</option>
- <option value="10">集萃园地</option>>
- </select>
- </span>
- <!--<span>
- 图文:
- <select name="" id="istw" class="inputs">
- <option value="">全部</option>
- <option value="1">是</option>
- <option value="0">否</option>
- </select>
- </span>-->
- <button class="btns searchGo">搜索</button>
- <button class="btns add">添加</button>
- </div>
- </div>
- <div class="treeTable clearfix">
- <div class="tableCon col-md-12">
- <table id="table1" data-row-style="rowStyle" data-query-params="queryParams" data-pagination="true">
- <thead>
- <tr>
- <th data-field="ClassId" data-formatter="getType">栏目</th>
- <th data-field="img" data-formatter="img">图片</th>
- <th data-field="bt">标题</th>
- <!--<th data-field="iszd" data-formatter="iszd">图文</th>-->
- <th data-field="UserCode">添加人</th>
- <th data-field="sj">添加时间</th>
- <th data-align="left" data-formatter="Dispose">操作</th>
- </tr>
- </thead>
- <tbody id="tbody"></tbody>
- </table>
- </div>
- </div>
- </div>
- <!--添加弹出内容-->
- <div class="model addModel">
- <div class="box">
- <div class="btop clearfix">
- <p class="btl">新闻操作</p>
- <p class="btr addBtr" title="关闭">X</p>
- </div>
- <div class="boxCon">
- <table>
- <tbody>
- <tr>
- <th>选择栏目:</th>
- <td >
- <select name="" id="lmlxs" class="inputs">
- <option value="1">工作动态</option>
- <option value="2">民情速递</option>
- <option value="3">曝光台</option>
- <option value="4">政策法规</option>
- <option value="5">工作掠影</option>
- <option value="6">公告</option>
- <option value="7">答疑释惑</option>
- <option value="8">服务承诺</option>
- <option value="9">效能建设</option>
- <option value="10">集萃园地</option>>
- </select>
- </td>
- </tr>
- <tr class="tp" style="display:none;">
- <th>图片:</th>
- <td >
- <span class="tpname"></span>
- <input type="button" value="上传图片" class="sctp" />
- <input type="file" name="upFile" id="upFile" accept="image/jpeg,image/jpg,image/png" style="display: none;">
- </td>
- </tr>
- <!--<tr class="xw">
- <th>是否图文:</th>
- <td>
- <input type="checkbox" class="iszd" />
- </td>
- </tr>-->
- <tr class="xw">
- <th style="color: red;">标题:</th>
- <td ><input type="text" class="bt inputs" /></td>
- </tr>
- <tr class="xw">
- <th style="color: red;">内容:</th>
- <td ><textarea id="addEditor" name="content" style="width: 100%;height: 100px;"></textarea></td>
- </tr>
- <tr>
- <th>排序:</th>
- <td ><input type="text" class="px inputs" /></td>
- </tr>
- </tbody>
- </table>
- <div style="text-align: center;">
- <button class="btns addCun1">保存</button>
- <button class="btns addCun">保存</button>
- </div>
- </div>
- <input type="hidden" id="Ids" />
- <input type="hidden" id="Id" />
- </div>
- <input type="hidden" id="Pages" />
- </div>
- <script src="../css/layer/layer.js"></script>
- <script src="../js/kindeditor/kindeditor-all-min.js"></script>
- <script src="../js/kindeditor/lang/zh-CN.js"></script>
- <script>
- var table = $('#table1');
- var token = $.cookie("token");
- $(document).ready(function () {
- initTable();
- //添加
- $(".add").click(function () {
- $(".addModel").show();
- $(".addCun").hide();
- $(".addCun1").show();
- Clean();
- });
- //关闭
- $(".addBtr").click(function () {
- $(".addModel").hide();
- })
- //
- $('.addCun').click(function () {
- AddNew();
- });
- $('.addCun1').click(function () {
- AddNews();
- });
- //搜索
- $('.searchGo').click(function () {
- initTable();
- })
- //回车搜索
- document.onkeydown = function (e) {
- var theEvent = window.event || e;
- var code = theEvent.keyCode || theEvent.which;
- if (code == 13) {
- initTable();
- }
- };
- $("#lmlxs").change(function () {
- if ($("#lmlxs").val() == '5') {
- $(".xw").hide();
- $(".tp").show();
- } else {
- $(".xw").show();
- $(".tp").hide();
- }
- })
- //编辑器配置
- KindEditor.ready(function (K) {
- window.editor = K.create('#addEditor', {
- //urlType: 'domain',
- uploadJson: '../../js/kindeditor/asp.net/upload_json.ashx',
- fileManagerJson: '../../js/kindeditor/asp.net/file_manager_json.ashx',
- allowFileManager: true
- }); //添加弹出框编辑器
- });
- //上传图片
- $(".sctp").click(function () {
- $("#upFile").trigger("click");
- })
- $("#upFile").change(function () {
- uploadtp();
- });
- });
- //右边展示
- function initTable() {
- //先销毁表格
- table.bootstrapTable('destroy');
- //初始化表格,动态从服务器加载数据
- table.bootstrapTable({
- method: "get", //使用get请求到服务器获取数据
- url: huayi.config.callcenter_url + "Web/GetNewsList", //获取数据的Servlet地址
- // url: "kehu.json", //获取数据的Servlet地址
- contentType: "application/x-www-form-urlencoded",
- striped: true, //表格显示条纹
- pagination: true, //启动分页
- pageSize: 10, //每页显示的记录数
- pageNumber: 1, //当前第几页
- pageList: [10, 20, 50, 100], //记录数可选列表
- search: false, //是否启用查询
- showColumns: false, //显示下拉框勾选要显示的列
- showRefresh: false, //显示刷新按钮
- sidePagination: "server", //表示服务端请求r
- queryParamsType: "undefined",
- queryParams: function queryParams(params) { //设置查询参数
- var param = {
- page: params.pageNumber,
- pagesize: params.pageSize,
- token: token,
- name: $('#Bt').val().trim(), //标题
- type: $('#lmlx').val(), //栏目
- iszd: $('#istw').val() //图文
- };
- return param;
- },
- onLoadSuccess: function () { //加载成功时执行
- //layer.msg("加载成功");
- },
- onLoadError: function () { //加载失败时执行
- //layer.msg("加载数据失败", { time: 1500, icon: 2 });
- }
- });
- }
- function iszd(val) {
- var str ='否';
- if (val=='1') {
- str = '是';
- }
- return str;
- }
- function getType(val) {
- if (val) {
- switch (val + '') {
- case '1': val = "工作动态"; break;
- case '2': val = "民情速递"; break;
- case '3': val = "曝光台"; break;
- case '4': val = "政策法规"; break;
- case '5': val = "工作掠影"; break;
- case '6': val = "公告"; break;
- case '7': val = "答疑释惑"; break;
- case '8': val = "服务承诺"; break;
- case '9': val = "效能建设"; break;
- case '10': val = "集萃园地"; break;
- }
- return val;
- }
- else {
- return '';
- }
- }
- //操作
- function Dispose(val, row) {
- return '<div class="imgs" >' +
- '<a class="xg" onclick="ckxq(' + row.id + ')"> 修改</a>' +
- '<a class="xg" onclick="Move(' + row.id + ')"> 删除 </a>' +
- '</div>';
- }
- //图片
- function img(val) {
- if (val) {
- return '<div class="imgs" >' +
- '<img src="' + val + '" style="width:100px;height:50px;"/>' +
- '</div>';
- }
- else {
- return '';
- }
- }
- //删除工单
- function Move(str) {
- layer.confirm('确定删除当前记录?', {
- btn: ['是', '否'] //按钮
- }, function () {
- var arr = [];
- arr.push(str);
- $.post(huayi.config.callcenter_url + "Web/DelNews?", {
- ids: arr,
- token: $.cookie("token")
- }, function (data) {
- data = JSON.parse(data);
- /*验证请求*/
- if (data.state == "success") {
- layer.msg("删除成功");
- //重新加载
- initTable();
- }
- });
- });
- }
- //详情
- function ckxq(ids) {
- Clean();
- $(".addModel").show();
- $(".addCun").show();
- $(".addCun1").hide();
- $.getJSON(huayi.config.callcenter_url + "Web/GetNews", {
- id: ids,
- token: token
- }, function (data) {
- if (data.state == "success") {
- $(".bt").val(data.data.bt);
- $(".px").val(data.data.ordernum);
- $("#Id").val(data.data.id);
- var img=data.data.img;
- if (img) {
- $(".tpname").text(img.substring(img.lastIndexOf("/")+1, img.length));
- }
- if (data.data.iszd) {
- $(".iszd").prop("checked", true);
- }
- $('#lmlxs').val(data.data.ClassId)
- $('#lmlxs').trigger("change");
- editor.html(data.data.nr);
- }
- });
- }
- //新增编辑新闻
- function AddNews() {
- if ($("#lmlxs").val() == '5') {
- if (!$(".tpname").text()) {
- layer.confirm('请上传图片!', {
- btn: ['确定']
- });
- return;
- }
- $('.bt').val("");
- editor.html('');
- }
- else {
- if (!$('.bt').val()) {
- layer.confirm('请输入标题!', {
- btn: ['确定']
- });
- return;
- }
- if (!editor.html()) {
- layer.confirm('请输入内容!', {
- btn: ['确定']
- });
- return;
- }
- }
- var iszd = 0;
- if ($('.iszd').is(':checked')) {
- iszd = 1;
- if (!$(".tpname").text()) {
- layer.confirm('图文新闻必须上传图片!', {
- btn: ['确定']
- });
- return;
- }
- }
-
- $.post(huayi.config.callcenter_url + "Web/AddNews", {
- id: $("#Ids").val(),
- type: $('#lmlxs').val(),
- title: $('.bt').val(),
- cont: encodeURIComponent(editor.html()),
- img: $(".tpname").text(),
- sort: $('.px').val(),
- iszd: iszd,
- token: token
- }, function (data) {
- data = JSON.parse(data);
- if (data.state == "success") {
- $(".addModel").hide();
- Clean();
- initTable();
- }
- });
- }
- function AddNew() {
- if ($("#lmlxs").val() == '5') {
- if (!$(".tpname").text()) {
- layer.confirm('请上传图片!', {
- btn: ['确定']
- });
- return;
- }
- $('.bt').val("");
- editor.html('');
- }
- else {
- if (!$('.bt').val()) {
- layer.confirm('请输入标题!', {
- btn: ['确定']
- });
- return;
- }
- if (!editor.html()) {
- layer.confirm('请输入内容!', {
- btn: ['确定']
- });
- return;
- }
- }
- var iszd = 0;
- if ($('.iszd').is(':checked')) {
- iszd = 1;
- if (!$(".tpname").text()) {
- layer.confirm('图文新闻必须上传图片!', {
- btn: ['确定']
- });
- return;
- }
- }
- $.post(huayi.config.callcenter_url + "Web/AddNews", {
- id: $("#Id").val(),
- type: $('#lmlxs').val(),
- title: $('.bt').val(),
- cont: encodeURIComponent(editor.html()),
- sort: $('.px').val(),
- img: $(".tpname").text(),
- iszd:iszd,
- token: token
- }, function (data) {
- data = JSON.parse(data);
- if (data.state == "success") {
- $(".addModel").hide();
- Clean();
- initTable();
- }
- });
- }
- //清除
- function Clean() {
- $("#Ids").val('');
- $('.lmlxs').val('');
- $('.bt').val('');
- $('.px').val('');
- $(".tpname").text('');
- $(".iszd").prop("checked", false);
- editor.html('');
- }
- //上传图片
- function uploadtp() {
- if (document.getElementById("upFile").files.length > 0) {
- var formData = new FormData();
- formData.append("upFile", document.getElementById("upFile").files[0]);
- formData.append("token", $.cookie("token"));
- $.ajax({
- url: huayi.config.callcenter_url + "WorkOrder/UploadFile",
- type: "POST",
- data: formData,
- /**
- *必须false才会自动加上正确的Content-Type
- */
- contentType: false,
- /**
- * 必须false才会避开jQuery对 formdata 的默认处理
- * XMLHttpRequest会对 formdata 进行正确的处理
- */
- processData: false,
- success: function (result) {
- document.getElementById("upFile").outerHTML = document.getElementById("upFile").outerHTML;
- $("#upFile").change(function () {
- uploadtp();
- });
- var r = $.parseJSON(result);
- if (r.state.toLowerCase() == "success") {
- $(".tpname").text(r.data);
- layer.msg("上传成功");
- }
- }
- });
- } else {
- layer.confirm('请上传图片!', {
- btn: ['确定']
- });
- }
- }
- </script>
- </body>
- </html>
|