news.js 29 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747
  1. var delFiles = []; //用于删除图片
  2. var filesContainer = {}; //存储最终要上传的图片
  3. var files; //存储选择图片的数量
  4. var fContainer = {}; //用于传父级传变量,格式 parent.fContainer
  5. var depositImg = [];//用于存放弹窗图片
  6. var hideImg = []; //用于存放从正文图片路径
  7. layui.use(['form', 'layer', 'laydate', 'table', 'laytpl', 'layedit', 'upload'], function () {
  8. var form = layui.form,
  9. // layer = parent.layer === undefined ? layui.layer : top.layer,
  10. layer = layui.layer,
  11. $ = layui.jquery,
  12. laydate = layui.laydate,
  13. laytpl = layui.laytpl,
  14. table = layui.table,
  15. layedit = layui.layedit
  16. , upload = layui.upload;
  17. var tableIds = 'newsList';
  18. //楼盘列表
  19. var tableIns = table.render({
  20. elem: '#' + tableIds,
  21. url: '/news/newsform',
  22. cellMinWidth: 95,
  23. method: 'post',
  24. page: true,
  25. height: 600,
  26. limit: 20,
  27. id: 'tablerReload',
  28. cols: [[
  29. {type: "checkbox", width: 50},
  30. {type: 'numbers'},
  31. {field: 'id', title: 'ID', width: 80, align: "center", sort: true},
  32. {
  33. field: 'subject', title: '标题', align: 'center', templet: function (d) {
  34. return '<a href="http://www.pinfanghw.com/news/details/' + d.id + '" target="_blank">' + d.subject + '</a>'
  35. }
  36. },
  37. {field: 'city_name', title: '区域', width: 100, align: 'center'},
  38. {field: 'news_name', title: '栏目', width: 120, align: 'center'},
  39. // {field: 'house_name', title: '楼盘', width: 170, align: 'center'},
  40. // {
  41. // field: 'hstate',
  42. // title: '推送楼盘',
  43. // width: 100,
  44. // event: 'housesNews',
  45. // align: 'center',
  46. // templet: function (d) {
  47. // if (d.hstate == 2) {
  48. // return '<input type="checkbox" value="' + d.id + '" name="open" lay-skin="switch" lay-filter="switchHid" lay-text="|">'
  49. // } else {
  50. // return '<input type="checkbox" checked value="' + d.id + '" name="open" lay-skin="switch" lay-filter="switchHid" lay-text="|">'
  51. // }
  52. // }
  53. // },
  54. {
  55. field: 'clicks',
  56. title: '点击数',
  57. width: 100,
  58. edit: 'text',
  59. align: 'center',
  60. clicks: true,
  61. templet: "#clicksBox"
  62. },
  63. {field: 'true_click', title: '真实点击数', width: 120, align: 'center', sort: true},
  64. {field: 'sort', title: '排序', width: 100, edit: 'text', align: 'center', sort: true, templet: "#sortBox"},
  65. {
  66. field: 'top', title: '置顶', width: 75, event: 'housesNews', align: 'center', templet: function (d) {
  67. if (d.top == 2) {
  68. return '<input type="checkbox" checked value="' + d.id + '" name="open" lay-skin="switch" lay-filter="switchTop" lay-text="|">'
  69. } else {
  70. return '<input type="checkbox" value="' + d.id + '" name="open" lay-skin="switch" lay-filter="switchTop" lay-text="|">'
  71. }
  72. }
  73. },
  74. {field: 'create_at', title: '添加时间', width: 120, event: 'sortData', align: 'center', sort: true},
  75. {
  76. field: 'state', title: '审核', width: 75, event: 'housesNews', align: 'center', templet: function (d) {
  77. if (d.state === 'N') {
  78. return '<input type="checkbox" value="' + d.id + '" name="open" lay-skin="switch" lay-filter="switchTest" lay-text="|">'
  79. } else {
  80. return '<input type="checkbox" checked value="' + d.id + '" name="open" lay-skin="switch" lay-filter="switchTest" lay-text="|">'
  81. }
  82. }
  83. },
  84. {title: '操作', width: 100, templet: '#housesListBar', fixed: "right", align: "center"}
  85. ]]
  86. });
  87. table.reload('tablerReload'); //重新加载
  88. // 日期
  89. laydate.render({
  90. elem: '#EventDate'
  91. });
  92. laydate.render({
  93. elem: '#ModificationDate'
  94. });
  95. //表格头部操作菜单
  96. var $ = layui.$, active = {
  97. addData: function () { //获取选中数据
  98. var index = layui.layer.open({
  99. title: "添加资讯",
  100. type: 2,
  101. area: ['80%', '100%'],
  102. maxmin: true,
  103. content: "/news/add",
  104. })
  105. layui.layer.full(index);
  106. //改变窗口大小时,重置弹窗的宽高,防止超出可视区域(如F12调出debug的操作)
  107. $(window).on("resize", function () {
  108. layui.layer.full(index);
  109. })
  110. },
  111. reload: function () {
  112. var form = pfgs_serialize($('form'));
  113. var name = '';
  114. var id = '';
  115. if (form.input_house == 'name') {
  116. name = form.input_house_text;
  117. } else if (form.input_house == 'id') {
  118. id = form.input_house_text;
  119. }
  120. table.reload('tablerReload', {
  121. where: {
  122. sort: form.input_sort,
  123. id: id,
  124. name: name,
  125. news: form.input_news,
  126. city: form.input_city
  127. }
  128. })
  129. }, batch_sync: function () {
  130. var checkStatus = table.checkStatus('tablerReload');
  131. if (typeof checkStatus.data[0] == 'object') {
  132. var nid = '';
  133. $.each(checkStatus.data, function (key, val) {
  134. nid += val.id + ',';
  135. })
  136. var index = layui.layer.open({
  137. title: "批量操作",
  138. type: 2,
  139. area: ['50%', '100%'],
  140. maxmin: true,
  141. content: "/news/batchsync?nid=" + nid,
  142. })
  143. return false;
  144. }
  145. layer.msg('请选择需要同步的资讯');
  146. }
  147. };
  148. //监听指定开关
  149. form.on('switch(switchTest)', function (data) {
  150. layer.confirm('确定要修改此操作吗?', {btn: ['确定', '取消']}, function () {
  151. $.post('/house/housesortedit', {id: data.value, examineid: 1}, function (data) {
  152. if (data.code == 200) {
  153. layer.msg(data.msg);
  154. table.reload('tablerReload');
  155. } else if (data.code == 300) {
  156. layer.msg(data.msg);
  157. }
  158. })
  159. }, function (aa) {
  160. table.reload('tablerReload'); //重新加载
  161. })
  162. });
  163. $('.demoTable .layui-btn').on('click', function () {
  164. var type = $(this).data('type');
  165. active[type] ? active[type].call(this) : '';
  166. });
  167. /* 列表操作 edit 修改后执行 2018.7.24*/
  168. table.on('edit(' + tableIds + ')', function (obj) {
  169. var data = obj.data;
  170. if (obj.field === 'clicks') {
  171. $.post('/news/editclicks', {id: data.id, type: 'clicks', clicks: data.clicks}, function (data) {
  172. if (data.code == 200) {
  173. layer.msg(data.msg);
  174. // obj.update({
  175. // sort: data.sort
  176. // });
  177. // TableClose();
  178. } else if (data.code == 300) {
  179. layer.msg(data.msg);
  180. }
  181. })
  182. } else if (obj.field === 'sort') {
  183. $.post('/news/editclicks', {id: data.id, type: 'sort', sort: data.sort}, function (data) {
  184. if (data.code == 200) {
  185. layer.msg(data.msg);
  186. // obj.update({
  187. // sort: data.sort
  188. // });
  189. // TableClose();
  190. } else if (data.code == 300) {
  191. layer.msg(data.msg);
  192. }
  193. })
  194. }
  195. })
  196. // if(obj.event === 'clicksData'){
  197. // layer.prompt({
  198. // formType: 2
  199. // ,title: '点击数'
  200. // ,value: data.clicks
  201. // }, function(value, index){
  202. // $.post('/news/editclicks',{id:data.id,type:'clicks',clicks:value},function (data) {
  203. // layer.msg(data.msg);
  204. // layer.close(index);
  205. // table.reload('tablerReload');
  206. // })
  207. // });
  208. // } else
  209. //表格右边操作栏目
  210. table.on('tool(' + tableIds + ')', function (obj) {
  211. var data = obj.data;
  212. if (obj.event === 'del') { //删除操作
  213. layer.confirm('确定要删除吗?', {btn: ['确定', '取消']}, function () {
  214. $.post('/news/newsdel', {id: data.id}, function (data) {
  215. if (data.code == 200) {
  216. layer.msg(data.msg);
  217. table.reload('tablerReload');
  218. } else if (data.code == 300) {
  219. layer.msg(data.msg);
  220. }
  221. })
  222. })
  223. } else if (obj.event === 'edit') { //编辑操作
  224. var index = layui.layer.open({
  225. title: "编辑资讯",
  226. type: 2,
  227. area: ['', '100%'],
  228. maxmin: true,
  229. content: '/news/newsedit?id=' + data.id + '&house_name=' + data.house_name,
  230. })
  231. layui.layer.full(index);
  232. //改变窗口大小时,重置弹窗的宽高,防止超出可视区域(如F12调出debug的操作)
  233. $(window).on("resize", function () {
  234. layui.layer.full(index);
  235. })
  236. } else if (obj.event === 'sortData') { //修改排序
  237. layer.prompt({
  238. formType: 2
  239. , title: '修改'
  240. , value: data.sort
  241. }, function (value, index) {
  242. $.post('/house/housesortedit', {id: data.id, sort: value}, function (data) {
  243. if (data.code == 200) {
  244. layer.msg(data.msg);
  245. layer.close(index);
  246. obj.update({
  247. sort: value
  248. });
  249. // TableClose();
  250. } else if (data.code == 300) {
  251. layer.msg(data.msg);
  252. }
  253. })
  254. });
  255. }
  256. });
  257. //监听指定开关
  258. form.on('switch(switchTest)', function (data) {
  259. layer.confirm('确定要修改此操作吗?', {btn: ['确定', '取消']}, function () {
  260. $.post('/news/newsviewcontrol', {id: data.value}, function (data) {
  261. if (data.code == 200) {
  262. layer.msg(data.msg);
  263. table.reload('tablerReload');
  264. } else if (data.code == 300) {
  265. layer.msg(data.msg);
  266. }
  267. })
  268. }, function (aa) {
  269. table.reload('tablerReload');
  270. })
  271. });
  272. //监听指定开关
  273. form.on('switch(switchTop)', function (data) {
  274. layer.confirm('确定要修改此操作吗?', {btn: ['确定', '取消']}, function () {
  275. $.post('/news/topnews', {id: data.value}, function (data) {
  276. if (data.code == 200) {
  277. layer.msg(data.msg);
  278. table.reload('tablerReload');
  279. } else if (data.code == 300) {
  280. layer.msg(data.msg);
  281. }
  282. })
  283. }, function (aa) {
  284. table.reload('tablerReload');
  285. })
  286. });
  287. //监听指定开关
  288. form.on('switch(switchHid)', function (data) {
  289. layer.confirm('确定要修改此操作吗?', {btn: ['确定', '取消']}, function () {
  290. $.post('/news/newhouse', {id: data.value}, function (data) {
  291. if (data.code == 200) {
  292. layer.msg(data.msg);
  293. table.reload('tablerReload');
  294. } else if (data.code == 300) {
  295. layer.msg(data.msg);
  296. }
  297. })
  298. }, function (aa) {
  299. table.reload('tablerReload');
  300. })
  301. });
  302. //添加and修改图片
  303. upload.render({
  304. elem: '#upload_edit',
  305. url: '/news/newseditform'
  306. , data: {token: csrfToken}
  307. , multiple: true
  308. , number: 3
  309. , auto: false
  310. , size: 1000 //限制上传图片的大小,单位为KB
  311. , exts: 'png|jpg|jpeg' //只允许上传压缩文件
  312. , bindAction: '#addcity'
  313. , choose: function (obj) {
  314. //将每次选择的文件追加到文件队列
  315. files = obj.pushFile();
  316. //预读本地文件,如果是多文件,则会遍历。(不支持ie8/9)
  317. obj.preview(function (index, file, result) {
  318. depositImg.push({src: result, data: file});
  319. filesContainer[index] = file;
  320. $('#popup_1_imgBox').append('<div class="layui-upload-img"><div class="delete-list" id="delimg"><i class="layui-icon fa-trash-o" >&#xe640;</i></div><img delIdentification="' + index + '" src="' + result + '" alt="' + file.name + '"></div>');
  321. });
  322. }
  323. });
  324. layer.photos({
  325. photos: '#demo2'
  326. , anim: 5 //0-6的选择,指定弹出图片动画类型,默认随机(请注意,3.0之前的版本用shift参数)
  327. });
  328. $('.The_house').focus(function () {
  329. // $('form').append('<input type="hidden" name="aa" value="aaa">');
  330. indexOpen = parent.layui.layer.open({
  331. type: 2,
  332. title: '选择需要添加的楼盘',
  333. area: ['', '100%'],
  334. content: '/publicuse/housename',
  335. success: function (layero, index) {
  336. },
  337. end: function () {
  338. }
  339. });
  340. parent.layui.layer.full(indexOpen);
  341. //改变窗口大小时,重置弹窗的宽高,防止超出可视区域(如F12调出debug的操作)
  342. $(window).on("resize", function () {
  343. parent.layui.layer.full(indexOpen);
  344. })
  345. })
  346. // 正文上传事件
  347. $('#popup_2').on('click', '.layui-upload-img', function () {
  348. // 处理选中与取消
  349. $(this).find('.layui_w_triangle').toggle('30', function () {
  350. $(this).parent().attr('data-id', 'pitch')
  351. if ($(this).is(":hidden")) {
  352. $(this).parent().removeAttr('data-id');
  353. var _fsrc = $(this).parents('.layui-upload-img').find('img.pitch_img').attr('src');
  354. var _furl = "pc/" + _fsrc.split("//")[2]
  355. for (i in depositImg) {
  356. if (depositImg[i] == _fsrc) {
  357. depositImg.splice(i, 1); //取消选择时,从数组中删除
  358. }
  359. if (hideImg[i] == _furl) {
  360. parent.hideImg.splice(i, 1);
  361. }
  362. }
  363. } else {
  364. $(this).parent().attr('data-id', 'pitch')
  365. var _fsrc = $(this).parents('.layui-upload-img').find('img.pitch_img').attr('src');
  366. var _furl = "pc/" + _fsrc.split("//")[2]
  367. depositImg.push(_fsrc); //选中的图片,把src地址存入数组
  368. parent.hideImg.push(_furl); //选中的图片,把src地址存入数组
  369. }
  370. });
  371. })
  372. // 封面图功能
  373. $('.upload_box').on('click', function () {
  374. var txtData = UE.getEditor('editor_content').getContent();
  375. var imgReg = /<img.*?(?:>|\/>)/gi; //匹配图片(g表示匹配所有结果i表示区分大小写)
  376. var srcReg = /src=[\'\"]?([^\'\"]*)[\'\"]?/i; //匹配src属性
  377. var txtImg = txtData.match(imgReg);
  378. var index = layer.open({
  379. type: 2,
  380. title: '选择封面',
  381. skin: 'layui-layer-rim', //加上边框
  382. area: ['650px', '500px'], //宽高
  383. content: "/news/popup",
  384. success: function (layero, index) {
  385. var poupBody = layer.getChildFrame('body', index); //获取当前弹窗的doc
  386. for (i in txtImg) {
  387. var _src = txtImg[i].match(srcReg)[0];
  388. poupBody.find('#popup_2').append('<div class="layui-upload-img"><div class="layui_w_triangle"><img src="/static/images/triangle.png" alt="" /></div><img class="pitch_img" ' + _src + '/></div>');
  389. }
  390. }
  391. })
  392. })
  393. $('#layui_confirm').on('click', function () {
  394. var doc = $('#demo2', window.parent.document); //JQ获取弹窗父层doc
  395. var index = parent.layer.getFrameIndex(window.name); //获取窗口索引
  396. if (depositImg.length > 3) {
  397. layer.msg('封面图只能选择3张!!', {time: 1000, shade: 0.5})
  398. return false;
  399. }
  400. var _leng = doc.find('.layui-upload-img').length;
  401. if (_leng < 3) {
  402. for (i in depositImg) {
  403. if (typeof depositImg[i] == "object") {
  404. doc.append('<div class="layui-upload-img"><div class="delete-list" id="delimg"><i class="layui-icon fa-trash-o" >&#xe640;</i></div><img src="' + depositImg[i].src + '" ></div>');
  405. parent.fContainer[i] = depositImg[i].data
  406. } else {
  407. doc.append('<div class="layui-upload-img"><div class="delete-list" id="delimg"><i class="layui-icon fa-trash-o" >&#xe640;</i></div><img src="' + depositImg[i] + '" ></div>')
  408. parent.fContainer[i] = depositImg[i];
  409. }
  410. }
  411. } else if (_leng > 3) {
  412. layer.msg('封面图只能选择3张!!', {time: 1000, shade: 0.5})
  413. }
  414. parent.layer.close(index); //关闭iframe页面
  415. })
  416. delImg("popup_1_imgBox", "delimg"); // 删除图片
  417. layer.photos({
  418. photos: '#demo2'
  419. , closeBtn: 1
  420. , anim: 5 //0-6的选择,指定弹出图片动画类型,默认随机(请注意,3.0之前的版本用shift参数)
  421. });
  422. //添加
  423. form.on('submit(tijiao)', function (data) {
  424. var index = layer.msg('数据提交中,请稍候', {icon: 16, time: false, shade: 0.8}); //数据提交提示
  425. var formData = new FormData($("#signupForm")[0]);
  426. for (i in fContainer) {
  427. formData.append('img[]', fContainer[i]);
  428. }
  429. //从正文上传文件图片
  430. if (hideImg.length > 0) {
  431. $.each(hideImg, function (k, v) {
  432. formData.append('mainImg[]', v);
  433. })
  434. }
  435. $.ajax({
  436. cache: true,
  437. type: "post",
  438. url: "/news/addform",
  439. data: formData, // 你的formid
  440. // async : false, //async 默认为true异步,修改为false为同步,
  441. contentType: false, //jax 中 contentType 设置为 false 是为了避免 JQuery 对其操作,从而失去分界符,而使服务器不能正常解析文件
  442. processData: false, //当设置为true的时候,jquery ajax 提交的时候不会序列化 data,而是直接使用data
  443. error: function (request) {
  444. layer.close(index);
  445. layer.alert("网络超时");
  446. },
  447. success: function (data) {
  448. if (data.code == 200) {
  449. layer.msg(data.msg);
  450. parent.layui.table.reload('tablerReload');
  451. TableClose();
  452. } else if (data.code == 300) {
  453. layer.msg(data.msg)
  454. layer.msg(ReturnInfo(data.data), {icon: 5});
  455. }
  456. }
  457. });
  458. return false;
  459. })
  460. //修改
  461. form.on('submit(edit)', function (data) {
  462. var index = layer.msg('数据提交中,请稍候', {icon: 16, time: false, shade: 0.8}); //数据提交提示
  463. var formData = new FormData($("#signupForm")[0]);
  464. // $.each(filesContainer,function (k,v) {
  465. // if(v != null){
  466. // formData.append('img[]',v);
  467. // }
  468. // })
  469. for (i in fContainer) {
  470. formData.append('img[]', fContainer[i]);
  471. }
  472. //需要删除的图片
  473. if (delFiles.length > 0) {
  474. $.each(delFiles, function (k, v) {
  475. formData.append('delimg[]', v);
  476. })
  477. }
  478. //从正文上传文件图片
  479. if (hideImg.length > 0) {
  480. $.each(hideImg, function (k, v) {
  481. formData.append('mainImg[]', v);
  482. })
  483. }
  484. $.ajax({
  485. cache: true,
  486. type: "post",
  487. url: "/news/newseditform",
  488. data: formData, // 你的formid
  489. contentType: false, //jax 中 contentType 设置为 false 是为了避免 JQuery 对其操作,从而失去分界符,而使服务器不能正常解析文件
  490. processData: false, //当设置为true的时候,jquery ajax 提交的时候不会序列化 data,而是直接使用data
  491. error: function (request) {
  492. layer.close(index); //关闭数据提交信息
  493. layer.alert("网络超时");
  494. },
  495. success: function (data) {
  496. if (data.code == 200) {
  497. layer.msg(data.msg);
  498. parent.layui.table.reload('tablerReload');
  499. TableClose();
  500. } else {
  501. layer.msg(data.msg)
  502. layer.msg(ReturnInfo(data.data), {icon: 5});
  503. }
  504. }
  505. });
  506. return false;
  507. })
  508. //检测关键词
  509. form.on('submit(check_words)', function (data) {
  510. var index = layer.msg('数据提交中,请稍候', {icon: 16, time: false, shade: 0.8}); //数据提交提示
  511. var content = UE.getEditor('editor_content').getContentTxt();
  512. var centhtml = UE.getEditor('editor_content').getContent();
  513. $.ajax({
  514. //cache : false,
  515. type: "post",
  516. url: "/sensitivewords/checkword",
  517. data: {content: content}, // 你的formid
  518. //contentType: false, //jax 中 contentType 设置为 false 是为了避免 JQuery 对其操作,从而失去分界符,而使服务器不能正常解析文件
  519. //processData: false, //当设置为true的时候,jquery ajax 提交的时候不会序列化 data,而是直接使用data
  520. error: function (request) {
  521. layer.close(index);
  522. layer.alert("网络超时");
  523. },
  524. success: function (data) {
  525. if (data.data != null) {
  526. var index = layer.open({
  527. type: 1,
  528. // skin: 'layui-layer-rim', //加上边框
  529. title: '违禁词信息',
  530. area: ['420px', '240px'], //宽高
  531. content: '<div style="color:red;">' + data.data + '</div>'
  532. });
  533. for (var i = 0; i < data.data.length; i++) {
  534. centhtml = centhtml.replace(data.data[i], "<span style='color: rgb(255, 0, 0);'>" + data.data[i] + "</span>");
  535. }
  536. UE.getEditor('editor_content').setContent(centhtml);
  537. layer.msg(data.msg)
  538. } else {
  539. layer.msg(data.msg)
  540. }
  541. }
  542. });
  543. return false;
  544. })
  545. //批量删除
  546. form.on('submit(del_alls_news)', function (data) {
  547. var checkStatus = table.checkStatus('tablerReload');
  548. if (typeof checkStatus.data[0] == 'object') {
  549. layer.confirm('您确定要删除吗?', {btn: ['确认', '取消']}, function () {
  550. var index = layer.msg('数据提交中,请稍候', {icon: 16, time: false, shade: 0.8}); //数据提交提示
  551. var formdat = new FormData();
  552. $.each(checkStatus.data, function (key, val) {
  553. formdat.append('id[]', val.id);
  554. })
  555. $.ajax({
  556. cache: true,
  557. type: "post",
  558. url: "/news/newsdel",
  559. data: formdat, // 你的formid
  560. contentType: false, //jax 中 contentType 设置为 false 是为了避免 JQuery 对其操作,从而失去分界符,而使服务器不能正常解析文件
  561. processData: false, //当设置为true的时候,jquery ajax 提交的时候不会序列化 data,而是直接使用data
  562. error: function (request) {
  563. layer.close(index); //关闭数据提交信息
  564. layer.alert("网络超时");
  565. },
  566. success: function (data) {
  567. if (data.code == 200) {
  568. layer.msg(data.msg);
  569. table.reload('tablerReload')
  570. } else {
  571. layer.msg(data.msg);
  572. }
  573. }
  574. });
  575. })
  576. return false;
  577. }
  578. layer.msg('请选择需要删除的资讯', {icon: 5});
  579. return false;
  580. })
  581. //
  582. // //同步资料
  583. // form.on('submit(batch_sync_submit)', function (data) {
  584. // var index = layer.msg('数据提交中,请稍候', {icon: 16, time: false, shade: 0.8}); //数据提交提示
  585. // $.ajax({
  586. // cache: true,
  587. // type: "post",
  588. // url: "/news/confirmsync",
  589. // data: data.field, // 你的formid
  590. // success: function (data) {
  591. // if (data.code == 200) {
  592. // layer.msg(data.msg);
  593. // parent.layui.table.reload('tablerReload');
  594. // TableClose();
  595. // } else if (data.code == 300) {
  596. // layer.msg(data.msg)
  597. // }
  598. // }
  599. // });
  600. // return false;
  601. // })
  602. });
  603. //删除图片
  604. $('#demo2').on("click", "#delimg", function () {
  605. var name = $(this).next().attr("imgname");
  606. var delIdentification = $(this).next().attr("delIdentification");
  607. if (typeof(delIdentification) != 'undefined') {
  608. delete filesContainer[delIdentification];
  609. delete files[delIdentification];
  610. }
  611. if (typeof(name) != 'undefined') {
  612. delFiles.push(name);
  613. }
  614. $(this).parent().remove();
  615. })
  616. function RestrictImgNum() {
  617. var imgNum = $('.layui-w-img').children('img').length;
  618. if (imgNum > 3 || imgNum == 3) {
  619. return false;
  620. }
  621. }
  622. $(function () {
  623. // 动态添加批量删除按钮
  624. var _btn = '<div class="layui-inline " style="float:left;position:relative;left:10px;bottom:35px">'
  625. + '<a class="layui-btn layui-btn-danger search_btn layui_w_btn" style="height:30px;line-height:30px;font-size:14px;" lay-submit="" lay-filter="del_alls_news">批量删除</a>'
  626. + '</div>'
  627. $('.layui-form').append(_btn)
  628. })
  629. //判断是否需要编辑,需要才加载
  630. var verdict = $('#editor_content').html();
  631. if (typeof verdict == "string") {
  632. var ue = UE.getEditor('editor_content'); //编辑器
  633. // 2018
  634. ue.addListener("keyup", function () {
  635. var arr = (UE.getEditor('editor_content').getContentTxt());
  636. console.log(arr)
  637. })
  638. }
  639. // 选择封面图弹窗选择项卡
  640. $('.layui-tab-title .site-demo-active').on('click', function () {
  641. $(this).addClass('layui-this').siblings().removeClass('layui-this');
  642. var lay_id = $(this).attr('lay-id');
  643. $('.layui-tab-item').removeClass('layui-show')
  644. $('.layui-tab-content #' + lay_id).addClass('layui-show')
  645. });
  646. // 弹窗本地选择图片删除功能
  647. function delImg(oid, delId) {
  648. $('#' + oid).on("click", "#" + delId, function () {
  649. var name = $(this).next().attr("imgname");
  650. var delIdentification = $(this).next().attr("delIdentification");
  651. if (typeof(delIdentification) != 'undefined') {
  652. delete filesContainer[delIdentification];
  653. delete files[delIdentification];
  654. }
  655. if (typeof(name) != 'undefined') {
  656. delFiles.push(name);
  657. }
  658. var _ksrc = $(this).parents('.layui-upload-img').find('img').attr('src');
  659. for (i in depositImg) {
  660. if (typeof depositImg[i] == "object") {
  661. if (depositImg[i].src == _ksrc) {
  662. depositImg.splice(i, 1); //取消选择时,从数组中删除
  663. }
  664. } else if (depositImg[i] == _ksrc) {
  665. depositImg.splice(i, 1); //取消选择时,从数组中删除
  666. }
  667. }
  668. $(this).parent().remove();
  669. })
  670. // 监听短标题输入的字符数
  671. $('.w-slug').on('input', function () {
  672. var count = $(this).val().length;
  673. $('.w-count').html(count)
  674. });
  675. }