var datainfo = $.query.get("data");
|
var JsonData = jQuery.parseJSON(decodeURI(datainfo));
|
|
var lastsearinfo = $.query.get("lastsearch");
|
var lastSearchData = jQuery.parseJSON(decodeURI(lastsearinfo));
|
var framename = $.query.get("framename");
|
|
|
var htmls = "";
|
$.each(JsonData, function (n, item) {
|
var musthtml = "";
|
if (item.ismust != undefined && item.ismust == true) {
|
musthtml = "<i class='red'>*</i>";
|
}
|
htmls += " <div class='row' style='margin: 5px'> ";
|
htmls += " <div class='col-xs-3' style='text-align:right; padding-right:10px; padding-top:7px'><label class='control-label'>" + item.label + musthtml + "</label></div> ";
|
//ismust txt date datetime datearea checkbox
|
var ctrlhtml = "";
|
|
if (item.labtype == "txt") {
|
ctrlhtml = "<input type='text' id='" + item.name + "' class='form-control'>";
|
}
|
|
if (item.labtype == "date") {
|
//laydate({elem: \'' + item.name + '\'});readonly
|
ctrlhtml = '<input class="form-control layer-date" id="' + 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="' + item.name + '" value="'+nyear+'-'+nmonth+'">';
|
ctrlhtml += ' </div>';
|
}
|
|
if (item.labtype == "yeardate") {
|
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="' + item.name + '" value="' + nyear + '">';
|
ctrlhtml += ' </div>';
|
}
|
|
if (item.labtype == "datearea") {
|
ctrlhtml = '<div class="input-daterange input-group" id="' + item.name + '">';
|
|
|
|
ctrlhtml += ' <input type="text" class="input-sm form-control" id="' + item.name + 'start" placeholder="开始" value="" /><span class="input-group-addon">到</span>';
|
ctrlhtml += ' <input type="text" placeholder="结束" class="input-sm form-control" id="' + item.name + 'end" value="" />';
|
|
ctrlhtml += '</div>'
|
|
|
}
|
if (item.labtype == "treedept") {
|
|
ctrlhtml += '<input type="text" id="' + item.name + '" style="background: #fff;" readonly="readonly" class="form-control"/>';
|
}
|
if (item.labtype == "treeArticle") {
|
|
ctrlhtml += '<input type="text" id="' + item.name + '" style="background: #fff;" readonly="readonly" class="form-control"/>';
|
}
|
if (item.labtype == "checkbox") {
|
ctrlhtml = ' <label class="checkbox-inline i-checks"><input type="checkbox" id="' + item.name + '" value=""></label>';
|
}
|
|
if (item.labtype == "combox") {
|
ctrlhtml = '<select data-placeholder="选择' + item.label + '..." id="' + item.name + '" class="chosen-select" style="width:100%;" tabindex="2" allow_single_deselect="true">';
|
ctrlhtml += '<option value="">请选择' + item.label + '</option>';
|
var combox_data = [];
|
var eles = top.document.getElementsByTagName("iframe");
|
var ele = null;
|
for (var i = 0 ; i < eles.length; i++) {
|
if ($(eles[i]).attr("name") == framename) {
|
ele = eles[i];
|
break;
|
}
|
debugger;
|
var celes = eles[i].contentWindow.document.getElementsByTagName("iframe");
|
if (ele == null && celes.length > 0) {
|
for (var j = 0; j < celes.length; j++) {
|
debugger;
|
if ($(celes[j]).attr("name") == framename) {
|
ele = celes[j];
|
break;
|
}
|
}
|
}
|
}
|
ele.contentWindow.searchCol.forEach(function (e, i) {
|
if (e.name == item.name) {
|
combox_data = e.data;
|
}
|
});
|
$.each(combox_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="' + item.name + '" >';
|
ctrlhtml += '</div>';
|
}
|
|
htmls += " <div class='col-xs-9'>" + ctrlhtml + "</div></div>";
|
|
|
|
|
|
});
|
|
$(document).ready(function () {
|
|
|
$("#searchzone").append(htmls);
|
$(".i-checks").iCheck({ checkboxClass: "icheckbox_square-green", radioClass: "iradio_square-green" });
|
$.each(JsonData, function (n, item) {
|
if (item.labtype == "combox") {
|
$("#" + item.name).chosen();
|
}
|
if (item.labtype == "datearea") {
|
$("#" + item.name).datepicker({
|
todayBtn: "linked",
|
keyboardNavigation: !1,
|
forceParse: !1, calendarWeeks: !0,
|
autoclose: !0
|
});
|
}
|
if (item.labtype == "date") {
|
$("#" + item.name).datepicker({
|
todayBtn: "linked",
|
keyboardNavigation: !1,
|
forceParse: !1,
|
calendarWeeks: !0,
|
autoclose: !0
|
});
|
}
|
if (item.labtype == 'treedept') {
|
|
}
|
if (item.labtype == 'treeArticle') {
|
|
}
|
if (item.labtype == "monthdate") {
|
$("#" + item.name).datepicker({
|
startView: 1,
|
minViewMode: 1,
|
format: 'yyyy-mm',
|
autoclose: true,
|
startDate: -Infinity,
|
});
|
}
|
if (item.labtype == "yeardate") {
|
$("#" + item.name).datepicker({
|
startView: 1,
|
minViewMode: 2,
|
format: 'yyyy',
|
autoclose: true,
|
startDate: -Infinity
|
});
|
}
|
if (item.labtype == 'itxt') {
|
|
var op = {
|
url: item.url
|
//, isMulti: _isMulti, searchEnd: searchEnd, clearEnd: clearEnd
|
|
};
|
$("#" + item.name).iTexbox(op);
|
}
|
|
});
|
//数据查询初始
|
$.each(lastSearchData, function (n, item) {
|
if (item != undefined && item != "") {
|
$.each(JsonData, function (dn, ditem) {
|
|
if (n == ditem.name) {
|
if (ditem.labtype == "datearea") {
|
var index = item.indexOf('|');
|
// alert(item.substring(0, index) + " -- " + item.substring(index+1));
|
$("#" + n + "start").val(item.substring(0, index));
|
$("#" + n + "end").val(item.substring(index + 1));
|
|
} else if (ditem.labtype == "checkbox") {
|
|
if (item == "true") {
|
|
// $("#" + n).is(':checked');
|
$("#" + n).iCheck('check');
|
}
|
}
|
else if (ditem.labtype == "combox") {
|
$("#" + n).val(item);
|
$("#" + n).trigger('chosen:updated');//更新选项
|
}
|
else if (ditem.labtype == "treedept") {
|
$("#" + n).val('');
|
$("#" + n).attr('deptid',0);
|
}
|
else if (ditem.labtype == "treeArticle") {
|
$("#" + n).val('');
|
$("#" + n).attr('materialcode', 0);
|
}
|
else
|
{
|
$("#" + n).val(item);
|
|
}
|
|
|
}
|
|
|
});
|
|
}
|
|
});
|
|
});
|
|
|
function dlogBtnYes() {
|
|
// var returnJson = [];
|
|
var IsOk = true;
|
var jsonStr = "";
|
$.each(JsonData, function (n, item) {
|
var itemname = item.name;
|
|
if (item.labtype == "txt" || item.labtype == "date" || item.labtype == "combox" || item.labtype == "monthdate") {
|
var v = $("#" + 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") {
|
var v = $("#" + itemname).attr('deptid');
|
if ($.trim(v) != "") {
|
jsonStr += ',"' + itemname + '": "' + v + '"';
|
}
|
|
}
|
if (item.labtype == "treeArticle") {
|
var v = $("#" + itemname).attr('materialcode');
|
if ($.trim(v) != "") {
|
jsonStr += ',"' + itemname + '": "' + v + '"';
|
}
|
|
}
|
if (item.labtype == "itxt") {
|
var v = $("#" + itemname).ival();
|
if ($.trim(v) != "") {
|
jsonStr += ',"' + itemname + '": "' + v + '"';
|
//returnJson.push(JSON.parse(stringJson));
|
}
|
|
}
|
if (item.labtype == "checkbox") {
|
var v = $("#" + itemname).is(':checked');
|
if ($.trim(v) != "") {
|
jsonStr += ',"' + itemname + '": "' + v + '"';
|
//returnJson.push(JSON.parse(stringJson));
|
}
|
}
|
|
|
|
if (item.labtype == "datearea") {
|
var start = $("#" + itemname + "start").val();
|
var end = $("#" + itemname + "end").val();
|
// alert(start + " - " + end);
|
if ($.trim(start) == "" && $.trim(end) == "") {
|
if (item.ismust != undefined && item.ismust == true) {
|
|
IsOk = false;
|
$("#" + itemname + "start").focus()
|
msg.info(item.label + "必须录入信息");
|
return false;
|
|
}
|
return;//实现break功能
|
|
}
|
|
if ($.trim(start) == "" || $.trim(end) == "") {
|
msg.info(item.label + "日期必须选择完善");
|
IsOk = false;
|
//开始结束日期必须选择完善
|
return false;//实现break功能
|
}
|
jsonStr += ',"' + itemname + '":"' + start + '|' + end + '"';
|
// var stringJson = '{"' + itemname + '": "' + start + '|' + end + '"}';
|
// returnJson.push(JSON.parse(stringJson));
|
}
|
|
|
|
|
});
|
|
if (!IsOk) {
|
return false;
|
|
}
|
|
if (jsonStr == "") {
|
return jQuery.parseJSON("{}");
|
|
}
|
|
// alert(JSON.stringify(returnJson));
|
return jQuery.parseJSON("{" + jsonStr.substring(1) + "}");
|
|
|
}
|
function dlogBtn3() {
|
alert("12312");
|
alert("1231211");
|
return false;
|
$.each(JsonData, function (n, item) {
|
if (item.labtype == "combox") {
|
$("#" + item.name).val("");
|
$("#" + item.name).trigger('chosen:updated');//更新选项
|
} else
|
if (item.labtype == "datearea") {
|
$("#" + item.name + "start").val("");
|
$("#" + item.name + "end").val("");
|
} else
|
if (item.labtype == "checkbox") {
|
$("#" + item.name).iCheck('uncheck');
|
}
|
else {
|
$("#" + item.name).val("");
|
}
|
|
});
|
return false;
|
}
|