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 = "*"; } htmls += "
"; htmls += "
"; //ismust txt date datetime datearea checkbox var ctrlhtml = ""; if (item.labtype == "txt") { ctrlhtml = ""; } if (item.labtype == "date") { //laydate({elem: \'' + item.name + '\'});readonly ctrlhtml = ' '; } if (item.labtype == "monthdate") { //laydate({elem: \'' + item.name + '\'});readonly ctrlhtml = '
'; ctrlhtml += ''; var seldtn = new Date(); var nyear = seldtn.getFullYear(); var nmonth = seldtn.getMonth() + 1; nmonth = nmonth < 10 ? '0' + nmonth : nmonth; ctrlhtml += ''; ctrlhtml += '
'; } if (item.labtype == "yeardate") { ctrlhtml = '
'; ctrlhtml += ''; var nyear = new Date().getFullYear(); ctrlhtml += ''; ctrlhtml += '
'; } if (item.labtype == "datearea") { ctrlhtml = '
'; ctrlhtml += ' '; ctrlhtml += ' '; ctrlhtml += '
' } if (item.labtype == "treedept") { ctrlhtml += ''; } if (item.labtype == "treeArticle") { ctrlhtml += ''; } if (item.labtype == "checkbox") { ctrlhtml = ' '; } if (item.labtype == "combox") { ctrlhtml = ''; } if (item.labtype == 'itxt') { ctrlhtml += '
'; ctrlhtml += '
'; } htmls += "
" + ctrlhtml + "
"; }); $(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; }