table.dev.js 42 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941
  1. "use strict";
  2. function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
  3. /** layui-v2.5.6 MIT License By https://www.layui.com */
  4. ;
  5. layui.define(["laytpl", "laypage", "layer", "form", "util"], function (e) {
  6. "use strict";
  7. var t = layui.$,
  8. i = layui.laytpl,
  9. a = layui.laypage,
  10. l = layui.layer,
  11. n = layui.form,
  12. o = (layui.util, layui.hint()),
  13. r = layui.device(),
  14. d = {
  15. config: {
  16. checkName: "LAY_CHECKED",
  17. indexName: "LAY_TABLE_INDEX"
  18. },
  19. cache: {},
  20. index: layui.table ? layui.table.index + 1e4 : 0,
  21. set: function set(e) {
  22. var i = this;
  23. return i.config = t.extend({}, i.config, e), i;
  24. },
  25. on: function on(e, t) {
  26. return layui.onevent.call(this, y, e, t);
  27. }
  28. },
  29. c = function c() {
  30. var e = this,
  31. t = e.config,
  32. i = t.id || t.index;
  33. return i && (c.that[i] = e, c.config[i] = t), {
  34. config: t,
  35. reload: function reload(t) {
  36. e.reload.call(e, t);
  37. },
  38. setColsWidth: function setColsWidth() {
  39. e.setColsWidth.call(e);
  40. },
  41. resize: function resize() {
  42. e.resize.call(e);
  43. }
  44. };
  45. },
  46. s = function s(e) {
  47. var t = c.config[e];
  48. return t || o.error("The ID option was not found in the table instance"), t || null;
  49. },
  50. u = function u(e, a, l, n) {
  51. var o = e.templet ? function () {
  52. return "function" == typeof e.templet ? e.templet(l) : i(t(e.templet).html() || String(a)).render(l);
  53. }() : a;
  54. return n ? t("<div>" + o + "</div>").text() : o;
  55. },
  56. y = "table",
  57. h = ".layui-table",
  58. f = "layui-hide",
  59. p = "layui-none",
  60. v = "layui-table-view",
  61. m = ".layui-table-tool",
  62. g = ".layui-table-box",
  63. b = ".layui-table-init",
  64. x = ".layui-table-header",
  65. k = ".layui-table-body",
  66. C = ".layui-table-main",
  67. w = ".layui-table-fixed",
  68. T = ".layui-table-fixed-l",
  69. A = ".layui-table-fixed-r",
  70. L = ".layui-table-total",
  71. N = ".layui-table-page",
  72. S = ".layui-table-sort",
  73. R = "layui-table-edit",
  74. W = "layui-table-hover",
  75. _ = function _(e) {
  76. var t = '{{#if(item2.colspan){}} colspan="{{item2.colspan}}"{{#} if(item2.rowspan){}} rowspan="{{item2.rowspan}}"{{#}}}';
  77. return e = e || {}, ['<table cellspacing="0" cellpadding="0" border="0" class="layui-table" ', '{{# if(d.data.skin){ }}lay-skin="{{d.data.skin}}"{{# } }} {{# if(d.data.size){ }}lay-size="{{d.data.size}}"{{# } }} {{# if(d.data.even){ }}lay-even{{# } }}>', "<thead>", "{{# layui.each(d.data.cols, function(i1, item1){ }}", "<tr>", "{{# layui.each(item1, function(i2, item2){ }}", '{{# if(item2.fixed && item2.fixed !== "right"){ left = true; } }}', '{{# if(item2.fixed === "right"){ right = true; } }}', function () {
  78. return e.fixed && "right" !== e.fixed ? '{{# if(item2.fixed && item2.fixed !== "right"){ }}' : "right" === e.fixed ? '{{# if(item2.fixed === "right"){ }}' : "";
  79. }(), "{{# var isSort = !(item2.colGroup) && item2.sort; }}", '<th data-field="{{ item2.field||i2 }}" data-key="{{d.index}}-{{i1}}-{{i2}}" {{# if( item2.parentKey){ }}data-parentkey="{{ item2.parentKey }}"{{# } }} {{# if(item2.minWidth){ }}data-minwidth="{{item2.minWidth}}"{{# } }} ' + t + ' {{# if(item2.unresize || item2.colGroup){ }}data-unresize="true"{{# } }} class="{{# if(item2.hide){ }}layui-hide{{# } }}{{# if(isSort){ }} layui-unselect{{# } }}{{# if(!item2.field){ }} layui-table-col-special{{# } }}">', '<div class="layui-table-cell laytable-cell-', "{{# if(item2.colGroup){ }}", "group", "{{# } else { }}", "{{d.index}}-{{i1}}-{{i2}}", '{{# if(item2.type !== "normal"){ }}', " laytable-cell-{{ item2.type }}", "{{# } }}", "{{# } }}", '" {{#if(item2.align){}}align="{{item2.align}}"{{#}}}>', '{{# if(item2.type === "checkbox"){ }}', '<input type="checkbox" name="layTableCheckbox" lay-skin="primary" lay-filter="layTableAllChoose" {{# if(item2[d.data.checkName]){ }}checked{{# }; }}>', "{{# } else { }}", '<span>{{item2.title||""}}</span>', "{{# if(isSort){ }}", '<span class="layui-table-sort layui-inline"><i class="layui-edge layui-table-sort-asc" title="升序"></i><i class="layui-edge layui-table-sort-desc" title="降序"></i></span>', "{{# } }}", "{{# } }}", "</div>", "</th>", e.fixed ? "{{# }; }}" : "", "{{# }); }}", "</tr>", "{{# }); }}", "</thead>", "</table>"].join("");
  80. },
  81. E = ['<table cellspacing="0" cellpadding="0" border="0" class="layui-table" ', '{{# if(d.data.skin){ }}lay-skin="{{d.data.skin}}"{{# } }} {{# if(d.data.size){ }}lay-size="{{d.data.size}}"{{# } }} {{# if(d.data.even){ }}lay-even{{# } }}>', "<tbody></tbody>", "</table>"].join(""),
  82. z = ['<div class="layui-form layui-border-box {{d.VIEW_CLASS}}" lay-filter="LAY-table-{{d.index}}" lay-id="{{ d.data.id }}" style="{{# if(d.data.width){ }}width:{{d.data.width}}px;{{# } }} {{# if(d.data.height){ }}height:{{d.data.height}}px;{{# } }}">', "{{# if(d.data.toolbar){ }}", '<div class="layui-table-tool">', '<div class="layui-table-tool-temp"></div>', '<div class="layui-table-tool-self"></div>', "</div>", "{{# } }}", '<div class="layui-table-box">', "{{# if(d.data.loading){ }}", '<div class="layui-table-init" style="background-color: #fff;">', '<i class="layui-icon layui-icon-loading layui-anim layui-anim-rotate layui-anim-loop"></i>', "</div>", "{{# } }}", "{{# var left, right; }}", '<div class="layui-table-header">', _(), "</div>", '<div class="layui-table-body layui-table-main">', E, "</div>", "{{# if(left){ }}", '<div class="layui-table-fixed layui-table-fixed-l">', '<div class="layui-table-header">', _({
  83. fixed: !0
  84. }), "</div>", '<div class="layui-table-body">', E, "</div>", "</div>", "{{# }; }}", "{{# if(right){ }}", '<div class="layui-table-fixed layui-table-fixed-r">', '<div class="layui-table-header">', _({
  85. fixed: "right"
  86. }), '<div class="layui-table-mend"></div>', "</div>", '<div class="layui-table-body">', E, "</div>", "</div>", "{{# }; }}", "</div>", "{{# if(d.data.totalRow){ }}", '<div class="layui-table-total">', '<table cellspacing="0" cellpadding="0" border="0" class="layui-table" ', '{{# if(d.data.skin){ }}lay-skin="{{d.data.skin}}"{{# } }} {{# if(d.data.size){ }}lay-size="{{d.data.size}}"{{# } }} {{# if(d.data.even){ }}lay-even{{# } }}>', '<tbody><tr><td><div class="layui-table-cell" style="visibility: hidden;">Total</div></td></tr></tbody>', "</table>", "</div>", "{{# } }}", "{{# if(d.data.page){ }}", '<div class="layui-table-page">', '<div id="layui-table-page{{d.index}}"></div>', "</div>", "{{# } }}", "<style>", "{{# layui.each(d.data.cols, function(i1, item1){", "layui.each(item1, function(i2, item2){ }}", ".laytable-cell-{{d.index}}-{{i1}}-{{i2}}{ ", "{{# if(item2.width){ }}", "width: {{item2.width}}px;", "{{# } }}", " }", "{{# });", "}); }}", "</style>", "</div>"].join(""),
  87. H = t(window),
  88. j = t(document),
  89. F = function F(e) {
  90. var i = this;
  91. i.index = ++d.index, i.config = t.extend({}, i.config, d.config, e), i.render();
  92. };
  93. F.prototype.config = {
  94. limit: 10,
  95. loading: !0,
  96. cellMinWidth: 60,
  97. defaultToolbar: ["filter", "exports", "print"],
  98. autoSort: !0,
  99. text: {
  100. none: "无数据"
  101. }
  102. }, F.prototype.render = function () {
  103. var e = this,
  104. a = e.config;
  105. if (a.elem = t(a.elem), a.where = a.where || {}, a.id = a.id || a.elem.attr("id") || e.index, a.request = t.extend({
  106. pageName: "page",
  107. limitName: "limit"
  108. }, a.request), a.response = t.extend({
  109. statusName: "code",
  110. statusCode: 0,
  111. msgName: "msg",
  112. dataName: "data",
  113. totalRowName: "totalRow",
  114. countName: "count"
  115. }, a.response), "object" == _typeof(a.page) && (a.limit = a.page.limit || a.limit, a.limits = a.page.limits || a.limits, e.page = a.page.curr = a.page.curr || 1, delete a.page.elem, delete a.page.jump), !a.elem[0]) return e;
  116. a.height && /^full-\d+$/.test(a.height) && (e.fullHeightGap = a.height.split("-")[1], a.height = H.height() - e.fullHeightGap), e.setInit();
  117. var l = a.elem,
  118. n = l.next("." + v),
  119. o = e.elem = t(i(z).render({
  120. VIEW_CLASS: v,
  121. data: a,
  122. index: e.index
  123. }));
  124. if (a.index = e.index, e.key = a.id || a.index, n[0] && n.remove(), l.after(o), e.layTool = o.find(m), e.layBox = o.find(g), e.layHeader = o.find(x), e.layMain = o.find(C), e.layBody = o.find(k), e.layFixed = o.find(w), e.layFixLeft = o.find(T), e.layFixRight = o.find(A), e.layTotal = o.find(L), e.layPage = o.find(N), e.renderToolbar(), e.fullSize(), a.cols.length > 1) {
  125. var r = e.layFixed.find(x).find("th");
  126. r.height(e.layHeader.height() - 1 - parseFloat(r.css("padding-top")) - parseFloat(r.css("padding-bottom")));
  127. }
  128. e.pullData(e.page), e.events();
  129. }, F.prototype.initOpts = function (e) {
  130. var t = this,
  131. i = (t.config, {
  132. checkbox: 48,
  133. radio: 48,
  134. space: 15,
  135. numbers: 40
  136. });
  137. e.checkbox && (e.type = "checkbox"), e.space && (e.type = "space"), e.type || (e.type = "normal"), "normal" !== e.type && (e.unresize = !0, e.width = e.width || i[e.type]);
  138. }, F.prototype.setInit = function (e) {
  139. var t = this,
  140. i = t.config;
  141. return i.clientWidth = i.width || function () {
  142. var e = function e(t) {
  143. var a, l;
  144. t = t || i.elem.parent(), a = t.width();
  145. try {
  146. l = "none" === t.css("display");
  147. } catch (n) {}
  148. return !t[0] || a && !l ? a : e(t.parent());
  149. };
  150. return e();
  151. }(), "width" === e ? i.clientWidth : void layui.each(i.cols, function (e, a) {
  152. layui.each(a, function (l, n) {
  153. if (!n) return void a.splice(l, 1);
  154. if (n.key = e + "-" + l, n.hide = n.hide || !1, n.colGroup || n.colspan > 1) {
  155. var o = 0;
  156. layui.each(i.cols[e + 1], function (t, i) {
  157. i.HAS_PARENT || o > 1 && o == n.colspan || (i.HAS_PARENT = !0, i.parentKey = e + "-" + l, o += parseInt(i.colspan > 1 ? i.colspan : 1));
  158. }), n.colGroup = !0;
  159. }
  160. t.initOpts(n);
  161. });
  162. });
  163. }, F.prototype.renderToolbar = function () {
  164. var e = this,
  165. a = e.config,
  166. l = ['<div class="layui-inline" lay-event="add"><i class="layui-icon layui-icon-add-1"></i></div>', '<div class="layui-inline" lay-event="update"><i class="layui-icon layui-icon-edit"></i></div>', '<div class="layui-inline" lay-event="delete"><i class="layui-icon layui-icon-delete"></i></div>'].join(""),
  167. n = e.layTool.find(".layui-table-tool-temp");
  168. if ("default" === a.toolbar) n.html(l);else if ("string" == typeof a.toolbar) {
  169. var o = t(a.toolbar).html() || "";
  170. o && n.html(i(o).render(a));
  171. }
  172. var r = {
  173. filter: {
  174. title: "筛选列",
  175. layEvent: "LAYTABLE_COLS",
  176. icon: "layui-icon-cols"
  177. },
  178. exports: {
  179. title: "导出",
  180. layEvent: "LAYTABLE_EXPORT",
  181. icon: "layui-icon-export"
  182. },
  183. print: {
  184. title: "打印",
  185. layEvent: "LAYTABLE_PRINT",
  186. icon: "layui-icon-print"
  187. }
  188. },
  189. d = [];
  190. "object" == _typeof(a.defaultToolbar) && layui.each(a.defaultToolbar, function (e, t) {
  191. var i = "string" == typeof t ? r[t] : t;
  192. i && d.push('<div class="layui-inline" title="' + i.title + '" lay-event="' + i.layEvent + '"><i class="layui-icon ' + i.icon + '"></i></div>');
  193. }), e.layTool.find(".layui-table-tool-self").html(d.join(""));
  194. }, F.prototype.setParentCol = function (e, t) {
  195. var i = this,
  196. a = i.config,
  197. l = i.layHeader.find('th[data-key="' + a.index + "-" + t + '"]'),
  198. n = parseInt(l.attr("colspan")) || 0;
  199. if (l[0]) {
  200. var o = t.split("-"),
  201. r = a.cols[o[0]][o[1]];
  202. e ? n-- : n++, l.attr("colspan", n), l[n < 1 ? "addClass" : "removeClass"](f), r.colspan = n, r.hide = n < 1;
  203. var d = l.data("parentkey");
  204. d && i.setParentCol(e, d);
  205. }
  206. }, F.prototype.setColsPatch = function () {
  207. var e = this,
  208. t = e.config;
  209. layui.each(t.cols, function (t, i) {
  210. layui.each(i, function (t, i) {
  211. i.hide && e.setParentCol(i.hide, i.parentKey);
  212. });
  213. });
  214. }, F.prototype.setColsWidth = function () {
  215. var e = this,
  216. t = e.config,
  217. i = 0,
  218. a = 0,
  219. l = 0,
  220. n = 0,
  221. o = e.setInit("width");
  222. e.eachCols(function (e, t) {
  223. t.hide || i++;
  224. }), o = o - function () {
  225. return "line" === t.skin || "nob" === t.skin ? 2 : i + 1;
  226. }() - e.getScrollWidth(e.layMain[0]) - 1;
  227. var r = function r(e) {
  228. layui.each(t.cols, function (i, r) {
  229. layui.each(r, function (i, d) {
  230. var c = 0,
  231. s = d.minWidth || t.cellMinWidth;
  232. return d ? void (d.colGroup || d.hide || (e ? l && l < s && (a--, c = s) : (c = d.width || 0, /\d+%$/.test(c) ? (c = Math.floor(parseFloat(c) / 100 * o), c < s && (c = s)) : c || (d.width = c = 0, a++)), d.hide && (c = 0), n += c)) : void r.splice(i, 1);
  233. });
  234. }), o > n && a && (l = (o - n) / a);
  235. };
  236. r(), r(!0), e.autoColNums = a, e.eachCols(function (i, a) {
  237. var n = a.minWidth || t.cellMinWidth;
  238. a.colGroup || a.hide || (0 === a.width ? e.getCssRule(t.index + "-" + a.key, function (e) {
  239. e.style.width = Math.floor(l >= n ? l : n) + "px";
  240. }) : /\d+%$/.test(a.width) && e.getCssRule(t.index + "-" + a.key, function (e) {
  241. e.style.width = Math.floor(parseFloat(a.width) / 100 * o) + "px";
  242. }));
  243. });
  244. var d = e.layMain.width() - e.getScrollWidth(e.layMain[0]) - e.layMain.children("table").outerWidth();
  245. if (e.autoColNums && d >= -i && d <= i) {
  246. var c = function c(t) {
  247. var i;
  248. return t = t || e.layHeader.eq(0).find("thead th:last-child"), i = t.data("field"), !i && t.prev()[0] ? c(t.prev()) : t;
  249. },
  250. s = c(),
  251. u = s.data("key");
  252. e.getCssRule(u, function (t) {
  253. var i = t.style.width || s.outerWidth();
  254. t.style.width = parseFloat(i) + d + "px", e.layMain.height() - e.layMain.prop("clientHeight") > 0 && (t.style.width = parseFloat(t.style.width) - 1 + "px");
  255. });
  256. }
  257. e.loading(!0);
  258. }, F.prototype.resize = function () {
  259. var e = this;
  260. e.fullSize(), e.setColsWidth(), e.scrollPatch();
  261. }, F.prototype.reload = function (e) {
  262. var i = this;
  263. e = e || {}, delete i.haveInit, e.data && e.data.constructor === Array && delete i.config.data, i.config = t.extend(!0, {}, i.config, e), i.render();
  264. }, F.prototype.errorView = function (e) {
  265. var i = this,
  266. a = i.layMain.find("." + p),
  267. l = t('<div class="' + p + '">' + (e || "Error") + "</div>");
  268. a[0] && (i.layNone.remove(), a.remove()), i.layFixed.addClass(f), i.layMain.find("tbody").html(""), i.layMain.append(i.layNone = l), d.cache[i.key] = [];
  269. }, F.prototype.page = 1, F.prototype.pullData = function (e) {
  270. var i = this,
  271. a = i.config,
  272. l = a.request,
  273. n = a.response,
  274. o = function o() {
  275. "object" == _typeof(a.initSort) && i.sort(a.initSort.field, a.initSort.type);
  276. };
  277. if (i.startTime = new Date().getTime(), a.url) {
  278. var r = {};
  279. r[l.pageName] = e, r[l.limitName] = a.limit;
  280. var d = t.extend(r, a.where);
  281. a.contentType && 0 == a.contentType.indexOf("application/json") && (d = JSON.stringify(d)), i.loading(), t.ajax({
  282. type: a.method || "get",
  283. url: a.url,
  284. contentType: a.contentType,
  285. data: d,
  286. dataType: "json",
  287. headers: a.headers || {},
  288. success: function success(t) {
  289. "function" == typeof a.parseData && (t = a.parseData(t) || t), t[n.statusName] != n.statusCode ? (i.renderForm(), i.errorView(t[n.msgName] || '返回的数据不符合规范,正确的成功状态码应为:"' + n.statusName + '": ' + n.statusCode)) : (i.renderData(t, e, t[n.countName]), o(), a.time = new Date().getTime() - i.startTime + " ms"), i.setColsWidth(), "function" == typeof a.done && a.done(t, e, t[n.countName]);
  290. },
  291. error: function error(e, t) {
  292. i.errorView("数据接口请求异常:" + t), i.renderForm(), i.setColsWidth();
  293. }
  294. });
  295. } else if (a.data && a.data.constructor === Array) {
  296. var c = {},
  297. s = e * a.limit - a.limit;
  298. c[n.dataName] = a.data.concat().splice(s, a.limit), c[n.countName] = a.data.length, "object" == _typeof(a.totalRow) && (c[n.totalRowName] = t.extend({}, a.totalRow)), i.renderData(c, e, c[n.countName]), o(), i.setColsWidth(), "function" == typeof a.done && a.done(c, e, c[n.countName]);
  299. }
  300. }, F.prototype.eachCols = function (e) {
  301. var t = this;
  302. return d.eachCols(null, e, t.config.cols), t;
  303. }, F.prototype.renderData = function (e, n, o, r) {
  304. var c = this,
  305. s = c.config,
  306. y = e[s.response.dataName] || [],
  307. h = e[s.response.totalRowName],
  308. v = [],
  309. m = [],
  310. g = [],
  311. b = function b() {
  312. var e;
  313. return !r && c.sortKey ? c.sort(c.sortKey.field, c.sortKey.sort, !0) : (layui.each(y, function (a, l) {
  314. var o = [],
  315. y = [],
  316. h = [],
  317. p = a + s.limit * (n - 1) + 1;
  318. 0 !== l.length && (r || (l[d.config.indexName] = a), c.eachCols(function (n, r) {
  319. var c = r.field || n,
  320. v = s.index + "-" + r.key,
  321. m = l[c];
  322. if (void 0 !== m && null !== m || (m = ""), !r.colGroup) {
  323. var g = ['<td data-field="' + c + '" data-key="' + v + '" ' + function () {
  324. var e = [];
  325. return r.edit && e.push('data-edit="' + r.edit + '"'), r.align && e.push('align="' + r.align + '"'), r.templet && e.push('data-content="' + m + '"'), r.toolbar && e.push('data-off="true"'), r.event && e.push('lay-event="' + r.event + '"'), r.style && e.push('style="' + r.style + '"'), r.minWidth && e.push('data-minwidth="' + r.minWidth + '"'), e.join(" ");
  326. }() + ' class="' + function () {
  327. var e = [];
  328. return r.hide && e.push(f), r.field || e.push("layui-table-col-special"), e.join(" ");
  329. }() + '">', '<div class="layui-table-cell laytable-cell-' + function () {
  330. return "normal" === r.type ? v : v + " laytable-cell-" + r.type;
  331. }() + '">' + function () {
  332. var n = t.extend(!0, {
  333. LAY_INDEX: p
  334. }, l),
  335. o = d.config.checkName;
  336. switch (r.type) {
  337. case "checkbox":
  338. return '<input type="checkbox" name="layTableCheckbox" lay-skin="primary" ' + function () {
  339. return r[o] ? (l[o] = r[o], r[o] ? "checked" : "") : n[o] ? "checked" : "";
  340. }() + ">";
  341. case "radio":
  342. return n[o] && (e = a), '<input type="radio" name="layTableRadio_' + s.index + '" ' + (n[o] ? "checked" : "") + ' lay-type="layTableRadio">';
  343. case "numbers":
  344. return p;
  345. }
  346. return r.toolbar ? i(t(r.toolbar).html() || "").render(n) : u(r, m, n);
  347. }(), "</div></td>"].join("");
  348. o.push(g), r.fixed && "right" !== r.fixed && y.push(g), "right" === r.fixed && h.push(g);
  349. }
  350. }), v.push('<tr data-index="' + a + '">' + o.join("") + "</tr>"), m.push('<tr data-index="' + a + '">' + y.join("") + "</tr>"), g.push('<tr data-index="' + a + '">' + h.join("") + "</tr>"));
  351. }), c.layBody.scrollTop(0), c.layMain.find("." + p).remove(), c.layMain.find("tbody").html(v.join("")), c.layFixLeft.find("tbody").html(m.join("")), c.layFixRight.find("tbody").html(g.join("")), c.renderForm(), "number" == typeof e && c.setThisRowChecked(e), c.syncCheckAll(), c.haveInit ? c.scrollPatch() : setTimeout(function () {
  352. c.scrollPatch();
  353. }, 50), c.haveInit = !0, l.close(c.tipsIndex), s.HAS_SET_COLS_PATCH || c.setColsPatch(), void (s.HAS_SET_COLS_PATCH = !0));
  354. };
  355. return d.cache[c.key] = y, c.layPage[0 == o || 0 === y.length && 1 == n ? "addClass" : "removeClass"](f), r ? b() : 0 === y.length ? (c.renderForm(), c.errorView(s.text.none)) : (c.layFixed.removeClass(f), b(), c.renderTotal(y, h), void (s.page && (s.page = t.extend({
  356. elem: "layui-table-page" + s.index,
  357. count: o,
  358. limit: s.limit,
  359. limits: s.limits || [10, 20, 30, 40, 50, 60, 70, 80, 90],
  360. groups: 3,
  361. layout: ["prev", "page", "next", "skip", "count", "limit"],
  362. prev: '<i class="layui-icon">&#xe603;</i>',
  363. next: '<i class="layui-icon">&#xe602;</i>',
  364. jump: function jump(e, t) {
  365. t || (c.page = e.curr, s.limit = e.limit, c.pullData(e.curr));
  366. }
  367. }, s.page), s.page.count = o, a.render(s.page))));
  368. }, F.prototype.renderTotal = function (e, t) {
  369. var i = this,
  370. a = i.config,
  371. l = {};
  372. if (a.totalRow) {
  373. layui.each(e, function (e, t) {
  374. 0 !== t.length && i.eachCols(function (e, i) {
  375. var a = i.field || e,
  376. n = t[a];
  377. i.totalRow && (l[a] = (l[a] || 0) + (parseFloat(n) || 0));
  378. });
  379. }), i.dataTotal = {};
  380. var n = [];
  381. i.eachCols(function (e, o) {
  382. var r = o.field || e,
  383. d = function () {
  384. var e = o.totalRowText || "",
  385. i = parseFloat(l[r]).toFixed(2),
  386. a = {};
  387. return a[r] = i, i = u(o, i, a), t ? t[o.field] || e : o.totalRow ? i || e : e;
  388. }(),
  389. c = ['<td data-field="' + r + '" data-key="' + a.index + "-" + o.key + '" ' + function () {
  390. var e = [];
  391. return o.align && e.push('align="' + o.align + '"'), o.style && e.push('style="' + o.style + '"'), o.minWidth && e.push('data-minwidth="' + o.minWidth + '"'), e.join(" ");
  392. }() + ' class="' + function () {
  393. var e = [];
  394. return o.hide && e.push(f), o.field || e.push("layui-table-col-special"), e.join(" ");
  395. }() + '">', '<div class="layui-table-cell laytable-cell-' + function () {
  396. var e = a.index + "-" + o.key;
  397. return "normal" === o.type ? e : e + " laytable-cell-" + o.type;
  398. }() + '">' + d, "</div></td>"].join("");
  399. o.field && (i.dataTotal[r] = d), n.push(c);
  400. }), i.layTotal.find("tbody").html("<tr>" + n.join("") + "</tr>");
  401. }
  402. }, F.prototype.getColElem = function (e, t) {
  403. var i = this,
  404. a = i.config;
  405. return e.eq(0).find(".laytable-cell-" + (a.index + "-" + t) + ":eq(0)");
  406. }, F.prototype.renderForm = function (e) {
  407. n.render(e, "LAY-table-" + this.index);
  408. }, F.prototype.setThisRowChecked = function (e) {
  409. var t = this,
  410. i = (t.config, "layui-table-click"),
  411. a = t.layBody.find('tr[data-index="' + e + '"]');
  412. a.addClass(i).siblings("tr").removeClass(i);
  413. }, F.prototype.sort = function (e, i, a, l) {
  414. var n,
  415. r,
  416. c = this,
  417. s = {},
  418. u = c.config,
  419. h = u.elem.attr("lay-filter"),
  420. f = d.cache[c.key];
  421. "string" == typeof e && c.layHeader.find("th").each(function (i, a) {
  422. var l = t(this),
  423. o = l.data("field");
  424. if (o === e) return e = l, n = o, !1;
  425. });
  426. try {
  427. var n = n || e.data("field"),
  428. p = e.data("key");
  429. if (c.sortKey && !a && n === c.sortKey.field && i === c.sortKey.sort) return;
  430. var v = c.layHeader.find("th .laytable-cell-" + p).find(S);
  431. c.layHeader.find("th").find(S).removeAttr("lay-sort"), v.attr("lay-sort", i || null), c.layFixed.find("th");
  432. } catch (m) {
  433. return o.error("Table modules: Did not match to field");
  434. }
  435. c.sortKey = {
  436. field: n,
  437. sort: i
  438. }, u.autoSort && ("asc" === i ? r = layui.sort(f, n) : "desc" === i ? r = layui.sort(f, n, !0) : (r = layui.sort(f, d.config.indexName), delete c.sortKey)), s[u.response.dataName] = r || f, c.renderData(s, c.page, c.count, !0), l && layui.event.call(e, y, "sort(" + h + ")", {
  439. field: n,
  440. type: i
  441. });
  442. }, F.prototype.loading = function (e) {
  443. var i = this,
  444. a = i.config;
  445. a.loading && (e ? (i.layInit && i.layInit.remove(), delete i.layInit, i.layBox.find(b).remove()) : (i.layInit = t(['<div class="layui-table-init">', '<i class="layui-icon layui-icon-loading layui-anim layui-anim-rotate layui-anim-loop"></i>', "</div>"].join("")), i.layBox.append(i.layInit)));
  446. }, F.prototype.setCheckData = function (e, t) {
  447. var i = this,
  448. a = i.config,
  449. l = d.cache[i.key];
  450. l[e] && l[e].constructor !== Array && (l[e][a.checkName] = t);
  451. }, F.prototype.syncCheckAll = function () {
  452. var e = this,
  453. t = e.config,
  454. i = e.layHeader.find('input[name="layTableCheckbox"]'),
  455. a = function a(i) {
  456. return e.eachCols(function (e, a) {
  457. "checkbox" === a.type && (a[t.checkName] = i);
  458. }), i;
  459. };
  460. i[0] && (d.checkStatus(e.key).isAll ? (i[0].checked || (i.prop("checked", !0), e.renderForm("checkbox")), a(!0)) : (i[0].checked && (i.prop("checked", !1), e.renderForm("checkbox")), a(!1)));
  461. }, F.prototype.getCssRule = function (e, t) {
  462. var i = this,
  463. a = i.elem.find("style")[0],
  464. l = a.sheet || a.styleSheet || {},
  465. n = l.cssRules || l.rules;
  466. layui.each(n, function (i, a) {
  467. if (a.selectorText === ".laytable-cell-" + e) return t(a), !0;
  468. });
  469. }, F.prototype.fullSize = function () {
  470. var e,
  471. t = this,
  472. i = t.config,
  473. a = i.height;
  474. t.fullHeightGap && (a = H.height() - t.fullHeightGap, a < 135 && (a = 135), t.elem.css("height", a)), a && (e = parseFloat(a) - (t.layHeader.outerHeight() || 38), i.toolbar && (e -= t.layTool.outerHeight() || 50), i.totalRow && (e -= t.layTotal.outerHeight() || 40), i.page && (e -= t.layPage.outerHeight() || 41), t.layMain.css("height", e - 2));
  475. }, F.prototype.getScrollWidth = function (e) {
  476. var t = 0;
  477. return e ? t = e.offsetWidth - e.clientWidth : (e = document.createElement("div"), e.style.width = "100px", e.style.height = "100px", e.style.overflowY = "scroll", document.body.appendChild(e), t = e.offsetWidth - e.clientWidth, document.body.removeChild(e)), t;
  478. }, F.prototype.scrollPatch = function () {
  479. var e = this,
  480. i = e.layMain.children("table"),
  481. a = e.layMain.width() - e.layMain.prop("clientWidth"),
  482. l = e.layMain.height() - e.layMain.prop("clientHeight"),
  483. n = (e.getScrollWidth(e.layMain[0]), i.outerWidth() - e.layMain.width()),
  484. o = function o(e) {
  485. if (a && l) {
  486. if (e = e.eq(0), !e.find(".layui-table-patch")[0]) {
  487. var i = t('<th class="layui-table-patch"><div class="layui-table-cell"></div></th>');
  488. i.find("div").css({
  489. width: a
  490. }), e.find("tr").append(i);
  491. }
  492. } else e.find(".layui-table-patch").remove();
  493. };
  494. o(e.layHeader), o(e.layTotal);
  495. var r = e.layMain.height(),
  496. d = r - l;
  497. e.layFixed.find(k).css("height", i.height() >= d ? d : "auto"), e.layFixRight[n > 0 ? "removeClass" : "addClass"](f), e.layFixRight.css("right", a - 1);
  498. }, F.prototype.events = function () {
  499. var e,
  500. i = this,
  501. a = i.config,
  502. o = t("body"),
  503. c = {},
  504. s = i.layHeader.find("th"),
  505. h = ".layui-table-cell",
  506. p = a.elem.attr("lay-filter");
  507. i.layTool.on("click", "*[lay-event]", function (e) {
  508. var o = t(this),
  509. c = o.attr("lay-event"),
  510. s = function s(e) {
  511. var l = t(e.list),
  512. n = t('<ul class="layui-table-tool-panel"></ul>');
  513. n.html(l), a.height && n.css("max-height", a.height - (i.layTool.outerHeight() || 50)), o.find(".layui-table-tool-panel")[0] || o.append(n), i.renderForm(), n.on("click", function (e) {
  514. layui.stope(e);
  515. }), e.done && e.done(n, l);
  516. };
  517. switch (layui.stope(e), j.trigger("table.tool.panel.remove"), l.close(i.tipsIndex), c) {
  518. case "LAYTABLE_COLS":
  519. s({
  520. list: function () {
  521. var e = [];
  522. return i.eachCols(function (t, i) {
  523. i.field && "normal" == i.type && e.push('<li><input type="checkbox" name="' + i.field + '" data-key="' + i.key + '" data-parentkey="' + (i.parentKey || "") + '" lay-skin="primary" ' + (i.hide ? "" : "checked") + ' title="' + (i.title || i.field) + '" lay-filter="LAY_TABLE_TOOL_COLS"></li>');
  524. }), e.join("");
  525. }(),
  526. done: function done() {
  527. n.on("checkbox(LAY_TABLE_TOOL_COLS)", function (e) {
  528. var l = t(e.elem),
  529. n = this.checked,
  530. o = l.data("key"),
  531. r = l.data("parentkey");
  532. layui.each(a.cols, function (e, t) {
  533. layui.each(t, function (t, l) {
  534. if (e + "-" + t === o) {
  535. var d = l.hide;
  536. l.hide = !n, i.elem.find('*[data-key="' + a.index + "-" + o + '"]')[n ? "removeClass" : "addClass"](f), d != l.hide && i.setParentCol(!n, r), i.resize();
  537. }
  538. });
  539. });
  540. });
  541. }
  542. });
  543. break;
  544. case "LAYTABLE_EXPORT":
  545. r.ie ? l.tips("导出功能不支持 IE,请用 Chrome 等高级浏览器导出", this, {
  546. tips: 3
  547. }) : s({
  548. list: function () {
  549. return ['<li data-type="csv">导出到 Csv 文件</li>', '<li data-type="xls">导出到 Excel 文件</li>'].join("");
  550. }(),
  551. done: function done(e, l) {
  552. l.on("click", function () {
  553. var e = t(this).data("type");
  554. d.exportFile.call(i, a.id, null, e);
  555. });
  556. }
  557. });
  558. break;
  559. case "LAYTABLE_PRINT":
  560. var u = window.open("打印窗口", "_blank"),
  561. h = ["<style>", "body{font-size: 12px; color: #666;}", "table{width: 100%; border-collapse: collapse; border-spacing: 0;}", "th,td{line-height: 20px; padding: 9px 15px; border: 1px solid #ccc; text-align: left; font-size: 12px; color: #666;}", "a{color: #666; text-decoration:none;}", "*.layui-hide{display: none}", "</style>"].join(""),
  562. v = t(i.layHeader.html());
  563. v.append(i.layMain.find("table").html()), v.append(i.layTotal.find("table").html()), v.find("th.layui-table-patch").remove(), v.find(".layui-table-col-special").remove(), u.document.write(h + v.prop("outerHTML")), u.document.close(), u.print(), u.close();
  564. }
  565. layui.event.call(this, y, "toolbar(" + p + ")", t.extend({
  566. event: c,
  567. config: a
  568. }, {}));
  569. }), s.on("mousemove", function (e) {
  570. var i = t(this),
  571. a = i.offset().left,
  572. l = e.clientX - a;
  573. i.data("unresize") || c.resizeStart || (c.allowResize = i.width() - l <= 10, o.css("cursor", c.allowResize ? "col-resize" : ""));
  574. }).on("mouseleave", function () {
  575. t(this);
  576. c.resizeStart || o.css("cursor", "");
  577. }).on("mousedown", function (e) {
  578. var l = t(this);
  579. if (c.allowResize) {
  580. var n = l.data("key");
  581. e.preventDefault(), c.resizeStart = !0, c.offset = [e.clientX, e.clientY], i.getCssRule(n, function (e) {
  582. var t = e.style.width || l.outerWidth();
  583. c.rule = e, c.ruleWidth = parseFloat(t), c.minWidth = l.data("minwidth") || a.cellMinWidth;
  584. });
  585. }
  586. }), j.on("mousemove", function (t) {
  587. if (c.resizeStart) {
  588. if (t.preventDefault(), c.rule) {
  589. var a = c.ruleWidth + t.clientX - c.offset[0];
  590. a < c.minWidth && (a = c.minWidth), c.rule.style.width = a + "px", l.close(i.tipsIndex);
  591. }
  592. e = 1;
  593. }
  594. }).on("mouseup", function (t) {
  595. c.resizeStart && (c = {}, o.css("cursor", ""), i.scrollPatch()), 2 === e && (e = null);
  596. }), s.on("click", function (a) {
  597. var l,
  598. n = t(this),
  599. o = n.find(S),
  600. r = o.attr("lay-sort");
  601. return o[0] && 1 !== e ? (l = "asc" === r ? "desc" : "desc" === r ? null : "asc", void i.sort(n, l, null, !0)) : e = 2;
  602. }).find(S + " .layui-edge ").on("click", function (e) {
  603. var a = t(this),
  604. l = a.index(),
  605. n = a.parents("th").eq(0).data("field");
  606. layui.stope(e), 0 === l ? i.sort(n, "asc", null, !0) : i.sort(n, "desc", null, !0);
  607. });
  608. var v = function v(e) {
  609. var a = t(this),
  610. l = a.parents("tr").eq(0).data("index"),
  611. n = i.layBody.find('tr[data-index="' + l + '"]'),
  612. o = d.cache[i.key] || [];
  613. return o = o[l] || {}, t.extend({
  614. tr: n,
  615. data: d.clearCacheKey(o),
  616. del: function del() {
  617. d.cache[i.key][l] = [], n.remove(), i.scrollPatch();
  618. },
  619. update: function update(e) {
  620. e = e || {}, layui.each(e, function (e, t) {
  621. if (e in o) {
  622. var a,
  623. l = n.children('td[data-field="' + e + '"]');
  624. o[e] = t, i.eachCols(function (t, i) {
  625. i.field == e && i.templet && (a = i.templet);
  626. }), l.children(h).html(u({
  627. templet: a
  628. }, t, o)), l.data("content", t);
  629. }
  630. });
  631. }
  632. }, e);
  633. };
  634. i.elem.on("click", 'input[name="layTableCheckbox"]+', function () {
  635. var e = t(this).prev(),
  636. a = i.layBody.find('input[name="layTableCheckbox"]'),
  637. l = e.parents("tr").eq(0).data("index"),
  638. n = e[0].checked,
  639. o = "layTableAllChoose" === e.attr("lay-filter");
  640. o ? (a.each(function (e, t) {
  641. t.checked = n, i.setCheckData(e, n);
  642. }), i.syncCheckAll(), i.renderForm("checkbox")) : (i.setCheckData(l, n), i.syncCheckAll()), layui.event.call(e[0], y, "checkbox(" + p + ")", v.call(e[0], {
  643. checked: n,
  644. type: o ? "all" : "one"
  645. }));
  646. }), i.elem.on("click", 'input[lay-type="layTableRadio"]+', function () {
  647. var e = t(this).prev(),
  648. a = e[0].checked,
  649. l = d.cache[i.key],
  650. n = e.parents("tr").eq(0).data("index");
  651. layui.each(l, function (e, t) {
  652. n === e ? t.LAY_CHECKED = !0 : delete t.LAY_CHECKED;
  653. }), i.setThisRowChecked(n), layui.event.call(this, y, "radio(" + p + ")", v.call(this, {
  654. checked: a
  655. }));
  656. }), i.layBody.on("mouseenter", "tr", function () {
  657. var e = t(this),
  658. a = e.index();
  659. e.data("off") || i.layBody.find("tr:eq(" + a + ")").addClass(W);
  660. }).on("mouseleave", "tr", function () {
  661. var e = t(this),
  662. a = e.index();
  663. e.data("off") || i.layBody.find("tr:eq(" + a + ")").removeClass(W);
  664. }).on("click", "tr", function () {
  665. m.call(this, "row");
  666. }).on("dblclick", "tr", function () {
  667. m.call(this, "rowDouble");
  668. });
  669. var m = function m(e) {
  670. var i = t(this);
  671. i.data("off") || layui.event.call(this, y, e + "(" + p + ")", v.call(i.children("td")[0]));
  672. };
  673. i.layBody.on("change", "." + R, function () {
  674. var e = t(this),
  675. a = this.value,
  676. l = e.parent().data("field"),
  677. n = e.parents("tr").eq(0).data("index"),
  678. o = d.cache[i.key][n];
  679. o[l] = a, layui.event.call(this, y, "edit(" + p + ")", v.call(this, {
  680. value: a,
  681. field: l
  682. }));
  683. }).on("blur", "." + R, function () {
  684. var e,
  685. a = t(this),
  686. l = this,
  687. n = a.parent().data("field"),
  688. o = a.parents("tr").eq(0).data("index"),
  689. r = d.cache[i.key][o];
  690. i.eachCols(function (t, i) {
  691. i.field == n && i.templet && (e = i.templet);
  692. }), a.siblings(h).html(function (t) {
  693. return u({
  694. templet: e
  695. }, t, r);
  696. }(l.value)), a.parent().data("content", l.value), a.remove();
  697. }), i.layBody.on("click", "td", function (e) {
  698. var i = t(this),
  699. a = (i.data("field"), i.data("edit")),
  700. l = i.children(h);
  701. if (!i.data("off") && a) {
  702. var n = t('<input class="layui-input ' + R + '">');
  703. return n[0].value = i.data("content") || l.text(), i.find("." + R)[0] || i.append(n), n.focus(), void layui.stope(e);
  704. }
  705. }).on("mouseenter", "td", function () {
  706. b.call(this);
  707. }).on("mouseleave", "td", function () {
  708. b.call(this, "hide");
  709. });
  710. var g = "layui-table-grid-down",
  711. b = function b(e) {
  712. var i = t(this),
  713. a = i.children(h);
  714. if (!i.data("off")) if (e) i.find(".layui-table-grid-down").remove();else if (a.prop("scrollWidth") > a.outerWidth()) {
  715. if (a.find("." + g)[0]) return;
  716. i.append('<div class="' + g + '"><i class="layui-icon layui-icon-down"></i></div>');
  717. }
  718. };
  719. i.layBody.on("click", "." + g, function (e) {
  720. var n = t(this),
  721. o = n.parent(),
  722. d = o.children(h);
  723. i.tipsIndex = l.tips(['<div class="layui-table-tips-main" style="margin-top: -' + (d.height() + 16) + "px;" + function () {
  724. return "sm" === a.size ? "padding: 4px 15px; font-size: 12px;" : "lg" === a.size ? "padding: 14px 15px;" : "";
  725. }() + '">', d.html(), "</div>", '<i class="layui-icon layui-table-tips-c layui-icon-close"></i>'].join(""), d[0], {
  726. tips: [3, ""],
  727. time: -1,
  728. anim: -1,
  729. maxWidth: r.ios || r.android ? 300 : i.elem.width() / 2,
  730. isOutAnim: !1,
  731. skin: "layui-table-tips",
  732. success: function success(e, t) {
  733. e.find(".layui-table-tips-c").on("click", function () {
  734. l.close(t);
  735. });
  736. }
  737. }), layui.stope(e);
  738. }), i.layBody.on("click", "*[lay-event]", function () {
  739. var e = t(this),
  740. a = e.parents("tr").eq(0).data("index");
  741. layui.event.call(this, y, "tool(" + p + ")", v.call(this, {
  742. event: e.attr("lay-event")
  743. })), i.setThisRowChecked(a);
  744. }), i.layMain.on("scroll", function () {
  745. var e = t(this),
  746. a = e.scrollLeft(),
  747. n = e.scrollTop();
  748. i.layHeader.scrollLeft(a), i.layTotal.scrollLeft(a), i.layFixed.find(k).scrollTop(n), l.close(i.tipsIndex);
  749. }), H.on("resize", function () {
  750. i.resize();
  751. });
  752. }, function () {
  753. j.on("click", function () {
  754. j.trigger("table.remove.tool.panel");
  755. }), j.on("table.remove.tool.panel", function () {
  756. t(".layui-table-tool-panel").remove();
  757. });
  758. }(), d.init = function (e, i) {
  759. i = i || {};
  760. var a = this,
  761. l = t(e ? 'table[lay-filter="' + e + '"]' : h + "[lay-data]"),
  762. n = "Table element property lay-data configuration item has a syntax error: ";
  763. return l.each(function () {
  764. var a = t(this),
  765. l = a.attr("lay-data");
  766. try {
  767. l = new Function("return " + l)();
  768. } catch (r) {
  769. o.error(n + l);
  770. }
  771. var c = [],
  772. s = t.extend({
  773. elem: this,
  774. cols: [],
  775. data: [],
  776. skin: a.attr("lay-skin"),
  777. size: a.attr("lay-size"),
  778. even: "string" == typeof a.attr("lay-even")
  779. }, d.config, i, l);
  780. e && a.hide(), a.find("thead>tr").each(function (e) {
  781. s.cols[e] = [], t(this).children().each(function (i) {
  782. var a = t(this),
  783. l = a.attr("lay-data");
  784. try {
  785. l = new Function("return " + l)();
  786. } catch (r) {
  787. return o.error(n + l);
  788. }
  789. var d = t.extend({
  790. title: a.text(),
  791. colspan: a.attr("colspan") || 0,
  792. rowspan: a.attr("rowspan") || 0
  793. }, l);
  794. d.colspan < 2 && c.push(d), s.cols[e].push(d);
  795. });
  796. }), a.find("tbody>tr").each(function (e) {
  797. var i = t(this),
  798. a = {};
  799. i.children("td").each(function (e, i) {
  800. var l = t(this),
  801. n = l.data("field");
  802. if (n) return a[n] = l.html();
  803. }), layui.each(c, function (e, t) {
  804. var l = i.children("td").eq(e);
  805. a[t.field] = l.html();
  806. }), s.data[e] = a;
  807. }), d.render(s);
  808. }), a;
  809. }, c.that = {}, c.config = {}, d.eachCols = function (e, i, a) {
  810. var l = c.config[e] || {},
  811. n = [],
  812. o = 0;
  813. a = t.extend(!0, [], a || l.cols), layui.each(a, function (e, t) {
  814. layui.each(t, function (t, i) {
  815. if (i.colGroup) {
  816. var l = 0;
  817. o++, i.CHILD_COLS = [], layui.each(a[e + 1], function (e, t) {
  818. t.PARENT_COL_INDEX || l > 1 && l == i.colspan || (t.PARENT_COL_INDEX = o, i.CHILD_COLS.push(t), l += parseInt(t.colspan > 1 ? t.colspan : 1));
  819. });
  820. }
  821. i.PARENT_COL_INDEX || n.push(i);
  822. });
  823. });
  824. var r = function r(e) {
  825. layui.each(e || n, function (e, t) {
  826. return t.CHILD_COLS ? r(t.CHILD_COLS) : void ("function" == typeof i && i(e, t));
  827. });
  828. };
  829. r();
  830. }, d.checkStatus = function (e) {
  831. var t = 0,
  832. i = 0,
  833. a = [],
  834. l = d.cache[e] || [];
  835. return layui.each(l, function (e, l) {
  836. return l.constructor === Array ? void i++ : void (l[d.config.checkName] && (t++, a.push(d.clearCacheKey(l))));
  837. }), {
  838. data: a,
  839. isAll: !!l.length && t === l.length - i
  840. };
  841. }, d.exportFile = function (e, t, i) {
  842. var a = this;
  843. t = t || d.clearCacheKey(d.cache[e]), i = i || "csv";
  844. var l = c.config[e] || {},
  845. n = {
  846. csv: "text/csv",
  847. xls: "application/vnd.ms-excel"
  848. }[i],
  849. s = document.createElement("a");
  850. return r.ie ? o.error("IE_NOT_SUPPORT_EXPORTS") : (s.href = "data:" + n + ";charset=utf-8,\uFEFF" + encodeURIComponent(function () {
  851. var i = [],
  852. l = [],
  853. n = [];
  854. return layui.each(t, function (t, a) {
  855. var n = [];
  856. "object" == _typeof(e) ? (layui.each(e, function (e, a) {
  857. 0 == t && i.push(a || "");
  858. }), layui.each(d.clearCacheKey(a), function (e, t) {
  859. n.push('"' + (t || "") + '"');
  860. })) : d.eachCols(e, function (e, l) {
  861. if (l.field && "normal" == l.type && !l.hide) {
  862. var o = a[l.field];
  863. void 0 !== o && null !== o || (o = ""), 0 == t && i.push(l.title || ""), n.push('"' + u(l, o, a, "text") + '"');
  864. }
  865. }), l.push(n.join(","));
  866. }), layui.each(a.dataTotal, function (e, t) {
  867. n.push(t);
  868. }), i.join(",") + "\r\n" + l.join("\r\n") + "\r\n" + n.join(",");
  869. }()), s.download = (l.title || "table_" + (l.index || "")) + "." + i, document.body.appendChild(s), s.click(), void document.body.removeChild(s));
  870. }, d.resize = function (e) {
  871. if (e) {
  872. var t = s(e);
  873. if (!t) return;
  874. c.that[e].resize();
  875. } else layui.each(c.that, function () {
  876. this.resize();
  877. });
  878. }, d.reload = function (e, t) {
  879. var i = s(e);
  880. if (i) {
  881. var a = c.that[e];
  882. return a.reload(t), c.call(a);
  883. }
  884. }, d.render = function (e) {
  885. var t = new F(e);
  886. return c.call(t);
  887. }, d.clearCacheKey = function (e) {
  888. return e = t.extend({}, e), delete e[d.config.checkName], delete e[d.config.indexName], e;
  889. }, d.init(), e(y, d);
  890. });