You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

246 lines
10 KiB

  1. /*
  2. * 版 本 Learun-ADMS-Ultimate V7.0.0 数字化智慧校园(http://www.learun.cn)
  3. * Copyright (c) 2013-2018 北京泉江科技有限公司
  4. * 创建人:陈彬彬
  5. * 日 期:2017.03.16
  6. * 描 述:弹层(基于layer.js-3.0.3)
  7. */
  8. (function ($, learun) {
  9. "use strict";
  10. $.extend(learun, {
  11. // 询问框
  12. layerConfirm: function (_msg, callback) {
  13. top.learun.language.get(_msg,
  14. function (msg) {
  15. top.layer.confirm(msg,
  16. {
  17. btn: ['确认', '取消'],
  18. title: "提示",
  19. icon: 0,
  20. skin: 'lr-layer',
  21. success: function (layero, index) {
  22. layero.find('.layui-layer-btn a').each(function () {
  23. var $this = $(this);
  24. var _text = $this.text();
  25. top.learun.language.get(_text,
  26. function (text) {
  27. $this.text(text);
  28. });
  29. });
  30. layero.find('.layui-layer-title').each(function () {
  31. var $this = $(this);
  32. var _text = $this.text();
  33. top.learun.language.get(_text,
  34. function (text) {
  35. $this.text(text);
  36. });
  37. });
  38. },
  39. },
  40. function (index) {
  41. callback(true, index);
  42. top.layer.close(index); //再执行关闭
  43. },
  44. function (index) {
  45. callback(false, index);
  46. top.layer.close(index); //再执行关闭
  47. });
  48. });
  49. },
  50. // 自定义表单弹层
  51. layerForm: function (op) {
  52. var dfop = {
  53. id: null,
  54. title: '系统窗口',
  55. width: 550,
  56. height: 400,
  57. url: 'error',
  58. btn: ['确认', '关闭'],
  59. callBack: false,
  60. maxmin: false,
  61. end: false,
  62. };
  63. $.extend(dfop, op || {});
  64. /*适应窗口大小*/
  65. dfop.width = dfop.width > $(window).width() ? $(window).width() - 10 : dfop.width;
  66. dfop.height = dfop.height > $(window).height() ? $(window).height() - 10 : dfop.height;
  67. var r = 0;
  68. r=top.layer.open({
  69. id: dfop.id,
  70. maxmin: dfop.maxmin,
  71. type: 2, //0(信息框,默认)1(页面层)2(iframe层)3(加载层)4(tips层)
  72. title: dfop.title,
  73. area: [dfop.width + 'px', dfop.height + 'px'],
  74. btn: dfop.btn,
  75. content: op.url,
  76. skin: dfop.btn == null ? 'lr-layer-nobtn' : 'lr-layer',
  77. success: function (layero, index) {
  78. top['layer_' + dfop.id] = learun.iframe($(layero).find('iframe').attr('id'), top.frames);
  79. layero[0].learun_layerid = 'layer_' + dfop.id;
  80. //如果底部有按钮添加-确认并关闭窗口勾选按钮
  81. if (!!dfop.btn && layero.find('.lr-layer-btn-cb').length == 0) {
  82. top.learun.language.get('确认并关闭窗口',
  83. function (text) {
  84. layero.find('.layui-layer-btn')
  85. .append('<div class="checkbox lr-layer-btn-cb" myIframeId="layer_' +
  86. dfop.id +
  87. '" ><label><input checked="checked" type="checkbox" >' +
  88. text +
  89. '</label></div>');
  90. });
  91. layero.find('.layui-layer-btn a').each(function () {
  92. var $this = $(this);
  93. var _text = $this.text();
  94. top.learun.language.get(_text,
  95. function (text) {
  96. $this.text(text);
  97. });
  98. });
  99. }
  100. layero.find('.layui-layer-title').each(function () {
  101. var $this = $(this);
  102. var _text = $this.text();
  103. top.learun.language.get(_text,
  104. function (text) {
  105. $this.text(text);
  106. });
  107. });
  108. },
  109. yes: function (index) {
  110. var flag = true;
  111. if (!!dfop.callBack) {
  112. flag = dfop.callBack('layer_' + dfop.id);
  113. }
  114. if (!!flag) {
  115. learun.layerClose('', index);
  116. }
  117. },
  118. end: function () {
  119. top['layer_' + dfop.id] = null;
  120. if (!!dfop.end) {
  121. dfop.end();
  122. }
  123. }
  124. });
  125. },
  126. layerFormForPercent: function (op) {
  127. var dfop = {
  128. id: null,
  129. title: '系统窗口',
  130. width: 550,
  131. height: 400,
  132. url: 'error',
  133. btn: ['确认', '关闭'],
  134. callBack: false,
  135. maxmin: false,
  136. end: false,
  137. };
  138. $.extend(dfop, op || {});
  139. /*适应窗口大小*/
  140. dfop.width = dfop.width > $(window).width() ? $(window).width() - 10 : dfop.width;
  141. dfop.height = dfop.height > $(window).height() ? $(window).height() - 10 : dfop.height;
  142. var r = top.layer.open({
  143. id: dfop.id,
  144. maxmin: dfop.maxmin,
  145. type: 2, //0(信息框,默认)1(页面层)2(iframe层)3(加载层)4(tips层)
  146. title: dfop.title,
  147. area: [dfop.width, dfop.height],
  148. btn: dfop.btn,
  149. content: op.url,
  150. skin: dfop.btn == null ? 'lr-layer-nobtn' : 'lr-layer',
  151. success: function (layero, index) {
  152. top['layer_' + dfop.id] = learun.iframe($(layero).find('iframe').attr('id'), top.frames);
  153. layero[0].learun_layerid = 'layer_' + dfop.id;
  154. //如果底部有按钮添加-确认并关闭窗口勾选按钮
  155. if (!!dfop.btn && layero.find('.lr-layer-btn-cb').length == 0) {
  156. top.learun.language.get('确认并关闭窗口',
  157. function (text) {
  158. layero.find('.layui-layer-btn')
  159. .append('<div class="checkbox lr-layer-btn-cb" myIframeId="layer_' +
  160. dfop.id +
  161. '" ><label><input checked="checked" type="checkbox" >' +
  162. text +
  163. '</label></div>');
  164. });
  165. layero.find('.layui-layer-btn a').each(function () {
  166. var $this = $(this);
  167. var _text = $this.text();
  168. top.learun.language.get(_text,
  169. function (text) {
  170. $this.text(text);
  171. });
  172. });
  173. }
  174. layero.find('.layui-layer-title').each(function () {
  175. var $this = $(this);
  176. var _text = $this.text();
  177. top.learun.language.get(_text,
  178. function (text) {
  179. $this.text(text);
  180. });
  181. });
  182. },
  183. yes: function (index) {
  184. var flag = true;
  185. if (!!dfop.callBack) {
  186. flag = dfop.callBack('layer_' + dfop.id);
  187. }
  188. if (dfop.id == 'formitem') {
  189. learun.layerClose('', index);
  190. }
  191. if (!!flag) {
  192. learun.layerClose('', index);
  193. }
  194. },
  195. end: function () {
  196. top['layer_' + dfop.id] = null;
  197. if (!!dfop.end) {
  198. dfop.end();
  199. }
  200. }
  201. });
  202. },
  203. // 关闭弹层
  204. layerClose: function (name, index) {
  205. var _index;
  206. if (!!index) {
  207. _index = index;
  208. } else {
  209. _index = top.layer.getFrameIndex(name);
  210. }
  211. var layero = top.$("#layui-layer" + _index);
  212. var $IsClose = layero.find('.layui-layer-btn').find(".lr-layer-btn-cb input");
  213. var IsClose = $IsClose.is(":checked");
  214. if ($IsClose.length == 0) {
  215. IsClose = true;
  216. }
  217. if (IsClose) {
  218. top.layer.close(_index); //再执行关闭
  219. } else {
  220. top[layero[0].learun_layerid].location.reload();
  221. }
  222. },
  223. prompt: function (text, callback) {
  224. top.layer.prompt({ title: text, formType: 2 }, callback);
  225. },
  226. close: function (index) {
  227. top.layer.close(index);
  228. }
  229. });
  230. })(window.jQuery, top.learun);