ry-ui.js 51 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225
  1. /**
  2. * 通用js方法封装处理
  3. * Copyright (c) 2019 ruoyi
  4. */
  5. (function ($) {
  6. $.extend({
  7. _treeTable: {},
  8. _tree: {},
  9. // 表格封装处理
  10. table: {
  11. _option: {},
  12. // 初始化表格参数
  13. init: function(options) {
  14. var defaults = {
  15. id: "bootstrap-table",
  16. type: 0, // 0 代表bootstrapTable 1代表bootstrapTreeTable
  17. height: undefined,
  18. sidePagination: "server",
  19. sortName: "",
  20. sortOrder: "asc",
  21. pagination: true,
  22. pageSize: 10,
  23. toolbar: "toolbar",
  24. striped: false,
  25. escape: false,
  26. showFooter: false,
  27. search: false,
  28. showSearch: true,
  29. showPageGo: false,
  30. showRefresh: true,
  31. showColumns: true,
  32. showToggle: true,
  33. showExport: false,
  34. clickToSelect: false,
  35. rememberSelected: false,
  36. fixedColumns: false,
  37. fixedNumber: 0,
  38. rightFixedColumns: false,
  39. rightFixedNumber: 0,
  40. queryParams: $.table.queryParams,
  41. rowStyle: {},
  42. };
  43. var options = $.extend(defaults, options);
  44. $.table._option = options;
  45. $.table.initEvent();
  46. $('#' + options.id).bootstrapTable({
  47. url: options.url, // 请求后台的URL(*)
  48. contentType: "application/x-www-form-urlencoded", // 编码类型
  49. method: 'post', // 请求方式(*)
  50. cache: false, // 是否使用缓存
  51. height: options.height, // 表格的高度
  52. striped: options.striped, // 是否显示行间隔色
  53. sortable: true, // 是否启用排序
  54. sortStable: true, // 设置为 true 将获得稳定的排序
  55. sortName: options.sortName, // 排序列名称
  56. sortOrder: options.sortOrder, // 排序方式 asc 或者 desc
  57. pagination: options.pagination, // 是否显示分页(*)
  58. pageNumber: 1, // 初始化加载第一页,默认第一页
  59. pageSize: options.pageSize, // 每页的记录行数(*)
  60. pageList: [10, 25, 50], // 可供选择的每页的行数(*)
  61. escape: options.escape, // 转义HTML字符串
  62. showFooter: options.showFooter, // 是否显示表尾
  63. iconSize: 'outline', // 图标大小:undefined默认的按钮尺寸 xs超小按钮sm小按钮lg大按钮
  64. toolbar: '#' + options.toolbar, // 指定工作栏
  65. sidePagination: options.sidePagination, // server启用服务端分页client客户端分页
  66. search: options.search, // 是否显示搜索框功能
  67. showSearch: options.showSearch, // 是否显示检索信息
  68. showPageGo: options.showPageGo, // 是否显示跳转页
  69. showRefresh: options.showRefresh, // 是否显示刷新按钮
  70. showColumns: options.showColumns, // 是否显示隐藏某列下拉框
  71. showToggle: options.showToggle, // 是否显示详细视图和列表视图的切换按钮
  72. showExport: options.showExport, // 是否支持导出文件
  73. clickToSelect: options.clickToSelect, // 是否启用点击选中行
  74. rememberSelected: options.rememberSelected, // 启用翻页记住前面的选择
  75. fixedColumns: options.fixedColumns, // 是否启用冻结列(左侧)
  76. fixedNumber: options.fixedNumber, // 列冻结的个数(左侧)
  77. rightFixedColumns: options.rightFixedColumns, // 是否启用冻结列(右侧)
  78. rightFixedNumber: options.rightFixedNumber, // 列冻结的个数(右侧)
  79. queryParams: options.queryParams, // 传递参数(*)
  80. rowStyle: options.rowStyle, // 通过自定义函数设置行样式
  81. columns: options.columns, // 显示列信息(*)
  82. responseHandler: $.table.responseHandler, // 在加载服务器发送来的数据之前处理函数
  83. onLoadSuccess: $.table.onLoadSuccess, // 当所有数据被加载时触发处理函数
  84. });
  85. },
  86. // 查询条件
  87. queryParams: function(params) {
  88. return {
  89. // 传递参数查询参数
  90. pageSize: params.limit,
  91. pageNum: params.offset / params.limit + 1,
  92. searchValue: params.search,
  93. orderByColumn: params.sort,
  94. isAsc: params.order
  95. };
  96. },
  97. // 请求获取数据后处理回调函数
  98. responseHandler: function(res) {
  99. if (res.code == 0) {
  100. if ($.common.isNotEmpty($.table._option.sidePagination) && $.table._option.sidePagination == 'client') {
  101. return res.rows;
  102. } else {
  103. if ($.common.isNotEmpty($.table._option.rememberSelected) && $.table._option.rememberSelected) {
  104. var column = $.common.isEmpty($.table._option.uniqueId) ? $.table._option.columns[1].field : $.table._option.uniqueId;
  105. $.each(res.rows, function(i, row) {
  106. row.state = $.inArray(row[column], selectionIds) !== -1;
  107. })
  108. }
  109. return { rows: res.rows, total: res.total };
  110. }
  111. } else {
  112. $.modal.alertWarning(res.msg);
  113. return { rows: [], total: 0 };
  114. }
  115. },
  116. // 初始化事件
  117. initEvent: function(data) {
  118. // 触发行点击事件 加载成功事件
  119. $("#" + $.table._option.id).on("check.bs.table uncheck.bs.table check-all.bs.table uncheck-all.bs.table load-success.bs.table", function () {
  120. // 工具栏按钮控制
  121. var rows = $.common.isEmpty($.table._option.uniqueId) ? $.table.selectFirstColumns() : $.table.selectColumns($.table._option.uniqueId);
  122. $('#' + $.table._option.toolbar + ' .btn-del').toggleClass('disabled', !rows.length);
  123. $('#' + $.table._option.toolbar + ' .btn-edit').toggleClass('disabled', rows.length!=1);
  124. });
  125. // 绑定选中事件、取消事件、全部选中、全部取消
  126. $("#" + $.table._option.id).on("check.bs.table check-all.bs.table uncheck.bs.table uncheck-all.bs.table", function (e, rows) {
  127. // 复选框分页保留保存选中数组
  128. var rowIds = $.table.affectedRowIds(rows);
  129. if ($.common.isNotEmpty($.table._option.rememberSelected) && $.table._option.rememberSelected) {
  130. func = $.inArray(e.type, ['check', 'check-all']) > -1 ? 'union' : 'difference';
  131. selectionIds = _[func](selectionIds, rowIds);
  132. }
  133. });
  134. },
  135. // 当所有数据被加载时触发
  136. onLoadSuccess: function(data) {
  137. // 浮动提示框特效
  138. $("[data-toggle='tooltip']").tooltip();
  139. },
  140. // 表格销毁
  141. destroy: function (tableId) {
  142. var currentId = $.common.isEmpty(tableId) ? $.table._option.id : tableId;
  143. $("#" + currentId).bootstrapTable('destroy');
  144. },
  145. // 序列号生成
  146. serialNumber: function (index) {
  147. var table = $('#' + $.table._option.id).bootstrapTable('getOptions');
  148. var pageSize = table.pageSize;
  149. var pageNumber = table.pageNumber;
  150. return pageSize * (pageNumber - 1) + index + 1;
  151. },
  152. // 列超出指定长度浮动提示
  153. tooltip: function (value, length) {
  154. var _length = $.common.isEmpty(length) ? 20 : length;
  155. var _text = "";
  156. var _value = $.common.nullToStr(value);
  157. if (_value.length > _length) {
  158. _text = _value.substr(0, _length) + "...";
  159. return $.common.sprintf("<a href='#' class='tooltip-show' data-toggle='tooltip' title='%s'>%s</a>", _value, _text);
  160. } else {
  161. _text = _value;
  162. return _text;
  163. }
  164. },
  165. // 下拉按钮切换
  166. dropdownToggle: function (value) {
  167. var actions = [];
  168. actions.push('<div class="btn-group">');
  169. actions.push('<button type="button" class="btn btn-xs dropdown-toggle" data-toggle="dropdown" aria-expanded="false">');
  170. actions.push('<i class="fa fa-cog"></i>&nbsp;<span class="fa fa-chevron-down"></span></button>');
  171. actions.push('<ul class="dropdown-menu">');
  172. actions.push(value.replace(/<a/g,"<li><a").replace(/<\/a>/g,"</a></li>"));
  173. actions.push('</ul>');
  174. actions.push('</div>');
  175. return actions.join('');
  176. },
  177. // 搜索-默认第一个form
  178. search: function(formId) {
  179. var currentId = $.common.isEmpty(formId) ? $('form').attr('id') : formId;
  180. var params = $("#" + $.table._option.id).bootstrapTable('getOptions');
  181. params.queryParams = function(params) {
  182. var search = {};
  183. $.each($("#" + currentId).serializeArray(), function(i, field) {
  184. search[field.name] = field.value;
  185. });
  186. search.pageSize = params.limit;
  187. search.pageNum = params.offset / params.limit + 1;
  188. search.searchValue = params.search;
  189. search.orderByColumn = params.sort;
  190. search.isAsc = params.order;
  191. return search;
  192. }
  193. $("#" + $.table._option.id).bootstrapTable('refresh', params);
  194. },
  195. // 导出数据
  196. exportExcel: function(formId) {
  197. $.modal.confirm("确定导出所有" + $.table._option.modalName + "吗?", function() {
  198. var currentId = $.common.isEmpty(formId) ? $('form').attr('id') : formId;
  199. $.modal.loading("正在导出数据,请稍后...");
  200. $.post($.table._option.exportUrl, $("#" + currentId).serializeArray(), function(result) {
  201. if (result.code == web_status.SUCCESS) {
  202. window.location.href = ctx + "common/download?fileName=" + encodeURI(result.msg) + "&delete=" + true;
  203. } else if (result.code == web_status.WARNING) {
  204. $.modal.alertWarning(result.msg)
  205. } else {
  206. $.modal.alertError(result.msg);
  207. }
  208. $.modal.closeLoading();
  209. });
  210. });
  211. },
  212. // 下载模板
  213. importTemplate: function() {
  214. $.get($.table._option.importTemplateUrl, function(result) {
  215. if (result.code == web_status.SUCCESS) {
  216. window.location.href = ctx + "common/download?fileName=" + encodeURI(result.msg) + "&delete=" + true;
  217. } else if (result.code == web_status.WARNING) {
  218. $.modal.alertWarning(result.msg)
  219. } else {
  220. $.modal.alertError(result.msg);
  221. }
  222. });
  223. },
  224. // 导入数据
  225. importExcel: function(formId) {
  226. var currentId = $.common.isEmpty(formId) ? 'importForm' : formId;
  227. $.form.reset(currentId);
  228. layer.open({
  229. type: 1,
  230. area: ['400px', '230px'],
  231. fix: false,
  232. //不固定
  233. maxmin: true,
  234. shade: 0.3,
  235. title: '导入' + $.table._option.modalName + '数据',
  236. content: $('#' + currentId),
  237. btn: ['<i class="fa fa-check"></i> 导入', '<i class="fa fa-remove"></i> 取消'],
  238. // 弹层外区域关闭
  239. shadeClose: true,
  240. btn1: function(index, layero){
  241. var file = layero.find('#file').val();
  242. if (file == '' || (!$.common.endWith(file, '.xls') && !$.common.endWith(file, '.xlsx'))){
  243. $.modal.msgWarning("请选择后缀为 “xls”或“xlsx”的文件。");
  244. return false;
  245. }
  246. var index = layer.load(2, {shade: false});
  247. $.modal.disable();
  248. var formData = new FormData();
  249. formData.append("file", $('#file')[0].files[0]);
  250. formData.append("updateSupport", $("input[name='updateSupport']").is(':checked'));
  251. $.ajax({
  252. url: $.table._option.importUrl,
  253. data: formData,
  254. cache: false,
  255. contentType: false,
  256. processData: false,
  257. type: 'POST',
  258. success: function (result) {
  259. if (result.code == web_status.SUCCESS) {
  260. $.modal.closeAll();
  261. $.modal.alertSuccess(result.msg);
  262. $.table.refresh();
  263. } else if (result.code == web_status.WARNING) {
  264. layer.close(index);
  265. $.modal.enable();
  266. $.modal.alertWarning(result.msg)
  267. } else {
  268. layer.close(index);
  269. $.modal.enable();
  270. $.modal.alertError(result.msg);
  271. }
  272. }
  273. });
  274. }
  275. });
  276. },
  277. // 刷新表格
  278. refresh: function() {
  279. $("#" + $.table._option.id).bootstrapTable('refresh', {
  280. silent: true
  281. });
  282. },
  283. // 查询表格指定列值
  284. selectColumns: function(column) {
  285. var rows = $.map($('#' + $.table._option.id).bootstrapTable('getSelections'), function (row) {
  286. return row[column];
  287. });
  288. if ($.common.isNotEmpty($.table._option.rememberSelected) && $.table._option.rememberSelected) {
  289. rows = rows.concat(selectionIds);
  290. }
  291. return $.common.uniqueFn(rows);
  292. },
  293. // 获取当前页选中或者取消的行ID
  294. affectedRowIds: function(rows) {
  295. var column = $.common.isEmpty($.table._option.uniqueId) ? $.table._option.columns[1].field : $.table._option.uniqueId;
  296. var rowIds;
  297. if ($.isArray(rows)) {
  298. rowIds = $.map(rows, function(row) {
  299. return row[column];
  300. });
  301. } else {
  302. rowIds = [rows[column]];
  303. }
  304. return rowIds;
  305. },
  306. // 查询表格首列值
  307. selectFirstColumns: function() {
  308. var rows = $.map($('#' + $.table._option.id).bootstrapTable('getSelections'), function (row) {
  309. return row[$.table._option.columns[1].field];
  310. });
  311. if ($.common.isNotEmpty($.table._option.rememberSelected) && $.table._option.rememberSelected) {
  312. rows = rows.concat(selectionIds);
  313. }
  314. return $.common.uniqueFn(rows);
  315. },
  316. // 回显数据字典
  317. selectDictLabel: function(datas, value) {
  318. var actions = [];
  319. $.each(datas, function(index, dict) {
  320. if (dict.dictValue == ('' + value)) {
  321. var listClass = $.common.equals("default", dict.listClass) ? "" : "badge badge-" + dict.listClass;
  322. actions.push($.common.sprintf("<span class='%s'>%s</span>", listClass, dict.dictLabel));
  323. return false;
  324. }
  325. });
  326. return actions.join('');
  327. },
  328. // 显示表格指定列
  329. showColumn: function(column) {
  330. $("#" + $.table._option.id).bootstrapTable('showColumn', column);
  331. },
  332. // 隐藏表格指定列
  333. hideColumn: function(column) {
  334. $("#" + $.table._option.id).bootstrapTable('hideColumn', column);
  335. }
  336. },
  337. // 表格树封装处理
  338. treeTable: {
  339. // 初始化表格
  340. init: function(options) {
  341. var defaults = {
  342. id: "bootstrap-tree-table",
  343. type: 1, // 0 代表bootstrapTable 1代表bootstrapTreeTable
  344. height: 0,
  345. rootIdValue: null,
  346. ajaxParams: {},
  347. toolbar: "toolbar",
  348. striped: false,
  349. expandColumn: 1,
  350. showRefresh: true,
  351. showColumns: true,
  352. expandAll: true,
  353. expandFirst: true
  354. };
  355. var options = $.extend(defaults, options);
  356. $.table._option = options;
  357. var treeTable = $('#' + options.id).bootstrapTreeTable({
  358. code: options.code, // 用于设置父子关系
  359. parentCode: options.parentCode, // 用于设置父子关系
  360. type: 'get', // 请求方式(*)
  361. url: options.url, // 请求后台的URL(*)
  362. ajaxParams: options.ajaxParams, // 请求数据的ajax的data属性
  363. rootIdValue: options.rootIdValue, // 设置指定根节点id值
  364. height: options.height, // 表格树的高度
  365. expandColumn: options.expandColumn, // 在哪一列上面显示展开按钮
  366. striped: options.striped, // 是否显示行间隔色
  367. bordered: true, // 是否显示边框
  368. toolbar: '#' + options.toolbar, // 指定工作栏
  369. showRefresh: options.showRefresh, // 是否显示刷新按钮
  370. showColumns: options.showColumns, // 是否显示隐藏某列下拉框
  371. expandAll: options.expandAll, // 是否全部展开
  372. expandFirst: options.expandFirst, // 是否默认第一级展开--expandAll为false时生效
  373. columns: options.columns
  374. });
  375. $._treeTable = treeTable;
  376. },
  377. // 条件查询
  378. search: function(formId) {
  379. var currentId = $.common.isEmpty(formId) ? $('form').attr('id') : formId;
  380. var params = {};
  381. $.each($("#" + currentId).serializeArray(), function(i, field) {
  382. params[field.name] = field.value;
  383. });
  384. $._treeTable.bootstrapTreeTable('refresh', params);
  385. },
  386. // 刷新
  387. refresh: function() {
  388. $._treeTable.bootstrapTreeTable('refresh');
  389. },
  390. },
  391. // 表单封装处理
  392. form: {
  393. // 表单重置
  394. reset: function(formId) {
  395. var currentId = $.common.isEmpty(formId) ? $('form').attr('id') : formId;
  396. $("#" + currentId)[0].reset();
  397. },
  398. // 获取选中复选框项
  399. selectCheckeds: function(name) {
  400. var checkeds = "";
  401. $('input:checkbox[name="' + name + '"]:checked').each(function(i) {
  402. if (0 == i) {
  403. checkeds = $(this).val();
  404. } else {
  405. checkeds += ("," + $(this).val());
  406. }
  407. });
  408. return checkeds;
  409. },
  410. // 获取选中下拉框项
  411. selectSelects: function(name) {
  412. var selects = "";
  413. $('#' + name + ' option:selected').each(function (i) {
  414. if (0 == i) {
  415. selects = $(this).val();
  416. } else {
  417. selects += ("," + $(this).val());
  418. }
  419. });
  420. return selects;
  421. }
  422. },
  423. // 弹出层封装处理
  424. modal: {
  425. // 显示图标
  426. icon: function(type) {
  427. var icon = "";
  428. if (type == modal_status.WARNING) {
  429. icon = 0;
  430. } else if (type == modal_status.SUCCESS) {
  431. icon = 1;
  432. } else if (type == modal_status.FAIL) {
  433. icon = 2;
  434. } else {
  435. icon = 3;
  436. }
  437. return icon;
  438. },
  439. // 消息提示
  440. msg: function(content, type) {
  441. if (type != undefined) {
  442. layer.msg(content, { icon: $.modal.icon(type), time: 1000, shift: 5 });
  443. } else {
  444. layer.msg(content);
  445. }
  446. },
  447. // 错误消息
  448. msgError: function(content) {
  449. $.modal.msg(content, modal_status.FAIL);
  450. },
  451. // 成功消息
  452. msgSuccess: function(content) {
  453. $.modal.msg(content, modal_status.SUCCESS);
  454. },
  455. // 警告消息
  456. msgWarning: function(content) {
  457. $.modal.msg(content, modal_status.WARNING);
  458. },
  459. // 弹出提示
  460. alert: function(content, type) {
  461. layer.alert(content, {
  462. icon: $.modal.icon(type),
  463. title: "系统提示",
  464. btn: ['确认'],
  465. btnclass: ['btn btn-primary'],
  466. });
  467. },
  468. // 消息提示并刷新父窗体
  469. msgReload: function(msg, type) {
  470. layer.msg(msg, {
  471. icon: $.modal.icon(type),
  472. time: 500,
  473. shade: [0.1, '#8F8F8F']
  474. },
  475. function() {
  476. $.modal.reload();
  477. });
  478. },
  479. // 错误提示
  480. alertError: function(content) {
  481. $.modal.alert(content, modal_status.FAIL);
  482. },
  483. // 成功提示
  484. alertSuccess: function(content) {
  485. $.modal.alert(content, modal_status.SUCCESS);
  486. },
  487. // 警告提示
  488. alertWarning: function(content) {
  489. $.modal.alert(content, modal_status.WARNING);
  490. },
  491. // 关闭窗体
  492. close: function () {
  493. var index = parent.layer.getFrameIndex(window.name);
  494. parent.layer.close(index);
  495. },
  496. // 关闭全部窗体
  497. closeAll: function () {
  498. layer.closeAll();
  499. },
  500. // 确认窗体
  501. confirm: function (content, callBack) {
  502. layer.confirm(content, {
  503. icon: 3,
  504. title: "系统提示",
  505. btn: ['确认', '取消'],
  506. btnclass: ['btn btn-primary', 'btn btn-danger'],
  507. }, function (index) {
  508. layer.close(index);
  509. callBack(true);
  510. });
  511. },
  512. // 弹出层指定宽度
  513. open: function (title, url, width, height, callback) {
  514. //如果是移动端,就使用自适应大小弹窗
  515. if (navigator.userAgent.match(/(iPhone|iPod|Android|ios)/i)) {
  516. width = 'auto';
  517. height = 'auto';
  518. }
  519. if ($.common.isEmpty(title)) {
  520. title = false;
  521. };
  522. if ($.common.isEmpty(url)) {
  523. url = "/404.html";
  524. };
  525. if ($.common.isEmpty(width)) {
  526. width = 800;
  527. };
  528. if ($.common.isEmpty(height)) {
  529. height = ($(window).height() - 50);
  530. };
  531. if ($.common.isEmpty(callback)) {
  532. callback = function(index, layero) {
  533. var iframeWin = layero.find('iframe')[0];
  534. iframeWin.contentWindow.submitHandler();
  535. }
  536. }
  537. layer.open({
  538. type: 2,
  539. area: [width + 'px', height + 'px'],
  540. fix: false,
  541. //不固定
  542. maxmin: true,
  543. shade: 0.3,
  544. title: title,
  545. content: url,
  546. btn: ['确定', '关闭'],
  547. // 弹层外区域关闭
  548. shadeClose: true,
  549. yes: callback,
  550. cancel: function(index) {
  551. return true;
  552. }
  553. });
  554. },
  555. // 弹出层指定参数选项
  556. openOptions: function (options) {
  557. var _url = $.common.isEmpty(options.url) ? "/404.html" : options.url;
  558. var _title = $.common.isEmpty(options.title) ? "系统窗口" : options.title;
  559. var _width = $.common.isEmpty(options.width) ? "800" : options.width;
  560. var _height = $.common.isEmpty(options.height) ? ($(window).height() - 50) : options.height;
  561. layer.open({
  562. type: 2,
  563. maxmin: true,
  564. shade: 0.3,
  565. title: _title,
  566. fix: false,
  567. area: [_width + 'px', _height + 'px'],
  568. content: _url,
  569. shadeClose: true,
  570. btn: ['<i class="fa fa-check"></i> 确认', '<i class="fa fa-close"></i> 关闭'],
  571. yes: function (index, layero) {
  572. options.callBack(index, layero)
  573. }, cancel: function () {
  574. return true;
  575. }
  576. });
  577. },
  578. // 弹出层全屏
  579. openFull: function (title, url, width, height) {
  580. //如果是移动端,就使用自适应大小弹窗
  581. if (navigator.userAgent.match(/(iPhone|iPod|Android|ios)/i)) {
  582. width = 'auto';
  583. height = 'auto';
  584. }
  585. if ($.common.isEmpty(title)) {
  586. title = false;
  587. };
  588. if ($.common.isEmpty(url)) {
  589. url = "/404.html";
  590. };
  591. if ($.common.isEmpty(width)) {
  592. width = 800;
  593. };
  594. if ($.common.isEmpty(height)) {
  595. height = ($(window).height() - 50);
  596. };
  597. var index = layer.open({
  598. type: 2,
  599. area: [width + 'px', height + 'px'],
  600. fix: false,
  601. //不固定
  602. maxmin: true,
  603. shade: 0.3,
  604. title: title,
  605. content: url,
  606. btn: ['确定', '关闭'],
  607. // 弹层外区域关闭
  608. shadeClose: true,
  609. yes: function(index, layero) {
  610. var iframeWin = layero.find('iframe')[0];
  611. iframeWin.contentWindow.submitHandler();
  612. },
  613. cancel: function(index) {
  614. return true;
  615. }
  616. });
  617. layer.full(index);
  618. },
  619. // 选卡页方式打开
  620. openTab: function (title, url) {
  621. createMenuItem(url, title);
  622. },
  623. // 禁用按钮
  624. disable: function() {
  625. var doc = window.top == window.parent ? window.document : window.parent.document;
  626. $("a[class*=layui-layer-btn]", doc).addClass("layer-disabled");
  627. },
  628. // 启用按钮
  629. enable: function() {
  630. var doc = window.top == window.parent ? window.document : window.parent.document;
  631. $("a[class*=layui-layer-btn]", doc).removeClass("layer-disabled");
  632. },
  633. // 打开遮罩层
  634. loading: function (message) {
  635. $.blockUI({ message: '<div class="loaderbox"><div class="loading-activity"></div> ' + message + '</div>' });
  636. },
  637. // 关闭遮罩层
  638. closeLoading: function () {
  639. setTimeout(function(){
  640. $.unblockUI();
  641. }, 50);
  642. },
  643. // 重新加载
  644. reload: function () {
  645. parent.location.reload();
  646. }
  647. },
  648. // 操作封装处理
  649. operate: {
  650. // 提交数据
  651. submit: function(url, type, dataType, data) {
  652. var config = {
  653. url: url,
  654. type: type,
  655. dataType: dataType,
  656. data: data,
  657. beforeSend: function () {
  658. $.modal.loading("正在处理中,请稍后...");
  659. },
  660. success: function(result) {
  661. $.operate.ajaxSuccess(result);
  662. }
  663. };
  664. $.ajax(config)
  665. },
  666. // post请求传输
  667. post: function(url, data) {
  668. $.operate.submit(url, "post", "json", data);
  669. },
  670. // get请求传输
  671. get: function(url) {
  672. $.operate.submit(url, "get", "json", "");
  673. },
  674. // 详细信息
  675. detail: function(id, width, height) {
  676. var _url = $.common.isEmpty(id) ? $.table._option.detailUrl : $.table._option.detailUrl.replace("{id}", id);
  677. var _width = $.common.isEmpty(width) ? "800" : width;
  678. var _height = $.common.isEmpty(height) ? ($(window).height() - 50) : height;
  679. //如果是移动端,就使用自适应大小弹窗
  680. if (navigator.userAgent.match(/(iPhone|iPod|Android|ios)/i)) {
  681. _width = 'auto';
  682. _height = 'auto';
  683. }
  684. layer.open({
  685. type: 2,
  686. area: [_width + 'px', _height + 'px'],
  687. fix: false,
  688. //不固定
  689. maxmin: true,
  690. shade: 0.3,
  691. title: $.table._option.modalName + "详细",
  692. content: _url,
  693. btn: ['关闭'],
  694. // 弹层外区域关闭
  695. shadeClose: true,
  696. cancel: function(index){
  697. return true;
  698. }
  699. });
  700. },
  701. // 删除信息
  702. remove: function(id) {
  703. $.modal.confirm("确定删除该条" + $.table._option.modalName + "信息吗?", function() {
  704. var url = $.common.isEmpty(id) ? $.table._option.removeUrl : $.table._option.removeUrl.replace("{id}", id);
  705. if($.table._option.type == table_type.bootstrapTreeTable) {
  706. $.operate.get(url);
  707. } else {
  708. var data = { "ids": id };
  709. $.operate.submit(url, "post", "json", data);
  710. }
  711. });
  712. },
  713. // 批量删除信息
  714. removeAll: function() {
  715. var rows = $.common.isEmpty($.table._option.uniqueId) ? $.table.selectFirstColumns() : $.table.selectColumns($.table._option.uniqueId);
  716. if (rows.length == 0) {
  717. $.modal.alertWarning("请至少选择一条记录");
  718. return;
  719. }
  720. $.modal.confirm("确认要删除选中的" + rows.length + "条数据吗?", function() {
  721. var url = $.table._option.removeUrl;
  722. var data = { "ids": rows.join() };
  723. $.operate.submit(url, "post", "json", data);
  724. });
  725. },
  726. // 清空信息
  727. clean: function() {
  728. $.modal.confirm("确定清空所有" + $.table._option.modalName + "吗?", function() {
  729. var url = $.table._option.cleanUrl;
  730. $.operate.submit(url, "post", "json", "");
  731. });
  732. },
  733. // 添加信息
  734. add: function(id) {
  735. $.modal.open("添加" + $.table._option.modalName, $.operate.addUrl(id));
  736. },
  737. // 添加信息,以tab页展现
  738. addTab: function (id) {
  739. $.modal.openTab("添加" + $.table._option.modalName, $.operate.addUrl(id));
  740. },
  741. // 添加信息 全屏
  742. addFull: function(id) {
  743. var url = $.common.isEmpty(id) ? $.table._option.createUrl : $.table._option.createUrl.replace("{id}", id);
  744. $.modal.openFull("添加" + $.table._option.modalName, url);
  745. },
  746. // 添加访问地址
  747. addUrl: function(id) {
  748. var url = $.common.isEmpty(id) ? $.table._option.createUrl : $.table._option.createUrl.replace("{id}", id);
  749. return url;
  750. },
  751. // 修改信息
  752. edit: function(id) {
  753. if($.common.isEmpty(id) && $.table._option.type == table_type.bootstrapTreeTable) {
  754. var row = $('#' + $.table._option.id).bootstrapTreeTable('getSelections')[0];
  755. if ($.common.isEmpty(row)) {
  756. $.modal.alertWarning("请至少选择一条记录");
  757. return;
  758. }
  759. var url = $.table._option.updateUrl.replace("{id}", row[$.table._option.uniqueId]);
  760. $.modal.open("修改" + $.table._option.modalName, url);
  761. } else {
  762. $.modal.open("修改" + $.table._option.modalName, $.operate.editUrl(id));
  763. }
  764. },
  765. // 修改信息,以tab页展现
  766. editTab: function(id) {
  767. $.modal.openTab("修改" + $.table._option.modalName, $.operate.editUrl(id));
  768. },
  769. // 修改信息 全屏
  770. editFull: function(id) {
  771. var url = "/404.html";
  772. if ($.common.isNotEmpty(id)) {
  773. url = $.table._option.updateUrl.replace("{id}", id);
  774. } else {
  775. var row = $.common.isEmpty($.table._option.uniqueId) ? $.table.selectFirstColumns() : $.table.selectColumns($.table._option.uniqueId);
  776. url = $.table._option.updateUrl.replace("{id}", row);
  777. }
  778. $.modal.openFull("修改" + $.table._option.modalName, url);
  779. },
  780. // 修改访问地址
  781. editUrl: function(id) {
  782. var url = "/404.html";
  783. if ($.common.isNotEmpty(id)) {
  784. url = $.table._option.updateUrl.replace("{id}", id);
  785. } else {
  786. var id = $.common.isEmpty($.table._option.uniqueId) ? $.table.selectFirstColumns() : $.table.selectColumns($.table._option.uniqueId);
  787. if (id.length == 0) {
  788. $.modal.alertWarning("请至少选择一条记录");
  789. return;
  790. }
  791. url = $.table._option.updateUrl.replace("{id}", id);
  792. }
  793. return url;
  794. },
  795. // 保存信息 刷新表格
  796. save: function(url, data) {
  797. var config = {
  798. url: url,
  799. type: "post",
  800. dataType: "json",
  801. data: data,
  802. beforeSend: function () {
  803. $.modal.loading("正在处理中,请稍后...");
  804. $.modal.disable();
  805. },
  806. success: function(result) {
  807. $.operate.successCallback(result);
  808. }
  809. };
  810. $.ajax(config)
  811. },
  812. // 保存信息 弹出提示框
  813. saveModal: function(url, data) {
  814. var config = {
  815. url: url,
  816. type: "post",
  817. dataType: "json",
  818. data: data,
  819. beforeSend: function () {
  820. $.modal.loading("正在处理中,请稍后...");
  821. },
  822. success: function(result) {
  823. if (result.code == web_status.SUCCESS) {
  824. $.modal.alertSuccess(result.msg)
  825. } else if (result.code == web_status.WARNING) {
  826. $.modal.alertWarning(result.msg)
  827. } else {
  828. $.modal.alertError(result.msg);
  829. }
  830. $.modal.closeLoading();
  831. }
  832. };
  833. $.ajax(config)
  834. },
  835. // 保存选项卡信息
  836. saveTab: function(url, data) {
  837. var config = {
  838. url: url,
  839. type: "post",
  840. dataType: "json",
  841. data: data,
  842. beforeSend: function () {
  843. $.modal.loading("正在处理中,请稍后...");
  844. },
  845. success: function(result) {
  846. $.operate.successTabCallback(result);
  847. }
  848. };
  849. $.ajax(config)
  850. },
  851. // 保存结果弹出msg刷新table表格
  852. ajaxSuccess: function (result) {
  853. if (result.code == web_status.SUCCESS && $.table._option.type == table_type.bootstrapTable) {
  854. $.modal.msgSuccess(result.msg);
  855. $.table.refresh();
  856. } else if (result.code == web_status.SUCCESS && $.table._option.type == table_type.bootstrapTreeTable) {
  857. $.modal.msgSuccess(result.msg);
  858. $.treeTable.refresh();
  859. } else if (result.code == web_status.WARNING) {
  860. $.modal.alertWarning(result.msg)
  861. } else {
  862. $.modal.alertError(result.msg);
  863. }
  864. $.modal.closeLoading();
  865. },
  866. // 成功结果提示msg(父窗体全局更新)
  867. saveSuccess: function (result) {
  868. if (result.code == web_status.SUCCESS) {
  869. $.modal.msgReload("保存成功,正在刷新数据请稍后……", modal_status.SUCCESS);
  870. } else if (result.code == web_status.WARNING) {
  871. $.modal.alertWarning(result.msg)
  872. } else {
  873. $.modal.alertError(result.msg);
  874. }
  875. $.modal.closeLoading();
  876. },
  877. // 成功回调执行事件(父窗体静默更新)
  878. successCallback: function(result) {
  879. if (result.code == web_status.SUCCESS) {
  880. var parent = window.parent;
  881. if (parent.$.table._option.type == table_type.bootstrapTable) {
  882. $.modal.close();
  883. parent.$.modal.msgSuccess(result.msg);
  884. parent.$.table.refresh();
  885. } else if (parent.$.table._option.type == table_type.bootstrapTreeTable) {
  886. $.modal.close();
  887. parent.$.modal.msgSuccess(result.msg);
  888. parent.$.treeTable.refresh();
  889. } else {
  890. $.modal.msgReload("保存成功,正在刷新数据请稍后……", modal_status.SUCCESS);
  891. }
  892. } else if (result.code == web_status.WARNING) {
  893. $.modal.alertWarning(result.msg)
  894. } else {
  895. $.modal.alertError(result.msg);
  896. }
  897. $.modal.closeLoading();
  898. $.modal.enable();
  899. },
  900. // 选项卡成功回调执行事件(父窗体静默更新)
  901. successTabCallback: function(result) {
  902. if (result.code == web_status.SUCCESS) {
  903. var topWindow = $(window.parent.document);
  904. var currentId = $('.page-tabs-content', topWindow).find('.active').attr('data-panel');
  905. var $contentWindow = $('.RuoYi_iframe[data-id="' + currentId + '"]', topWindow)[0].contentWindow;
  906. $.modal.close();
  907. $contentWindow.$.modal.msgSuccess(result.msg);
  908. $contentWindow.$(".layui-layer-padding").removeAttr("style");
  909. if ($contentWindow.$.table._option.type == table_type.bootstrapTable) {
  910. $contentWindow.$.table.refresh();
  911. } else if ($contentWindow.$.table._option.type == table_type.bootstrapTreeTable) {
  912. $contentWindow.$.treeTable.refresh();
  913. }
  914. closeItem();
  915. } else if (result.code == web_status.WARNING) {
  916. $.modal.alertWarning(result.msg)
  917. } else {
  918. $.modal.alertError(result.msg);
  919. }
  920. $.modal.closeLoading();
  921. }
  922. },
  923. // 校验封装处理
  924. validate: {
  925. // 判断返回标识是否唯一 false 不存在 true 存在
  926. unique: function (value) {
  927. if (value == "0") {
  928. return true;
  929. }
  930. return false;
  931. },
  932. // 表单验证
  933. form: function (formId) {
  934. var currentId = $.common.isEmpty(formId) ? $('form').attr('id') : formId;
  935. return $("#" + currentId).validate().form();
  936. }
  937. },
  938. // 树插件封装处理
  939. tree: {
  940. _option: {},
  941. _lastValue: {},
  942. // 初始化树结构
  943. init: function(options) {
  944. var defaults = {
  945. id: "tree", // 属性ID
  946. expandLevel: 0, // 展开等级节点
  947. view: {
  948. selectedMulti: false, // 设置是否允许同时选中多个节点
  949. nameIsHTML: true // 设置 name 属性是否支持 HTML 脚本
  950. },
  951. check: {
  952. enable: false, // 置 zTree 的节点上是否显示 checkbox / radio
  953. nocheckInherit: true, // 设置子节点是否自动继承
  954. },
  955. data: {
  956. key: {
  957. title: "title" // 节点数据保存节点提示信息的属性名称
  958. },
  959. simpleData: {
  960. enable: true // true / false 分别表示 使用 / 不使用 简单数据模式
  961. }
  962. },
  963. };
  964. var options = $.extend(defaults, options);
  965. $.tree._option = options;
  966. // 树结构初始化加载
  967. var setting = {
  968. callback: {
  969. onClick: options.onClick, // 用于捕获节点被点击的事件回调函数
  970. onCheck: options.onCheck, // 用于捕获 checkbox / radio 被勾选 或 取消勾选的事件回调函数
  971. onDblClick: options.onDblClick // 用于捕获鼠标双击之后的事件回调函数
  972. },
  973. check: options.check,
  974. view: options.view,
  975. data: options.data
  976. };
  977. $.get(options.url, function(data) {
  978. var treeId = $("#treeId").val();
  979. tree = $.fn.zTree.init($("#" + options.id), setting, data);
  980. $._tree = tree;
  981. var nodes = tree.getNodesByParam("level", options.expandLevel - 1);
  982. for (var i = 0; i < nodes.length; i++) {
  983. tree.expandNode(nodes[i], true, false, false);
  984. }
  985. var node = tree.getNodesByParam("id", treeId, null)[0];
  986. $.tree.selectByIdName(treeId, node);
  987. });
  988. },
  989. // 搜索节点
  990. searchNode: function() {
  991. // 取得输入的关键字的值
  992. var value = $.common.trim($("#keyword").val());
  993. if ($.tree._lastValue == value) {
  994. return;
  995. }
  996. // 保存最后一次搜索名称
  997. $.tree._lastValue = value;
  998. var nodes = $._tree.getNodes();
  999. // 如果要查空字串,就退出不查了。
  1000. if (value == "") {
  1001. $.tree.showAllNode(nodes);
  1002. return;
  1003. }
  1004. $.tree.hideAllNode(nodes);
  1005. // 根据搜索值模糊匹配
  1006. $.tree.updateNodes($._tree.getNodesByParamFuzzy("name", value));
  1007. },
  1008. // 根据Id和Name选中指定节点
  1009. selectByIdName: function(treeId, node) {
  1010. if ($.common.isNotEmpty(treeId) && treeId == node.id) {
  1011. $._tree.selectNode(node, true);
  1012. }
  1013. },
  1014. // 显示所有节点
  1015. showAllNode: function(nodes) {
  1016. nodes = $._tree.transformToArray(nodes);
  1017. for (var i = nodes.length - 1; i >= 0; i--) {
  1018. if (nodes[i].getParentNode() != null) {
  1019. $._tree.expandNode(nodes[i], true, false, false, false);
  1020. } else {
  1021. $._tree.expandNode(nodes[i], true, true, false, false);
  1022. }
  1023. $._tree.showNode(nodes[i]);
  1024. $.tree.showAllNode(nodes[i].children);
  1025. }
  1026. },
  1027. // 隐藏所有节点
  1028. hideAllNode: function(nodes) {
  1029. var tree = $.fn.zTree.getZTreeObj("tree");
  1030. var nodes = $._tree.transformToArray(nodes);
  1031. for (var i = nodes.length - 1; i >= 0; i--) {
  1032. $._tree.hideNode(nodes[i]);
  1033. }
  1034. },
  1035. // 显示所有父节点
  1036. showParent: function(treeNode) {
  1037. var parentNode;
  1038. while ((parentNode = treeNode.getParentNode()) != null) {
  1039. $._tree.showNode(parentNode);
  1040. $._tree.expandNode(parentNode, true, false, false);
  1041. treeNode = parentNode;
  1042. }
  1043. },
  1044. // 显示所有孩子节点
  1045. showChildren: function(treeNode) {
  1046. if (treeNode.isParent) {
  1047. for (var idx in treeNode.children) {
  1048. var node = treeNode.children[idx];
  1049. $._tree.showNode(node);
  1050. $.tree.showChildren(node);
  1051. }
  1052. }
  1053. },
  1054. // 更新节点状态
  1055. updateNodes: function(nodeList) {
  1056. $._tree.showNodes(nodeList);
  1057. for (var i = 0, l = nodeList.length; i < l; i++) {
  1058. var treeNode = nodeList[i];
  1059. $.tree.showChildren(treeNode);
  1060. $.tree.showParent(treeNode)
  1061. }
  1062. },
  1063. // 获取当前被勾选集合
  1064. getCheckedNodes: function(column) {
  1065. var _column = $.common.isEmpty(column) ? "id" : column;
  1066. var nodes = $._tree.getCheckedNodes(true);
  1067. return $.map(nodes, function (row) {
  1068. return row[_column];
  1069. }).join();
  1070. },
  1071. // 不允许根父节点选择
  1072. notAllowParents: function(_tree) {
  1073. var nodes = _tree.getSelectedNodes();
  1074. for (var i = 0; i < nodes.length; i++) {
  1075. if (nodes[i].level == 0) {
  1076. $.modal.msgError("不能选择根节点(" + nodes[i].name + ")");
  1077. return false;
  1078. }
  1079. if (nodes[i].isParent) {
  1080. $.modal.msgError("不能选择父节点(" + nodes[i].name + ")");
  1081. return false;
  1082. }
  1083. }
  1084. return true;
  1085. },
  1086. // 不允许最后层级节点选择
  1087. notAllowLastLevel: function(_tree) {
  1088. var nodes = _tree.getSelectedNodes();
  1089. for (var i = 0; i < nodes.length; i++) {
  1090. if (!nodes[i].isParent) {
  1091. $.modal.msgError("不能选择最后层级节点(" + nodes[i].name + ")");
  1092. return false;
  1093. }
  1094. }
  1095. return true;
  1096. },
  1097. // 隐藏/显示搜索栏
  1098. toggleSearch: function() {
  1099. $('#search').slideToggle(200);
  1100. $('#btnShow').toggle();
  1101. $('#btnHide').toggle();
  1102. $('#keyword').focus();
  1103. },
  1104. // 折叠
  1105. collapse: function() {
  1106. $._tree.expandAll(false);
  1107. },
  1108. // 展开
  1109. expand: function() {
  1110. $._tree.expandAll(true);
  1111. }
  1112. },
  1113. // 通用方法封装处理
  1114. common: {
  1115. // 判断字符串是否为空
  1116. isEmpty: function (value) {
  1117. if (value == null || this.trim(value) == "") {
  1118. return true;
  1119. }
  1120. return false;
  1121. },
  1122. // 判断一个字符串是否为非空串
  1123. isNotEmpty: function (value) {
  1124. return !$.common.isEmpty(value);
  1125. },
  1126. // 空对象转字符串
  1127. nullToStr: function(value) {
  1128. if ($.common.isEmpty(value)) {
  1129. return "-";
  1130. }
  1131. return value;
  1132. },
  1133. // 是否显示数据 为空默认为显示
  1134. visible: function (value) {
  1135. if ($.common.isEmpty(value) || value == true) {
  1136. return true;
  1137. }
  1138. return false;
  1139. },
  1140. // 空格截取
  1141. trim: function (value) {
  1142. if (value == null) {
  1143. return "";
  1144. }
  1145. return value.toString().replace(/(^\s*)|(\s*$)|\r|\n/g, "");
  1146. },
  1147. // 比较两个字符串(大小写敏感)
  1148. equals: function (str, that) {
  1149. return str == that;
  1150. },
  1151. // 比较两个字符串(大小写不敏感)
  1152. equalsIgnoreCase: function (str, that) {
  1153. return String(str).toUpperCase() === String(that).toUpperCase();
  1154. },
  1155. // 将字符串按指定字符分割
  1156. split: function (str, sep, maxLen) {
  1157. if ($.common.isEmpty(str)) {
  1158. return null;
  1159. }
  1160. var value = String(str).split(sep);
  1161. return maxLen ? value.slice(0, maxLen - 1) : value;
  1162. },
  1163. // 字符串格式化(%s )
  1164. sprintf: function (str) {
  1165. var args = arguments, flag = true, i = 1;
  1166. str = str.replace(/%s/g, function () {
  1167. var arg = args[i++];
  1168. if (typeof arg === 'undefined') {
  1169. flag = false;
  1170. return '';
  1171. }
  1172. return arg;
  1173. });
  1174. return flag ? str : '';
  1175. },
  1176. // 指定随机数返回
  1177. random: function (min, max) {
  1178. return Math.floor((Math.random() * max) + min);
  1179. },
  1180. // 判断字符串是否是以start开头
  1181. startWith: function(value, start) {
  1182. var reg = new RegExp("^" + start);
  1183. return reg.test(value)
  1184. },
  1185. // 判断字符串是否是以end结尾
  1186. endWith: function(value, end) {
  1187. var reg = new RegExp(end + "$");
  1188. return reg.test(value)
  1189. },
  1190. // 数组去重
  1191. uniqueFn: function(array) {
  1192. var result = [];
  1193. var hashObj = {};
  1194. for (var i = 0; i < array.length; i++) {
  1195. if (!hashObj[array[i]]) {
  1196. hashObj[array[i]] = true;
  1197. result.push(array[i]);
  1198. }
  1199. }
  1200. return result;
  1201. }
  1202. }
  1203. });
  1204. })(jQuery);
  1205. /** 表格类型 */
  1206. table_type = {
  1207. bootstrapTable: 0,
  1208. bootstrapTreeTable: 1
  1209. };
  1210. /** 消息状态码 */
  1211. web_status = {
  1212. SUCCESS: 0,
  1213. FAIL: 500,
  1214. WARNING: 301
  1215. };
  1216. /** 弹窗状态码 */
  1217. modal_status = {
  1218. SUCCESS: "success",
  1219. FAIL: "error",
  1220. WARNING: "warning"
  1221. };