/** layui-v2.4.5 MIT License By https://www.layui.com */
;layui.define(["laytpl", "laypage", "layer", "form", "util"], function (e) {
"use strict";
var t = layui.$, i = layui.laytpl, a = layui.laypage, l = layui.layer, n = layui.form,
o = (layui.util, layui.hint()), r = layui.device(), d = {
config: {checkName: "LAY_CHECKED", indexName: "LAY_TABLE_INDEX"},
cache: {},
index: layui.table ? layui.table.index + 1e4 : 0,
set: function (e) {
var i = this;
return i.config = t.extend({}, i.config, e), i
},
on: function (e, t) {
return layui.onevent.call(this, u, e, t)
}
}, c = function () {
var e = this, t = e.config, i = t.id || t.index;
return i && (c.that[i] = e, c.config[i] = t), {
reload: function (t) {
e.reload.call(e, t)
}, setColsWidth: function () {
e.setColsWidth.call(e)
}, resize: function () {
e.resize.call(e)
}, config: t
}
}, s = function (e) {
var t = c.config[e];
return t || o.error("The ID option was not found in the table instance"), t || null
}, u = "table", h = ".layui-table", y = "layui-hide", f = "layui-none", p = "layui-table-view",
v = ".layui-table-tool", m = ".layui-table-box", g = ".layui-table-init", b = ".layui-table-header",
x = ".layui-table-body", k = ".layui-table-main", C = ".layui-table-fixed", w = ".layui-table-fixed-l",
T = ".layui-table-fixed-r", A = ".layui-table-total", L = ".layui-table-page", S = ".layui-table-sort",
N = "layui-table-edit", W = "layui-table-hover", _ = function (e) {
var t = '{{#if(item2.colspan){}} colspan="{{item2.colspan}}"{{#} if(item2.rowspan){}} rowspan="{{item2.rowspan}}"{{#}}}';
return e = e || {}, ['
")) : (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])
},
error: function (e, t) {
i.layMain.html('
数据接口请求异常:' + t + "
"), i.renderForm(), i.setColsWidth()
}
})
} else if (a.data && a.data.constructor === Array) {
var c = {}, s = e * a.limit - a.limit;
c[n.dataName] = a.data.concat().splice(s, a.limit), c[n.countName] = a.data.length, i.renderData(c, e, a.data.length), o(), i.setColsWidth(), "function" == typeof a.done && a.done(c, e, c[n.countName])
}
}, F.prototype.eachCols = function (e) {
var t = this;
return d.eachCols(null, e, t.config.cols), t
}, F.prototype.renderData = function (e, n, o, r) {
var c = this, s = c.config, u = e[s.response.dataName] || [], h = [], p = [], v = [], m = function () {
var e;
return !r && c.sortKey ? c.sort(c.sortKey.field, c.sortKey.sort, !0) : (layui.each(u, function (a, l) {
var o = [], u = [], f = [], m = a + s.limit * (n - 1) + 1;
0 !== l.length && (r || (l[d.config.indexName] = a), c.eachCols(function (n, r) {
var c = r.field || n, h = s.index + "-" + r.key, p = l[c];
if (void 0 !== p && null !== p || (p = ""), !r.colGroup) {
var v = ['
', '
' + function () {
var n = t.extend(!0, {LAY_INDEX: m}, l), o = d.config.checkName;
switch (r.type) {
case"checkbox":
return '";
case"radio":
return n[o] && (e = a), '';
case"numbers":
return m
}
return r.toolbar ? i(t(r.toolbar).html() || "").render(n) : r.templet ? function () {
return "function" == typeof r.templet ? r.templet(n) : i(t(r.templet).html() || String(p)).render(n)
}() : p
}(), "
")
}
}, F.prototype.getColElem = function (e, t) {
var i = this, a = i.config;
return e.eq(0).find(".laytable-cell-" + (a.index + "-" + t) + ":eq(0)")
}, F.prototype.renderForm = function (e) {
n.render(e, "LAY-table-" + this.index)
}, F.prototype.setThisRowChecked = function (e) {
var t = this, i = (t.config, "layui-table-click"), a = t.layBody.find('tr[data-index="' + e + '"]');
a.addClass(i).siblings("tr").removeClass(i)
}, F.prototype.sort = function (e, i, a, l) {
var n, r, c = this, s = {}, h = c.config, y = h.elem.attr("lay-filter"), f = d.cache[c.key];
"string" == typeof e && c.layHeader.find("th").each(function (i, a) {
var l = t(this), o = l.data("field");
if (o === e) return e = l, n = o, !1
});
try {
var n = n || e.data("field"), p = e.data("key");
if (c.sortKey && !a && n === c.sortKey.field && i === c.sortKey.sort) return;
var v = c.layHeader.find("th .laytable-cell-" + p).find(S);
c.layHeader.find("th").find(S).removeAttr("lay-sort"), v.attr("lay-sort", i || null), c.layFixed.find("th")
} catch (m) {
return o.error("Table modules: Did not match to field")
}
c.sortKey = {
field: n,
sort: i
}, h.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[h.response.dataName] = r || f, c.renderData(s, c.page, c.count, !0), l && layui.event.call(e, u, "sort(" + y + ")", {
field: n,
type: i
})
}, F.prototype.loading = function (e) {
var i = this, a = i.config;
a.loading && (e ? (i.layInit && i.layInit.remove(), delete i.layInit, i.layBox.find(g).remove()) : (i.layInit = t(['
', '', "
"].join("")), i.layBox.append(i.layInit)))
}, F.prototype.setCheckData = function (e, t) {
var i = this, a = i.config, l = d.cache[i.key];
l[e] && l[e].constructor !== Array && (l[e][a.checkName] = t)
}, F.prototype.syncCheckAll = function () {
var e = this, t = e.config, i = e.layHeader.find('input[name="layTableCheckbox"]'), a = function (i) {
return e.eachCols(function (e, a) {
"checkbox" === a.type && (a[t.checkName] = i)
}), i
};
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)))
}, F.prototype.getCssRule = function (e, t) {
var i = this, a = i.elem.find("style")[0], l = a.sheet || a.styleSheet || {}, n = l.cssRules || l.rules;
layui.each(n, function (i, a) {
if (a.selectorText === ".laytable-cell-" + e) return t(a), !0
})
}, F.prototype.fullSize = function () {
var e, t = this, i = t.config, a = i.height;
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 = e - (t.layPage.outerHeight() || 41) - 2), t.layMain.css("height", e))
}, F.prototype.getScrollWidth = function (e) {
var t = 0;
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
}, F.prototype.scrollPatch = function () {
var e = this, i = e.layMain.children("table"), a = e.layMain.width() - e.layMain.prop("clientWidth"),
l = e.layMain.height() - e.layMain.prop("clientHeight"),
n = (e.getScrollWidth(e.layMain[0]), i.outerWidth() - e.layMain.width()), o = function (e) {
if (a && l) {
if (e = e.eq(0), !e.find(".layui-table-patch")[0]) {
var i = t('
');
i.find("div").css({width: a}), e.find("tr").append(i)
}
} else e.find(".layui-table-patch").remove()
};
o(e.layHeader), o(e.layTotal);
var r = e.layMain.height(), d = r - l;
e.layFixed.find(x).css("height", i.height() >= d ? d : "auto"), e.layFixRight[n > 0 ? "removeClass" : "addClass"](y), e.layFixRight.css("right", a - 1)
}, F.prototype.events = function () {
var e, a = this, o = a.config, c = t("body"), s = {}, h = a.layHeader.find("th"), f = ".layui-table-cell",
p = o.elem.attr("lay-filter");
a.layTool.on("click", "*[lay-event]", function (e) {
var i = t(this), c = i.attr("lay-event"), s = function (e) {
var l = t(e.list), n = t('
');
n.html(l), o.height && n.css("max-height", o.height - (a.layTool.outerHeight() || 50)), i.find(".layui-table-tool-panel")[0] || i.append(n), a.renderForm(), n.on("click", function (e) {
layui.stope(e)
}), e.done && e.done(n, l)
};
switch (layui.stope(e), R.trigger("table.tool.panel.remove"), l.close(a.tipsIndex), c) {
case"LAYTABLE_COLS":
s({
list: function () {
var e = [];
return a.eachCols(function (t, i) {
i.field && "normal" == i.type && e.push('')
}), e.join("")
}(), done: function () {
n.on("checkbox(LAY_TABLE_TOOL_COLS)", function (e) {
var i = t(e.elem), l = this.checked, n = i.data("key"), r = i.data("parentkey");
layui.each(o.cols, function (e, t) {
layui.each(t, function (t, i) {
if (e + "-" + t === n) {
var d = i.hide;
i.hide = !l, a.elem.find('*[data-key="' + o.index + "-" + n + '"]')[l ? "removeClass" : "addClass"](y), d != i.hide && a.setParentCol(!l, r), a.resize()
}
})
})
})
}
});
break;
case"LAYTABLE_EXPORT":
r.ie ? l.tips("导出功能不支持 IE,请用 Chrome 等高级浏览器导出", this, {tips: 3}) : s({
list: function () {
return ['
导出到 Csv 文件
', '
导出到 Excel 文件
'].join("")
}(), done: function (e, i) {
i.on("click", function () {
var e = t(this).data("type");
d.exportFile(o.id, null, e)
})
}
});
break;
case"LAYTABLE_PRINT":
var h = window.open("打印窗口", "_blank"),
f = [""].join(""),
v = t(a.layHeader.html());
v.append(a.layMain.find("table").html()), v.find("th.layui-table-patch").remove(), v.find(".layui-table-col-special").remove(), h.document.write(f + v.prop("outerHTML")), h.document.close(), h.print(), h.close()
}
layui.event.call(this, u, "toolbar(" + p + ")", t.extend({event: c, config: o}, {}))
}), h.on("mousemove", function (e) {
var i = t(this), a = i.offset().left, l = e.clientX - a;
i.data("unresize") || s.resizeStart || (s.allowResize = i.width() - l <= 10, c.css("cursor", s.allowResize ? "col-resize" : ""))
}).on("mouseleave", function () {
t(this);
s.resizeStart || c.css("cursor", "")
}).on("mousedown", function (e) {
var i = t(this);
if (s.allowResize) {
var l = i.data("key");
e.preventDefault(), s.resizeStart = !0, s.offset = [e.clientX, e.clientY], a.getCssRule(l, function (e) {
var t = e.style.width || i.outerWidth();
s.rule = e, s.ruleWidth = parseFloat(t), s.minWidth = i.data("minwidth") || o.cellMinWidth
})
}
}), R.on("mousemove", function (t) {
if (s.resizeStart) {
if (t.preventDefault(), s.rule) {
var i = s.ruleWidth + t.clientX - s.offset[0];
i < s.minWidth && (i = s.minWidth), s.rule.style.width = i + "px", l.close(a.tipsIndex)
}
e = 1
}
}).on("mouseup", function (t) {
s.resizeStart && (s = {}, c.css("cursor", ""), a.scrollPatch()), 2 === e && (e = null)
}), h.on("click", function (i) {
var l, n = t(this), o = n.find(S), r = o.attr("lay-sort");
return o[0] && 1 !== e ? (l = "asc" === r ? "desc" : "desc" === r ? null : "asc", void a.sort(n, l, null, !0)) : e = 2
}).find(S + " .layui-edge ").on("click", function (e) {
var i = t(this), l = i.index(), n = i.parents("th").eq(0).data("field");
layui.stope(e), 0 === l ? a.sort(n, "asc", null, !0) : a.sort(n, "desc", null, !0)
});
var v = function (e) {
var l = t(this), n = l.parents("tr").eq(0).data("index"), o = a.layBody.find('tr[data-index="' + n + '"]'),
r = d.cache[a.key][n];
return t.extend({
tr: o, data: d.clearCacheKey(r), del: function () {
d.cache[a.key][n] = [], o.remove(), a.scrollPatch()
}, update: function (e) {
e = e || {}, layui.each(e, function (e, l) {
if (e in r) {
var n, d = o.children('td[data-field="' + e + '"]');
r[e] = l, a.eachCols(function (t, i) {
i.field == e && i.templet && (n = i.templet)
}), d.children(f).html(function () {
return n ? function () {
return "function" == typeof n ? n(r) : i(t(n).html() || l).render(r)
}() : l
}()), d.data("content", l)
}
})
}
}, e)
};
a.elem.on("click", 'input[name="layTableCheckbox"]+', function () {
var e = t(this).prev(), i = a.layBody.find('input[name="layTableCheckbox"]'),
l = e.parents("tr").eq(0).data("index"), n = e[0].checked,
o = "layTableAllChoose" === e.attr("lay-filter");
o ? (i.each(function (e, t) {
t.checked = n, a.setCheckData(e, n)
}), a.syncCheckAll(), a.renderForm("checkbox")) : (a.setCheckData(l, n), a.syncCheckAll()), layui.event.call(e[0], u, "checkbox(" + p + ")", v.call(e[0], {
checked: n,
type: o ? "all" : "one"
}))
}), a.elem.on("click", 'input[lay-type="layTableRadio"]+', function () {
var e = t(this).prev(), i = e[0].checked, l = d.cache[a.key], n = e.parents("tr").eq(0).data("index");
layui.each(l, function (e, t) {
n === e ? t.LAY_CHECKED = !0 : delete t.LAY_CHECKED
}), a.setThisRowChecked(n), layui.event.call(this, u, "radio(" + p + ")", v.call(this, {checked: i}))
}), a.layBody.on("mouseenter", "tr", function () {
var e = t(this), i = e.index();
a.layBody.find("tr:eq(" + i + ")").addClass(W)
}).on("mouseleave", "tr", function () {
var e = t(this), i = e.index();
a.layBody.find("tr:eq(" + i + ")").removeClass(W)
}).on("click", "tr", function () {
m.call(this, "row")
}).on("dblclick", "tr", function () {
m.call(this, "rowDouble")
});
var m = function (e) {
var i = t(this);
layui.event.call(this, u, e + "(" + p + ")", v.call(i.children("td")[0]))
};
a.layBody.on("change", "." + N, function () {
var e = t(this), i = this.value, l = e.parent().data("field"), n = e.parents("tr").eq(0).data("index"),
o = d.cache[a.key][n];
o[l] = i, layui.event.call(this, u, "edit(" + p + ")", v.call(this, {value: i, field: l}))
}).on("blur", "." + N, function () {
var e, l = t(this), n = l.parent().data("field"), o = l.parents("tr").eq(0).data("index"),
r = d.cache[a.key][o];
a.eachCols(function (t, i) {
i.field == n && i.templet && (e = i.templet)
}), l.siblings(f).html(function (a) {
return e ? function () {
return "function" == typeof e ? e(r) : i(t(e).html() || this.value).render(r)
}() : a
}(this.value)), l.parent().data("content", this.value), l.remove()
}), a.layBody.on("click", "td", function (e) {
var i = t(this), a = (i.data("field"), i.data("edit")), l = i.children(f);
if (!i.data("off") && a) {
var n = t('');
return n[0].value = i.data("content") || l.text(), i.find("." + N)[0] || i.append(n), n.focus(), void layui.stope(e)
}
}).on("mouseenter", "td", function () {
b.call(this)
}).on("mouseleave", "td", function () {
b.call(this, "hide")
});
var g = "layui-table-grid-down", b = function (e) {
var i = t(this), a = i.children(f);
if (e) i.find(".layui-table-grid-down").remove(); else if (a.prop("scrollWidth") > a.outerWidth()) {
if (a.find("." + g)[0]) return;
i.append('
')
}
};
a.layBody.on("click", "." + g, function (e) {
var i = t(this), n = i.parent(), d = n.children(f);
a.tipsIndex = l.tips(['
', d.html(), "
", ''].join(""), d[0], {
tips: [3, ""],
time: -1,
anim: -1,
maxWidth: r.ios || r.android ? 300 : a.elem.width() / 2,
isOutAnim: !1,
skin: "layui-table-tips",
success: function (e, t) {
e.find(".layui-table-tips-c").on("click", function () {
l.close(t)
})
}
}), layui.stope(e)
}), a.layBody.on("click", "*[lay-event]", function () {
var e = t(this), i = e.parents("tr").eq(0).data("index");
layui.event.call(this, u, "tool(" + p + ")", v.call(this, {event: e.attr("lay-event")})), a.setThisRowChecked(i)
}), a.layMain.on("scroll", function () {
var e = t(this), i = e.scrollLeft(), n = e.scrollTop();
a.layHeader.scrollLeft(i), a.layTotal.scrollLeft(i), a.layFixed.find(x).scrollTop(n), l.close(a.tipsIndex)
}), R.on("click", function () {
R.trigger("table.remove.tool.panel")
}), R.on("table.remove.tool.panel", function () {
t(".layui-table-tool-panel").remove()
}), H.on("resize", function () {
a.resize()
})
}, d.init = function (e, i) {
i = i || {};
var a = this, l = t(e ? 'table[lay-filter="' + e + '"]' : h + "[lay-data]"),
n = "Table element property lay-data configuration item has a syntax error: ";
return l.each(function () {
var a = t(this), l = a.attr("lay-data");
try {
l = new Function("return " + l)()
} catch (r) {
o.error(n + l)
}
var c = [], s = t.extend({
elem: this,
cols: [],
data: [],
skin: a.attr("lay-skin"),
size: a.attr("lay-size"),
even: "string" == typeof a.attr("lay-even")
}, d.config, i, l);
e && a.hide(), a.find("thead>tr").each(function (e) {
s.cols[e] = [], t(this).children().each(function (i) {
var a = t(this), l = a.attr("lay-data");
try {
l = new Function("return " + l)()
} catch (r) {
return o.error(n + l)
}
var d = t.extend({
title: a.text(),
colspan: a.attr("colspan") || 0,
rowspan: a.attr("rowspan") || 0
}, l);
d.colspan < 2 && c.push(d), s.cols[e].push(d)
})
}), a.find("tbody>tr").each(function (e) {
var i = t(this), a = {};
i.children("td").each(function (e, i) {
var l = t(this), n = l.data("field");
if (n) return a[n] = l.html()
}), layui.each(c, function (e, t) {
var l = i.children("td").eq(e);
a[t.field] = l.html()
}), s.data[e] = a
}), d.render(s)
}), a
}, c.that = {}, c.config = {}, d.eachCols = function (e, i, a) {
var l = c.config[e] || {}, n = [], o = 0;
a = t.extend(!0, [], a || l.cols), layui.each(a, function (e, t) {
layui.each(t, function (t, i) {
if (i.colGroup) {
var l = 0;
o++, i.CHILD_COLS = [], layui.each(a[e + 1], function (e, t) {
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))
})
}
i.PARENT_COL_INDEX || n.push(i)
})
});
var r = function (e) {
layui.each(e || n, function (e, t) {
return t.CHILD_COLS ? r(t.CHILD_COLS) : void ("function" == typeof i && i(e, t))
})
};
r()
}, d.checkStatus = function (e) {
var t = 0, i = 0, a = [], l = d.cache[e] || [];
return layui.each(l, function (e, l) {
return l.constructor === Array ? void i++ : void (l[d.config.checkName] && (t++, a.push(d.clearCacheKey(l))))
}), {data: a, isAll: !!l.length && t === l.length - i}
}, d.exportFile = function (e, t, i) {
t = t || d.clearCacheKey(d.cache[e]), i = i || "csv";
var a = c.config[e] || {}, l = {csv: "text/csv", xls: "application/vnd.ms-excel"}[i],
n = document.createElement("a");
return r.ie ? o.error("IE_NOT_SUPPORT_EXPORTS") : (n.href = "data:" + l + ";charset=utf-8,\ufeff" + encodeURIComponent(function () {
var i = [], a = [];
return layui.each(t, function (t, l) {
var n = [];
"object" == typeof e ? (layui.each(e, function (e, a) {
0 == t && i.push(a || "")
}), layui.each(d.clearCacheKey(l), function (e, t) {
n.push(t)
})) : d.eachCols(e, function (e, a) {
a.field && "normal" == a.type && !a.hide && (0 == t && i.push(a.title || ""), n.push(l[a.field]))
}), a.push(n.join(","))
}), i.join(",") + "\r\n" + a.join("\r\n")
}()), n.download = (a.title || "table_" + (a.index || "")) + "." + i, document.body.appendChild(n), n.click(), void document.body.removeChild(n))
}, d.resize = function (e) {
if (e) {
var t = s(e);
if (!t) return;
c.that[e].resize()
} else layui.each(c.that, function () {
this.resize()
})
}, d.reload = function (e, i) {
i = i || {};
var a = s(e);
if (a) return i.data && i.data.constructor === Array && delete a.data, d.render(t.extend(!0, {}, a, i))
}, d.render = function (e) {
var t = new F(e);
return c.call(t)
}, d.clearCacheKey = function (e) {
return e = t.extend({}, e), delete e[d.config.checkName], delete e[d.config.indexName], e
}, d.init(), e(u, d)
});