function getP(name) {
this.switchParam = {
and: {
source: [
{ desc: "与", value: "0" },
{ desc: "或", value: "1" },
],
},
date: {
source: [
{ desc: "年", value: "1", className: "smallButton" },
{ desc: "月", value: "2", className: "smallButton" },
{ desc: "日", value: "3", className: "smallButton" },
],
},
/* 再改 management(String) 为 int -- 0 为未指定,99 为所有(原为 "0")。Lin
management:{source:[{desc:"所有",value:"0"},{desc:"管理",value:"2"},{desc:"创建",value:"1"},{desc:"已办",value:"3"},{desc:"停用",value:"55"}]},
*/ management: {
source: [
{ desc: "所有", value: 99 },
{ desc: "管理", value: 2 },
{ desc: "创建", value: 1 },
{ desc: "已办", value: 3 },
{ desc: "停用", value: 55 },
],
},
isfulltext: {
source: [
{ desc: "全文", value: "0" },
{ desc: "全文", value: "1" },
],
},
};
return this.switchParam[name];
}
function getPValue(name, v, findcurrent) {
var c = getP(name);
var cc = c["source"];
if (!v) return cc[0];
var i = 0;
for (var i = 0; i < cc.length; i++) {
if (cc[i].value == v) {
if (findcurrent) {
return cc[i];
} else if (i + 1 < cc.length) {
return cc[i + 1];
}
break;
}
}
return cc[0];
}
//日期
$("[ssType=date]") // [wdType=。Lin
.css({ position: "absolute", right: "4px", top: "3px" }) //定位
.each(function () {
var wdName = $(this).attr("ssName"); // ("wdName")。Lin
if ($("[name=" + wdName + "]").val()) {
var matchNumArr = $("[name=" + wdName + "]")
.val()
.match(/\d+/g);
if (matchNumArr) {
var matchNum = matchNumArr.length;
$(this).attr("ssVal", matchNum); // ("wdVal",。Lin
}
} else {
//设置默认格式
var matchNumArr = $("[name=" + wdName + "]")
.attr("format")
.match(/(yyyy|MM|dd)/g);
if (matchNumArr) {
var matchNum = matchNumArr.length;
$(this).attr("ssVal", matchNum); // ("wdVal",。Lin
}
}
$(this).click(function () {
var ccc = getPValue("date", $(this).attr("ssVal")); // ("wdVal"))。Lin
var ccc1 = getPValue("date", $(this).attr("ssVal"), true); // ("wdVal"),。Lin
$(this)
.val(ccc.desc)
.attr("ssVal", ccc.value)
.removeClass(ccc1.className)
.addClass(ccc.className); // ("wdVal",。Lin
});
var ccc = getPValue("date", $(this).attr("ssVal"), true); // ("wdVal"),。Lin
$(this).val(ccc.desc).attr("ssVal", ccc.value).addClass(ccc.className); // ("wdVal",。Lin
$("[name=" + wdName + "]").click(function () {
var radioVal = $('[ssName="' + $(this).attr("name") + '"]').attr("ssVal"); // ('[wdName="'+。("wdVal")。Lin
if (1 == radioVal) {
wd.edit.datePicker({
dateFmt: "yyyy",
});
} else if (2 == radioVal) {
wd.edit.datePicker({
dateFmt: "yyyy-MM",
});
} else if (3 == radioVal) {
wd.edit.datePicker({
dateFmt: "yyyy-MM-dd",
});
}
});
});
//与,或
$("[ssType=and]").each(function () {
// [wdType=。Lin
$(this)
.click(function () {
var v = $(this).attr("ssVal"); // ("wdVal")。Lin
var n = $(this).attr("ssName"); // ("wdName")。Lin
var ccc = getPValue("and", v);
$(this)
.val(ccc.desc)
.attr("ssVal", ccc.value)
.addClass("content-onButton"); // ("wdVal",。Lin
var isAndStr = $("[name=isAnd]").val();
var isAnd = isAndStr ? JSON.parse(isAndStr) : {};
isAnd[n] = ccc.value;
$("[name=isAnd]").val(JSON.stringify(isAnd));
})
.trigger("click");
});
//全文
$("[ssType=fts]")
.hide()
.each(function () {
// [wdType=isFulltext。Lin
var wdName = $(this).attr("ssName"); // ("wdName")。Lin
$(this).click(function () {
var v = $(this).attr("ssVal"); // ("wdVal")。Lin
var ccc = getPValue("isfulltext", v);
$(this)
.val(ccc.desc)
.attr("ssVal", ccc.value)
.toggleClass("content-onButton", ccc.value == "1")
.toggleClass("content-offButton", ccc.value == "0"); // ("wdVal",。Lin
$("[name='isFulltext']").val(ccc.value);
});
var ccc = getPValue("isfulltext", $("[name='isFulltext']").val(), true);
$("[name='isFulltext']").val(ccc.value);
$(this)
.val(ccc.desc)
.attr("ssVal", ccc.value)
.toggleClass("content-onButton", ccc.value == "1")
.toggleClass("content-offButton", ccc.value == "0"); // ("wdVal",。Lin
});
//management
var $m = $("[name=management]");
/* 再改,management(String) 为 int -- 0 为未指定,99 为所有(原为 "0")。Lin
if(! $m.val())
*/ if (!$m.val() || "0" == $m.val()) $m.val(getPValue("management").value);
var TAB_NORMAL = "lightTab";
var TAB_SELECTED = "lightTab-selected";
$("[ssType=searchScope]")
.addClass(TAB_NORMAL)
.each(function () {
// [wdType=manage。Lin
var wdName = $(this).attr("ssName"); // ("wdName")。Lin
$(this).click(function () {
$("[ssType=searchScope]").removeClass(TAB_SELECTED).addClass(TAB_NORMAL); // [wdType=manage。Lin
$(this).removeClass(TAB_NORMAL).addClass(TAB_SELECTED);
var v = $(this).attr("ssVal"); // ("wdVal")。Lin
$m.val(v);
$("[name=ssSearch]").trigger("click"); // $("[name=wdSearch]").。Lin
});
if ($m.val() == $(this).attr("ssVal")) {
// ("wdVal"))。Lin
$(this).removeClass(TAB_NORMAL).addClass(TAB_SELECTED);
}
});
var moveCount = 0;
var ele = null;
var resizeDom = null;
var resizeStart = {};
var GRAPH_CLASS = "graph-list";
var ghost = $("#gho666");
if (ghost.length == 0)
ghost = $("
').css({
width: 0,
height: 50,
border: "1px solid red",
marginLeft: 0,
marginRight: 0,
padding: 0,
display: "inline-block",
});
$(document.body)
.on("mousedown", "." + GRAPH_CLASS, function (e) {
console.log("mousedown");
if (GRAPH_CLASS + "-mask" != e.target.getAttribute("class")) return true;
ele = this;
$(this).trigger("mouseenter");
})
.on("mouseenter", "." + GRAPH_CLASS, function () {
if (!ele) return;
$(this).before(ghost);
})
.on("mousedown", "." + GRAPH_CLASS + "-resize", function (e) {
ele = null;
resizeDom = this.parentNode;
resizeStart = {
x: e.pageX,
y: e.pageY,
width: $(resizeDom).width(),
height: $(resizeDom).height(),
};
return false;
})
.on("mouseleave", function (e) {
// $(this).before(ghost);
console.log("bye");
$("#gho666").css("");
})
.on("mouseup", function () {
var saveSize = false;
if (resizeDom || ele) {
saveSize = true;
if (ele) {
var pos = ele.compareDocumentPosition(ghost[0]);
saveSize = "2" != pos;
}
}
if (saveSize) savegrtjSize(resizeDom.attributes.grtjid.value); // 改,增加入口参数 id -- 为 redrawPcht(。Lin
if (ele) ghost.before(ele).remove();
resizeDom = null;
ele = null;
})
.on("mousemove", function (e) {
if (!resizeDom) return;
$(resizeDom)
.width(resizeStart.width + (e.pageX - resizeStart.x) * 1)
.height(resizeStart.height + (e.pageY - resizeStart.y) * 1);
})
.on("click", ".graphButton", function () {
var url = $("[name=addgrtjUrl]").val();
eval(url);
/* $.post(url,function(data){
data=eval("("+data+")");
wd.display.alert(data.msg);
window.location.reload();
})*/
});
function initGraph() {
if ($(".graphButton").length == 0) return false;
window.onload = function () {
$("." + GRAPH_CLASS).each(function (index, ele) {
//var url=$("[name=getgrtjJsonUrl]").val();
/* 去掉,共用 redrawPcht(id)。Lin
* 对 个人统计表 部件,不调用 redrawPcht(
var url=$("[name=getEChartData]").val();
$.post(url,{grtjid:$(ele).attr("grtjid")},function(result){
if(!result)return true;
result=eval("("+result+")");
var $body=$(ele).find("."+GRAPH_CLASS+"-body").attr("style","height: 100%;");
if($body.width()==0){
$body.parent().width(50);
$body.width(50);
}
if($body.height()==0){
$body.parent().height(50);
$body.height(50);
}
// $body.empty();
/// * 改,去掉 ZGZ:AjaxJson,AjaxJson.success(boolean) 改为 .ssCode(int) -- 用 ServU.wrOkDataByAjax(、ServU.wrErrMsgByAjax(、Map 了。Lin
// if(result.success){
/// *
if(result.ssCode == 1){
console.log(result);
var data = result.data;
var ECData = {};
ECData.name = data.grtj.mc;
ECData.id = $(ele).attr("grtjid");
ECData.type = data.grtj.tjtlbm;
ECData.rename = {name:"mc",value:"sl"};
ECData.dom=$body[0];
// /// *var map = new Map();
// for(var i;i savegrtjSize(id)、window.onload()
// 原 savegrtjSize() 里,保存完 Size 后,调用的 initGraph() 只有 return true;
function redrawPcht(id) {
var url = $("[name=getEChartData]").val();
$.post(url, { grtjid: id }, function (result) {
if (!result) return true;
result = eval("(" + result + ")");
var $body = $("#tjt-" + id).attr("style", "height: 100%;");
/* 改,去掉 ZGZ:AjaxJson,AjaxJson.success(boolean) 改为 .ssCode(int) -- 用 ServU.wrOkDataByAjax(、ServU.wrErrMsgByAjax(、Map 了。Lin
* 统一 Ajax 返回标准 -- .ssCode、.ssMsg、.ssData
if(result.success){
*/ if (result.ssCode == 0) {
var data = result.ssData;
var ECData = {};
ECData.name = data.grtj.mc;
ECData.id = id;
ECData.type = data.grtj.tjtlbm;
ECData.rename = { name: "mc", value: "sl" };
ECData.dom = $body[0];
ECData.dataList = data.dataArray;
MyECharts.init(ECData);
} else {
if ("0" == result.ssData) {
$("#tjt-" + id)
.parent()
.animate({ height: 50, width: "100%" })
.animate({ width: 0 })
.remove();
} else {
$body.html($body.html() + ":" + result.ssMsg);
}
}
});
}
$(function () {
$(".property").each(function (index, ele) {
if (changeArray[index].length == 0) {
$(this).hide().next().hide();
return;
}
var a = changeArray[index][0];
$(ele).html(
"" +
a.name +
'从' +
a.oldValue +
'改为' +
a.newValue +
""
);
var size = changeArray[index].length;
$(ele).next(".icon-num").html(size);
console.log($(ele));
$(ele).on("mouseover", function () {
if ($(".propertys").length > 0) {
$(".propertys").remove();
return false;
}
var html =
"| 修改项 | 更改后的值 | 原来的值 |
";
for (var i = 0; i < changeArray[index].length; i++) {
html += "| " +
changeArray[index][i].name +
" | " +
changeArray[index][i].newValue +
" | " +
changeArray[index][i].oldValue +
" |
";
}
html =
'";
$("body").append(html);
var bounding = this.getBoundingClientRect();
$(".propertys").css({
left: bounding.left,
top: bounding.top + bounding.height,
});
return false;
});
});
});
//拖动头
$(function () {
return; // 再增加,objList.ss.jsp 的首页,部分上、下两部分了。Lin
try {
if ($(".graphButton").length == 0) return;
var graphDiv = document.querySelector(".graph");
var cardlistDiv = document.querySelector(".longCardList-div");
var lines = document.querySelectorAll("#line");
if (lines.length == 0) {
var line_div = document.createElement("div"); // 新增元素
line_div.className = "content-hSeperator";
line_div.id = "line";
//拖动遮罩层
var mask =
'';
line_div.innerHTML = mask + "";
cardlistDiv.parentNode.insertBefore(line_div, cardlistDiv); // 在这个元素前面增加上去
}
var topDiv = graphDiv;
var bottomDiv = cardlistDiv;
// topDiv.style.display = "block";
// bottomDiv.style.display = "block";
// topDiv.style.height="100%"
// bottomDiv.style.height="auto"
var hh = parseInt($(".longCardList-div").css("height"));
topDiv.style.height = hh * 0.7;
bottomDiv.style.height = hh * 0.3;
// topDiv.style.overflow="hidden"
// bottomDiv.style.overflow="hidden"
el = document.getElementById("line");
el.style.zIndex = "99";
//PC端的变量
var start_Y;
var top_Height;
var middle_Height;
var starty = 0;
var topStartHeight = 0;
var bottomStartHeight = 0;
var dragmask = el.querySelector(".dragmask");
var ismousedown = false;
el.onmousedown = function (e) {
ismousedown = true;
e.preventDefault();
starty = e.screenY;
// topStartHeight = parseInt(topDiv.offsetHeight) || 50;
// bottomStartHeight = parseInt(bottomDiv.offsetHeight) || 50;
topStartHeight = parseInt(topDiv.style.height) || 0;
bottomStartHeight = parseInt(bottomDiv.style.height) || 0;
if (dragmask) {
dragmask.style.display = "";
}
};
document.onmouseup = function (e) {
ismousedown = false;
// wd.display.initWdFitHeight(window);
//
if (dragmask) {
dragmask.style.display = "none";
}
};
document.onmousemove = function (e) {
e = e || window.event;
if (ismousedown && e.which == 0) {
ismousedown = false;
// wd.display.initWdFitHeight(window);
}
if (ismousedown) {
e.preventDefault();
var pageY = e.screenY;
// var topDivHeight = topStartHeight + (pageY - starty);
// var bottomDivHeight = maxHeight - topDivHeight - 2;
var topDivHeight = topStartHeight + (pageY - starty);
var bottomDivHeight = bottomStartHeight - (pageY - starty);
// console.log(topDivHeight+" "+bottomDivHeight)
if (topDivHeight < 0 || bottomDivHeight < 0) {
ismousedown = false;
// wd.display.initWdFitHeight(window);
return;
}
topDiv.style.height = topDivHeight + "px";
bottomDiv.style.height = bottomDivHeight + "px";
//console.log(e.which);
}
};
} catch (e) {
console.log(e);
}
});
// 抽取图片布局处理逻辑为单独的函数
function handleImageLayout($td, $img) {
var tdW = $td.width();
var thumbnailW = $td.find(".longCardList-thumbnail").width();
var infoW = parseInt(tdW - thumbnailW - 18 - 76);
$td.find('.longCardList-info').width(infoW);
var thisH = $td.height();
var infoH = $td.find('.longCardList-info').height();
var imgH = $td.find('.longCardList-thumbnail').height();
if (imgH > infoH) {
var top = parseInt(imgH - infoH);
$td.find('.longCardList').css("margin-top", top + "px");
} else if (imgH < infoH) {
var marginTop = (infoH - imgH) / 2;
$td.find('.longCardList-thumbnail').css("margin-top", marginTop + "px");
}
}
$(function () {
try {
console.log("1111111111");
$(".longCardList-div td").each(function () {
var $td = $(this);
var $thumbnail = $td.find(".longCardList-thumbnail");
var $img = $thumbnail.find("img");
if ($thumbnail.length > 0) {
//有图片的情况下
$img.on("load", function () {
handleImageLayout($td, $img);
// var tdW = $(this).width();
// var thumbnailW = $(this).find(".longCardList-thumbnail").width();
// var infoW = parseInt(tdW - thumbnailW - 18 - 76);
// $(this).find(".longCardList-info").width(infoW);
// var thisH = $(this).height();
// var infoH = $(this).find(".longCardList-info").height();
// var imgH = $(this).find(".longCardList-thumbnail").height();
// if (imgH > infoH) {
// var top = parseInt(imgH - infoH);
// $(this)
// .find(".longCardList")
// .css("margin-top", top + "px");
// } else if (imgH < infoH) {
// var marginTop = (infoH - imgH) / 2;
// $(this)
// .find(".longCardList-thumbnail")
// .css("margin-top", marginTop + "px");
// }
});
// 如果图片已经加载完成,直接触发load事件
if ($img[0].complete) {
handleImageLayout($(this), $img);
}
// $(this).find(".change-button").height(thisH).css("line-height",thisH);
} else {
var tdW = $(this).width();
//没图片的情况下
$(this)
.find(".longCardList-info")
.width(tdW - 85);
}
var thisH = $(this).height();
// $(this).find('.button-change').css("height",thisH);
// $(this).find('.button-revise').css("height",thisH);
// $(this).find('.button-enable').css("height",thisH);
// $(this).find('.button-reason').css("height",thisH);
// $(this).find('.button-recruit').css("height",thisH);
$(this)
.find(".button")
.css({
"line-height": thisH + 22 + "px",
height: thisH,
});
if (thisH < 45) {
// $(this).find('.lbutton').css({
// "font-size":"0px",
// "background-position-y":"center",
// "height":"36px",
// "line-height":"36px"
// })
$(this).find(".button").css({
"font-size": "0px",
"background-position-y": "center",
height: "36px",
"line-height": "36px",
});
}
});
$(".ellipsisDiv").css({
"text-overflow": "ellipsis",
overflow: "hidden",
"-webkit-line-clamp": "2",
"-webkit-box-orient": "vertical",
display: "-webkit-box",
});
} catch (e) {
console.log(e);
}
//初始化growheight
var ids = [];
$(".growHeightDiv").each(function () {
ids.push($(this).attr("id"));
});
if (ids.length > 0) {
wd.display.initGrowHighByIds(ids, "150px");
}
// $(".ellipsisDiv").css({"text-overflow": "ellipsis","overflow": "hidden","-webkit-line-clamp": "2","-webkit-box-orient": "vertical","display": "-webkit-box"})
// }catch(e){
// console.log(e);
// }
});
window.onresize = function() {
$(".longCardList-div td").each(function () {
var $td = $(this);
var $thumbnail = $td.find(".longCardList-thumbnail");
var $img = $thumbnail.find("img");
if ($thumbnail.length > 0) {
handleImageLayout($td, $img);
}
});
}
function wdRefresh() {
if (initGraph()) {
} else {
$("form").submit();
}
}
//折叠
$(function () {
var data = {};
var all = {};
var childData = {};
var topData = {};
$("[searchPId]").each(function () {
var pid = $(this).attr("searchPId");
var id = $(this).attr("searchId");
all[id] = $(this);
if (pid) {
if (!data[pid]) data[pid] = [];
childData[id] = $(this);
data[pid].push($(this));
} else {
topData[id] = $(this);
}
});
var defaultExpand = false;
function showChildren(ishow, id) {
if (!data[id]) return;
for (var i = 0; i < data[id].length; i++) {
if (ishow) {
data[id][i].show();
} else {
data[id][i].hide();
}
arguments.callee(ishow, data[id][i].attr("searchId"));
}
}
for (var key in topData) {
if (!(data[key] && data[key].length > 0)) continue;
//
// $("喵夹
").prependTo(topData[key]).
var $ele = topData[key].find(".indenter");
console.log($ele);
$ele
.attr("id", key)
.addClass($ele.attr(defaultExpand ? "expandClass" : "collapseClass"))
.show()
.on("click", function () {
var iidd = this.getAttribute("id");
this.isShow =
typeof this.isShow == "undefined" ? !defaultExpand : !this.isShow;
if (this.isShow) {
$(this).attr("class", $(this).attr("expandClass"));
} else {
$(this).attr("class", $(this).attr("collapseClass"));
}
showChildren(this.isShow, iidd);
return false;
});
showChildren(defaultExpand, key);
}
for (var key in data) {
for (var i = 0; i < data[key].length; i++) {
var THIS = data[key][i];
var c = 1;
THIS.css({ marginLeft: c * 20, width: "calc(100% - 20px)" });
}
}
});
$(function () {
try {
var availHeight =
window.innerHeight -
parseInt(initWdFitHeightFunction.toString().match(/[0-9]+/)[0]);
var rowCountPerPage = parseInt(availHeight / 70);
var ele = $("[name=rowCountPerPage]");
if (ele.length == 0)
ele = $('').appendTo("form");
ele.val(rowCountPerPage);
} catch (e) {
console.log(e);
}
});
//草稿箱 如果没绑定点击事件 绑定查看
$(function () {
try {
$(".cgxItem[clickPlay]").each(function () {
var clickPlay = $(this).attr("clickPlay");
console.log(clickPlay);
console.log($(this).attr("onclick"));
if (clickPlay && !$(this).attr("onclick")) {
$(this).attr("onclick", clickPlay);
}
});
} catch (e) {
console.log(e);
}
});