function callIntervalAfterTimeout(interval, timeout, fun) {
let intervalHandle = setInterval(fun, interval);
setTimeout(function () {
clearInterval(intervalHandle);
}, timeout);
}
getRootPath: function () {
var strFullPath = window.document.location.href;
var strPath = window.document.location.pathname;
var pos = strFullPath.indexOf(strPath);
var prePath = strFullPath.substring(0, pos);
var postPath = strPath.substring(0, strPath.substr(1).indexOf('/') + 1);
return (prePath + postPath);
},
菜单项高亮
•
index() 算自己是父类的第几个孩子。
•
给css加important
$(function () {
let a = $("a[href='" +window.location.pathname + "']");
let li = a.parent();
a.css("cssText","color:white!important;text-shadow: 0px 0px white;");
UIkit.nav($('#wg-nav-left')[0]).toggle($('#wg-nav-left>li').index(li.parent().parent()), false);
});
拓展 Date的format方法
Date.prototype.format = function (fmt) {
if (isEmpty(fmt)) fmt = date_partten;
var o = {
"M+": this.getMonth() + 1, //月份
"d+": this.getDate(), //日
"H+": this.getHours(), //小时
"m+": this.getMinutes(), //分
"s+": this.getSeconds(), //秒
"q+": Math.floor((this.getMonth() + 3) / 3), //季度
"S": this.getMilliseconds() //毫秒
};
if (/(y+)/.test(fmt)) fmt = fmt.replace(RegExp.$1, (this.getFullYear() + "").substr(4 - RegExp.$1.length));
for (var k in o)
if (new RegExp("(" + k + ")").test(fmt)) fmt = fmt.replace(RegExp.$1, (RegExp.$1.length == 1) ? (o[k]) : (("00" + o[
k]).substr(("" + o[k]).length)));
return fmt;
}
打开文件选择框,选完直接上传
<form id="background-form" style="display: none;" enctype="multipart/form-data" action="dept/upload" method="post">
<input id="background-id" type="text" name="id">
<input id="background-image" type="file" name="file" multiple="true">
<button id="background-button" type="submit">上传</button>
</form>
function openBackgroundWindow() {
$("#background-id").val(treeID);
$("#background-image").val("").click();
return false;
}
$("#background-image").change(function () {
// 上传图片
var form = new FormData(document.getElementById("background-form"));
$.ajax({
url: ctx + "/dept/upload",
type: "post",
data: form,
processData: false,
contentType: false,
success: function (data) {
if (data.code == '200')
IPLAT.NotificationUtil("保存背景图片成功", "success")
else
IPLAT.NotificationUtil("保存背景图片失败 " + data.message, "error")
},
error: function (e) {
IPLAT.NotificationUtil("保存背景图片失败", "error")
}
});
});
if ($("#background").length < 1) {
// 添加 图片上传按钮
let clone = $('#add>button').first().css("margin-right", "8px").clone().attr("id", "background").attr("title", "暂时只支持png格式图片!");
clone.html("上传背景图片").on("click", openBackgroundWindow);
$("#add").append(clone);
}
评论区