已?span class='st-pageSelcount'>0?/div>")
//每页展示数量选择
pageView.find(".st-pagelimits").focus(function () {
let $it = $(this);
let _html = "
";
$.each(limits, function (i, item) {
_html += "" + item + "??/span>";
})
_html += "
";
let $html = $(_html)
$it.after($html);
$html.slideDown(200);
$html.find("span").click(function () {
if ($(this).html() != $it.val()) {
let _newops = { ..._table.options };
_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("
U(zhou)d(nian)鼠标臌里(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 = "
" + ((totalText || "").trim() != "" ? totalText : "L据量") + "Q? + total + ""
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.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) {
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 () {
var mydate = this;
var h = mydate.getHours().toString().HeadZero(2);
var m = mydate.getMinutes().toString().HeadZero(2);
var 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()
}
},
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(() => {
LAYID = that.layer.tips(tipsStr, $el, ops);
}, ops.delay)
} 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 otherIcon
} 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);
}
}
;