$(document).ready(function () {
//var maxcee = $(document.body).width();
//if (maxcee >= 970)
//{
// MaxCol = 3;
//}
//else
//{
// MaxCol = 2;
//}
if (MaxCol > 20) {
} else {
MaxCol = 20;
}
if (searchCol == undefined || searchCol.length == 0) {
return;
}
var showhtmls = "";
var count = 0;
$.each(searchCol, function (n, item) {
if (count < MaxCol && item.ismust != undefined && item.ismust == true) {
showhtmls += toGetCtrlHtml(item);
count++;
if (count % 4 === 0) {
showhtmls+="
"
}
}
});
$.each(searchCol, function (n, item) {
if (count < MaxCol && (item.ismust == undefined || item.ismust != true)) {
showhtmls += toGetCtrlHtml(item);
count++;
if (count % 4 === 0) {
showhtmls += "
"
}
}
});
SetToolBar(count);
//before
$("#btnview").before(showhtmls);
// $("#searchview").html(showhtmls);
// GetDeptTree();
$(".i-checks").iCheck({ checkboxClass: "icheckbox_square-green", radioClass: "iradio_square-green" });
$.each(searchCol, function (n, item) {
if ($("#PBS" + item.name).length == 0) {
return true;
}
// console.log(searchCol.length + " - " + n);
if (item.labtype == "combox") {
$("#PBS" + item.name).chosen();
}
if (item.labtype == "datearea") {
$("#PBS" + item.name).datepicker({
todayBtn: "linked",
keyboardNavigation: !1,
forceParse: !1, calendarWeeks: !1,
autoclose: !0
});
}
if (item.labtype == "date") {
$("#PBS" + item.name).datepicker({
todayBtn: "linked",
keyboardNavigation: !1,
forceParse: !1,
calendarWeeks: !0,
autoclose: !0
});
}
if (item.labtype == "monthdate") {
$("#PBS" + item.name).datepicker({
startView: 1,
minViewMode: 1,
format: 'yyyy-mm',
autoclose: true,
startDate: -Infinity,
});
}
if (item.labtype == "yeardate") {
$("#PBS" + item.name).datepicker({
startView: 1,
minViewMode: 2,
format: 'yyyy',
autoclose: true,
startDate: -Infinity
});
}
if (item.labtype == 'treedept') {
}
if (item.labtype == 'treeArticle') {
}
if (item.labtype == 'txt') {
$("#PBS" + item.name).keydown(function (e) {
if (e.keyCode == 13) {
if ($("#PBS" + item.name).val() != "") {
_pageSeach()
}
else {
msg.info("请录入条件");
}
}
});
}
if (item.labtype == 'itxt') {
var op = {
url: item.url
//, isMulti: _isMulti, searchEnd: searchEnd, clearEnd: clearEnd
};
$("#PBS" + item.name).iTexbox(op);
}
});
});
function GetDeptTree() {
$.ajax({
type: "Post",
url: "/Hr_dept/GetTreeJson",
dataType: "json",
success: function (result) {
console.log(JSON.stringify(result));
var treedata = [result];
$('#showdept').treeview({
data: treedata, // 数据源
backColor: 'white', //列表树所有节点背景颜色
showCheckbox: false, //是否显示复选框
highlightSelected: false, //是否高亮选中
nodeIcon: 'glyphicon glyphicon-globe',
emptyIcon: '', //没有子节点的节点图标
multiSelect: true, //多选
levels: 2,
onNodeChecked: function (event, data) {
},
onNodeSelected: function (event, data) {
$('#showdept').hide();
$('#showdept').parent().find('input').val(data.text);
$('#showdept').parent().find('input').attr('deptid', data.Id);
}
});
},
error: function () {
alert("部门树形结构加载失败!")
}
});
}
function GetSearchEnd() {
if (searchCol == undefined || searchCol.length == 0) {
return;
}
var IsOk = true;
var jsonStr = "";
$.each(searchCol, function (n, item) {
var itemname = item.name;
if ($("#PBS" + itemname).length == 0) {
return true;
}
if (item.labtype == "txt" || item.labtype == "date" || item.labtype == "monthdate" || item.labtype == "yeardate" || item.labtype == "combox") {
var v = $("#PBS" + itemname).val();
if ($.trim(v) != "") {
jsonStr += ',"' + itemname + '": "' + v + '"';
// returnJson.push(JSON.parse(stringJson));
}
else {
if (item.ismust != undefined && item.ismust == true) {
IsOk = false;
$("#" + itemname).focus()
msg.info(item.label + "必须录入信息");
return false;
}
}
}
if (item.labtype == 'treedept') {
jsonStr += ',"' + itemname + '":"' + $("#PBS" + itemname).attr('deptid') + '"';
}
if (item.labtype == 'treeArticle') {
var $value = $("#PBS" + itemname).attr("materialcode");
if ($value == undefined || $value == '') $value = "";
jsonStr += ',"' + itemname + '":"' + $value + '"';
}
if (item.labtype == "itxt") {
var v = $("#PBS" + itemname).ival();
if ($.trim(v) != "") {
jsonStr += ',"' + itemname + '": "' + v + '"';
//returnJson.push(JSON.parse(stringJson));
}
}
if (item.labtype == "checkbox") {
var v = $("#PBS" + itemname).is(':checked');
if ($.trim(v) != "") {
jsonStr += ',"' + itemname + '": "' + v + '"';
//returnJson.push(JSON.parse(stringJson));
}
}
if (item.labtype == "datearea") {
var start = $("#PBS" + itemname + "start").val();
var end = $("#PBS" + itemname + "end").val();
// alert(start + " - " + end);
if ($.trim(start) == "" && $.trim(end) == "") {
if (item.ismust != undefined && item.ismust == true) {
IsOk = false;
$("#PBS" + itemname + "start").focus()
msg.info(item.label + "必须录入信息");
return false;
}
return;//实现break功能
}
console.log(start);
console.log(end);
if ($.trim(start) == "" || $.trim(end) == "") {
console.log(start);
msg.info(item.label + "日期必须选择完善");
IsOk = false;
//开始结束日期必须选择完善
return false; //实现break功能
}
var s = new Date(start);
var e = new Date(end);
var isd = s.getTime() - e.getTime();
if (isd > 0) {
IsOk = false;
$("#PBS" + itemname + "start").focus()
msg.info("开始时间不能大于结束时间");
return false;
}
jsonStr += ',"' + itemname + '":"' + start + '|' + end + '"';
// var stringJson = '{"' + itemname + '": "' + start + '|' + end + '"}';
// returnJson.push(JSON.parse(stringJson));
}
});
if (!IsOk) {
return false;
}
if (jsonStr == "") {
return jQuery.parseJSON("{}");
}
console.log(jsonStr.substring(1));
// alert(JSON.stringify(returnJson));
return jQuery.parseJSON("{" + jsonStr.substring(1) + "}");
}
function toSetTooBarVal() {
$.each(lastSearch, function (n, item) {
if (item != undefined && item != "") {
$.each(searchCol, function (dn, ditem) {
if ($("#PBS" + ditem.name).length == 0) {
return true;
}
if (n == ditem.name) {
if (ditem.labtype == "datearea") {
var index = item.indexOf('|');
// alert(item.substring(0, index) + " -- " + item.substring(index+1));
$("#PBS" + n + "start").val(item.substring(0, index));
$("#PBS" + n + "end").val(item.substring(index + 1));
} else if (ditem.labtype == "checkbox") {
if (item == "true") {
// $("#" + n).is(':checked');
$("#PBS" + n).iCheck('check');
}
}
else if (ditem.labtype == "combox") {
$("#PBS" + n).val(item);
$("#PBS" + n).trigger('chosen:updated');//更新选项
}
else if (ditem.labtype == "treedept") { }
else if (ditem.labtype == "treeArticle") { }
else {
$("#PBS" + n).val(item);
}
}
});
}
});
}
function toGetCtrlHtml(item) {
var ctrlhtml = "";
var musthtml = "";
if (item.ismust != undefined && item.ismust == true) {
musthtml = "*";
}
if (item.ismust != undefined && item.ismust == true) {
musthtml = "*";
}
if (item.cwidth != undefined && item.cccwidth != undefined) {
htmls = ' ";
htmls += "