common.js 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637
  1. /**
  2. * 通用方法封装处理
  3. * Copyright (c) 2019 ruoyi
  4. */
  5. var startLayDate;
  6. var endLayDate;
  7. var isScrollToTop = parent.isScrollToTop;
  8. $(function() {
  9. // 回到顶部绑定
  10. if ($.fn.toTop !== undefined) {
  11. $('#scroll-up').toTop();
  12. }
  13. // select2复选框事件绑定
  14. if ($.fn.select2 !== undefined) {
  15. $.fn.select2.defaults.set( "theme", "bootstrap" );
  16. $("select.form-control:not(.noselect2)").each(function () {
  17. $(this).select2().on("change", function () {
  18. $(this).valid();
  19. })
  20. })
  21. }
  22. // iCheck单选框及复选框事件绑定
  23. if ($.fn.iCheck !== undefined) {
  24. $(".check-box:not(.noicheck),.radio-box:not(.noicheck)").each(function() {
  25. $(this).iCheck({
  26. checkboxClass: 'icheckbox-blue',
  27. radioClass: 'iradio-blue',
  28. })
  29. })
  30. }
  31. // 取消回车自动提交表单
  32. $(document).on("keypress", ":input:not(textarea):not([type=submit])", function(event) {
  33. if (event.keyCode == 13) {
  34. event.preventDefault();
  35. }
  36. });
  37. // laydate 时间控件绑定
  38. if ($(".select-time").length > 0 && $('#startTime').length > 0 && $('#endTime').length > 0) {
  39. layui.use('laydate', function() {
  40. var laydate = layui.laydate;
  41. startLayDate = laydate.render({
  42. elem: '#startTime',
  43. max: $('#endTime').val(),
  44. theme: 'molv',
  45. type: $('#startTime').attr("data-type") || 'date',
  46. trigger: 'click',
  47. done: function(value, date) {
  48. // 结束时间大于开始时间
  49. if (value !== '') {
  50. endLayDate.config.min.year = date.year;
  51. endLayDate.config.min.month = date.month - 1;
  52. endLayDate.config.min.date = date.date;
  53. } else {
  54. endLayDate.config.min.year = '';
  55. endLayDate.config.min.month = '';
  56. endLayDate.config.min.date = '';
  57. }
  58. $('#endTime').trigger('click');
  59. }
  60. });
  61. endLayDate = laydate.render({
  62. elem: '#endTime',
  63. min: $('#startTime').val(),
  64. theme: 'molv',
  65. type: $('#endTime').attr("data-type") || 'date',
  66. trigger: 'click',
  67. done: function(value, date) {
  68. // 开始时间小于结束时间
  69. if (value !== '') {
  70. startLayDate.config.max.year = date.year;
  71. startLayDate.config.max.month = date.month - 1;
  72. startLayDate.config.max.date = date.date;
  73. } else {
  74. startLayDate.config.max.year = '2099';
  75. startLayDate.config.max.month = '12';
  76. startLayDate.config.max.date = '31';
  77. }
  78. }
  79. });
  80. });
  81. }
  82. // laydate time-input 时间控件绑定
  83. if ($(".time-input").length > 0) {
  84. layui.use('laydate', function () {
  85. var com = layui.laydate;
  86. $(".time-input").each(function (index, item) {
  87. var time = $(item);
  88. // 控制控件外观
  89. var type = time.attr("data-type") || 'date';
  90. // 控制回显格式
  91. var format = time.attr("data-format") || 'yyyy-MM-dd';
  92. // 控制日期控件按钮
  93. var buttons = time.attr("data-btn") || 'clear|now|confirm', newBtnArr = [];
  94. // 日期控件选择完成后回调处理
  95. var callback = time.attr("data-callback") || {};
  96. if (buttons) {
  97. if (buttons.indexOf("|") > 0) {
  98. var btnArr = buttons.split("|"), btnLen = btnArr.length;
  99. for (var j = 0; j < btnLen; j++) {
  100. if ("clear" === btnArr[j] || "now" === btnArr[j] || "confirm" === btnArr[j]) {
  101. newBtnArr.push(btnArr[j]);
  102. }
  103. }
  104. } else {
  105. if ("clear" === buttons || "now" === buttons || "confirm" === buttons) {
  106. newBtnArr.push(buttons);
  107. }
  108. }
  109. } else {
  110. newBtnArr = ['clear', 'now', 'confirm'];
  111. }
  112. com.render({
  113. elem: item,
  114. theme: 'molv',
  115. trigger: 'click',
  116. type: type,
  117. format: format,
  118. btns: newBtnArr,
  119. done: function (value, data) {
  120. if (typeof window[callback] != 'undefined'
  121. && window[callback] instanceof Function) {
  122. window[callback](value, data);
  123. }
  124. }
  125. });
  126. });
  127. });
  128. }
  129. // tree 关键字搜索绑定
  130. if ($("#keyword").length > 0) {
  131. $("#keyword").bind("focus", function focusKey(e) {
  132. if ($("#keyword").hasClass("empty")) {
  133. $("#keyword").removeClass("empty");
  134. }
  135. }).bind("blur", function blurKey(e) {
  136. if ($("#keyword").val() === "") {
  137. $("#keyword").addClass("empty");
  138. }
  139. $.tree.searchNode(e);
  140. }).bind("input propertychange", $.tree.searchNode);
  141. }
  142. // tree表格树 展开/折叠
  143. var expandFlag;
  144. $("#expandAllBtn").click(function() {
  145. var dataExpand = $.common.isEmpty(table.options.expandAll) ? true : table.options.expandAll;
  146. expandFlag = $.common.isEmpty(expandFlag) ? dataExpand : expandFlag;
  147. if (!expandFlag) {
  148. $.bttTable.bootstrapTreeTable('expandAll');
  149. } else {
  150. $.bttTable.bootstrapTreeTable('collapseAll');
  151. }
  152. expandFlag = expandFlag ? false: true;
  153. })
  154. // 按下ESC按钮关闭弹层
  155. $('body', document).on('keyup', function(e) {
  156. if (e.which === 27) {
  157. $.modal.closeAll();
  158. }
  159. });
  160. $(document).on('blur', 'input[type="text"], input[type="email"], textarea', function () {
  161. const $this = $(this);
  162. $this.val($.trim($this.val()));
  163. });
  164. // 放在 common.js 或每个页面公共的 JS 文件中
  165. $(document).ready(function () {
  166. // 监听所有表单提交事件
  167. $('form').on('submit', function () {
  168. $(this).find('input[type="text"], input[type="email"], textarea').each(function () {
  169. const $this = $(this);
  170. $this.val($.trim($this.val()));
  171. });
  172. });
  173. });
  174. });
  175. (function ($) {
  176. 'use strict';
  177. $.fn.toTop = function(opt) {
  178. var elem = this;
  179. var win = (opt && opt.hasOwnProperty('win')) ? opt.win : $(window);
  180. var doc = (opt && opt.hasOwnProperty('doc')) ? opt.doc : $('html, body');
  181. var options = $.extend({
  182. autohide: true,
  183. offset: 50,
  184. speed: 500,
  185. position: true,
  186. right: 15,
  187. bottom: 5
  188. }, opt);
  189. elem.css({
  190. 'cursor': 'pointer'
  191. });
  192. if (options.autohide) {
  193. elem.css('display', 'none');
  194. }
  195. if (options.position) {
  196. elem.css({
  197. 'position': 'fixed',
  198. 'right': options.right,
  199. 'bottom': options.bottom,
  200. });
  201. }
  202. elem.click(function() {
  203. doc.animate({
  204. scrollTop: 0
  205. }, options.speed);
  206. });
  207. win.scroll(function() {
  208. var scrolling = win.scrollTop();
  209. if (options.autohide) {
  210. if (scrolling > options.offset) {
  211. elem.fadeIn(options.speed);
  212. } else elem.fadeOut(options.speed);
  213. }
  214. });
  215. };
  216. })(jQuery);
  217. /** 刷新选项卡 */
  218. var refreshItem = function(){
  219. var topWindow = $(window.parent.document);
  220. var currentId = $('.page-tabs-content', topWindow).find('.active').attr('data-id');
  221. var target = $('.RuoYi_iframe[data-id="' + currentId + '"]', topWindow);
  222. var url = target.attr('src');
  223. target.attr('src', url).ready();
  224. }
  225. /** 关闭选项卡 */
  226. var closeItem = function(dataId){
  227. var topWindow = $(window.parent.document);
  228. if ($.common.isNotEmpty(dataId)) {
  229. window.parent.$.modal.closeLoading();
  230. // 根据dataId关闭指定选项卡
  231. $('.menuTab[data-id="' + dataId + '"]', topWindow).remove();
  232. // 移除相应tab对应的内容区
  233. $('.mainContent .RuoYi_iframe[data-id="' + dataId + '"]', topWindow).remove();
  234. return;
  235. }
  236. var panelUrl = window.frameElement.getAttribute('data-panel');
  237. $('.page-tabs-content .active i', topWindow).click();
  238. if ($.common.isNotEmpty(panelUrl)) {
  239. $('.menuTab[data-id="' + panelUrl + '"]', topWindow).addClass('active').siblings('.menuTab').removeClass('active');
  240. $('.mainContent .RuoYi_iframe', topWindow).each(function() {
  241. if ($(this).data('id') == panelUrl) {
  242. openToCurrentTab(this);
  243. return false;
  244. }
  245. });
  246. }
  247. }
  248. /** 创建选项卡 */
  249. function createMenuItem(dataUrl, menuName, isRefresh) {
  250. var panelUrl = window.frameElement.getAttribute('data-id'),
  251. dataIndex = $.common.random(1, 100),
  252. flag = true;
  253. if (dataUrl == undefined || $.trim(dataUrl).length == 0) return false;
  254. var topWindow = $(window.parent.document);
  255. // 选项卡菜单已存在
  256. $('.menuTab', topWindow).each(function() {
  257. if ($(this).data('id') == dataUrl) {
  258. if (!$(this).hasClass('active')) {
  259. $(this).addClass('active').siblings('.menuTab').removeClass('active');
  260. scrollToTab(this);
  261. $('.page-tabs-content').animate({ marginLeft: ""}, "fast");
  262. // 显示tab对应的内容区
  263. $('.mainContent .RuoYi_iframe', topWindow).each(function() {
  264. if ($(this).data('id') == dataUrl) {
  265. openToCurrentTab(this);
  266. return false;
  267. }
  268. });
  269. }
  270. if (isRefresh) {
  271. refreshTab();
  272. }
  273. flag = false;
  274. return false;
  275. }
  276. });
  277. // 选项卡菜单不存在
  278. if (flag) {
  279. var str = '<a href="javascript:;" class="active menuTab noactive" data-id="' + dataUrl + '" data-panel="' + panelUrl + '">' + menuName + ' <i class="fa fa-times-circle"></i></a>';
  280. $('.menuTab', topWindow).removeClass('active');
  281. // 添加选项卡对应的iframe
  282. var str1 = '<iframe class="RuoYi_iframe" name="iframe' + dataIndex + '" width="100%" height="100%" src="' + dataUrl + '" frameborder="0" data-id="' + dataUrl + '" data-panel="' + panelUrl + '" seamless></iframe>';
  283. if (isScrollToTop) {
  284. $('.mainContent', topWindow).find('iframe.RuoYi_iframe').hide().parents('.mainContent').append(str1);
  285. } else {
  286. $('.mainContent', topWindow).find('iframe.RuoYi_iframe').css({"visibility": "hidden", "position": "absolute"}).parents('.mainContent').append(str1);
  287. }
  288. window.parent.$.modal.loading(i18n("common.tip.loading"));
  289. $('.mainContent iframe:visible', topWindow).on('load', function() {
  290. window.parent.$.modal.closeLoading();
  291. });
  292. // 添加选项卡
  293. $('.menuTabs .page-tabs-content', topWindow).append(str);
  294. scrollToTab($('.menuTab.active', topWindow));
  295. }
  296. return false;
  297. }
  298. // 刷新iframe
  299. function refreshTab() {
  300. var topWindow = $(window.parent.document);
  301. var currentId = $('.page-tabs-content', topWindow).find('.active').attr('data-id');
  302. var target = $('.RuoYi_iframe[data-id="' + currentId + '"]', topWindow);
  303. var url = target.attr('src');
  304. target.attr('src', url).ready();
  305. }
  306. // 滚动到指定选项卡
  307. function scrollToTab(element) {
  308. var topWindow = $(window.parent.document);
  309. var marginLeftVal = calSumWidth($(element).prevAll()),
  310. marginRightVal = calSumWidth($(element).nextAll());
  311. // 可视区域非tab宽度
  312. var tabOuterWidth = calSumWidth($(".content-tabs", topWindow).children().not(".menuTabs"));
  313. //可视区域tab宽度
  314. var visibleWidth = $(".content-tabs", topWindow).outerWidth(true) - tabOuterWidth;
  315. //实际滚动宽度
  316. var scrollVal = 0;
  317. if ($(".page-tabs-content", topWindow).outerWidth() < visibleWidth) {
  318. scrollVal = 0;
  319. } else if (marginRightVal <= (visibleWidth - $(element).outerWidth(true) - $(element).next().outerWidth(true))) {
  320. if ((visibleWidth - $(element).next().outerWidth(true)) > marginRightVal) {
  321. scrollVal = marginLeftVal;
  322. var tabElement = element;
  323. while ((scrollVal - $(tabElement).outerWidth()) > ($(".page-tabs-content", topWindow).outerWidth() - visibleWidth)) {
  324. scrollVal -= $(tabElement).prev().outerWidth();
  325. tabElement = $(tabElement).prev();
  326. }
  327. }
  328. } else if (marginLeftVal > (visibleWidth - $(element).outerWidth(true) - $(element).prev().outerWidth(true))) {
  329. scrollVal = marginLeftVal - $(element).prev().outerWidth(true);
  330. }
  331. $('.page-tabs-content', topWindow).animate({ marginLeft: 0 - scrollVal + 'px' }, "fast");
  332. }
  333. // 计算元素集合的总宽度
  334. function calSumWidth(elements) {
  335. var width = 0;
  336. $(elements).each(function() {
  337. width += $(this).outerWidth(true);
  338. });
  339. return width;
  340. }
  341. // 返回当前激活的Tab页面关联的iframe的Windows对象
  342. function activeWindow() {
  343. var topWindow = $(window.parent.document);
  344. var currentId = $('.page-tabs-content', topWindow).find('.active').attr('data-id');
  345. if (!currentId) {
  346. return window.parent;
  347. }
  348. return $('.RuoYi_iframe[data-id="' + currentId + '"]', topWindow)[0].contentWindow;
  349. }
  350. function openToCurrentTab(obj) {
  351. if (isScrollToTop) {
  352. $(obj).show().siblings('.RuoYi_iframe').hide();
  353. } else {
  354. $(obj).css({"visibility": "visible", "position": "static"}).siblings('.RuoYi_iframe').css({"visibility": "hidden", "position": "absolute"});
  355. }
  356. }
  357. /** 密码规则范围验证 */
  358. function checkpwd(chrtype, password) {
  359. if (chrtype == 1) {
  360. if (!$.common.numValid(password)) {
  361. $.modal.alertWarning("密码只能为0-9数字");
  362. return false;
  363. }
  364. } else if (chrtype == 2) {
  365. if (!$.common.enValid(password)) {
  366. $.modal.alertWarning("密码只能为a-z和A-Z字母");
  367. return false;
  368. }
  369. } else if (chrtype == 3) {
  370. if (!$.common.enNumValid(password)) {
  371. $.modal.alertWarning("密码必须包含字母以及数字");
  372. return false;
  373. }
  374. } else if (chrtype == 4) {
  375. if (!$.common.charValid(password)) {
  376. $.modal.alertWarning("密码必须包含字母、数字、以及特殊符号<font color='red'>~!@#$%^&*()-=_+</font>");
  377. return false;
  378. }
  379. }
  380. return true;
  381. }
  382. /** 开始时间/时分秒 */
  383. function beginOfTime(date) {
  384. if ($.common.isNotEmpty(date)) {
  385. return $.common.sprintf("%s 00:00:00", date);
  386. }
  387. }
  388. /** 结束时间/时分秒 */
  389. function endOfTime(date) {
  390. if ($.common.isNotEmpty(date)) {
  391. return $.common.sprintf("%s 23:59:59", date);
  392. }
  393. }
  394. /** 重置日期/年月日 */
  395. function resetDate() {
  396. if ($.common.isNotEmpty(startLayDate) && $.common.isNotEmpty(endLayDate)) {
  397. endLayDate.config.min.year = '';
  398. endLayDate.config.min.month = '';
  399. endLayDate.config.min.date = '';
  400. startLayDate.config.max.year = '2099';
  401. startLayDate.config.max.month = '12';
  402. startLayDate.config.max.date = '31';
  403. }
  404. }
  405. // 日志打印封装处理
  406. var log = {
  407. log: function(msg) {
  408. console.log(msg);
  409. },
  410. info: function(msg) {
  411. console.info(msg);
  412. },
  413. warn: function(msg) {
  414. console.warn(msg);
  415. },
  416. error: function(msg) {
  417. console.error(msg);
  418. }
  419. };
  420. // 本地缓存处理
  421. var storage = {
  422. set: function(key, value) {
  423. window.localStorage.setItem(key, value);
  424. },
  425. get: function(key) {
  426. return window.localStorage.getItem(key);
  427. },
  428. remove: function(key) {
  429. window.localStorage.removeItem(key);
  430. },
  431. clear: function() {
  432. window.localStorage.clear();
  433. }
  434. };
  435. // 主子表操作封装处理
  436. var sub = {
  437. editRow: function() {
  438. var dataColumns = [];
  439. for (var columnIndex = 0; columnIndex < table.options.columns.length; columnIndex++) {
  440. if (table.options.columns[columnIndex].visible != false) {
  441. dataColumns.push(table.options.columns[columnIndex]);
  442. }
  443. }
  444. var params = new Array();
  445. var data = $("#" + table.options.id).bootstrapTable('getData');
  446. var count = data.length;
  447. for (var dataIndex = 0; dataIndex < count; dataIndex++) {
  448. var columns = $('#' + table.options.id + ' tr[data-index="' + dataIndex + '"] td:visible');
  449. var obj = new Object();
  450. for (var i = 0; i < columns.length; i++) {
  451. var inputValue = $(columns[i]).find('input');
  452. var selectValue = $(columns[i]).find('select');
  453. var textareaValue = $(columns[i]).find('textarea');
  454. var key = dataColumns[i].field;
  455. if ($.common.isNotEmpty(inputValue.val())) {
  456. obj[key] = inputValue.val();
  457. } else if ($.common.isNotEmpty(selectValue.val())) {
  458. obj[key] = selectValue.val();
  459. } else if ($.common.isNotEmpty(textareaValue.val())) {
  460. obj[key] = textareaValue.val();
  461. } else {
  462. if (key == "index" && $.common.isNotEmpty(data[dataIndex].index)) {
  463. obj[key] = data[dataIndex].index;
  464. } else {
  465. obj[key] = "";
  466. }
  467. }
  468. }
  469. var item = data[dataIndex];
  470. var extendObj = $.extend({}, item, obj);
  471. params.push({ index: dataIndex, row: extendObj });
  472. }
  473. $("#" + table.options.id).bootstrapTable("updateRow", params);
  474. },
  475. delRow: function(column) {
  476. sub.editRow();
  477. var subColumn = $.common.isEmpty(column) ? "index" : column;
  478. var ids = $.table.selectColumns(subColumn);
  479. if (ids.length == 0) {
  480. $.modal.alertWarning("请至少选择一条记录");
  481. return;
  482. }
  483. $("#" + table.options.id).bootstrapTable('remove', { field: subColumn, values: ids });
  484. },
  485. delRowByIndex: function(value, tableId) {
  486. var currentId = $.common.isEmpty(tableId) ? table.options.id : tableId;
  487. sub.editRow();
  488. $("#" + currentId).bootstrapTable('remove', { field: "index", values: [value] });
  489. sub.editRow();
  490. },
  491. addRow: function(row, tableId) {
  492. var currentId = $.common.isEmpty(tableId) ? table.options.id : tableId;
  493. table.set(currentId);
  494. var count = $("#" + currentId).bootstrapTable('getData').length;
  495. sub.editRow();
  496. $("#" + currentId).bootstrapTable('insertRow', { index: count + 1, row: row });
  497. }
  498. };
  499. // 动态加载css文件
  500. function loadCss(file, headElem) {
  501. var link = document.createElement('link');
  502. link.href = file;
  503. link.rel = 'stylesheet';
  504. link.type = 'text/css';
  505. if (headElem) headElem.appendChild(link);
  506. else document.getElementsByTagName('head')[0].appendChild(link);
  507. }
  508. // 动态加载js文件
  509. function loadJs(file, headElem) {
  510. var script = document.createElement('script');
  511. script.src = file;
  512. script.type = 'text/javascript';
  513. if (headElem) headElem.appendChild(script);
  514. else document.getElementsByTagName('head')[0].appendChild(script);
  515. }
  516. // 禁止后退键(Backspace)
  517. window.onload = function() {
  518. document.getElementsByTagName("body")[0].onkeydown = function() {
  519. // 获取事件对象
  520. var elem = event.relatedTarget || event.srcElement || event.target || event.currentTarget;
  521. // 判断按键为backSpace键
  522. if (event.keyCode == 8) {
  523. // 判断是否需要阻止按下键盘的事件默认传递
  524. var name = elem.nodeName;
  525. var className = elem.className;
  526. // 屏蔽特定的样式名称
  527. if (className.indexOf('note-editable') != -1)
  528. {
  529. return true;
  530. }
  531. if (name != 'INPUT' && name != 'TEXTAREA') {
  532. return _stopIt(event);
  533. }
  534. var type_e = elem.type.toUpperCase();
  535. if (name == 'INPUT' && (type_e != 'TEXT' && type_e != 'TEXTAREA' && type_e != 'PASSWORD' && type_e != 'FILE' && type_e != 'SEARCH' && type_e != 'NUMBER' && type_e != 'EMAIL' && type_e != 'URL')) {
  536. return _stopIt(event);
  537. }
  538. if (name == 'INPUT' && (elem.readOnly == true || elem.disabled == true)) {
  539. return _stopIt(event);
  540. }
  541. }
  542. };
  543. };
  544. function _stopIt(e) {
  545. if (e.returnValue) {
  546. e.returnValue = false;
  547. }
  548. if (e.preventDefault) {
  549. e.preventDefault();
  550. }
  551. return false;
  552. }
  553. /** 设置全局ajax处理 */
  554. $.ajaxSetup({
  555. complete: function(XMLHttpRequest, textStatus) {
  556. // 获取请求的URL
  557. var url = this.url;
  558. // 如果是语言包加载失败,则不提示
  559. if (url && url.indexOf('i18n/messages') >= 0) {
  560. return
  561. }
  562. if (textStatus == 'timeout') {
  563. $.modal.alertWarning("服务器超时,请稍后再试!");
  564. $.modal.enable();
  565. $.modal.closeLoading();
  566. } else if (textStatus == "parsererror" || textStatus == "error") {
  567. $.modal.alertWarning("服务器错误,请联系管理员!");
  568. $.modal.enable();
  569. $.modal.closeLoading();
  570. }
  571. }
  572. });
  573. /**
  574. * 处理服务器Ajax响应,用于表单保存信息提示;
  575. **/
  576. function processAjaxReponseJson(response){
  577. let tips = "";
  578. if(typeof(response["msg"]) != "undefined"){
  579. if(response["msg"].length > 0){
  580. tips = response["msg"].replace(new RegExp("\n","gm"),"<br />");
  581. }
  582. }
  583. if(response["code"] === 0) {
  584. if(tips.length == 0 ) { tips = '配置保存成功!' };
  585. $.modal.msgSuccess(tips);
  586. $.modal.closeLoading();
  587. $.modal.enable();
  588. }
  589. if(response["code"] === 500) {
  590. if(tips.length == 0 ) { tips = '配置保存失败!' };
  591. console.error('Error saving configuration:', tips);
  592. $.modal.msgError(tips);
  593. $.modal.closeLoading();
  594. $.modal.enable();
  595. }
  596. };