| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745 |
- <!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" />
- <link href="../css/plugins/cropper/cropper.min.css" rel="stylesheet">
- <title>新闻发布</title>
- <style>
- .toolBar {
- padding: 15px 0;
- border-bottom: 1px solid #ccc;
- }
-
- .boxCon {
- height: 450px !important;
- }
-
- .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;
- }
-
- .clearFix:after {
- content: "";
- display: block;
- clear: both;
- }
-
- .crop_left {
- width: 40%;
- height: 10px;
- float: left;
- }
-
- .crop_right {
- width: 30%;
- float: right;
- margin-right: 25px;
- }
-
- .btnn {
- background: #2f4050;
- color: #fff;
- padding: 3px 10px;
- border: 0;
- border-radius: 3px;
- cursor: pointer;
- }
- </style>
- </head>
- <body>
- <div class="container-fluid">
- <div class="daoHang clearfix">
- <div class="dhLeft">
- <sapn>
- <i class="syIcon"></i>位置:
- <a id="ReIndex">首页</a>>
- <a href="javaScript:;">系统后台</a>>
- <a href="" class="nowPosition">新闻发布</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="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="urlname" 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="6">公告</option>
- <!--<option value="7">答疑释惑</option>
- <option value="8">服务承诺</option>
- <option value="9">效能建设</option>
- <option value="10">集萃园地</option>>-->
- </select>
- </td>
- </tr>
- <tr>
- <th>排序:</th>
- <td><input type="text" class="px inputs" /></td>
- </tr>
- <tr>
- <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;">
- -->
- <div class="uploadTP">
- <div class="clearFix">
- <div class="crop_left">
- <div class="image-crop" style="height: 210px;">
- <!--<img src="">-->
- <img src="../img/gaga.jpg" style="width: 280px;">
- </div>
- <div class="progress">
- <div class="progress-bar" role="progressbar" aria-valuenow="0" aria-valuemin="0" aria-valuemax="100">
- 0%
- </div>
- </div>
- </div>
- <div class="crop_right">
- <h4>图片预览:</h4>
- <div class="img-preview img-preview-sm"></div>
- </div>
- </div>
- <div class="anniu" style="margin-top: 60px;text-align: left;">
- <label title="上传图片" for="inputImage" class="btnn" style="margin-right: 100px;">
- <input type="file" accept="image/jpeg,image/jpg,image/png" name="file" id="inputImage" class="hide"> 本地图片
- </label>
- <button class="btnn" id="zoomIn" type="button">放大</button>
- <button class="btnn" id="zoomOut" type="button">缩小</button>
- <button class="btnn" id="rotateLeft" type="button">左旋转</button>
- <button class="btnn" id="rotateRight" type="button">右旋转</button>
- <button class="btnn" id="setDrag" type="button">上传图片</button>
- </div>
- </div>
- </td>
- </tr>
- <tr class="xw">
- <th>标题:</th>
- <td><input type="text" class="bt inputs" /></td>
- </tr>
- <tr class="xw">
- <th>内容:</th>
- <td><textarea id="addEditor" name="content" style="width: 100%;height: 100px;"></textarea></td>
- </tr>
- <tr class="xw">
- <th>来源:</th>
- <td><input type="text" class="sourceText inputs" value="本站"/></td>
- </tr>
- <tr class="xw">
- <th>是否展示在公示栏:</th>
- <td>
- <input type="checkbox" class="iszd" />
- </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" />
- <input type="hidden" id="berImg" />
- <input type="hidden" id="aftImg" />
- </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 src="../js/plugins/cropper/cropper.min.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();
- })
- $("#lmlxs").change(function() {
- if($("#lmlxs").val() == '5') {
- $(".xw").hide();
- } else {
- $(".xw").show();
- }
- })
- //编辑器配置
- KindEditor.ready(function(K) {
- window.editor = K.create('#addEditor', {
- //urlType: 'domain',
- imgMaxSize: 10 * 1024 * 1024,
- 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(), //标题
- 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) {
- console.log(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);
- $(".sourceText").val(data.data.source);
- $(".px").val(data.data.ordernum);
- $("#Id").val(data.data.id);
- var img = data.data.img;
- var urlname = data.data.urlname;
- if(img) {
- $('.crop_left img').attr('src', data.data.ym + img);
- $('.crop_right img').attr('src', data.data.ym + urlname);
- $("#berImg").val(img);
- $("#aftImg").val(urlname);
- }
- 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(!$("#aftImg").val()) {
- 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;
- //console.log($(".tpname").text());
- //debugger;
- if(!$("#aftImg").val()) {
- 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: $("#berImg").val(), //原图
- smallimg: $("#aftImg").val(), //裁剪后的图
- sort: $('.px').val(),
- source:$('.sourceText').val(),
- iszd: iszd,
- token: token
- }, function(data) {
- data = JSON.parse(data);
- if(data.state == "success") {
- debugger
- $(".addModel").hide();
- Clean();
- initTable();
- }
- });
- }
- function AddNew() {
- if($("#lmlxs").val() == '5') {
- if(!$("#aftImg").val()) {
- 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(!$("#aftImg").val()) {
- 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: $("#berImg").val(), //原图
- smallimg: $("#aftImg").val(), //裁剪后的图
- source:$('.sourceText').val(),
- iszd: iszd,
- token: token
- }, function(data) {
- data = JSON.parse(data);
- if(data.state == "success") {
- debugger
- $(".addModel").hide();
- Clean();
- initTable();
- }
- });
- }
- //清除
- function Clean() {
- $("#Ids").val('');
- $('.lmlxs').val('');
- $('.bt').val('');
- $('.sourceText').val(),
- $('.px').val('');
- $("#berImg").val('');
- $("#aftImg").val('');
- $(".iszd").prop("checked", false);
- editor.html('');
- }
- //图片裁剪
- var o = $(".image-crop > img");
- $(o).cropper({
- aspectRatio: 4 / 3,
- resizable: true,
- dragCrop: true,
- preview: ".img-preview",
- done: function() {}
- });
- var r = $("#inputImage");
- if(window.FileReader) {
- r.change(function() {
- $('.progress-bar').css('width', '0%');
- $('.progress-bar').text('0%');
- var e, i = new FileReader,
- t = this.files;
- if(t.length && (e = t[0], /^image\/\w+$/.test(e.type))) {
- i.readAsDataURL(e);
- i.onload = function() {
- r.val("");
- o.cropper("reset", !0).cropper("replace", this.result);
- }
- } else {
- layer.msg("请选择图片文件");
- }
- });
- $("#setDrag").click(function() {
- o.cropper("setDragMode", "crop");
- var img = o.cropper("getCroppedCanvas").toDataURL('image/png');
- $.post(huayi.config.callcenter_url + "web/UploadImage", {
- dataurl: encodeURIComponent(img),
- "token": $.cookie("token")
- }, function(result) {
- result = $.parseJSON(result);
- if(result.state.toLowerCase() == "success") {
- //$(".yhtx").attr("src",result.data);
- $("#berImg").val(result.data.imgurl);
- $("#aftImg").val(result.data.smallimgurl);
- layer.msg("上传成功");
- }
- })
- });
- $("#zoomIn").click(function() {
- o.cropper("zoom", .1)
- });
- $("#zoomOut").click(function() {
- o.cropper("zoom", -.1)
- });
- $("#rotateLeft").click(function() {
- o.cropper("rotate", 45)
- });
- $("#rotateRight").click(function() {
- o.cropper("rotate", -45)
- });
- } else {
- r.addClass("hide");
- }
- </script>
- </body>
- </html>
|