$(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+="<br>"
|
}
|
}
|
});
|
$.each(searchCol, function (n, item) {
|
|
if (count < MaxCol && (item.ismust == undefined || item.ismust != true)) {
|
showhtmls += toGetCtrlHtml(item);
|
count++;
|
if (count % 4 === 0) {
|
showhtmls += "<br>"
|
}
|
}
|
});
|
|
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) == "") {
|
if ($.trim(start) == "") {
|
$("#PBS" + itemname + "start").val($.trim(end));
|
start = end;
|
}
|
else if ($.trim(end) == "")
|
{
|
$("#PBS" + itemname + "end").val($.trim(start));
|
end = start;
|
}
|
//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 + '":"' + $.trim(start) + '|' + $.trim(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 = "<i class='red'>*</i>";
|
}
|
|
|
if (item.ismust != undefined && item.ismust == true) {
|
musthtml = "<i class='red'>*</i>";
|
}
|
if (item.cwidth != undefined && item.cccwidth != undefined) {
|
htmls = ' <label style="text-align:right; display:inline-block; width:' + item.cwidth + ';" >' + item.label + musthtml + "</label> ";
|
htmls += "<div class=\"\" style=\"padding-right:0px; display:inline-block; width:" + item.cccwidth +"; vertical-align:middle; position: relative; \">";
|
} else {
|
htmls = ' <label style="text-align:right; display:inline-block; width:5%;" >' + item.label + musthtml + "</label> ";
|
htmls += "<div class=\"\" style=\"padding-right:0px; display:inline-block; width:15%; vertical-align:middle; position: relative; \">";
|
}
|
|
|
var ctrlhtml = "";
|
|
|
if (item.labtype == "txt") {
|
ctrlhtml = "<input type='text' id='PBS" + item.name + "' class='form-control'>";
|
}
|
|
if (item.labtype == "date") {
|
;
|
//laydate({elem: \'' + item.name + '\'});readonly
|
ctrlhtml = '<input class="form-control layer-date" id="PBS' + item.name + '" "> ';
|
|
}
|
if (item.labtype == "monthdate") {
|
|
//laydate({elem: \'' + item.name + '\'});readonly
|
ctrlhtml = '<div class="input-group date">';
|
ctrlhtml += '<span class="input-group-addon"><i class="fa fa-calendar"></i></span>';
|
var seldtn = new Date();
|
var nyear = seldtn.getFullYear();
|
var nmonth = seldtn.getMonth() + 1;
|
nmonth = nmonth < 10 ? '0' + nmonth : nmonth;
|
ctrlhtml += '<input type="text" class="form-control layer-date" id="PBS' + item.name + '" value="' + nyear + '-' + nmonth + '">';
|
ctrlhtml += ' </div>';
|
}
|
if (item.labtype == "yeardate") {
|
|
//laydate({elem: \'' + item.name + '\'});readonly
|
ctrlhtml = '<div class="input-group date">';
|
ctrlhtml += '<span class="input-group-addon"><i class="fa fa-calendar"></i></span>';
|
var nyear = new Date().getFullYear();
|
ctrlhtml += '<input type="text" class="form-control layer-date" id="PBS' + item.name + '" value="' + nyear + '">';
|
ctrlhtml += ' </div>';
|
}
|
if (item.labtype == "treedept") {
|
|
ctrlhtml += '<input type="text" id="PBS' + item.name + '" style="background: #fff;" readonly="readonly" class="form-control" />';
|
}
|
if (item.labtype == "treeArticle") {
|
|
ctrlhtml += '<input type="text" id="PBS' + item.name + '" style="background: #fff;" readonly="readonly" class="form-control" />';
|
}
|
if (item.labtype == "datearea") {
|
ctrlhtml = '<div class="input-daterange input-group" id="PBS' + item.name + '">';
|
|
|
|
ctrlhtml += ' <input type="text" class="input-sm form-control" id="PBS' + item.name + 'start" placeholder="开始" value="" style="padding-left:0px ;padding-right:0px" /><span class="input-group-addon">到</span>';
|
ctrlhtml += ' <input type="text" placeholder="结束" class="input-sm form-control" id="PBS' + item.name + 'end" value="" style="padding-left:0px ;padding-right:0px" />';
|
|
ctrlhtml += '</div>'
|
|
|
}
|
if (item.labtype == "checkbox") {
|
ctrlhtml = ' <label class="checkbox-inline i-checks"><input type="checkbox" id="PBS' + item.name + '" value=""></label>';
|
|
|
}
|
|
if (item.labtype == "combox") {
|
ctrlhtml = '<select data-placeholder=" " id="PBS' + item.name + '" class="chosen-select" style="width:100%;" tabindex="2" allow_single_deselect="true">'; // data-placeholder="选择' + item.label + '..."
|
ctrlhtml += '<option value=""> </option>'; //' + item.label + '
|
|
|
|
$.each(item.data, function (n, selectitem) {
|
var defuvas = "";
|
if (item.defultvalue != undefined && item.defultvalue == selectitem.code) {
|
defuvas = ' selected="selected" ';
|
}
|
ctrlhtml += '<option value="' + selectitem.code + '" ' + defuvas + ' hassubinfo="true">' + selectitem.label + '</option>';
|
});
|
|
ctrlhtml += '</select>';
|
|
|
|
}
|
if (item.labtype == 'itxt') {
|
|
ctrlhtml += '<div class="input-group" id="PBS' + item.name + '" >';
|
ctrlhtml += '</div>';
|
}
|
htmls += ctrlhtml;
|
|
htmls += "</div>"
|
return htmls;
|
}
|
function SetToolBar(ctlcont) {
|
//970
|
|
if (parseInt(searchCol.length) < parseInt((MaxCol + 1))) {
|
|
$("#searchmorendatabtn").hide();
|
}
|
else {
|
|
}
|
}
|