/* 未能~小。正在返回未~小的内宏V? (46,45-46): run-time error JS1195: Expected expression: ) (46,48-49): run-time error JS1195: Expected expression: > (50,14-15): run-time error JS1195: Expected expression: ) (78,34-35): run-time error JS1195: Expected expression: ) (78,37-38): run-time error JS1195: Expected expression: > (87,10-11): run-time error JS1195: Expected expression: , (87,15-16): run-time error JS1003: Expected ':': ) (88,5-6): run-time error JS1002: Syntax error: } (90,32-33): run-time error JS1004: Expected ';': { (91,24-25): run-time error JS1195: Expected expression: ) (91,27-28): run-time error JS1195: Expected expression: > (91,82-83): run-time error JS1004: Expected ';': ) (92,6-7): run-time error JS1195: Expected expression: , (94,38-39): run-time error JS1004: Expected ';': { (101,49-50): run-time error JS1195: Expected expression: > (106,48-49): run-time error JS1195: Expected expression: ) (106,51-52): run-time error JS1195: Expected expression: > (113,26-27): run-time error JS1195: Expected expression: , (113,31-32): run-time error JS1003: Expected ':': . (115,23-27): run-time error JS1004: Expected ';': else (117,18-19): run-time error JS1195: Expected expression: ) (122,17-18): run-time error JS1002: Syntax error: } (126,21-22): run-time error JS1195: Expected expression: ) (126,23-24): run-time error JS1004: Expected ';': { (243,40-41): run-time error JS1195: Expected expression: > (243,43-44): run-time error JS1197: Too many errors. The file might not be a JavaScript file: ( (241,38-49): run-time error JS1301: End of file encountered before function is properly closed: function () (243,44-48): run-time error JS1004: Expected ';': item (243,96-97): run-time error JS1004: Expected ';': ) (244,21-22): run-time error JS1197: Too many errors. The file might not be a JavaScript file: . (99,9,115,22): run-time error JS1018: 'return' statement outside of function: return { run: function (toRun) { let p = new Promise((rev, ref) => { if (typeof (func_condi) == "function") { let timeout = 0; let sid = setInterval(() => { timeout += ops.time; let r = func_condi(); if (r != null && r == true) { rev(""); clearInterval(sid); } else if (timeout >= ops.timeout) rev("{待时Q? + ops.timeout + "ms"); }, ops.time) } */ var myConst = { ERR_API_LOGIC: "数据接口逻辑发生异常", ERR_PAGE_JSON: "面数据反序列化时发生异?, ERR_DATA_NOT_FOUND: "没有扑ֈ数据", ERR_DATA_NOT_SELECT_EDI: "没有选择要修改的数据", ERR_DATA_NOT_SELECT_DEL: "没有选择要删除的数据", ERR_DATA_NOT_SELECT_ACTION: "没有选择要操作的数据", ERR_DATA_NOT_SELECT_LOGOFF: "没有选择要冲销的数?, ERR_DATA_NOT_SELECT_ACCOUNT: "没有选择要充值的账号", ERR_DATA_NOT_SELECT_TemplateFile: "没有选择模板文g", ERR_DATA_NAN_PRIMARYKEY: "获取选择索引逻辑异常", ERR_DATA_NAN_SEARCHWHERE: "数据qo条g异常", ERR_DATA_NAN: "面数据异常", ERR_PAGE_REQUIRED: "请完成必ȝ填?, ERR_WAIT_TIMEOUT: "{待时", Err_UNKNOWN:"不明异常", SUCC_DATA_OK: "数据没有异常", SUCC_ACTION_OK: "执行成功", SUCC_SAVE_OK: "保存成功", SUCC_ACTION_Fail: "执行p|", } let loadtime1 = null; let loadtime2 = null; $(_showFullLoad); function _showFullLoad() { if (window["ST_THEME_DEFAULT"]) return; let ST_FullLoad = $(".common-full-load"); if (ST_FullLoad != null && ST_FullLoad.length>0) return; ST_FullLoad = $("
"); $("body").before(ST_FullLoad); loadtime1 = new Date().getTime(); } function _closeFullLoad(callback) { let time_load = 1000; let time_anim = 500; let ST_FullLoad = $(".common-full-load"); if (ST_FullLoad != null && ST_FullLoad.usable()) { function _close() { $("body").show(); ST_FullLoad.fadeOut(time_anim, () => { ST_FullLoad.remove(); ST_FullLoad = null; if (typeof (callback) == "function") callback(); }); } loadtime2 = new Date().getTime(); let timedif = (loadtime2 - loadtime1); if (timedif < time_load) setTimeout(_close, time_load - timedif); else _close(); } else if (typeof (callback) == "function") callback(); } var mycommon = { //常用逻辑初始? init_completed: false, ajaxErr: [], layer: null, table: null, cardshow: null, rowselect: null, requireing: false,//是否正在h DtCache: {}, jsonshow: null, init_start: null, init_end: null, pageStyle: null, colors: ["#86cbff", "#42d79c", "#ffcd4d", "#ffa081", "#f097ff", "#ffb8b8", "#6ad9ce", "#a6c5db", "#e3b5b5", "#bb9fdb"], on: function (callback) { let that = this; let __sid = setInterval(() => { if (that.init_completed) { if ($.isFunction(callback)) callback(); that.init_end = new Date(); that.logOk("On-TimeStamp:" + ((that.init_end.getTime() - that.init_start.getTime()) / 1000) + "s", "background:orange;") clearInterval(__sid); } }, 100); }, //{街Dom加蝲完成后执行call ready: function (callback) { mycommon.wait(() => document.readyState == "complete", { timeout: 60000 }).run(callback); }, //{待指定条g后执行指定的动作 wait: function (func_condi, ops) { ops = ops || {}; ops.time = ops.time || 100; ops.timeout = ops.timeout || "60000"; return { run: function (toRun) { let p = new Promise((rev, ref) => { if (typeof (func_condi) == "function") { let timeout = 0; let sid = setInterval(() => { timeout += ops.time; let r = func_condi(); if (r != null && r == true) { rev(""); clearInterval(sid); } else if (timeout >= ops.timeout) rev("{待时Q? + ops.timeout + "ms"); }, ops.time) } else rev("条g参数无效"); }); p.then(msg => { if ((msg || "") == "" && typeof (toRun) == "function") toRun(); else mycommon.logWarn(msg); }) } } }, init: function () { let FullLoad = null; this.init_start = new Date(); let that = this; let libTimeSpan = "?v=" + new Date().getTime(); String.prototype.HeadZero = this.__HeadZero; String.prototype.tryJson = this.tryJson; String.prototype.TrimChar = this.__TrimChar; Date.prototype.CvAddDay = this.CV_addDay; Date.prototype.CvDate = this.CV_getDate; Date.prototype.CvTime = this.CV_getTime; Date.prototype.CvTimems = this.CV_getTimems; Date.prototype.CvDateTime = this.CV_getDatetime; Date.prototype.CvDateTimems = this.CV_getDatetimems; Date.prototype.CvDateObj = this.CV_getDatetimeObj; Date.prototype.CvDateTimeStr = this.CV_getDateTimeStr; String.prototype.strNotNull = this.__strNotNull; //取得当前地址的参? String.prototype.params = function () { var url = this.toString() var reg = /[\?\&]?([^\?\&]*\=[^\?\&]*)\&?/g; var res = url.match(reg) if (res != null && res.length > 0) { var arr = {} for (var i = 0; i < res.length; i++) { var str = res[i].replace(/[\?\&]/g, '') var w = str.split('='); arr[w[0]] = w[1]; } return arr } return null }; //当前地址U除指定参数q回新地址 String.prototype.removeParam = function (str) { let _this = this; let _params = _this.params(); if (_params != null && _params[str] != null) { let _base = _this.split('?')[0]; let newparamstr = "" for (let p in _params) { if (p.toLowerCase() != str) { newparamstr += p + "=" + _params[p] + "&" } } if (newparamstr.strNotNull()) { return _base + "?" + newparamstr.trim("&"); } else return _base; } else return _this; }; $.fn.extend({ //JQ对象是否可用 usable: this.__jqNotNull, //JQ对象的value是否非空 valusable: function () { if (this.val() != null && this.val().toString().trim() != "") return true; else return false; }, //警报JQ元素 warn: function () { var $el = this; that.warnElement($el); }, ifrview: function () { let $ifr = this; return $ifr[0].contentDocument.defaultView } }); //加蝲layui模块 layui.config({ base: "../../JS/layui/layui_exts/" }).extend({ rowselect: "rowselect/rowselect.js" + libTimeSpan, phonedate: "phonedate/phonedate.js" + libTimeSpan, textboxselect: "textboxselect/textboxselect.js" + libTimeSpan, mpgoodsselect: "mpgoodsselect/mpgoodsselect.js" + libTimeSpan, mpdeviceselect: "mpdeviceselect/mpdeviceselect.js" + libTimeSpan, smsrolearea: "smsrolearea/smsrolearea.js" + libTimeSpan, smssearchbar: "smssearchbar/smssearchbar.js" + libTimeSpan, smsaccessdata: "smsaccessdata/smsaccessdata.js" + libTimeSpan, btnupload: "btnupload/btnupload.js" + libTimeSpan, btnuploadpieces: "btnuploadpieces/btnuploadpieces.js" + libTimeSpan, smssetting: "smssetting/smssetting.js" + libTimeSpan, tooleventcalls: "tooleventcalls/tooleventcalls.js" + libTimeSpan, movediv: "MoveDiv/movediv.js" + libTimeSpan, smsupload: "smsupload/smsupload.js" + libTimeSpan, smslistbox: "smslistbox/smslistbox.js" + libTimeSpan, meaccountselect: "meaccountselect/meaccountselect.js" + libTimeSpan, mefileselect: "mefileselect/mefileselect.js" + libTimeSpan, jsonshow: "jsonshow/jsonshow.js" + libTimeSpan, imgplayer: "imgplayer/imgplayer.js" + libTimeSpan, imgscroller: "imgscroller/imgscroller.js" + libTimeSpan, treeshow: "treeshow/treeshow.js" + libTimeSpan, docshow: "docshow/docshow.js" + libTimeSpan, htmlelement: "htmlelement/htmlelement.js" + libTimeSpan, STslider: "STslider/STslider.js" + libTimeSpan, cardshow: "cardshow/cardshow.js" + libTimeSpan }); layui.use(["layer", "table", "rowselect", "jsonshow", "htmlelement", "cardshow"], function () { that.jsonshow = layui.jsonshow; that.layer = layui.layer; that.table = layui.table; that.rowselect = layui.rowselect; that.cardshow = layui.cardshow; //取得当前弹出层的最大烦? that.layer.getMaxLayID = function () { let oldlayerIDs = $(".layui-layer") .filter((i, item) => $(item).attr("id") != null && $(item).attr("id") != "") .map((i, item) => parseInt($(item).attr("id").replace("layui-layer", ""))); let oldshadeIds = $(".layui-layer-shade") .filter((i, item) => $(item).attr("id") != null && $(item).attr("id") != "") .map((i, item) => parseInt($(item).attr("id").replace("layui-layer-shade", ""))); let oldcommonIds = $("[st-commonlayerid]") .map((i, item) => parseInt($(item).attr("st-commonlayerid"))); let c1 = (oldlayerIDs == null || oldlayerIDs.length == 0); let c2 = (oldshadeIds == null || oldshadeIds.length == 0); let c3 = (oldcommonIds == null || oldcommonIds.length == 0); if (c1 && c2 && c3) return 0; let maxlayerID = c1 ? 0 : Math.max(...oldlayerIDs); let maxshadeID = c2 ? 0 : Math.max(...oldshadeIds); let maxcommonID = c3 ? 0 : Math.max(...oldcommonIds); return Math.max(...[maxlayerID, maxshadeID, maxcommonID]); } //装 layer.msg that.layer.ms = function (str, ops) { var _ops; if (ops == undefined) _ops = {}; else _ops = ops; if (_ops.area == undefined) _ops.area = ["auto", "auto"]; mycommon.wait(() => { let loads = $(".layui-layer").filter(".common-myload"); return loads.length == 0; }).run(() => { that.layer.msg(str, _ops) }) } //自徏的load? that.layer.myload = function (ops) { if (ops == undefined) ops = {}; ops.opacity = ops.opacity || 0; ops.zindex = (that.layer.zIndex || 99999900) + 1; ops.index = that.layer.index + 1; let _shade = $(""); //old //let _LAYER = $(""); //new //let _LAYER = $(""); let ThemeDic_shadow = { black: "#000000AA", green: "#144316AA" } let shadowColor = ((that.pageStyle || {}).theme || "") != "" ? ThemeDic_shadow[that.pageStyle.theme] : "#2f9fff44"; //canvas let _LAYER = $(""); let _lo = layui.htmlelement.Load_Circle(); _LAYER.children().css("border-radius", "20px"); _LAYER.children().append(_lo); _lo.css("width", "calc(100% - 40px)"); _lo.css("height", "calc(100% - 40px)"); _lo.css("padding", "20px"); $("body").append(_shade); $("body").append(_LAYER); _shade.slideDown(100); _LAYER.slideDown(100, function () { let ThemeDic_painColor = { black: "#ffffff", green: "#ffffff" } _lo[0].showEL({ color: ((that.pageStyle || {}).theme || "") != "" ? ThemeDic_painColor[that.pageStyle.theme] : "#0f6cb1" }); }) that.layer.index = ops.index; that.layer.zIndex = ops.zindex return ops.index; } //自徏的msgs层(昄C批处理的结查ListQ? that.layer.msgs = function (ops) { if (ops.data == null || ops.data.length == 0) return; let _area = ops.area || (mycommon.isPhone() ? ["100%", "100%"] : ["50%", "50%"]); let _html = "
"; $.each(ops.data, function (i, item) { _html += "
" + item + "
"; }); _html += "
" that.layer.open({ title: mycommon.isPhone() ? "信息列表" : "", content: _html, resize: false, area: _area, btn: [] }) } //自徏的win?(面元素构徏操作UIH口) that.layer.win = function (ops) { //content 拼接的html字符? //area H口寸 //success 渲染完成的回?携参 {contentEL, layid, zID} //yes 定按钮的点d?携参 {contentEL, layid} //yesText //yesBtn true/false //cancelText //cancelBtn true/false //end H口销毁后的回? //title 标题 let _area = ops.area || (that.isPhone() ? ["100%", "100%"] : ["50%", "40vh"]); let _yesText = ops.yesText || "定"; let _cancelText = ops.cancelText || "取消" let _yesBtn = ops.yesBtn == null ? true : ops.yesBtn; let _cancelBtn = ops.cancelBtn == null ? true : ops.cancelBtn; let _html = "
" _html += ops.title != null ? ("
" + ops.title + "
") : ""; _html += "
" + ops.content + "
" _html += "
" _html += "
 " + _yesText + " " + _cancelText + "
" let contentEL = null; that.layer.open({ type: ops.type == null ? 1 : ops.type, closeBtn: 0, title: "", resize: false, area: _area, btn: [], content: _html, success: function (layerEL, layid) { layerEL.addClass("layer-win-parent") contentEL = layerEL.find(".alert-form").children(); let zID = that.layer.zIndex; //定按钮 let okBtn = layerEL.find(".st-win-ok"); okBtn.on("click", function () { if ($.isFunction(ops.yes)) ops.yes(contentEL, layid); }) //取消按钮 let CloseBtn = layerEL.find(".st-win-close"); CloseBtn.on("click", function () { that.layer.close(layid); }) if ($.isFunction(ops.success)) ops.success(contentEL, layid, zID); }, end: function () { if ($.isFunction(ops.end)) ops.end(contentEL); } }) } //适尺弹出层显C图? that.layer.pic = function (url, ops) { that.layerShowPic(url, ops); return; //ops.area: gؓ可以?["50%"]、["auto","60%"]Q有宽取宽,无宽取高 if (ops == undefined) ops = {}; if (url.toLowerCase().indexOf("//") < 0 && url.toLowerCase().indexOf("//") < 0) url = "/" + url.replace(/\\/g, "/").TrimChar("/") + "?v=" + (new Date().getTime()); let _img = $("") _img[0].onerror = function (e) { that.layer.ms("囄文g已丢?); } _img[0].onload = function (e) { let _h = _img.height(); let _w = _img.width(); let ww; let hh; let ed; ops.area = ops.area || ["60%"]; if (ops.area.length == 1) { ww = ops.area[0]; ed = ww.indexOf("%") >= 0 ? "%" : "px"; let wa = parseInt(ww.toLowerCase().replace(ed, "")); let ha = (_h * wa / _w); if (ed == "%") ha = ha * window.innerWidth / window.innerHeight; hh = ha + ed; } else if (ops.area.length == 2 && ops.area[0].toLowerCase() == "auto") { hh = ops.area[1]; ed = hh.indexOf("%") >= 0 ? "%" : "px"; let ha = parseInt(hh.toLowerCase().replace(ed, "")); let wa = (_w * ha / _h); if (ed == "%") wa = wa * window.innerHeight / window.innerWidth; ww = wa + ed; } ops.area = [ww, hh]; ops.title = ""; ops.type = 1; ops.content = _img; ops.success = function (layEL, LayId) { _img.css("max-width", "calc(100% - 40px)"); _img.css("max-height", "calc(100% - 40px)"); _img.css("object-fit", "contain"); _img.css("top", ""); _img.css("left", ""); _img.css("position", ""); _img.css("margin", "auto"); _img.parent().css("display", "flex"); layEL.css("overflow", "visible"); if (layEL.width() > window.innerWidth - 60) { layEL.width(window.innerWidth - 60); layEL.css("left", "30px") } }; ops.end = function () { _img.remove(); }; that.layer.open(ops); } $("body").append(_img); } //本子H层控制 that.layer.view = { HideClose: function () { mycommon.logOk("HideClose") let LayWhole = $(window.frameElement).parent().parent(); let LayContent = LayWhole.children(".layui-layer-content") let LayIfr = LayContent.children("iframe"); try { LayWhole.css("transition", "0.3s"); LayContent.css("transition", "0.3s"); LayIfr.css("transition", "0.3s"); LayWhole.children(".layui-layer-title").css("max-height", "50px"); LayWhole.children(".layui-layer-title").css("opacity", "1"); LayWhole.children(".layui-layer-title").css("transition", "0.3s"); LayWhole.children(".layui-layer-setwin").children(".layui-layer-close").hide(300); LayWhole.children(".layui-layer-title").css("opacity", "0"); LayWhole.css("background", "transparent"); LayWhole.css("box-shadow", "none"); if (LayWhole.height() == window.frameElement.ownerDocument.defaultView.innerHeight) { LayWhole.children(".layui-layer-title").css("max-height", "0px"); LayWhole.children(".layui-layer-title").css("border-bottom", "none"); LayContent.attr("st-height", LayContent.height()); LayContent.css("height", "100%"); LayIfr.attr("st-height", LayIfr.height()); LayIfr.css("height", "100%"); } setTimeout(() => { LayWhole.css("transition", ""); LayContent.css("transition", ""); LayIfr.css("transition", ""); LayWhole.children(".layui-layer-title").css("transition", ""); }, 400) } catch (e) { } }, ShowClose: function () { mycommon.logOk("ShowClose") let LayWhole = $(window.frameElement).parent().parent(); let LayContent = LayWhole.children(".layui-layer-content") let LayIfr = LayContent.children("iframe"); LayWhole.children(".layui-layer-setwin").children(".layui-layer-close").css("display", ""); try { LayWhole.css("transition", "0.3s"); LayContent.css("transition", "0.3s"); LayIfr.css("transition", "0.3s"); LayWhole.children(".layui-layer-title").css("transition", "0.3s"); LayWhole.children(".layui-layer-title").css("opacity", "1"); LayWhole.css("background", ""); LayWhole.css("box-shadow", ""); if (LayWhole.height() == window.frameElement.ownerDocument.defaultView.innerHeight) { LayWhole.children(".layui-layer-title").css("max-height", "50px"); LayWhole.children(".layui-layer-title").css("border-bottom", ""); let cHeight = LayContent.attr("st-height"); LayContent.css("height", cHeight + "px"); let iHeight = LayIfr.attr("st-height"); LayIfr.css("height", iHeight + "px"); } setTimeout(() => { LayWhole.css("transition", ""); LayContent.css("transition", ""); LayIfr.css("transition", ""); LayWhole.children(".layui-layer-title").css("transition", ""); }, 400) } catch (e) { } } } //指示输入? that.layer.input = function (ops) { ops = ops || {}; ops.iconClass = ops.iconClass || "" ops.msg = ops.msg || ""; ops.title = ops.title || ""; let _yes = ops.yes; let _end = ops.end; let _succ = ops.success; ops.yes = function (contentEL, layid) { let iptEL = contentEL.filter(".layout-win").find("input"); let iptVal = iptEL.val(); if (typeof (_yes) == "function") _yes(contentEL, layid, iptVal); }; ops.success = function (contentEL, layid, zID) { let iptEL = contentEL.filter(".layout-win").find("input"); if (typeof (_succ) == "function") _succ(contentEL, layid, zID, iptEL); }; ops.end = function () { if (typeof (_end) == "function") _end(); }; let html_msg = (ops.iconClass == "" ? "" : ("")) + (ops.msg == "" ? "" : ("
" + ops.msg + "
")) ops.content = html_msg.trim() == "" ? "" : ("
" + html_msg + "
"); ops.content += "
"; mycommon.layer.win(ops); } //面底部消息? that.layer.ms_PageBottom = function (str, ops) { ops = ops || {}; let time = ops.time || 4000; let msCon = $("body").find(".common-layer-msg-bottom"); if (msCon.length == 0) { msCon = $("
"); $("body").append(msCon); } let $lay = $("") msCon.append($lay); $lay.show(500); setTimeout(() => { $lay.hide(500, function () { $lay.remove(); if (msCon.children().length == 0) msCon.remove(); }) }, time) } //面异常覆盖? that.layer.pageError = function (innerhtml, ops) { let shade = $("
"); let msg = $("
" + innerhtml + "
"); shade.append(msg); $("body").append(shade); shade.slideDown(200, function () { msg.slideDown(200); }); } that.checkCssFile("content/mycommon.css" + libTimeSpan); that.checkCssFile("content/fonts/En/TitleBlack.css" + libTimeSpan); function afterStyle() { let myloadCss = "/content/mycommonload.css" if (((that.pageStyle || {}).theme || "") != "") myloadCss = "/themes/" + that.pageStyle.theme + "/mycommonload.css"; that.checkCssFile(myloadCss + libTimeSpan); _closeFullLoad(() => { that.logOk("init_completed"); that.init_completed = true; }); } if (window["ST_THEME_DEFAULT"]) afterStyle(); else that.getPageStyle(afterStyle); }) }, //全局事g响应讄 eventSet: { beforeClose: function (mid, callback) { // callback中返?_layer, close) let winTop = window.top; if (winTop["ST_EVENT_BeforClose"] != null) { winTop["ST_EVENT_BeforClose"]["Menu" + mid] = callback; } else { console.log("todo") //window.onbeforeunload = function (e) { // e.returnValue = "定d当前面吗?"; // e.preventDefault(); // return false; //} } }, winfocus: function (mid, callback) { // callback中返?_layer) let winTop = window.top; if (winTop["ST_EVENT_winfocus"] != null) { winTop["ST_EVENT_winfocus"]["Menu" + mid] = callback; } } }, //面风格加蝲切换 loadPageStyle(pagestyle, callback) { window["ST_PAGE_USING_THEME"] = ""; let that = this; if (pagestyle == null || pagestyle.id == -1) { //默认风格 that.pageStyle = null; $("html").removeAttr("ST-Theme"); if (typeof (callback) == "function") callback(); } else if ((pagestyle.theme || "").trim() != "") { //指定风格 $("html").attr("ST-Theme", pagestyle.theme); window["ST_PAGE_USING_THEME"] = pagestyle.theme; that.RunStyleChange(pagestyle.theme, callback); } else { //默认风格 that.pageStyle = null; $("html").removeAttr("ST-Theme"); if (typeof (callback) == "function") callback(); } //主面的子H口加蝲主题 if (window["SiteConole"]) { let ifrS = $(".sms-sub-tPage").find("iframe"); if (ifrS != null && ifrS.usable()) { ifrS.each(function (i, item) { let $it = $(item); let _win = item.contentDocument.defaultView; if (_win.mycommon != null) _win.mycommon.loadPageStyle(pagestyle); }) } } }, getPageStyle(callback) { let that = this; if (window["ST_PAGE_USING_THEME"] != null && window["ST_PAGE_USING_THEME"].toString().trim() != "") { let _pageStyle = window["ST_PAGE_USING_THEME"].tryJson(); if (_pageStyle != null) { that.pageStyle = _pageStyle; that.loadPageStyle(_pageStyle, callback); return; } } that.ajax({ url: "/home/getPageStyle", load: false, success: res => { if (res.code == 0 && res.data != null) { that.pageStyle = res.data; that.loadPageStyle(res.data, callback); } else if (typeof (callback) == "function") callback(); }, error: () => { if (typeof (callback) == "function") callback(); } }) }, RunStyleChange: function (theme, Callback) { this.logOk("Style:" + theme, "background-color:orangered"); let _time = new Date().getTime(); main(); function main() { mycommon.checkCssFile("/content/themes/" + theme + ".css?v=" + _time, "st-theme='1'", function () { calinServer(eahcEL); }); } // 后端处理 function calinServer(_callback) { let _style = allStyle(); mycommon.ajax({ url: '/Theme/newcss', data: { style: JSON.stringify(_style), theme }, success: res => { let _links = allLinks(() => { if (res.code == 0 && res.data != null) { mycommon.checkCssFile(res.data + "?v=" + _time, "", function () { //if (typeof (_callback) == "function") _callback(); if (typeof (Callback) == "function") Callback(); }); } }); }, error: function () { if (typeof (Callback) == "function") Callback(); } }) } // 逐元? function eahcEL() { $("body").find(":not(script)").not("[ST_PageStyleConvertEnd]").each(function (i, item) { let $it = $(item); checkStyle($it); }) setTimeout(eahcEL, 1000); } // 验style属? function checkStyle($el) { $el.attr("ST_PageStyleConvertEnd", "1"); let sl = $el.attr("style") || ""; if (sl.trim() == "") return; var sls = sl.split(';'); if (sls.length == 0) return; $.each(sls, function (i, item) { let _item = item.trim(); if (_item == "") return if (_item.substring(0, 10) == "background") { console.log(_item); console.log("background"); } if (_item.substring(0, 16) == "background-color") { console.log(_item); console.log("background-color"); } if (_item.substring(0, 5) == "color") { console.log(_item); $el.css("color", "white"); } }) } // 获取所有引入的css文g function allLinks(_callback) { let list1 = []; let list2 = []; let ignorS = [ "content/fonts", "content/themes", //"js/layui/css" ]; let resultList = [] $("link").each(function (i, item) { let href = $(item).attr("href"); var curr = ignorS.find(a => href.toLowerCase().replace(/\\/g, "/").indexOf(a) >= 0); if (curr == null) { list1.push(href); var filename = href; if (href.indexOf("?") >= 0) filename = href.toLowerCase().split("?")[0].replace(/\\/g, "/"); filename = filename.substring(filename.lastIndexOf("/") + 1); if (href.indexOf(".css") < 0) filename += ".css"; filename = "/themes/" + theme + "/" + filename + "?t=" + (new Date().getTime()); let newLink = $(""); newLink[0].st_onload = false; newLink[0].onload = function () { newLink[0].st_onload = true; } $("head").append(newLink); resultList.push(newLink); //setTimeout(() => { // $(item).remove(); //}, 2000); list2.push(newLink); } }) if (resultList.length > 0) { mycommon.wait(() => { return resultList.every(a => a[0].st_onload); }).run(() => { if (typeof (_callback) == "function") _callback(); }) } else { if (typeof (_callback) == "function") _callback(); } return list1; } // 获取所面上的style标签 function allStyle() { let list = []; $("style").each(function (i, item) { list.push($(item).html()); }) return list; } // 待删? // 重输出css样式文本 //function BgRGB(color) { // let reg = /rgb\(.*?\)/g; // let match = color.match(reg); // if (match == null) return color; // let list = []; // let id = 0; // let _color = color // while (match) { // id++ // list.push({ old: match[0], new: newBackRGB(match[0]), id: "{{" + id + "}}" }); // _color = _color.replace(match[0], ""); // match = _color.match(reg); // } // if (list.length > 0) { // let newcolor = color; // $.each(list, function (i, item) { // newcolor = newcolor.replace(item.old, item.id) // }) // $.each(list, function (i, item) { // newcolor = newcolor.replace(item.id, item.new) // }) // return newcolor; // } else return color; //} //function BgRGBA(color) { // let reg = /rgba\(.*?\)/g; // let match = color.match(reg); // if (match == null) return color; // let list = []; // let id = 0; // let _color = color // while (match) { // id++ // list.push({ old: match[0], new: newBackRGBA(match[0]), id: "{{" + id + "}}" }); // _color = _color.replace(match[0], ""); // match = _color.match(reg); // } // if (list.length > 0) { // let newcolor = color; // $.each(list, function (i, item) { // newcolor = newcolor.replace(item.old, item.id) // }) // $.each(list, function (i, item) { // newcolor = newcolor.replace(item.id, item.new) // }) // return newcolor; // } else return color; //} //function FcRGB(color) { // return color; // let reg = /rgb\(.*?\)/g; // let match = color.match(reg); // if (match == null) return color; // let list = []; // let id = 0; // let _color = color // while (match) { // id++ // list.push({ old: match[0], new: newFontRGB(match[0]), id: "{{" + id + "}}" }); // _color = _color.replace(match[0], ""); // match = _color.match(reg); // } // if (list.length > 0) { // let newcolor = color; // $.each(list, function (i, item) { // newcolor = newcolor.replace(item.old, item.id) // }) // $.each(list, function (i, item) { // newcolor = newcolor.replace(item.id, item.new) // }) // return newcolor; // } else return color; //} //function FcRGBA(color, $it) { // let isDeepBack = whiteFc($it); // if ($it[0].tagName.toLowerCase() == "tr") { // //console.log(isDeepBack); // //console.log($it); // } // if ($it != null && isDeepBack) return "white"; // else return color; // let reg = /rgba\(.*?\)/g; // let match = color.match(reg); // if (match == null) return color; // let list = []; // let id = 0; // let _color = color // while (match) { // id++ // list.push({ old: match[0], new: newFontRGBA(match[0]), id: "{{" + id + "}}" }); // _color = _color.replace(match[0], ""); // match = _color.match(reg); // } // if (list.length > 0) { // let newcolor = color; // $.each(list, function (i, item) { // newcolor = newcolor.replace(item.old, item.id) // }) // $.each(list, function (i, item) { // newcolor = newcolor.replace(item.id, item.new) // }) // return newcolor; // } else return color; //} // 色替? //function newBackRGB(rgb) { // let reg = /\d+\s?\,\s?\d+\s?\,\s?\d+/; // let match = rgb.match(reg); // if (match == null) return rgb; // let spt = match[0].split(','); // let r = parseInt(spt[0].trim()); // let g = parseInt(spt[1].trim()); // let b = parseInt(spt[2].trim()); // if (r == 255 && g == 255 && b == 255) return rgb; // r = colorBGVal("r", r); // g = colorBGVal("g", g); // b = colorBGVal("b", b); // let result = ("rgb(" + r + "," + g + "," + b + ")"); // return result; //} //function newBackRGBA(rgb) { // let reg = /\d+\s?\,\s?\d+\s?\,\s?\d+\s?\,\s?\d+/; // let match = rgb.match(reg); // if (match == null) return rgb; // let spt = match[0].split(','); // let r = parseInt(spt[0].trim()); // let g = parseInt(spt[1].trim()); // let b = parseInt(spt[2].trim()); // let a = parseInt(spt[3].trim()); // if (r == 255 && g == 255 && b == 255) return rgb; // r = colorBGVal("r", r); // g = colorBGVal("g", g); // b = colorBGVal("b", b); // let result = ("rgba(" + r + "," + g + "," + b + "," + a + ")"); // return result; //} //function newFontRGB(rgb) { // let reg = /\d+\s?\,\s?\d+\s?\,\s?\d+/; // let match = rgb.match(reg); // if (match == null) return rgb; // let spt = match[0].split(','); // let r = parseInt(spt[0].trim()); // let g = parseInt(spt[1].trim()); // let b = parseInt(spt[2].trim()); // if (r == 255 && g == 255 && b == 255) return rgb; // r = colorFCVal("r", r); // g = colorFCVal("g", g); // b = colorFCVal("b", b); // let result = ("rgb(" + r + "," + g + "," + b + ")"); // return result; //} //function newFontRGBA(rgb) { // let reg = /\d+\s?\,\s?\d+\s?\,\s?\d+\s?\,\s?\d+/; // let match = rgb.match(reg); // if (match == null) return rgb; // let spt = match[0].split(','); // let r = parseInt(spt[0].trim()); // let g = parseInt(spt[1].trim()); // let b = parseInt(spt[2].trim()); // let a = parseInt(spt[3].trim()); // if (r == 255 && g == 255 && b == 255) return rgb; // r = colorFCVal("r", r); // g = colorFCVal("g", g); // b = colorFCVal("b", b); // let result = ("rgba(" + r + "," + g + "," + b + "," + a + ")"); // return result; //} // 是否强制白色字体 //function whiteFc($it) { // let $el = $it; // let bc = $el.css("background-color"); // while (isemptyBG(bc)) { // $el = $el.parent(); // if ($el.length == 0) { // if (isemptyBG(bc)) return false; // break; // } // bc = $el.css("background-color"); // if ($el[0].tagName.toLowerCase() == "body") { // if (isemptyBG(bc)) return false; // break; // } // } // let reg2 = /\d+\s?\,\s?\d+\s?\,\s?\d+/; // let reg1 = /\d+\s?\,\s?\d+\s?\,\s?\d+\s?\,\s?\d+/; // let r = null; // let g = null; // let b = null; // let setWhite = false; // let match = bc.match(reg1); // if (match != null) { // let spt = match[0].split(','); // r = parseInt(spt[0].trim()); // g = parseInt(spt[1].trim()); // b = parseInt(spt[2].trim()); // let a = parseInt(spt[3].trim()); // setWhite = (r <= 100 && g <= 100 && b <= 100 && a >= 200); // } else { // match = bc.match(reg2); // if (match != null) { // let spt = match[0].split(','); // r = parseInt(spt[0].trim()); // g = parseInt(spt[1].trim()); // b = parseInt(spt[2].trim()); // setWhite = (r <= 100 && g <= 100 && b <= 100); // } // } // return setWhite; //} //function isemptyBG(bc) { // let reg1 = /\d+\s?\,\s?\d+\s?\,\s?\d+\s?\,\s?\d+/; // let r = null; // let g = null; // let b = null; // let isempyt = false; // let match = bc.match(reg1); // if (match != null) { // let spt = match[0].split(','); // r = parseInt(spt[0].trim()); // g = parseInt(spt[1].trim()); // b = parseInt(spt[2].trim()); // let a = parseInt(spt[3].trim()); // isempyt = (r == 0 && g == 0 && b == 0 && a == 0); // } // return isempyt; //} //function colorBGVal(unitName, value) { // let val = null; // switch (unitName) { // case "r": // val = Math.round(value * 0.2); // break; // case "g": // val = Math.round(value * 0.2); // break; // case "b": // val = Math.round(value * 0.2); // break; // default: // } // return val; //} //function colorFCVal(unitName, value) { // return value; // let val = null; // switch (unitName) { // case "r": // val = Math.round(value * 0.2); // break; // case "g": // val = Math.round(value * 0.2); // break; // case "b": // val = Math.round(value * 0.2); // break; // default: // } // return val; //} }, animate: { //文本滚动动画 scrollText: function ($el, ops) { //ops.time :默认1000 ops = ops || {}; ops.time = ops.time || 1000; let oldHtml = $el.html(); let oldText = $el.text(); let ens1 = "abcdefghijklmnopqrstuvwxyz" let ens2 = "ABCDEFGHIJKLMNOPQRSTUVWXYZ" let cns = "富强民主文明和谐自由q等公正法治爱国敬业诚信友善" if ((oldHtml || "").trim() == "" || (oldText || "").trim() == "") { return; } $el.html(HtmlRd(oldText, true)); let delay = 50; let delay_count = 0; let lid = setInterval(() => { let newTxt = HtmlRd(oldHtml); $el.html(newTxt); delay_count += delay; if (delay_count > ops.time) { $el.html(oldHtml); clearInterval(lid); } }, delay) //生成随机字符Ԍ含HTMLQ? function HtmlRd(str, first) { let _str = str; let reg1 = /<.*?>/g; let reg2 = /<.*?>/; let isfit = function () { let r = reg1.test(_str); return r } let list = [] while (isfit()) { reg1 = /<.*?>/g; reg2 = /<.*?>/; let ma = _str.match(reg2); if (ma.index > 0) { list.push({ type: "str", value: _str.substring(0, ma.index) }); list.push({ type: "reg", value: ma[0] }); _str = _str.substring(ma.index) } else { list.push({ type: "reg", value: ma[0] }); _str = _str.replace(reg2, ''); } _str = _str.replace(reg2, ''); } if (_str.length > 0) { list.push({ type: "str", value: _str }); } let R = ""; if (list.length > 0) { $.each(list, function (i, item) { if (item.type == "reg") R += item.value; else R += TxtRd(item.value, first); }) } else { R = TxtRd(str, first); } return R; } //生成随机字符Ԍ不含HTMLQ? function TxtRd(str, first) { let r = ""; for (let i of str) { let _r = ""; if (isNum(i)) { let _num = first ? "0" : Math.round(Math.random() * 9); _r = _num.toString(); } else if (isEnUpper(i)) { _r = first ? "X" : ens2[(Math.round(Math.random() * 25))]; } else if (isEnLower(i)) { _r = first ? "x" : ens1[(Math.round(Math.random() * 25))]; } else if (isCn(i)) { _r = first ? "c? : cns[(Math.round(Math.random() * (cns.length - 1)))]; } else { _r = i; } r += _r; } return r } //是否为数? function isNum(str) { let reg = /[0-9]/; return reg.test(str); } //是否为大写英? function isEnUpper(str) { let reg = /[A-Z]/; return reg.test(str); } //是否为小写英? function isEnLower(str) { let reg = /[a-z]/; return reg.test(str); } //是否Z? function isCn(str) { let reg = /[\u4e00-\u9fa5]/; return reg.test(str); } } }, log: function (str) { }, logOk: function (str, styleStr) { console.log("%c" + str, 'color:white;background-color:#2f9fff;border-radius:3px;padding:1px 5px;' + ((styleStr || "") != "" ? styleStr : "")) }, logErr: function (str) { this.logOk(str, "background-color:orangered;") }, logWarn: function (str) { this.logOk(str, "background-color:orange;") }, layerShowPic: function (imgUrl, options) { let $body = $("body"); let $layer = mycommon.layer; if ($layer == null || $layer.open == null) return; mycommon.checkCssFile("content/fonts/icon26A/iconfont.css") if (mycommon != null && mycommon.pageStyle != null && (mycommon.pageStyle.theme || "") != "") mycommon.checkCssFile("/themes/" + mycommon.pageStyle.theme + "/layerShowPic.css"); else mycommon.checkCssFile("JS/common/layerShowPic.css"); let ops = options || {}; let url = imgUrl || ""; if (url.toLowerCase().indexOf("http") < 0) { url = "/" + url; } if (url.toLowerCase().indexOf("//") < 0 && url.toLowerCase().indexOf("//") < 0) url = "/" + url.replace(/\\/g, "/").TrimChar("/") + (url.indexOf("?") < 0 ? ("?v=" + (new Date().getTime())) : ""); let $img = $(""); ops.content = ops.content || $img; ops.type = ops.type || 1; ops.title = ops.title == null ? (mycommon.isPhone() ? "囄" : "囄") : ops.title; ops.shade = ops.shade || [0.3, "#000"]; let $contetn = $("
时针旋?/span>逆时针旋?/span>实(wei)大小(he)适合大小攑(ju)~小
"); $body.append($contetn) ops.content.css("margin", "auto"); $contetn.find(".hq-img-con").children().append(ops.content); $contetn.find(".hq-img-con").children().append("
"); $contetn.append("
"); ops.content = $contetn; ops.maxmin = true; let imgEL = $contetn.find("img"); imgEL[0]._showable_ = false; let $end = ops.end; let imgCo = imgEL.parent().parent(); let imgover = $contetn.find(".hq-img-whiteRight"); let LayCo = null; //取得当前囄实际大小 let imgHi = imgEL.height(); let imgWi = imgEL.width(); let ConHi = imgCo.height(); let ConWi = imgCo.width(); ops.end = function () { if (typeof ($end) == "function") $end(); $contetn.remove(); } ops.success = function (layEL) { LayCo = layEL.children(".layui-layer-content"); layEL.css("transition", "0.3s"); imgHi = imgEL.height(); imgWi = imgEL.width(); setTimeout(() => { ConHi = imgCo[0].clientHeight; ConWi = imgCo[0].clientWidth; imgEL.css("max-height", ConHi + "px"); imgEL.css("max-width", "100%"); imgEL.css("opacity", ""); }, 100) }; ops.full = function () { LayCo.css("height", "calc(100% - 51px)"); setTimeout(() => { ConHi = imgCo[0].clientHeight; ConWi = imgCo[0].clientWidth; }, 350) }; ops.restore = function () { LayCo.css("height", "calc(100% - 51px)"); setTimeout(() => { ConHi = imgCo[0].clientHeight; ConWi = imgCo[0].clientWidth; }, 350) }; imgEL[0].onload = function () { let _h = imgEL.height(); let _w = imgEL.width(); let ww; let hh; let ed; ops.area = ops.area || ["70%"]; if (ops.area.length == 1) { ww = ops.area[0]; ed = ww.indexOf("%") >= 0 ? "%" : "px"; let wa = parseInt(ww.toLowerCase().replace(ed, "")); let ha = (_h * wa / _w); if (ed == "%") ha = ha * window.innerWidth / window.innerHeight; hh = ha + ed; } else if (ops.area.length == 2 && ops.area[0].toLowerCase() == "auto") { hh = ops.area[1]; ed = hh.indexOf("%") >= 0 ? "%" : "px"; let ha = parseInt(hh.toLowerCase().replace(ed, "")); let wa = (_w * ha / _h); if (ed == "%") { wa = wa * window.innerHeight / window.innerWidth; if (wa < 50) wa = 50; if (wa > 100) wa = 90; } ww = wa + ed; } //ops.area = ops.area || (mycommon.isPhone() ? ["100%", "100%"] : [ww, hh]); ops.area = (mycommon.isPhone() ? ["100%", "100%"] : [ww, hh]); $layer.open(ops); } //当前角度 let rotateDeg = 0; //当前~放 let scaleSize = 1; //实际大小 $contetn.find(".ac-3").click(Ac3); function Ac3(e, rotating) { imgEL.css("max-width", ""); imgEL.css("max-height", ""); let imgH = imgEL.height(); let imgW = imgEL.width(); let conH = ConHi; let conW = ConWi; if (imgW > conW || imgH > conH) { imgCo.css("width", "calc(100% + 12px)"); imgCo.css("overflow", "scroll"); imgover.css("background-color", "#e2f2ff"); } else { imgCo.css("width", ""); imgCo.css("overflow", ""); imgover.css("background-color", ""); } if (rotating == null || rotating == false) { rotateDeg = 0; scaleSize = 1; imgEL.css("transform", "rotate(" + rotateDeg + "deg)"); imgEL.css("width", ""); imgEL.css("height", ""); } } //适合大小 $contetn.find(".ac-4").click(Ac4); function Ac4(e, rotating) { imgEL.css("max-width", "100%"); imgEL.css("max-height", ConHi + "px"); imgCo.css("width", ""); imgCo.css("overflow", ""); imgover.css("background-color", ""); if (rotating == null || rotating == false) { rotateDeg = 0; scaleSize = 1; imgEL.css("transform", "rotate(" + rotateDeg + "deg)"); imgEL.css("width", ""); imgEL.css("height", ""); } } //时? $contetn.find(".ac-1").click(function () { Ac3(null, true); rotateDeg += 90; let _ct = "rotate(" + rotateDeg + "deg)"; if (rotateDeg % 180 == 90) { let _wi = imgWi * scaleSize; let _hi = imgHi * scaleSize; if (_wi >= ConWi || _hi >= ConHi) { _ct += " translateX(" + ((_wi - _hi) / 2) + "px)"; _ct += " translateY(" + ((_wi - _hi) / 2) + "px)"; } } imgEL.css("transform", _ct); }) //逆时? $contetn.find(".ac-2").click(function () { Ac3(null, true); rotateDeg -= 90; let _ct = "rotate(" + rotateDeg + "deg)"; if (rotateDeg % 180 == 90) { let _wi = imgWi * scaleSize; let _hi = imgHi * scaleSize; if (_wi >= ConWi || _hi >= ConHi) { _ct += " translateX(" + ((_wi - _hi) / 2) + "px)"; _ct += " translateY(" + ((_wi - _hi) / 2) + "px)"; } } imgEL.css("transform", _ct); }) //攑֤ $contetn.find(".ac-5").click(function () { Ac3(null, true); scaleSize += 0.2 imgEL.css("width", (imgWi * scaleSize) + "px"); imgEL.css("height", (imgHi * scaleSize) + "px"); let _ct = "rotate(" + rotateDeg + "deg)"; if (rotateDeg % 180 == 90) { let _wi = imgWi * scaleSize; let _hi = imgHi * scaleSize; if (_wi >= ConWi || _hi >= ConHi) { _ct += " translateX(" + ((_wi - _hi) / 2) + "px)"; _ct += " translateY(" + ((_wi - _hi) / 2) + "px)"; } } imgEL.css("transform", _ct); }) //~小 $contetn.find(".ac-6").click(function () { Ac3(null, true); scaleSize -= 0.2 if (scaleSize < 0.2) scaleSize = 0.2 imgEL.css("width", (imgWi * scaleSize) + "px"); imgEL.css("height", (imgHi * scaleSize) + "px"); let _ct = "rotate(" + rotateDeg + "deg)"; if (rotateDeg % 180 == 90) { let _wi = imgWi * scaleSize; let _hi = imgHi * scaleSize; if (_wi >= ConWi || _hi >= ConHi) { _ct += " translateX(" + ((_wi - _hi) / 2) + "px)"; _ct += " translateY(" + ((_wi - _hi) / 2) + "px)"; } } imgEL.css("transform", _ct); }) //拖动 let mx, my, sl, st; imgEL.mousedown(function (e) { mx = e.pageX; my = e.pageY; sl = imgCo[0].scrollLeft; st = imgCo[0].scrollTop; }) imgEL.mousemove(function (e) { if (mx == null) return; let dx = e.pageX - mx; let dy = e.pageY - my; imgCo[0].scrollLeft = sl - dx; imgCo[0].scrollTop = st - dy; }) imgEL.mouseup(function (e) { sl = null; st = null; mx = null; my = null; }) }, //前端加蝲传? __clientEncode__: function (str) { let that = this; var v1 = new Date(); var v2 = v1.getTime().toString(); var v3 = "a65se71g23s463gy75f4h23f1ghnsdfgv8sd4f3sad132asd31sadf" var v4 = ""; for (var i = v2.length - 1; i >= 0; i--) { v4 += v2[i]; } var va = ((v2 + v3).length + 10).toString().HeadZero(5); var vb = ((v2 + v3 + str).length + 10).toString().HeadZero(5); var v5 = va + vb + v2 + v3 + str + v3 + v4; return mycommon.b64Encode(v5); }, b64Encode: function (str) { let oldlink = $("script").filter(function (i, item) { let src = item.src; let c1 = src.toLowerCase().indexOf("b64coder.js") >= 0; }) if (oldlink.length == 0) { let timeStr = new Date().getTime(); let newlink = $(""); $("head").append(newlink); } var coder = new Base64(); return coder.encode(str); }, b64Decode: function (str) { let oldlink = $("script").filter(function (i, item) { let src = item.src; let c1 = src.toLowerCase().indexOf("b64coder.js") >= 0; }) if (oldlink.length == 0) { let timeStr = new Date().getTime(); let newlink = $(""); $("head").append(newlink); } var coder = new Base64(); return coder.decode(str); }, htmlEncode: function (html) { //1.首先动态创Z个容器标{օ素,如DIV var temp = document.createElement("div"); //2.然后要转换的字W串讄个元素的innerText或者textContent (temp.textContent != undefined) ? (temp.textContent = html) : (temp.innerText = html); //3.最后返回这个元素的innerHTMLQ即得到l过HTML~码转换的字W串? var output = temp.innerHTML; temp = null; return output; }, htmlDecode: function (text) { //1.首先动态创Z个容器标{օ素,如DIV var temp = document.createElement("div"); //2.然后要转换的字W串讄个元素的innerHTML(ieQ火狐,google都支? temp.innerHTML = text; //3.最后返回这个元素的innerText或者textContentQ即得到l过HTML解码的字W串了? var output = temp.innerText || temp.textContent; temp = null; return output; }, //l一传值方法对Q父面攄 setFuncs: function (obj) { window["VALUEFUNCSOBJECT"] = obj; }, //l一传值方法对Q子面取用 getFuncs: function () { return window.parent["VALUEFUNCSOBJECT"]; }, //产生随机?整数) random: function (min, max) { let _min = min || 0; let _max = max || 100; let rdm = Math.random() * (_max - _min) + _min; return Math.round(rdm); }, //整型调长 __HeadZero: function (len) { let oldval = this; if (len > oldval.length) { let result = oldval; for (var i = 0; i < (len - oldval.length); i++) { result = "0" + result; } return result; } return oldval; }, //去除字符串中头部及尾部指定字W(单字W) __TrimChar: function (char) { if ((this || "").trim() == "") return ""; char = (char || "").trim(); let oldStr = this.trim(); if (char == "") return oldStr; while (oldStr.substring(0, 1) == char) { oldStr = oldStr.substring(1); } while (oldStr.substring(oldStr.length - 1, oldStr.length) == char) { oldStr = oldStr.substring(0, oldStr.length - 1); } return oldStr; }, //是否为空 __strNotNull: function () { let oldval = this; if (oldval == undefined || oldval == null) return false; if (oldval.toString().trim() == "") return false; return true; }, //jquer对象是否有效 __jqNotNull: function (count) { let _count = count || 1; let oldval = this; if (oldval == undefined || oldval == null) return false; if (oldval.length == undefined || oldval.length == null) return false; if (oldval.length == 0) return false; if (oldval.length < _count) return false; return true; }, //dq事g blur: function ($el, callback) { setTimeout(function () { $el[0].ST_BLUR_LISTENER = listener = (e) => { if (!$el[0].contains(e.target)) { if ($.isFunction(callback)) callback(); document.removeEventListener("click", $el[0].ST_BLUR_LISTENER) } } document.addEventListener('click', $el[0].ST_BLUR_LISTENER); }, 500) }, blurOff($el) { if (typeof ($el[0].ST_BLUR_LISTENER) == "function") { document.removeEventListener("click", $el[0].ST_BLUR_LISTENER) } }, //iframe子页面的点击 ifrDocClick: function ($ifDocEL, callback) { let iframClick = setInterval(() => { if (!$ifDocEL.usable()) { clearInterval(iframClick); return; } var ifDoc = $ifDocEL[0].contentDocument if (ifDoc != null && ifDoc != undefined) { ifDoc.addEventListener('click', function () { if ($.isFunction(callback)) callback(); }); clearInterval(iframClick); } }, 100); }, DtSelect: function (tableid) { let that = this; if (that.DtCache != null && that.DtCache[tableid] != null) { let _data = that.DtCache[tableid].data(); if (_data != null && _data.length > 0) { let _sel = _data.filter(a => a.LAY_CHECKED); console.log(_sel); if (_sel != null && _sel.length > 0) return _sel; else return undefined; } else return undefined; } else return undefined; }, DtShow: function (ops) { // ops.load :默认true; // ops.el :必需的,?#table'; // ops.id :选设 // ops.data :带有查询条g的上传对? // ops.success :表格成功渲染后的回调 // ops.page // ops.limit // ops.limits // ops.ShowCards :数据陈列为卡? // ops.dataDicSetable: true/false; 是否开启快速字兔R|? // ops.rowselect:炚w行的回? // ops.onRes :用于回传table渲染l果的回? // ops.cols :用于指定列特D显C? // ops.showtree :是否昄为树型结?true/falsetableOps // ops.showLV :默认展开到的树型U数 int // ops.tree: // { // show:true/false, // showLV: int // titleField: ep:'title', // iconClass: string/ [string function(d){}] // } // ops.extCols[{ title,templet,width,beforeField,..}...] //扩展的字股输出配|,存在则覆盖属性,不存在则d let that = this; if (!that.init_completed) { //console.log("mycommon.table未定?); setTimeout(function () { that.DtShow(ops); }, 50) return; } if (that.ajax == undefined) { console.log("mycommon.ajax未定?); return; } ops.tree = ops.tree || {}; ops.tree.show = ops.tree.show || false; ops.tree.showLV = ops.tree.showLV || 2; ops.tree.titleField = ops.tree.titleField || ""; var tableResult; let newops = { ...ops }; //数据展示方式; newops.ShowCards = newops.ShowCards || false; newops.CardsColsCount = (newops.CardsColsCount || null); newops.id = ops.id || (ops.el.replace("#", "")); $(newops.el).attr("lay-filter", newops.id); newops.tree = ops.tree newops.page = ops.page || 1; newops.limit = newops.ShowCards ? (newops.newlimit || 20) : (ops.limit || 100); newops.limits = newops.ShowCards ? [20, 50, 100] : (ops.limits || [100, 200, 500]); newops.extCols = ops.extCols || []; newops.rowSelect = ops.rowSelect; newops.data = ops.data || {}; newops.data.onlywhere = newops.onlywhere || ""; newops.data.page = newops.page; newops.data.limit = newops.limit; newops.data.treeShow = newops.tree.show; newops.data.treeTitleField = newops.tree.titleField; newops.dataDicSetable = newops.dataDicSetable || false; function setLoad() { let msgEL = $("
 正在加蝲
"); $(newops.el).parent().children().not($(newops.el)).remove(); $(newops.el).after(msgEL); return msgEL; } let loadEL = setLoad(); //渲染执行 newops.success = function (res) { //清理监听 let LISTEN_THREADS = "LISTEN_THREADS"; if (window[LISTEN_THREADS] != null && window[LISTEN_THREADS].length > 0) { $.each(window[LISTEN_THREADS], function (r, rtem) { clearInterval(rtem); }) } window[LISTEN_THREADS] = []; loadEL.remove(); let isSTmsg = ((newops.data || {}).view || "").toLowerCase() == "v_stmsg" || ((newops.data || {}).view || "").toLowerCase() == "stmsg" $(newops.el).parent().children().not($(newops.el)).remove(); if (res.code == 0 && res.data != null && res.data.length > 0) { //数据前置加工 var newcols = [] var primarykey = ""; var hasSel = []; var totalwi = $(newops.el).parent().width(); //字段呈现Q时间格? function datetimeColCovert(mycol) { if (mycol.item_list_object != null && (mycol.item_list_object.colwidth || 0) != 0) mycol.width = mycol.item_list_object.colwidth; if (mycol.valuetype == "datetime") { mycol.templet = function (d) { let myval = d[mycol.field]; if (myval == null || myval == undefined || myval.toString().trim() == "") return ""; let _dateval = new Date(myval); return _dateval.CvDateTime(); } } else if (mycol.valuetype == "date") { mycol.templet = function (d) { let myval = d[mycol.field]; if (myval == null || myval == undefined || myval.toString().trim() == "") return ""; let _dateval = new Date(myval); return _dateval.CvDate(); } } else if (mycol.valuetype == "datetimems") { mycol.templet = function (d) { let myval = d[mycol.field]; if (myval == null || myval == undefined || myval.toString().trim() == "") return ""; let _dateval = new Date(myval); return _dateval.CvDateTimems(); } } } //字段呈现Q一般列的处理(宽Q? function defaultColCovert(mycol) { //宽度限 if (mycol.width > 270) { mycol.width = 270; mycol.templet = function (d) { let _html = "
" + (d[mycol.field] || "") + "
"; return _html; } } if (mycol.item_list_object != null && (mycol.item_list_object.colwidth || 0) != 0) mycol.width = mycol.item_list_object.colwidth; } //宽处理 function slideDownCon(mycol) { mycol.templet = function (d) { let _html = "
" + (d[mycol.field] || "") + "
"; return _html; } } //字段呈现Q域 function AreaColCovert(mycol) { mycol.width = 270; mycol.templet = function (_data_) { let myarea = ""; if (_data_["area"] != null) myarea = _data_["area"] || ""; else if (_data_["sys_area"] != null) myarea = _data_["sys_area"] || ""; let html = "
"; if (myarea == "" || myarea == "0") html += "公共?/span>" else if (myarea == "1") html += "域管?/span>" else if (isSTmsg && (myarea == "1" || myarea == "1:")) html += "公共?/span>" else if (isSTmsg && (myarea == "2" || myarea == "2:")) html += "(wei)部" else if (myarea.indexOf(":") < 0 && myarea.indexOf(",") < 0) html += "" + myarea + "" else if (myarea.indexOf(":") >= 0) { let spt = myarea.split(':'); let areaTx = ["数据异常", "公共?, (isSTmsg ? "限制? : "域管?), "指定?] let areaCs = ["err", "sys", "lv1", "lv2"] let arealv = parseInt(spt[0].trim()) || -1; html += "" + areaTx[arealv + 1] + ""; if (myarea.length > 1) { let areavals = spt[1].split(','); $.each(areavals, function (i, item) { if (item.strNotNull()) html += "" + item + ""; }) } } else if (myarea.indexOf(",") >= 0) { let areavals = myarea.split(','); $.each(areavals, function (i, item) { if (item.strNotNull()) html += "" + item + ""; }) } html += "
"; return html; }; } //字段呈现Q文件类? function filesColCover(mycol) { let item_list_object = null; if (mycol.item_list_object != null) item_list_object = mycol.item_list_object; mycol.width = 270; let setWidth = false; if (mycol.item_list_object != null && (mycol.item_list_object.colwidth || 0) != 0) { setWidth = true; mycol.width = mycol.item_list_object.colwidth; } mycol.templet = function (d) { //点击事g响应 let eventName = "__Table_cell_event" + ((mycol.field || "").trim() != "" ? ("_" + mycol.field) : "") + (new Date().getTime() + "_" + mycommon.random(100, 999)); if (window[eventName] == undefined) window[eventName] = function (_that, e) { let _fEL = $(_that) let _url = (_fEL.attr("st-url") || "").replace(/\\/g, "/").TrimChar("/"); let _url_full = (_url.toLowerCase().indexOf("//") < 0 && _url.toLowerCase().indexOf("//") < 0) ? ("/" + _url) : url; let imgs = that.__img_FileExts__; let urlext = _url.substring(_url.lastIndexOf('.') + 1).toLowerCase(); let _fNa = "temp_" + new Date().getTime(); if (item_list_object != null && (item_list_object.titleField || "").trim() != "" && (d[item_list_object.titleField] || "").trim() != "") { _fNa = d[item_list_object.titleField] + "_" + mycommon.random(100, 999); } if (urlext.indexOf("?") >= 0) urlext = urlext.substring(0, urlext.indexOf("?")); if (imgs.indexOf(urlext) >= 0) { that.layer.pic(_url_full, { area: ["auto", "70%"] }); } else { let aEL = $(""); aEL[0].download = _fNa + "." + urlext; aEL[0].click(); } e.stopPropagation(); return false; } let tdata = d[mycol.field] || ""; let _show = "" if (tdata != "") { let _files = tdata.split(',') $.each(_files, function (i, item) { let _icon = that.fileIcon(item); _show += "" + _icon + ""; }) } let _html = ""; if (!setWidth) { _html = "
" + _show + "
"; } else { _html = "
" + _show + "
"; } return _html; } } //字段呈现Qlogo/头像 function logoColCover(mycol) { mycol.width = 80; mycol.align = "center"; let isPic = false; if (mycol.item_list_object != null && (mycol.item_list_object.type || "").trim().toLowerCase() == "pic") isPic = true; mycol.templet = function (d) { let tdata = d[mycol.field] || ""; if (tdata.trim() == "") return ""; let urls = tdata.split(","); let html = "
"; //点击事g响应 let eventName = ""; if (isPic) { eventName = "__Table_cell_event" + ((mycol.field || "").trim() != "" ? ("_" + mycol.field) : "") + (new Date().getTime() + "_" + mycommon.random(100, 999)); if (typeof (window[eventName]) != "function") window[eventName] = function (e) { let $target = $(e.target); let url = $target.attr("src"); mycommon.layer.pic(url, { area: ["auto", "70%"] }); e.stopPropagation(); } } $.each(urls, function (i, item) { let _url = item; let imgs = that.__img_FileExts__; let urlext = _url.substring(_url.lastIndexOf('.') + 1).toLowerCase(); if (urlext.indexOf("?") >= 0) urlext = urlext.substring(0, urlext.indexOf("?")); if (imgs.indexOf(urlext) >= 0) { if (_url.toLowerCase().indexOf("//") < 0 && _url.toLowerCase().indexOf("//") < 0) _url = "../../" + _url; html += "" } }) html += "
"; return html; } } //字段呈现Qpage function pageColCover(mycol) { mycol.width = 80; mycol.align = "center"; let isIF = (mycol.item_list_object != null && (mycol.item_list_object.type || "").trim().toLowerCase() == "iframe"); let isTipTokVideo = (mycol.item_list_object != null && (mycol.item_list_object.type || "").trim().toLowerCase() == "TipTokVideo".toLowerCase() && (mycol.item_list_object.params || "").trim().toLowerCase() != ""); mycol.templet = function (d) { let tdata = d[mycol.field] || ""; if (tdata.trim() == "") return ""; //点击事g响应 let eventName = "__Table_cell_event" + ((mycol.field || "").trim() != "" ? ("_" + mycol.field) : "") + (new Date().getTime() + "_" + mycommon.random(100, 999)); let title = "查看"; if (mycol.item_list_object != null && (mycol.item_list_object.title || "").trim() != "") { title = mycol.item_list_object.title; for (let prop in d) { while (title.indexOf("@" + prop) >= 0) { title = title.replace("@" + prop, d[prop].toString()); } } } if (typeof (window[eventName]) != "function") window[eventName] = function (e) { let _url = $(e.target).attr("st-url"); if (isIF) { //pȝ内页面的加蝲昄 let _area = mycommon.isPhone() ? ["100%", "100%"] : ["720px", "80%"]; LAYER_ID = mycommon.layer.open({ title: [title, "text-align:center;padding: 0px 80px;"], type: 2, content: _url, resize: false, area: _area }) } else if (isTipTokVideo) { //抖音q_专用的视频嵌? let newurl = mycol.item_list_object.params || ""; for (let prop in d) { while (newurl.indexOf("@" + prop) >= 0) { newurl = newurl.replace("@" + prop, escape(d[prop])); } } newurl = "../../MeTipTok/play?" + newurl; let layeropne = window.top.mycommon.layer.open || mycommon.layer.open; layeropne({ title: "", type: 2, offset: 'r', anim: 'slideLeft', // 从右往? area: ['374px', '100%'], shade: 0.5, shadeClose: true, content: newurl, closeBtn: 0, success: function (layEL) { console.log(layEL); layEL.append("点击左边I(chu)白处关闭本H(dai)口") } }); } else { //在新H口中打开面 window.open(_url) } e.stopPropagation(); } let _url = tdata; if (_url.toLowerCase().indexOf("//") < 0 && _url.toLowerCase().indexOf("//") < 0) _url = "../../" + _url; let html = "
"; html += "打开" html += "
"; return html; } } //字段呈现Qjson格式? function jsonColCover(mycol) { mycol.width = 130; mycol.align = "center"; if (mycol.item_list_object != null && (mycol.item_list_object.colwidth || 0) != 0) mycol.width = mycol.item_list_object.colwidth; mycol.templet = function (d) { if ((mycol.field || "").trim() == "" || (d[mycol.field] || "").toString() == "") return ""; let eventName = "__Table_cell_event" + ((mycol.field || "").trim() != "" ? ("_" + mycol.field) : "") + (new Date().getTime() + "_" + mycommon.random(100, 999)); if (typeof (window[eventName]) != "function") window[eventName] = function (e) { if (mycol.field != null && (mycol.field || "").trim() != "") { let jsonStr = "
" + (d[mycol.field] || "") + "
"; if (jsonStr.trim() == "") { mycommon.layer.ms("没有内容"); } else { let _area = mycommon.isPhone() ? ["100%", "100%"] : ["720px", "80%"]; let _title = mycol.title || "JSON FORMATED DATA"; LAYER_ID = mycommon.layer.open({ title: [_title, "text-align:center;padding: 0px 80px;"], type: 1, content: jsonStr, resize: false, area: _area, success: function (layerEL) { let jsonCon = layerEL.find(".st-table-jsonlayer").children(); mycommon.jsonshow.render({ el: jsonCon, copy: mycommon.copytext }) } }) } } e.stopPropagation(); } let _html = "JSON "; return _html; } } //字段呈现Qjson格式? function layershowColCover(mycol) { mycol.width = 130; mycol.align = "center"; if (mycol.item_list_object != null && (mycol.item_list_object.colwidth || 0) != 0) mycol.width = mycol.item_list_object.colwidth; mycol.templet = function (d) { if ((mycol.field || "").trim() == "" || (d[mycol.field] || "").toString() == "") return ""; let eventName = "__Table_cell_event" + ((mycol.field || "").trim() != "" ? ("_" + mycol.field) : "") + (new Date().getTime() + "_" + mycommon.random(100, 999)); if (typeof (window[eventName]) != "function") window[eventName] = function (e) { if (mycol.field != null && (mycol.field || "").trim() != "") { let jsonStr = "
" + (d[mycol.field] || "") + "
"; if (jsonStr.trim() == "") { mycommon.layer.ms("没有内容"); } else { let _area = mycommon.isPhone() ? ["100%", "100%"] : ["720px", "80%"]; let _title = mycol.title || "JSON FORMATED DATA"; LAYER_ID = mycommon.layer.open({ title: [_title, "text-align:center;padding: 0px 80px;"], type: 1, content: jsonStr, resize: false, area: _area, success: function (layerEL) { let jsonCon = layerEL.find(".st-table-jsonlayer").children(); mycommon.jsonshow.render({ el: jsonCon, justText: true, copy: mycommon.copytext }) } }) } } e.stopPropagation(); } let _html = "Show "; return _html; } } //字段呈现Q时间戟转时? function timestampColCover(mycol) { mycol.width = 164; let IsSecond = (mycol.item_list_object == null || (mycol.item_list_object.type || "").trim().toLowerCase() != "ms"); let Format = "datetime"; if (mycol.item_list_object != null && (mycol.item_list_object.format || "").trim().toLowerCase() == "date") { Format = "date"; mycol.width = 110; } if (mycol.item_list_object != null && (mycol.item_list_object.format || "").trim().toLowerCase() == "time") { mycol.width = 110; Format = "time"; } mycol.templet = function (d) { if ((mycol.field || "").trim() == "") return ""; let val = parseInt((d[mycol.field] || "").toString().trim()); if (isNaN(val)) return d[mycol.field] || ""; if (IsSecond) val = val * 1000; let da = new Date(val); let dateobj = da.CvDateObj(); return dateobj[Format]; } } //可触发查询指定数? function datapageColCover(mycol) { mycol.width = mycol.width + 24; //是否指定了列? if (mycol.item_list_object != null && (mycol.item_list_object.colwidth || 0) != 0) { mycol.width = mycol.item_list_object.colwidth; } mycol.templet = function (d) { let eventName = "__Table_cell_event" + ((mycol.field || "").trim() != "" ? ("_" + mycol.field) : "") + (new Date().getTime() + "_" + mycommon.random(100, 999)); if (typeof (window[eventName]) != "function") window[eventName] = function (e) { if (mycol.item_list_object != null && (mycol.item_list_object.url || "").trim() != "" && (mycol.dic_id || "").toString().trim() != "" && (primarykey || "").trim() != "") { let _area = (mycommon.isPhone() || mycol.item_list_object.full) ? ["100%", "100%"] : ["720px", "80%"]; let _title = mycol.item_list_object.title || "匚w数据展开"; for (var prop in d) { while (_title.indexOf("{{" + prop + "}}") >= 0) { _title = _title.replace("{{" + prop + "}}", d[prop]); } } let ows = mycommon.b64Encode(mycol.dic_id + "|" + d[primarykey]); let _url = '../../' + mycol.item_list_object.url; _url += ((_url.indexOf("?") >= 0) ? ("&") : "?") + "ows=" + ows; LAYER_ID = mycommon.layer.open({ title: [_title, "text-align:center;padding: 0px 80px;"], type: 2, content: _url, resize: false, area: _area, success: function () { mycommon.layer.view.HideClose(); }, end: function () { mycommon.layer.view.ShowClose(); } }) } e.stopPropagation(); } let able = false; if (mycol.item_list_object != null) { able = true; if (mycol.item_list_object.ablefield != null) { let ableVal = (d[mycol.item_list_object.ablefield] || "0").toString(); if (ableVal.trim() != "") able = ableVal.toString().trim() == "1" || ableVal.toString().trim().toLowerCase() == "true"; } } let _html = "
" + ((mycol.field || "").trim() != "" ? (d[mycol.field] || "") : "") + "
"; return _html; } } //字段呈现Q按钮类? function btnsColCover(mycol) { //点击响应 if (window["TABLE_BTNS_CLICKEVENT"] == undefined) window["TABLE_BTNS_CLICKEVENT"] = function (event, _that, mIndex, dataid, enable) { if (!enable) { console.log("׃数据状态,没有响应") event.stopPropagation(); return; } window["TABLE_BTNS_CURR_ROW_ID"] = dataid; var toolEL = $(".layout-tool").children("[st-mid='" + mIndex + "']") if (toolEL.usable()) { toolEL[0].click(); } window["TABLE_BTNS_CURR_ROW_ID"] = null; event.stopPropagation(); } mycol.width = 230; if (mycol.item_list_object != null && (mycol.item_list_object.colwidth || 0) != 0) mycol.width = mycol.item_list_object.colwidth; let btns = $(".layout-tool").children("[st-at='tableapi']") if (!btns.usable()) { mycol.hide = true; } else { mycol.templet = function (d) { if (!btns.usable()) return "?; let _htm = ""; $.each(btns, function (i, item) { // enablel定处理 let $item = $(item) let _ablefield = $item.attr("st-af") || ""; let _title = $item.children("span").html(); let mIndex = $item.attr("st-mid"); let enable = _ablefield == "" || (d[_ablefield] != null && (d[_ablefield].toString() == "1" || d[_ablefield].toString().toLowerCase() == "true")); let icon = $item.children("i")[0].outerHTML _htm += "" + (enable ? icon + (" ") : " ") + _title + "" }) let _html = "
" + _htm + "
"; return _html; } } } //字段呈现Q实时监? function listenColCover(mycol) { if (mycol.item_list_object != null && (mycol.item_list_object.colwidth || 0) != 0) mycol.width = mycol.item_list_object.colwidth; if (mycol.item_list_object == null || (mycol.item_list_object.stopVal || "").trim() == "" || (mycol.field || "").trim() == "") return; let _pk = (window["PRIMARY_KEY"] || "").trim(); let _tb = (window["DATA_VIEW"] || "").trim(); let _stopvals = mycol.item_list_object.stopVal.split('|'); if (_pk == "" || _tb == "") return; mycol.templet = function (d) { if ((d[_pk] || "").toString().trim() == "") return d[mycol.field] || ""; //监后完成后再更新字段 function succRunFields() { if ((mycol.item_list_object.succRunFields || "").trim() == "") return; let _fields = mycol.item_list_object.succRunFields.split('|'); $.each(_fields, function (f, fitem) { let _row = newops.ShowCards ? mycommon.DtCardEL(newops.el, _pk, d[_pk]) : mycommon.DtRowEL(newops.el, _pk, d[_pk]); let fieldCell = newops.ShowCards ? _row.find("[data-field='" + fitem + "']") : _row.children("[data-field='" + fitem + "']"); if (fieldCell.length == 0) return; mycommon.ajax({ load: false, async: false, url: "/dataaccess/Listendata", data: { tablename: _tb, fieldname: fitem, primarykey: _pk, dataid: d[_pk] }, success: tres => { if (tres.code == 0 && tres.data != null) { let _col = res.cols.find(a => a.field != null && a.field == fitem); if (typeof (_col.templet) == "function") { d[fitem] = tres.data; let _html_ = _col.templet(d); newops.ShowCards ? fieldCell.html(_html_) : fieldCell.children().html(_html_); } else newops.ShowCards ? fieldCell.html(tres.data) : fieldCell.children().html(tres.data); } else { } } }) }); } let _loadico = "" let _curr = _stopvals.find(a => a.trim() == d[mycol.field].trim()); if (_curr == null) { let _sid = setInterval(() => { let tablename = _tb; let fieldname = mycol.field; let primarykey = _pk; let dataid = d[_pk]; mycommon.ajax({ load: false, async: false, url: "/dataaccess/Listendata", data: { tablename, fieldname, primarykey, dataid }, success: tres => { if (tres.code == 0 && tres.data != null) { let _cell = $("[listen-id-" + mycol.field + "='" + d[_pk] + "']"); _cell.children("span").html(tres.data); let _curr = _stopvals.find(a => a.trim() == tres.data.trim()); if (_curr != null) { _cell.children("i").hide(200, function () { _cell.children("i").remove(); succRunFields(); }) clearInterval(_sid); } } else { _cell.children("i").hide(200, function () { _cell.children("i").remove(); succRunFields(); }) clearInterval(_sid); } } }) }, 1000); window[LISTEN_THREADS].push(_sid); return "
" + _loadico + "" + (d[mycol.field] || "") + "
"; } else return d[mycol.field] || ""; } } //字段呈现Q展开详细 function FOLD_DETAILS_ColCovert(mycol) { mycol.templet = function (d) { if (d.FOLD_DETAILS != null && d.FOLD_DETAILS.toString().trim() != "") { let spt = d.FOLD_DETAILS.toString().trim().split('$'); if (spt.length == 3) { return "
"; } } return "
"; } } function headiconColCover(mycol) { mycol.width = mycol.width + 30; let itemList = mycol.item_list_object || {}; let styleObj = itemList.style || {}; let classStr = itemList.class || ""; let cssfile = itemList.cssfile || ""; if (cssfile.trim() != "") { mycommon.checkCssFile(cssfile); } mycol.templet = function (d) { let styleStr = ""; if (styleObj != {}) { for (var prop in styleObj) { styleStr += prop + ":" + styleObj[prop] + ";" } } let icon = "" if (mycol.field == null) return icon + ""; let oldval = d[mycol.field] == null ? "" : d[mycol.field]; return icon + oldval; } } //遍历字段执行呈现渲染 for (var i = 0; i < res.cols.length; i++) { let mycol = res.cols[i]; if ((mycol.valuetype || "").trim() == "") { defaultColCovert(mycol); } else { let _valuetypes = mycol.valuetype.split("|"); $.each(_valuetypes, function (k, ktem) { switch (ktem) { case "bit": mycol.templet = function (d) { if (mycol.item_list_object != null && (mycol.item_list_object.colwidth || 0) != 0) mycol.width = mycol.item_list_object.colwidth; let myval = d[mycol.field]; if (myval != null && (myval == true || myval.toString().toLowerCase() == 'true' || myval.toString() == '1')) { return "
"; } else { return "
"; } } case "datetime": datetimeColCovert(mycol); break; case "date": datetimeColCovert(mycol); break; case "datetimems": datetimeColCovert(mycol); break; case "sysArea": AreaColCovert(mycol); break; case "files": filesColCover(mycol); break; case "logo": logoColCover(mycol); break; case "page": pageColCover(mycol); break; case "json": jsonColCover(mycol); break; case "layershow": layershowColCover(mycol); break; case "headicon": headiconColCover(mycol); break; case "timestamp": timestampColCover(mycol); break; case "datapage": datapageColCover(mycol); break; case "btns": btnsColCover(mycol); break; case "FOLD_DETAILS": FOLD_DETAILS_ColCovert(mycol); break; case "slideDownCon": slideDownCon(mycol); break; case "listen": listenColCover(mycol); break; default: defaultColCovert(mycol); break; } }) } //取得主键 if (mycol.isPK) primarykey = mycol.field; if (newops.cols != null && newops.cols.length > 0) { var extCols = newops.cols.filter(function (jtem) { return (jtem.field != null && jtem.field == mycol.field) }); if (extCols != null && extCols.length > 0) { newcols.push(extCols[0]); continue; } } if (newops.tree.show && (mycol.field || "") == "__treeNode" && newops.tree.iconClass != null) { mycol.iconClass = newops.tree.iconClass; } if (newops.extCols != null && newops.extCols.length > 0 && i < res.cols.length - 1) { $.each(newops.extCols, function (t, extcol) { if ((mycol.field || "") != "" && (extcol.field || "") != "" && extcol.field == mycol.field) { for (var _pr in extcol) { mycol[_pr] = extcol[_pr]; } } else if ((mycol.field || "") != "" && (extcol.beforeField || "") != "" && extcol.beforeField == mycol.field) { newcols.push(extcol); } }) } newcols.push(mycol); } //ֈ调宽 endColWi(); function endColWi() { let _wiCount = 50; for (var i = 1; i < newcols.length; i++) { if (newcols[i].hide) continue; _wiCount += newcols[i].width; if (i == newcols.length - 1 && _wiCount < totalwi) { newcols[i].width = newcols[i].width + (totalwi - _wiCount) - 4; } } } //是否有已选中的数? if (that.DtCache != null && that.DtCache[newops.id] != null) { let caData = that.DtCache[newops.id].data(); if (caData != null && caData.length > 0 && primarykey != "") { hasSel = caData.filter(a => a.LAY_CHECKED).map(a => a[primarykey].toString()); } } let tableOps = { elem: newops.el, showLV: newops.tree.showLV, id: newops.id, page: false, cols: [newcols], limit: newops.limit, data: res.data, done: function () { let _table = this; let _pageInfo = null; //行元? let _tableRowTR = _table.elem.next(".layui-table-view").children(".layui-table-box").children(".layui-table-main, .layui-table-fixed").find("tbody > tr"); _table.RowTR = _tableRowTR; if ($.isFunction(ops.success)) { ops.success(res, _table); } newops.success = ops.success; _table.options = newops; _table.res = res; //UI调整 that.TableHeightOff(_table); //行点L? that.rowselect.selectRow(newops.id, function (selrows, currRow) { //昄已选中行数 if (_pageInfo != null && typeof (_pageInfo.setSelectCount) == "function") { _pageInfo.setSelectCount(selrows.data.length); } if ($.isFunction(newops.rowselect)) { newops.rowselect(selrows, currRow); } }, function (selrows, currRow) { //双击Q?ctrlQ? //调用全局的回? if ($.isFunction(window["DBL_CLICK_EDITE"])) window["DBL_CLICK_EDITE"](selrows, currRow) else console.log("响应未定?) }); //分页? _pageInfo = that.tablePage(_table); that.DtCache[newops.id] = { primarykey: primarykey, options: newops, el0: $(newops.el), el1: $(newops.el).next(".layui-table-view"), data: function () { return that.table.cache[newops.id]; } } //宽度限按钮响应 let showTooWi = false; let tableEL = _table.elem.next(); //限展开时不能滚? tableEL.find(".layui-table-body")[0].onwheel = function (e) { if (showTooWi) { e.preventDefault(); } } //限展开 tableEL.find("tr").delegate(".st-table-tooWi>i", "click", function () { let $icon = $(this); let $prev = $icon.prev(); let $span = $(""); if (!$icon.next().usable()) { showTooWi = true; $icon.after($span); let textChild = $span.contents().filter((i, a) => { return a.nodeName != null && a.nodeName == "#text"; }); if ($span.children().length == 0 || textChild.length > 0) { $span.css("height", "initial"); $span.css("white-space", "normal"); $span.css("max-height", "260px"); $span.css("width", "calc(100%)"); $span.css("overflow", "auto"); } $span.slideDown(200, function () { let tableBody = tableEL.find(".layui-table-body") let TB_bot = tableBody.offset().top + tableBody.height(); let SP_bot = $span.offset().top + $span.height(); if (TB_bot < SP_bot) { let _toTp = 0 - ($span.height() - $prev.height() + 10); $span.animate({ top: _toTp }, 100); } }); $span.mouseleave(spanremove); if ($span.parents(".layui-table-fixed").length > 0 && $span.parents(".layui-table-fixed-r").length > 0) $span.parents(".layui-table-body").css("overflow", "visible"); $span[0].onwheel = function (e) { let spanDom = $span[0]; if (e.wheelDeltaY <= -120) { spanDom.scrollTop = spanDom.scrollTop + 60; } else if (e.wheelDeltaY >= 120) { spanDom.scrollTop = spanDom.scrollTop - 60; } } function spanremove() { showTooWi = false; $span.slideUp(200, function () { $span.parents(".layui-table-body").css("overflow", ""); $span.remove(); }) } } return false; }) //详细展开 tableEL.find("tr").delegate(".st-Fold-open", "click", function () { let $it = $(this); let row = $it.parents("tr"); let showCols = newcols.filter(a => !a.hide); row.after("test todo") }) //恢复选中的项 if (hasSel != null && hasSel.length > 0) { let pkcell = $(newops.el).next(".layui-table-view").find(".layui-table-body").find("[data-field='" + primarykey + "']"); if (pkcell != null || pkcell.length > 0) { let selCell = pkcell.filter(function (i, item) { let celval = $(item).children(".layui-table-cell").html(); return hasSel.indexOf(celval) >= 0; }); if (selCell != null && selCell.length > 0) { setTimeout(function () { selCell.each(function (i, item) { $(item).parent().find(".laytable-cell-checkbox,.laytable-cell-radio").find(".layui-unselect")[0].click(); $(item).parent().addClass("sel"); }) }, 500) } } } //树型囄? if (newops.tree.show) that.rowselect.renderTree(res.data, tableOps); } } //渲染表格 let tableOutput; //卡片式显C数? if (newops.ShowCards) { that.logOk("Cards Show"); tableOps.CardsDone = function () { let outOps = this; if ($.isFunction(ops.success)) { ops.success(res, outOps.PageBarOps); } //讄~存 that.DtCache[newops.id] = { primarykey: primarykey, options: newops, el0: $(newops.el), el1: $(newops.el).next(".st-cardshow"), data: function () { return outOps.data; } } //恢复选中的项 if (hasSel != null && hasSel.length > 0 && (primarykey || "") != "") { $(newops.el).next(".st-cardshow").children(".st-cardshow-body").children().children(".scs-card").each((v, card) => { let tid = (card.ST_DATA[primarykey] || "").toString().trim(); if (hasSel.some(a => a.toString().trim() == tid)) $(card).find(".scs-card-check").children()[0].click(); }); } that.logOk("CardShow.Down"); } tableOps.ST_RES = res; tableOps.limit = 20; newops.limits = [20, 50, 100]; tableOps.ShowOps = newops; tableOps.CardsColsCount = newops.CardsColsCount; tableOutput = that.cardshow.render(tableOps); } //表格昄数据 else { that.logOk("Table Show"); tableOutput = that.table.render(tableOps) } //表格数据调序 that.table.on("sort(" + newops.id + ")", function (obj) { if (newops.tableData != null) { let _newops = { ...newops }; let colinfo = newops.tableCols.find(a => a.field != null && a.field == obj.field); _newops.tableData = newops.tableData.sort((a, b) => { if (colinfo != null && colinfo.valuetype != null && (colinfo.valuetype.toLowerCase() == "date" || colinfo.valuetype.toLowerCase() == "datetime" || colinfo.valuetype.toLowerCase() == "time")) { return obj.type != "desc" ? ((new Date(a[obj.field])) - (new Date(b[obj.field]))) : ((new Date(b[obj.field])) - (new Date(a[obj.field]))); } else if (colinfo != null && colinfo.valuetype != null && (colinfo.valuetype.toLowerCase() == "int" || colinfo.valuetype.toLowerCase() == "decimal")) { return obj.type != "desc" ? ((parseFloat(a[obj.field].toString())) - (parseFloat(b[obj.field].toString()))) : ((parseFloat(b[obj.field].toString())) - (parseFloat(a[obj.field].toString()))); } else if (!isNaN(parseFloat(a[obj.field])) && !isNaN(parseFloat(b[obj.field]))) { return obj.type != "desc" ? ((parseFloat(a[obj.field].toString())) - (parseFloat(b[obj.field].toString()))) : ((parseFloat(b[obj.field].toString())) - (parseFloat(a[obj.field].toString()))); } else { return obj.type != "desc" ? (a[obj.field].toString().localeCompare(b[obj.field].toString())) : (b[obj.field].toString().localeCompare(a[obj.field].toString())); } }); that.DtShow(_newops); } else { let _newops = { ...newops }; _newops.data.orderfield = obj.field + (obj.type == 'asc' ? '' : ' desc'); that.DtShow(_newops); return false; } }) //执行外部回调 if ($.isFunction(newops.onRes)) newops.onRes(tableOutput); } else { if (that.DtCache[newops.id] != null) { that.DtCache[newops.id].data = function () { return null; }; } let msg = (res.msg || myConst.ERR_API_LOGIC); $(newops.el).parent().children().not($(newops.el)).remove(); $(newops.el).after("
" + msg + "
") } } delete newops.data.st_session; if (newops.tableData != null) { let newRes = { code: 0, data: newops.tableData, cols: newops.tableCols, total: newops.tableData.length, msg: (newops.tableData.length == 0 ? "没有数据" : "ok") } newops.success(newRes); } else that.ajax(newops); return tableResult; }, DtRowEL: function (tableELid, pk, pkval) { return $(tableELid).next(".layui-table-view").find(".layui-table-body").find("tr").filter((i, item) => { let tds = $(item).children("[data-field='" + pk + "']"); if (tds.length == 0) return false; return tds.eq(0).children().html().trim() == pkval.toString(); }) }, DtCardEL: function (tableELid, pk, pkval) { return $(tableELid).next(".st-cardshow").find("[st-card-show-" + pk + "=" + pkval + "]"); }, //分页? tablePage: function (_table, res) { let that = this; let tableEL = _table.ShowCards ? _table.EL_body : _table.elem.next(".layui-table-view"); let pageCon = _table.ShowCards ? _table.EL_page : tableEL.children(".layui-table-page"); _table.ShowCards ? pageCon.html("") : pageCon.removeClass("layui-hide"); let pageView = _table.ShowCards ? pageCon : pageCon.children(".layui-table-pageview"); (_table.ShowCards) ? "" : pageView.removeClass("layui-hide-v"); let total = _table.res.total; let page = _table.options.page || 1; let limit = _table.options.limit || 100; let limits = _table.options.limits || [100, 200, 500]; let pagecount = Math.ceil(total / limit) let dataDicSetable = _table.options.dataDicSetable || false; let pageid = "
" pageid += "" if (pagecount < 5) { for (let i = 1; i <= pagecount; i++) { pageid += "" + i + "" } } else { let list1 = [1, 2, (pagecount - 1), pagecount] let list2 = [1, (parseInt(page) - 1), (page), (parseInt(page) + 1), pagecount] if (list1.indexOf(page) >= 0) { pageid += "" + list1[0] + "" pageid += "" + list1[1] + "" pageid += "
...
" pageid += "" + list1[2] + "" pageid += "" + list1[3] + "" } else { pageid += "" + list2[0] + "" pageid += "
...
" pageid += "" + list2[1] + "" pageid += "" + list2[2] + "" pageid += "" + list2[3] + "" pageid += "
...
" pageid += "" + list2[4] + "" } } pageid += "" pageid += "
" pageView.append(pageid) pageView.append("
到第?/div>") pageView.append("
? + total + "?/div>") pageView.append("
") if (dataDicSetable) pageView.append("") pageView.append("
已?span class='st-pageSelcount'>0?/div>") //每页展示数量选择 pageView.find(".st-pagelimits").focus(function () { let $it = $(this); let _html = ""; let $html = $(_html) $it.after($html); $html.slideDown(200); $html.find("span").click(function () { if ($(this).html() != $it.val()) { let _newops = { ..._table.options }; if (_table.ShowCards) _newops.newlimit = parseInt($(this).attr("st-limit")); else _newops.limit = parseInt($(this).attr("st-limit")); _newops.page = 1; that.DtShow(_newops); } $html.remove(); return; }) }) //每页展示数量选择_q pageView.find(".st-pagelimits").blur(function () { let $it = $(this); setTimeout(function () { let ot = $it.parent().children().not($it); ot.slideUp(200, function () { ot.remove(); }) }, 200) }) //正在览W几? pageView.find(".st-pageid").children().each(function (i, item) { if ($(item).html() == page.toString()) $(item).addClass("currpage"); }) //跛_W几? pageView.find(".st-pageid").find("span").click(function () { let _newops = { ..._table.options }; let $it = $(this); if ($it.hasClass("st-pageleft")) { if (page > 1) { _newops.page = parseInt(page) - 1; that.DtShow(_newops); } } else if ($it.hasClass("st-pageright")) { if (page < pagecount) { _newops.page = parseInt(page) + 1; that.DtShow(_newops); } } else { let _pid = $it.html(); if (_pid.toString() != page.toString()) { _newops.page = parseInt(_pid); that.DtShow(_newops); } } }); //按回车蟩到第X? pageView.find(".st-pageipt").keypress(function (e) { let _newops = { ..._table.options }; if (e.originalEvent.key == "Enter") { var _val = parseInt($(e.currentTarget).val()); if (!isNaN(_val)) { if (_val.toString() != page.toString()) { _newops.page = _val; that.DtShow(_newops); } } } }); //只能输入数字Q且不能大于当前总页? pageView.find(".st-pageipt")[0].oninput = function (e) { function getCharCount(str, char) { var regex = new RegExp(char, 'g'); var result = str.match(regex); var count = !result ? 0 : result.length; return count; } let data = e.data if (isNaN(data)) { let value = $(this).val() $(this).val(value.replace(/[^\d\.]/g, '')) var count = getCharCount($(this).val(), /\./) if (count > 0) { $(this).val($(this).val().substring(0, $(this).val().lastIndexOf('.'))); } } if (parseInt($(this).val()) > pagecount) { $(this).val(pagecount); } } //栏位调整 if (dataDicSetable) { //按钮昄控制 let toolOn = false; //延时q程 let _sid; //层元素烦? let _lid; //字段表头单元? let tableHd = tableEL.find(".layui-table-header").find("th").filter((i, item) => { return $(item).attr("data-field") != "0" && !$(item).hasClass("layui-table-patch"); }) function getfields(containHide) { let result = tableEL.children(".layui-table-box").children(".layui-table-header").find("th").filter((j, jtem) => { return $(jtem).attr("data-field") != "0" && (!$(jtem).hasClass("layui-hide") || (containHide == null ? false : containHide)) && !$(jtem).hasClass("layui-table-patch"); }) return result; } //每个单元格添加移入移Z件响? tableHd.each((i, item) => { //鼠标Ud响应 function _mouseOut() { if (_sid != null) clearTimeout(_sid); _sid = setTimeout(() => { mycommon.layer.close(_lid); }, 2000) } //鼠标Ud响应 function _mouseIn2() { if (_sid != null) clearTimeout(_sid); } //鼠标Ud响应 function _mouseIn1() { let btnHtml = "
" btnHtml += ""; btnHtml += ""; btnHtml += ""; btnHtml += "
"; if (toolOn) _lid = mycommon.layer.tips(btnHtml, item, { tips: 1, time: 6000000, success: function ($el, lid) { if (_sid != null) clearTimeout(_sid); //鼠标Ud $el.find("i").on("mouseenter", _mouseIn2); //鼠标Ud $el.find("i").on("mouseleave", _mouseOut); //~辑 $el.find("[st-dataDicSet-edit]").click(function () { let table = window["DATA_VIEW"] || ""; let field = $(item).attr("data-field") || ""; if (table == "" || field == "") { mycommon.layer.ms(myConst.ERR_DATA_NAN); return; } mycommon.ajax({ url: "../../Dataaccess/DataDicID", data: { table, field }, success: res => { if (res.code == 0 && res.data != null) { let _EventID = res.data; let _url = "../../DataAccess/EdiView?t=STdataDic"; let _title = "修改字典数据"; let _isphone = mycommon.isPhone(); let _area = _isphone ? ["100%", "100%"] : ["720px", "80%"] LAYER_ID = mycommon.layer.open({ title: [_title, "text-align:center;padding: 0px 80px;"], type: 2, content: _url + "&i=" + _EventID + "&pt=" + _title, resize: false, area: _area }) } else { mycommon.layer.ms(res.msg || myConst.ERR_API_LOGIC); } } }) }); //调序 function setSort(_table, _field, $fields, actionType) { let elidA; let elidB; let _fields = []; $fields.each((j, jtem) => { let _fieldname = $(jtem).attr("data-field") _fields.push(_fieldname); if (_field == _fieldname) { elidA = j; if (j == 0 && actionType.toLowerCase() == "left") elidB = -1; else if (j == $fields.length - 1 && actionType.toLowerCase() == "right") elidB = -1; else elidB = actionType.toLowerCase() == "left" ? (elidA - 1) : (elidA + 1); } }) mycommon.ajax({ url: "../../Dataaccess/DataDicSort", data: { table: _table, field: _field, fields: JSON.stringify(_fields), actiontype: actionType }, success: res => { if (res.code == 0) { mycommon.layer.ms(myConst.SUCC_ACTION_OK); if (elidB >= 0) { let ELA = $fields.eq(elidA); let ELB = $fields.eq(elidB); if (actionType.toLowerCase() == "left") { ELB.before(ELA); } else { ELB.after(ELA); } } } else { mycommon.layer.ms(res.msg || myConst.ERR_API_LOGIC); } } }) } //左移 $el.find("[st-dataDicSet-left]").click(function () { let table = window["DATA_VIEW"] || ""; let field = $(item).attr("data-field") || ""; let fields = getfields(); if (table == "" || field == "" || fields == null || fields.length == 0) { mycommon.layer.ms(myConst.ERR_DATA_NAN); return; } setSort(table, field, fields, "left"); }); //右移 $el.find("[st-dataDicSet-right]").click(function () { let table = window["DATA_VIEW"] || ""; let field = $(item).attr("data-field") || ""; let fields = getfields(); if (table == "" || field == "" || fields == null || fields.length == 0) { mycommon.layer.ms(myConst.ERR_DATA_NAN); return; } setSort(table, field, fields, "right"); }); } }) } //鼠标Ud $(item).on("mouseenter", _mouseIn1) //鼠标Ud //$(item).on("mouseleave", _mouseOut) }) //栏位调整开启、关? pageView.find(".st-dataDicSet").click(function () { if ($(this).html() == "栏位调整") { toolOn = true; $(this).html("调整完成"); $(this).addClass("st-dataDicSet-red"); //表格用 tableEL.find(".layui-table-body").css("transition", "0.5s"); tableEL.find(".layui-table-body").addClass("st-dataDicSet-bodyfreezing"); tableEL.find(".layui-table-body").each((i, item) => { let _coverlayer = $("") $(item).append(_coverlayer); let _prev = _coverlayer.prev(); _coverlayer.css("height", _prev.height() + "px"); _coverlayer.css("width", _prev.width() + "px"); _coverlayer.slideDown(200); }); //分页栏禁? $(this).parent().parent().children().not($(this).parent()).each((i, item) => { $(item).addClass("st-dataDicSet-bodyfreezing"); }) //ȝ层隐? var fiexdEL = tableEL.children(".layui-table-box").children(".layui-table-fixed").hide(); let firsTR = tableEL.find(".layui-table-header").find("th").not("[data-field='0']").not(".layui-hide")[0]; mycommon.layer.tips("Ud(hui)鼠标臌(san)里(han)操作", firsTR, { tips: 1, time: 4000, success: function ($el, lid) { if (_sid != null) clearTimeout(_sid); //$el.children("div").children("i").css("border-right-color", "#cde5f9"); } }) } else { toolOn = false; $(this).html("栏位调整"); $(this).removeClass("st-dataDicSet-red"); //表格恢复 tableEL.find(".layui-table-body").removeClass("st-dataDicSet-bodyfreezing"); setTimeout(() => { tableEL.find(".layui-table-body").css("transition", ""); }, 510) tableEL.find(".layui-table-body").find(".st-dataDicSet-bodycover").each((i, item) => { let $it = $(item); $it.slideUp(200, () => { $it.remove(); }) }); //分页栏恢? $(this).parent().parent().children().each((i, item) => { $(item).removeClass("st-dataDicSet-bodyfreezing"); }) //ȝ层显C? tableEL.children(".layui-table-box").children(".layui-table-fixed").show(); mycommon.layer.close(_lid); if (typeof (window["tableRender"]) == "function") { window["tableRender"](); } } }) //生成SQL脚本 pageView.find(".st-dataDicSQL").click(function () { let fieldELs = getfields(true); let table = window["DATA_VIEW"] || ""; if (table == "" || fieldELs == null || fieldELs.length == 0) { mycommon.layer.ms(myConst.ERR_DATA_NAN); return; } let fields = {}; fieldELs.each((i, item) => { let _name = $(item).attr("data-field"); fields[_name] = i + 1; }) mycommon.ajax({ url: "../../Dataaccess/DataDicSQL", data: { fields: JSON.stringify(fields), table }, success: res => { if (res.code == 0 && res.data != null && res.data.length > 0) { res.data.forEach(file => { let aEL = $(""); aEL[0].download = file.filename; aEL[0].click(); }); } else mycommon.layer.ms(res.msg || myConst.ERR_API_LOGIC); } }) }) //生成SQL脚本 pageView.find(".st-dataDicSQL").mouseenter(function () { //_lid = mycommon.layer.tips("仅对字段译名及排序操作生成脚?, this, { time: 20000, tips: 1 }) }) //生成SQL脚本 pageView.find(".st-dataDicSQL").mouseleave(function () { //mycommon.layer.close(_lid); }) } let rObj = { setSelectCount: function (val) { pageView.find(".st-pageSelcount").html(val); } } return rObj; }, //创徏分页栏,q回jq对像 BuiltPageBar: function (ops) { let total = ops.total; let pagesize = ops.pageSize; let curr = ops.curr; if (total == null || pagesize == null || curr == null) { console.warn("未配|完整的参数"); return; } let totalText = ops.totalText; let libTimeSpan = new Date().getTime(); this.checkCssFile("content/mycommonpage.css?v=" + libTimeSpan); let pagecount = Math.ceil(total / pagesize) let totalHtml1 = "" let totalHtml2 = "" + ((totalText || "").trim() != "" ? totalText : "L据量()") + "Q? + total + "" let html = "
" + totalHtml1; html += "
"; html += "前一?/span>"; function PageID_EQ_html(val1_curr, val2) { if (val1_curr == val2) return "" + val2 + ""; else return "" + val2 + "" } if (pagecount < 5) { for (var i = 1; i <= pagecount; i++) { html += PageID_EQ_html(curr, i); } } else { let list1 = [1, 2, (pagecount - 1), pagecount] let list2 = [1, (curr - 1), (curr), (curr + 1), pagecount] if (list1.indexOf(curr) >= 0) { html += PageID_EQ_html(curr, list1[0]); html += PageID_EQ_html(curr, list1[1]); html += "..." html += PageID_EQ_html(curr, list1[2]); html += PageID_EQ_html(curr, list1[3]); } else { html += PageID_EQ_html(curr, list1[0]); html += "..." html += PageID_EQ_html(curr, list1[1]); html += PageID_EQ_html(curr, list1[2]); html += PageID_EQ_html(curr, list1[3]); html += "..." html += PageID_EQ_html(curr, list1[4]); } } html += "后一?/span>"; html += "
" html += totalHtml2 + "
" let $html = $(html); $html.find(".st-pagebar-btn").click(function () { let $it = $(this); let _action = $it.attr("st-action"); if (typeof (ops.change) == "function") ops.change(_action); }) return $html; }, //播放指定路径的音? musicPlay: function (ops) { //ops.url //ops.end let url = ops.url || ""; if (url.trim() == "") { console.warn("ops.url无效"); return; } let music = new Audio(url); music.loop = ops.loop || false; music.addEventListener("play", function () { if (typeof (ops.play) == "function") ops.play(); }); music.addEventListener("ended", function () { if (typeof (ops.end) == "function") ops.end(); }); music.addEventListener("pause", function () { if (typeof (ops.break) == "function") ops.break(); }); music.play(); return music; }, //装的ajaxhҎ ajax: function (ops) { //ops.loginCheck:验证登陆p|时是否清Icookies // 0:无动? // 1:登陆p|或无登陆时清Icookies // 2:登陆p|或无登陆时清IcookiesQƈ跛_登陆面 // 默认为:2; //ops.load:是否使用load? //ops.loadops:load层的配置 //ops.resFull:是否完整输出响应数据Q如包含token{) //ops.errOut:发生异常累计跛_ơ数 默认? //ops.errOut_callback 跛_时的回调 //响应code?2Ӟ表示用户需要登陆方可访问接口,但受ops.loginCheck配置影响响应 //响应code?3Ӟ表示需强制提示msg let that = mycommon; ops.errOut = ops.errOut || 5; //跛_判断 let curr_err = that.ajaxErr.find(a => a.url = ops.url); let err_count = 0; if (curr_err != null && curr_err.err_count != null) err_count = curr_err.err_count; if (err_count >= ops.errOut) { that.logErr("AJAX.err限跛_"); if (typeof (ops.errOut_callback) == "function") { ops.errOut_callback(); } return; } ops.dataType = ops.dataType || "json"; ops.type = ops.type || "post"; ops.loginCheck = ops.loginCheck == null ? 2 : ops.loginCheck; ops.resFull = ops.resFull || false; ops.mytimeout = ops.mytimeout || 60000; if (ops.data != undefined && ops.type.toLowerCase() == 'post' && ops.data.st_session == null) ops.data.st_session = window["ST_SESSION"] || ""; ops.headers = ops.headers || {}; let tokenCookie = $.cookie("HQserverToken"); if (tokenCookie != null && tokenCookie != "") { ops.headers.Authorization = "Bearer " + tokenCookie; } //内部api的访问标? ops.headers.targettype = "innerApi"; ops.headers.st_session = window["ST_SESSION"] || ""; ops.headers.SP_SESSION = window["ST_SESSION"] || ""; ops.headers.stPagePath = that.getPagePath(); //loadlayer let _layID = null; if ((ops.load != undefined && ops.load) || ops.load == undefined) _layID = that.layer.myload(ops.loadops); let olderror = ops.error; let oldsucce = ops.success; ops.error = function (res) { //跛_前篏? let curr_err = that.ajaxErr.find(a => a.url = ops.url); let err_count = 1; if (curr_err != null && curr_err.err_count != null) err_count = curr_err.err_count + 1; let newerr = { url: ops.url, err_count, res }; that.ajaxErr = that.ajaxErr.filter(a => a.url != ops.url); that.ajaxErr.push(newerr); if (res.timeout) that.logOk("TimeOut End"); else that.logOk("Req Done "); that.requireing = false; if ($.isFunction(olderror)) olderror(res); console.log(res); console.log("url:" + ops.url); if (_layID) that.layer.close(_layID); if (res.timeout) that.layer.ms("h量过大,{待时"); else { that.layer.ms_PageBottom("AJAXh响应异常"); } }; ops.success = function (res) { if (_layID) setTimeout(() => { that.layer.close(_layID); }, 500); var c1 = res.loginOK != null && res.loginOK == false && res.errmsg != null && res.errmsg.toString().trim() != ""; var c2 = res.code == -2 && res.msg != null; var c3 = res.code == -3 && res.msg != null; if (ops.loginCheck >= 1 && (c1 || c2)) { $.removeCookie("HQserverToken", { path: "/" }); that.layer.alert(res.errmsg, function () { window.top.location.href = '../home' }); if (ops.loginCheck == 2) { that.layer.alert(res.errmsg || res.msg, { title: "", end: function () { window.top.location.href = ".."; } }) return; } return; } else if (res.code == 0 && res.token != null && res.token != "" && res.loginOK) { //写入令牌l期 $.cookie("HQserverToken", res.token, { expires: res.expire_forCookie, path: '/' }) } else if (c3) { that.layer.closeAll(); that.layer.alert(res.errmsg || res.msg, { title: "", }) } //会话更新 if (res.session != null) { mycommon.logOk("会话更新"); ST_SESSION = res.session.value; } if (!ops.resFull) { list1 = ["loginOK", "errmsg", "token", "UserModel", "expire_forCookie", "expire_now", "expire_spam", "expire_time", "username", "session", "isFromWeChat", "isFromWorkChat", "loginByWxUrl"]; for (var i = 0; i < list1.length; i++) { try { delete res[list1[i]]; } catch (error) { } } } that.logOk("Req Done "); that.requireing = false; //q行传入的回? if ($.isFunction(oldsucce)) oldsucce(res); } ops.url = ops.url || window.location.href; let timeNo = new Date().getTime(); if (!that.requireing) { //无需{待 that.logOk("Req Begin "); that.requireing = true; $.ajax(ops); } else { //{待可执行情? let t1 = new Date().getTime(); let ___sssid___ = setInterval(() => { if (!that.requireing) { that.logOk("Req Begin "); that.requireing = true; if (ops.data != undefined && ops.type.toLowerCase() == 'post') ops.data.st_session = window["ST_SESSION"] || ""; ops.headers.st_session = window["ST_SESSION"] || ""; $.ajax(ops); clearInterval(___sssid___); } else { that.logOk("WaitFor Req"); //{待时 let t2 = new Date().getTime(); if (t2 - t1 >= ops.mytimeout) { ops.error({ code: -1, msg: "timeout of waiting", timeout: true }) clearInterval(___sssid___); } } }, 50); } }, //取得面路径 getPagePath: function () { return window.location.pathname + window.location.search; }, //表格调高 //$tableCo:table标签的上Udiv容器的jqery对象 //offsetBottomQ可选参?距页面底边的距离Q不填定则默认ؓ25pxQ? //TableHeight()ҎQ应在全局中只执行一? //l合TableUI()Ҏ实现调高QTableUI()Ҏ应在每次layui.table渲染后执行一? //layui.table渲染时不要设定height参数 __hasTableHeight__: [], TableHeight: function ($tableCo, offsetBottom, animate, winresizID) { var that = this; if (offsetBottom == undefined) offsetBottom = 25; function setheight(e) { let tp = $tableCo.offset().top; let holehi = that.getBodyViewHeight($("body")) if (window.frameElement != null) { let ifEL = $(window.frameElement) let ParentWin = window.frameElement.ownerDocument.defaultView let parentDoc = window.frameElement.ownerDocument let Parentvh = that.getBodyViewHeight($(parentDoc.body)) let ifOutHi = ifEL.outerHeight() let iftop = ifEL.offset().top let deline = (ifOutHi + iftop) - Parentvh + (offsetBottom) if (deline <= 0) deline = (offsetBottom) let targetHeight = holehi - tp - deline if (animate != undefined && animate == true) $tableCo.animate({ height: targetHeight }, 2000) else $tableCo.outerHeight(targetHeight) //console.log("holehi:" + holehi) //console.log("top:" + tp) //console.log("deline:" + deline) //console.log("offsetBottom:" + offsetBottom) //console.log("result:" + (holehi - tp - deline)) //console.log("__________________") } else { let targetHeight = holehi - tp - (offsetBottom) if (animate != undefined && animate == true) $tableCo.animate({ height: targetHeight }, 2000) else $tableCo.outerHeight(targetHeight) } if ($tableCo.css("opacity") == 0) { $tableCo.css("transition", "1s") $tableCo.css("opacity", "1") setTimeout(function () { $tableCo.css("transition", ""); }, 1500) } } setheight() var resi if ($.isFunction(window.onresize)) { resi = window.onresize; } var c1 = winresizID != null; var c2 = that.__hasTableHeight__.indexOf(winresizID) < 0 if ((c1 && c2) || !c1) { window.onresize = function (e) { if ($.isFunction(resi)) { resi(e); } setheight(e); } if (c1) that.__hasTableHeight__.push(winresizID); console.log("H口大小变化响应") } }, getBodyViewHeight: function ($body) { let temdiv = $("
") $body.append(temdiv); var holehi = temdiv.height() temdiv.remove(); return holehi }, //用于表格调高done回调用? TableHeightOff: function (that) { var tEL = $("#" + that.id).next(".layui-table-view") var ttl = tEL.find(".layui-table-tool") var ttlhi = ttl.length > 0 ? ttl.outerHeight() : 0 var tbo = tEL.find(".layui-table-box") var ttb = tbo.find(".layui-table-body") tEL.css("height", "calc(100% - 10px)") tbo.css("height", "calc(100% - " + (41 + ttlhi) + "px)") ttb.css("height", "calc(100% - 39px)") }, TableHeightOff_noPageBar: function (that) { var tEL = $("#" + that.id).next(".layui-table-view") var tbo = tEL.find(".layui-table-box") var ttb = tbo.find(".layui-table-body") tEL.css("height", "calc(100% - 10px)") tbo.css("height", "calc(100% - 0px)") var cutHi = ttb.prev(".layui-table-header").height() ttb.css("height", "calc(100% - " + cutHi + "px)") }, //layui表格使用新的样式 TableUseStyle: function (id) { let cssList = [ "../../JS/Common/layuiTableCssOver.css" ] let _id = id || 0; if (_id > cssList.length - 1) _id = 0; if (cssList.length == 0) return; let cssPath = cssList[_id]; let filename = cssPath.substring(cssPath.lastIndexOf('/')).toLowerCase(); let oldLinks = $("html").find("link").filter(function (i, item) { let href = $(item).attr("href").toLowerCase(); return href.indexOf(filename) >= 0; }) if (oldLinks.length > 0) oldLinks.remove(); let newLink = '' $("head").find("link").last().after(newLink); }, //查css文g是否已在当前面引入Q若非则引入 checkCssFile: function (path, extPro, callback) { if ((path || "") == "") return; path = "/" + (path||"").toLowerCase().replace(/\\/g, "/").replace(/\.\.\//g, "").toString().TrimChar('/'); let links = $("html").find("link") let link = links.filter(function (i, item) { let _href = "/" + $(item).attr("href").toLowerCase().replace(/\\/g, "/").replace(/\.\.\//g, "").TrimChar('/'); return _href.indexOf(path) >= 0; }) if (link == null || link.length == 0) { let newlink = $("= 0 ? "" : ("?v=" + (new Date().getTime()))) + "' rel='stylesheet' />"); newlink[0].onload = function () { if (typeof (callback) == "function") callback(); } links.last().after(newlink); } }, //使用新的弹出层样? layerStyle: function (id) { let that = this; that.wait(() => that.init_completed).run(() => { let path1 = "/js/common/layer01.css"; if (that.pageStyle != null && (that.pageStyle.theme || "") != "") path1 = "/themes/" + that.pageStyle.theme + "/layer01.css"; let fileList = [path1]; var _id = id != undefined ? id : 0; if (fileList.length < _id + 1) _id = 0; if (fileList == null || fileList.length == 0) return; that.checkCssFile(fileList[_id]); }) }, //是否是移动设备访? isPhone: function () { return window.top.screen.width <= 700; }, //试对Json字符q序列化 tryJson: function () { let str = this; try { return JSON.parse(str); } catch (e) { if ((str || "").trim() == "") mycommon.logOk("mycommon.trJson:str empty"); else { mycommon.logWarn("mycommon.trJson fail"); console.log(str); } return null } }, //旉增加天数 CV_addDay: function (daycount) { var mydate = this.getTime(); return new Date(mydate + (1000 * 24 * 60 * 60 * daycount)); }, //旉cd取日期部? CV_getDate: function () { var mydate = this; var y = mydate.getFullYear(); var m = (mydate.getMonth() + 1).toString().HeadZero(2); var d = mydate.getDate().toString().HeadZero(2); return y + "-" + m + "-" + d; }, //旉cd取时间部? CV_getTime: function () { let mydate = this; let h = mydate.getHours().toString().HeadZero(2); let m = mydate.getMinutes().toString().HeadZero(2); let s = mydate.getSeconds().toString().HeadZero(2); return h + ":" + m + ":" + s; }, CV_getTimems: function () { var mydate = this; var h = mydate.getHours().toString().HeadZero(2); var m = mydate.getMinutes().toString().HeadZero(2); var s = mydate.getSeconds().toString().HeadZero(2); var f = mydate.getMilliseconds().toString().HeadZero(3); return h + ":" + m + ":" + s + "." + f; }, CV_getDatetime: function () { var mydate = this; return mydate.CvDate() + " " + mydate.CvTime(); }, CV_getDatetimems: function () { var mydate = this; return mydate.CvDate() + " " + mydate.CvTimems(); }, CV_getDatetimeObj: function () { return { date: this.CvDate(), datetime: this.CvDateTime(), time: this.CvTime() } }, CV_getDateTimeStr: function () { let mydate = this; var y = mydate.getFullYear(); var M = (mydate.getMonth() + 1).toString().HeadZero(2); var d = mydate.getDate().toString().HeadZero(2); let h = mydate.getHours().toString().HeadZero(2); let m = mydate.getMinutes().toString().HeadZero(2); let s = mydate.getSeconds().toString().HeadZero(2); var f = mydate.getMilliseconds().toString().HeadZero(3); return y + M + d + h + m + s + f; }, getMonthFirstDay: function () { var mydate = new Date(); var y = mydate.getFullYear(); var m = (mydate.getMonth() + 1).toString().HeadZero(2); var d = "01" return y + "-" + m + "-" + d; }, //指定面元素昄警示 warnElement: function ($el, tipsStr, tipsOPS, colorStr, shadowInset, showTextColor) { //tipsOPS.warnDone: () => { } tipsOPS = tipsOPS || {}; let that = this; let _shadowInset = shadowInset || false; $el.each(function (i, item) { if (showTextColor) mycommon.warnElement_textColor($(item)); else { let color = colorStr || "#ff3d00a6"; let time = 100; let $it = $(item); let boxShaddw = $it.css("box-shadow") || ""; let transition = $it.css("transition") || ""; $it.css("transiion", "none"); $it.css("box-shadow", "none"); $it.css("transiion", (time / 1000) + "s"); $it.css("box-shadow", "0px 0px 6px 2px " + color + (_shadowInset ? " inset" : "")); setTimeout(() => { $it.css("box-shadow", "none"); setTimeout(() => { $it.css("box-shadow", "0px 0px 5px 1px " + color + (_shadowInset ? " inset" : "")); setTimeout(() => { $it.css("box-shadow", "none"); setTimeout(() => { $it.css("box-shadow", "0px 0px 5px 1px " + color + (_shadowInset ? " inset" : "")); setTimeout(() => { $it.css("box-shadow", "none"); setTimeout(() => { $it.css("box-shadow", "0px 0px 5px 1px " + color + (_shadowInset ? " inset" : "")); setTimeout(() => { $it.css("box-shadow", "none"); setTimeout(() => { $it.css("box-shadow", boxShaddw); setTimeout(() => { $it.css("transition", "none"); $it.css("transition", transition); if (typeof (tipsOPS.warnDone) == "function") tipsOPS.warnDone(); }, time) }, time) }, time) }, time) }, time + 20) }, time + 20) }, time + 20) }, time + 20) }, time + 20) } if (tipsStr != null) { that.layer.tips(tipsStr, $el, tipsOPS); } }); }, warnElement_textColor($el) { //color: white; //: 1px 1px 5px orangered; let oldCo = $el.css("color") || "initial"; let oldsh = $el.css("text-shadow") || ""; let time = 100; let orangered = "0px 0px 5px #0f6cb1"; let white = "white"; $el.css("text-shadow", orangered); $el.css("color", white); setTimeout(function () { $el.css("color", oldCo); setTimeout(function () { $el.css("color", white); setTimeout(function () { $el.css("color", oldCo); setTimeout(function () { $el.css("color", white); setTimeout(function () { $el.css("color", oldCo); $el.css("text-shadow", oldsh); }, time + 20) }, time + 20) }, time + 20) }, time + 20) }, time + 20) }, //随机函数 random: function (min, max) { if (max < min) max = min; if (max == min) return min; let dv = max - min; let _val = Math.random() * (dv + 1) + min; var result = parseInt(_val.toFixed(0).toString()); if (result >= min && result <= max) return result; else return this.random(min, max); }, //指定控g昄动层,q可延时关闭及配|事件回? hovertips: function ($el, tipsStr, tipsOps) { //ops.delay 延迟弹出? //ops.leavehide true/false 默认为false // true :鼠标UdӞ层立d? // false :鼠标Ud且不在层上时Q层才会关闭 //ops.offset //ops:offAllEvent let that = mycommon; let LAYEL; let LAYID; let TimoutID; let mX; let mY; let Sid; let ops = { ...(tipsOps || {}) }; ops.success = function (layEL, layID, cfg) { LAYEL = layEL; if (ops.tips == 1) { LAYEL.css("top", (LAYEL.offset().top + (ops.offset != null ? ops.offset[0] : 10)) + "px") LAYEL.css("left", (LAYEL.offset().left + ((ops.offset != null && ops.offset.length >= 2) ? ops.offset[1] : 0)) + "px") } if (tipsOps != null && $.isFunction(tipsOps.success)) tipsOps.success(layEL, layID, cfg, that.layer.close); layEL.on("mouseleave", function () { return; setTimeout(function () { that.layer.close(layID) }, 500) }) } ops.tips = ops.tips || 1; ops.time = ops.time || 60000; function menter() { if (ops.delay) { TimoutID = setTimeout(() => { if (typeof (tipsStr) == "function") LAYID = that.layer.tips(tipsStr(), $el, ops); else LAYID = that.layer.tips(tipsStr, $el, ops); }, ops.delay) } else { if (typeof (tipsStr) == "function") LAYID = that.layer.tips(tipsStr(), $el, ops); else LAYID = that.layer.tips(tipsStr, $el, ops); } } function mleave() { if (TimoutID != null) clearTimeout(TimoutID); if (ops.leavehide && LAYID != null) that.layer.close(LAYID); Sid = setTimeout(() => { if (Sid != null) clearTimeout(Sid) if (LAYEL == null) return; let x1 = LAYEL.offset().left - 10; let x2 = x1 + LAYEL.width() + 10; let y1 = LAYEL.offset().top - 10; let y2 = y1 + LAYEL.height() + 10; let dcount = 30; let c1 = mX > x1 - dcount && mX < x2 + dcount && mY > y1 - dcount && mY < y2 + dcount; if (!c1) { that.layer.close(LAYID); } }, 100); } document.addEventListener("mousemove", function (e) { mX = e.pageX; mY = e.pageY; }) if (ops.offAllEvent || false) { $el.off(); } else { $el.off("mouseenter", menter); $el.off("mouseleave", mleave); } $el.on("mouseenter", menter); $el.on("mouseleave", mleave); }, //滚动到指定元? scrollto: function ($con, $item, ops) { // ops.time // ops.step ops = ops || {}; let time = ops.time || 200; let step = ops.step || 10; let CTo = $con[0].offsetTop; let ITo = $item[0].offsetTop; let toSet = ITo - CTo; if ($con[0].scrollTop > toSet) { let dit = $con[0].scrollTop - toSet; let _si = setInterval(() => { $con[0].scrollTop -= step; if ($con[0].scrollTop <= toSet || $con[0].scrollTop <= 0) { $con[0].scrollTop = toSet; clearInterval(_si); } }, time / (dit / step)); } if ($con[0].scrollTop < toSet) { let dit = toSet - $con[0].scrollTop; let _si = setInterval(() => { $con[0].scrollTop += step; if ($con[0].scrollTop >= toSet || $con[0].scrollTop >= $con[0].scrollHeight - $con[0].offsetHeight - 5) { $con[0].scrollTop = toSet; clearInterval(_si); } }, time / (dit / step)); } }, __img_FileExts__: ["jpg", "jpeg", "png", "gif", "bmp", "webp"], fileIcon: function (filename) { this.checkCssFile("content/fonts/STfont/iconfont.css"); var otherIcon = ""; if (filename == null || filename.toString().trim() == "") return otherIcon; if (filename.indexOf('.') < 0) return otherIcon; let fext = filename.substring(filename.lastIndexOf(".") + 1).toLowerCase(); let imgs = this.__img_FileExts__; let word = ["doc", "docx"]; let excel = ["xls", "xlsx"]; let pdf = ["pdf"]; let txt = ["txt"]; let html = ["html", "htm"]; if (imgs.indexOf(fext) >= 0) { return ""; } else if (word.indexOf(fext) >= 0) { return ""; } else if (excel.indexOf(fext) >= 0) { return ""; } else if (pdf.indexOf(fext) >= 0) { return ""; } else if (txt.indexOf(fext) >= 0) { return ""; } else if (html.indexOf(fext) >= 0) { return ""; } else return otherIcon }, //复制文本到剪切板 copytext: function (str) { //复制文本 function copyText(text) { var element = createElement(text); element.select(); element.setSelectionRange(0, element.value.length); document.execCommand('copy'); element.remove(); } //创徏临时的输入框元素 function createElement(text) { var isRTL = document.documentElement.getAttribute('dir') === 'rtl'; var element = document.createElement('textarea'); // 防止在ios中生羃放效? element.style.fontSize = '12pt'; // 重置盒模? element.style.border = '0'; element.style.padding = '0'; element.style.margin = '0'; // 元素移到屏q外 element.style.position = 'absolute'; element.style[isRTL ? 'right' : 'left'] = '-9999px'; // Ud元素到页面底? let yPosition = window.pageYOffset || document.documentElement.scrollTop; element.style.top = `${yPosition}px`; //讄元素只读 element.setAttribute('readonly', ''); element.value = text; document.body.appendChild(element); return element; } copyText(str); } } ;