document.onkeydown = hotkey; var benzi = ""; var popdivId = "";//隐藏42层用到 var popdiv = null; var systemUuid = {}; systemUuid.uuid = null; function generateUUID_hotkey() { var d = new Date().getTime(); if (window.performance && typeof window.performance.now === "function") { d += performance.now(); //use high-precision timer if available } var uuid = 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function (c) { var r = (d + Math.random() * 16) % 16 | 0; d = Math.floor(d / 16); return (c == 'x' ? r : (r & 0x3 | 0x8)).toString(16); }); return uuid; } (function () { if (typeof (generateUUID_hotkey) != "undefined") { systemUuid.uuid = generateUUID_hotkey(); //console.info("........generateUUID:"+systemUuid.uuid); } else { systemUuid.uuid = generateUUID(); } try { $(window).scroll(function () { if ($(document).scrollTop() > 0) { parent.subPageScrollHeight = $(document).scrollTop(); } }); } catch (e) { } })(); window.onload = function () { gridHeight();//格线高度设置 } window.onresize = function () { gridHeight();//格线高度设置 } function hotkey(event) { var e = window.event || event; var eCode = e.keyCode; if (eCode == 27) { e.returnValue = false; } if (((parent && parent.userType === "1")) && (eCode == 65) && (e.ctrlKey) && (e.shiftKey)) { open2_9802(''); } else if ((eCode == 83) && (e.ctrlKey) && (e.shiftKey)) {//ctrl+shift+S //(parent&&parent.userType==="1")&& open2_9802('s'); } else if ((eCode == 82) && (e.altKey)) { //alt+r 刷新 refresh(); } panelGrid(e); } function panelGrid(event) { //ctrl+shift+1,打开F11 if (event.keyCode == 49 && event.ctrlKey && event.shiftKey && formType == "1") { var mainDis = document.getElementById('tplt-grid').style.display; if (mainDis == "block" || mainDis == "") { gridToPanel = false; var va_ = mygrid.getCurRecord(); if (va_ != null) { panMain[panIndex].panInfoSet(panMain[panIndex].html_Col, va_, false); } gridToPanel = true; } document.getElementById('tplt-grid').style.display = (mainDis == "none") ? "block" : "none"; document.getElementById('tplt-panel').style.display = (mainDis == "none") ? "none" : "block"; } } function panelHid(op) { if (op == "0") { document.getElementById('tplt-panel').style.display = "none"; } else { document.getElementById('tplt-grid').style.display = "none"; } gridHeight(); } function open2_9802(o) { var url = ""; var fid = ""; var paUs = document.URL.split("/"); url = paUs[0] + "/" + paUs[1] + "/" + paUs[2]; fid = this.formId != null ? this.formId : paUs[7]; if (parent.addTab) { if (o == 's_all') { parent.addTab("生成所有页面", "", "", "", url + "/buildv2.do?m=a"); } else if (o == '') { parent.addTab("", 9802, 10, "wherePan=formid=" + fid); } else { parent.addTab(fid + "生成页面", "", "", "", url + "/buildv2.do?formID=" + fid); } } else { if (o != 's') { window.open(url + "/app/0/" + parent.dbid + "9802/10/index.jsp?wherePan=formid=" + fid, "", 'left=0,top=0,width=' + (screen.availWidth - 10) + ',height=' + (screen.availHeight - 50) + ',toolbar=no,menubar=no,scrollbars=no,location=no'); } else { window.open(url + "/buildv2.do?formID=" + fid, "", 'left=200,top=200,width=300,height=30,toolbar=no,menubar=no,scrollbars=no,location=no'); } } } function toJson(str) { var s = str.split("\?"); var temp = s[1].split("&"); var json = {}; for (var i = 0; i < temp.length; i++) { var ts; if (temp[i].indexOf && temp[i].indexOf("==") > 0) { ts = temp[i].split(/\b=\b/); } else { ts = temp[i].split(/=/); } //存在多个=的情况,by danaus 2020/2/24 20:28 var strs = ""; for (var j = 1; j < ts.length; j++) { if (j == 1) strs += ts[j]; else strs += "=" + ts[j]; } json[ts[0]] = strs; } return json; } function exportExcel() {//导出excel var excelurl; var excelTitle; var TGData = ""; showLoading(); try { if (top.myFresh.formType == 3 && !top.myFresh.clickNode) { alert("请先选择左边分类再执行导出"); closeLoading(); return; } } catch (e) { } if (typeof (mygrid) != "undefined") { if (typeof (panMain) != "undefined" && typeof (panMain[panIndex]) != "undefined") mygrid.excelTitle = new Base64().encode((panMain[panIndex].panelTitle == undefined ? "" : panMain[panIndex].panelTitle) + "~" + mygrid.gridTitlefun());// 面板+格线的动态标题 else mygrid.excelTitle = new Base64().encode("~" + mygrid.gridTitlefun());// a面板+格线的动态标题 var str = mygrid.exportExcl(); excelurl = str.split("&p&")[0]; if (excelurl.indexOf("flag=") < 0) { excelurl += "flag=-1"; } TGData = str.split("&p&")[1].replace("TGData=", ""); } else { if (typeof (panMain) != "undefined") excelTitle = new Base64().encode((panMain[panIndex].panelTitle == undefined ? "" : panMain[panIndex].panelTitle) + "~" + "");// 面板+格线的动态标题 TGData = '{"Cfg":{"Sort":"","SortCols":"","SortTypes":"0","Group":"","GroupCols":"","SearchAction":"","TimeZone":"-480","ScrollLeft":"0","LeftScrollLeft":"0","ScrollTop":"0"},"CutFilter":{"Filter":""},"rowspan":"","Filters":[],"IO":{},"Fields":{"FieldsName":"" },"CutFilter":{"Filter":"" },"Exprs":{"expr":"" },"Cps":{"cp":"" },"rowspan":"","excelTitle":"fg==","Body":[{"Pos":"0"}]}'; if (panMain[panIndex].panelTitle == null || panMain[panIndex].panelTitle == "") { var doccode = $("#doccode").val(); if (doccode != null && doccode != "") { panMain[panIndex].panelTitle = "doccode='" + doccode + "'"; } } excelurl = "/gtGrid.do?m=load&where=" + (panMain[panIndex].panelTitle == undefined ? "" : panMain[panIndex].panelTitle) + "&formID=" + formId + "&winType=" + (formType == 16 ? 17 : formType) + "|0&flag=-1&autopaging=3&cp=0&formdatafilters=&pageSize=100&picFild="; } var obj = toJson(excelurl); var form = $("
"); form.attr('style', 'display:none'); form.attr('target', ''); form.attr('method', 'post'); form.attr('action', "/gtGrid.do?m=" + obj.m); var input1 = $(''); input1.attr('type', 'hidden'); input1.attr('name', 'autopaging'); input1.attr('value', obj.autopaging); form.append(input1); var input2 = $(''); input2.attr('type', 'hidden'); input2.attr('name', 'cp'); input2.attr('value', obj.cp); form.append(input2); var input3 = $(''); input3.attr('type', 'hidden'); input3.attr('name', 'flag'); input3.attr('value', obj.flag); form.append(input3); var input4 = $(''); input4.attr('type', 'hidden'); input4.attr('name', 'formID'); input4.attr('value', obj.formID); form.append(input4); var input5 = $(''); input5.attr('type', 'hidden'); input5.attr('name', 'formdatafilters'); input5.attr('value', obj.formdatafilters); form.append(input5); var input6 = $(''); input6.attr('type', 'hidden'); input6.attr('name', 'pageSize'); input6.attr('value', obj.pageSize); form.append(input6); var input7 = $(''); input7.attr('type', 'hidden'); input7.attr('name', 'picFild'); input7.attr('value', obj.picFild); form.append(input7); var input8 = $(''); input8.attr('type', 'hidden'); input8.attr('name', 'where'); input8.attr('value', obj.where); form.append(input8); var input9 = $(''); input9.attr('type', 'hidden'); input9.attr('name', 'winType'); input9.attr('value', obj.winType); form.append(input9); var input10 = $(''); input10.attr('type', 'hidden'); input10.attr('name', 'isExportExcel'); input10.attr('value', obj.isExportExcel); form.append(input10); var input11 = $(''); input11.attr('type', 'hidden'); input11.attr('name', 'TGData'); input11.attr('value', TGData); form.append(input11); var input12 = $(''); input12.attr('type', 'hidden'); input12.attr('name', 'tbCols'); input12.attr('value', obj.tbCols); form.append(input12); $('body').append(form); form.submit(); form.remove(); if (typeof (mygrid) != "undefined") mygrid.ReloadBody(); closeLoading(); } function refalshGridOfColse() { var p_frame = parent.frames[inChangFrame]; if (p_frame) { if (C_Grid != "") { var gr = eval('(' + C_Grid + ')');//弹出的父页面传过来的信息 var pa = p_frame.Grids[gr.gridID];//得到grid if (pa.clickDb) { pa.clickDb = false; return; } if (pa && gr.clickGrid) { if (gr.toP == undefined || gr.toP == null || gr.toP == "null" || gr.toP == "") return;//没有需要返回字段,不作处理 //增加如果当前页面是31类型弹出作选择用则需要判断是否已保存了数据才给返回 if (gr.is31 && (this.getInsertedRecords().length > 0 || this.getUpdatedRecords().length > 0 || this.getDeletedRecords().length > 0)) { alert(this.GetText("isSave")); return; } var ower = gr.toP.split(";");//自表 var temp = []; var row = pa.Rows[gr.rowIDp];//三点弹出的所在行 for (var i = 0; i < ower.length; i++) { temp[i] = row[ower[i]]; } pa.threePop(temp, ower, row, null, -1); pa.EndEdit(0); } } } } function postCheck(y, grid) {//由直接按确认后才调用 //location.href=document.URL+"?"+y.split(",")[3]; var doc = y.split(",")[4]; //$("#doccode").attr("value",doc); isNew = 0;//更新 check = 3;//执行数据范围的确认前检查 ischeck = true;//表示需要在commitIs里面执行确定执行 trandoc = y.split(",")[0]; var pm = panMain[panIndex]; plane = pm.getPanMap(); var datas = grid.postData(plane, check); var url = '/check.do'; if (btnId != null) { url = url + '?btnid=' + btnId; } $.ajax({ type: "POST", async: false, // 设置同步方式 cache: false, url: url, data: {"_gt_json": datas, "point": 3, "formid": formId, "hasGrid": "1"}, dataType: 'text', success: function (data) { tranOk = true; parent.errShow.frame = parent.frames[inThisFrame]; parent.errShow.show_divErro(data, true); btnId = null; OA = ""; } }); } var g = null;//格线对象 var wpanl = "";//面板 function setValue(str) { if (g != null) {//处理格线 Grids[g.id].SetValue(g.r, g.c, str, 0); Grids[g.id].RefreshCell(g.r, g.c); g = null; } else if (wpanl != null) {//处理面板 if (str.indexOf('|') != -1) {//9类型上传附件,处理图片返回的uuid var ls = str.split('|')[1]; str = ls; } var uuid = str.replaceAll(".*uuid=", "");//获取uuid值 // var sturl=str.substring(0,str.indexOf('uuid=')+5);//截取图片显示调用函数 if (wpanl.pid != undefined) {//9类型附件上传控件赋值 if (uuid.indexOf('&') != -1) { uuid = uuid.substring(0, uuid.indexOf('&')); } setDoc(wpanl.pid, ".value='" + uuid + "'");// 赋字段值 setDoc(wpanl.th, ".src='/getImage.do?type=1&uuid=" + uuid + "'");//id+_UpImage图片的赋值 } else {//19类型附件上传赋值 uuid = uuid.substring(0, uuid.indexOf(';')); setDoc(wpanl, ".value='" + uuid + "'");// 赋字段值 } wpanl = null; } }; function showWindow_Grid(url, obj, callBack, arguments, tid, pid) { if (obj == undefined || obj == null || obj == '') { obj = {}; obj.isDialog = 1; } g = tid; wpanl = pid; // url=encodeURL(url); var param = { "url": url, vArguments: obj, dialogWidth: 420,//(screen.availWidth - 60), dialogHeight: 380,//(screen.availHeight - 110), callBack: callBack }; param = $.extend(param, arguments || {}); var openPage = new myapp(param);// new 一个打开对象 **改变了窗体不是默认大小 openPage.openNewWin(); }; var myapp = function (o) { this.options = { url: "",// 你要打开的页面url vArguments: "window",// 你要向打开的页面传递的数据 dialogWidth: 300,// 打开窗口的宽度 dialogHeight: 300,// 你打开窗口的高度 center: "yes",// center: {yes | no | 1 | 0 }:窗口是否居中,默认yes,但仍可以指定高度和宽度。 help: "no",// {yes | no | 1 | 0 }:是否显示帮助按钮,默认yes resizable: "yes",// {yes | no | 1 | 0 } [IE5+]:是否可被改变大小。默认no status: "yes",// {yes | no | 1 | 0 } [IE5+]:是否显示状态栏。默认为yes[ // Modeless]或no[Modal]。 scroll: "yes",// { yes | no | 1 | 0 | on | off }:指明对话框是否显示滚动条。默认为yes。 callBack: false }; Object.extend(this.options, o || {}); }; myapp.prototype = { openNewWin: function (url) { var options = this.options; var l = (screen.availWidth - options["dialogWidth"]) / 2; var h = (screen.availHeight - options["dialogHeight"]) / 2; var sp = "dialogTop:" + h + "px;dialogLeft:" + l + "px;dialogWidth:" + options["dialogWidth"] + "px;dialogHeight:" + options["dialogHeight"] + "px;center:" + options["center"] + ";help:" + options["help"] + ";resizable:" + options["resizable"] + ";status:" + options["status"] + ";scroll:" + options["scroll"]; if (typeof options["fieldid"] != 'undefined') { wpanl = options["fieldid"]; } var newWin = null; if (window.showModalDialog != undefined) { newWin = window.showModalDialog(options["url"], options["vArguments"], sp); var call = options["callBack"]; if (typeof call == "function") {// 调用 数据处理函数 call(newWin); } } else { var sp1 = "top=" + h + ",left=" + l + ",width=" + options["dialogWidth"] + ",height=" + options["dialogHeight"]; if (options["url"].indexOf('.do?') != -1) {//判断是否访问的是方法 2014-11-25 $.ajax({ type: "POST", async: false, // 设置同步方式 cache: false, url: options["url"], dataType: 'text', success: function (data) { if (data == '删除成功') { setDoc(wpanl.pid, ".value=''");//清空 setDoc(wpanl.th, ".src=''");//id+_UpImage图片的清空 document.getElementById(wpanl.pid + 'Update').style.display = "none";//隐藏更新 document.getElementById(wpanl.pid + 'Upload').style.display = "block";//显示上传 document.getElementById(wpanl.pid + 'Upload').value = "上传";//显示上传 } alert(data); } }); } else { window.open(options["url"], "newdiag", sp1); } } }, setOptions: function () { } }; /** * * Base64 encode / decode * * @author haitao.tu * @date 2010-04-26 * @email tuhaitao@foxmail.com * */ function Base64() { // private property _keyStr = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="; // public method for encoding this.encode = function (input) { var output = ""; var chr1, chr2, chr3, enc1, enc2, enc3, enc4; var i = 0; input = _utf8_encode(input); while (i < input.length) { chr1 = input.charCodeAt(i++); chr2 = input.charCodeAt(i++); chr3 = input.charCodeAt(i++); enc1 = chr1 >> 2; enc2 = ((chr1 & 3) << 4) | (chr2 >> 4); enc3 = ((chr2 & 15) << 2) | (chr3 >> 6); enc4 = chr3 & 63; if (isNaN(chr2)) { enc3 = enc4 = 64; } else if (isNaN(chr3)) { enc4 = 64; } output = output + _keyStr.charAt(enc1) + _keyStr.charAt(enc2) + _keyStr.charAt(enc3) + _keyStr.charAt(enc4); } return output; } // public method for decoding this.decode = function (input) { var output = ""; var chr1, chr2, chr3; var enc1, enc2, enc3, enc4; var i = 0; input = input.replace(/[^A-Za-z0-9\+\/\=]/g, ""); while (i < input.length) { enc1 = _keyStr.indexOf(input.charAt(i++)); enc2 = _keyStr.indexOf(input.charAt(i++)); enc3 = _keyStr.indexOf(input.charAt(i++)); enc4 = _keyStr.indexOf(input.charAt(i++)); chr1 = (enc1 << 2) | (enc2 >> 4); chr2 = ((enc2 & 15) << 4) | (enc3 >> 2); chr3 = ((enc3 & 3) << 6) | enc4; output = output + String.fromCharCode(chr1); if (enc3 != 64) { output = output + String.fromCharCode(chr2); } if (enc4 != 64) { output = output + String.fromCharCode(chr3); } } output = _utf8_decode(output); return output; } // private method for UTF-8 encoding _utf8_encode = function (string) { string = string.replace(/\r\n/g, "\n"); var utftext = ""; for (var n = 0; n < string.length; n++) { var c = string.charCodeAt(n); if (c < 128) { utftext += String.fromCharCode(c); } else if ((c > 127) && (c < 2048)) { utftext += String.fromCharCode((c >> 6) | 192); utftext += String.fromCharCode((c & 63) | 128); } else { utftext += String.fromCharCode((c >> 12) | 224); utftext += String.fromCharCode(((c >> 6) & 63) | 128); utftext += String.fromCharCode((c & 63) | 128); } } return utftext; } // private method for UTF-8 decoding _utf8_decode = function (utftext) { var string = ""; var i = 0; var c = c1 = c2 = 0; while (i < utftext.length) { c = utftext.charCodeAt(i); if (c < 128) { string += String.fromCharCode(c); i++; } else if ((c > 191) && (c < 224)) { c2 = utftext.charCodeAt(i + 1); string += String.fromCharCode(((c & 31) << 6) | (c2 & 63)); i += 2; } else { c2 = utftext.charCodeAt(i + 1); c3 = utftext.charCodeAt(i + 2); string += String.fromCharCode(((c & 15) << 12) | ((c2 & 63) << 6) | (c3 & 63)); i += 3; } } return string; } return this; } function closeOther() { if (popdiv) {//面板引用的id popdiv.colseAll(); } if (mygrid.popdiv) { mygrid.popdiv.colseAll(); } } var getDiv42 = { pop: createPopDiv(), ShowDivForPanel: function (e, id, formid, rod, index) { this.pop.ShowDivForPanel(e, id, formid, rod, index); try { // 单击触发事件 $(document).bind('click', function (e) { if (getDiv42.pop != null && e.target.offsetParent != null) { // 单击事件触发42类型控件层隐藏 // 处理42类型控件层的隐藏 2015-4-20 13:51:25 getDiv42.pop.popdivIdDisplay(e.target.offsetParent.id); } }); } catch (e) { } try { // tab触发事件 $(document).bind('keyup', function (e) { if (e.keyCode == 9 && getDiv42.pop != null && e.target.offsetParent != null) { // tab键触发42类型控件层隐藏 // 处理42类型控件层的隐藏 2015-4-20 13:51:25 getDiv42.pop.popdivIdDisplay(e.target.offsetParent.id); } }); } catch (e) { } }, closediv: function (thisd, div) { this.pop.closediv(thisd, div); } } function createPopDiv() { var popdiv1 = {// 42类型控件弹出列表 Tgrid: null,// 格线 Trow: null, inputValue: "",// 保存之前的值 timer: null,// 定时器,选择返回记得清除计时器 Tformid: null,// 弹出列表的功能号 lf: null,// 左边位置 tp: null,// 上边位置 positionss: 'absolute', Trand: 0,// 生成div id的随机数,以区别相同功能号的情况 isclose: true, rowcount: 0,// 记录行数 Tfield: null,// 保存当前的字段,以便格线计算公式用 ShowDivForPanel: function (e, id, formid, rod, index) {// 面板 elem表示当前触发的文本框对象 var div = this; clearTimeout(div.timer); if (e.offsetParent == null) return; this.Tformid = formid this.Trand = rod //获取scroll的top位置,弹出层需要减去这个高度,避免位置出现偏差 by danaus 2020/11/7 17:23 var scrollTop = document.documentElement.scrollTop ? document.documentElement.scrollTop : document.body.scrollTop; tp = e.offsetParent.offsetParent.offsetTop + e.offsetParent.offsetTop + 28 - scrollTop;// 42控件div的top控制 lf = e.offsetParent.offsetParent.offsetLeft + e.offsetParent.offsetLeft + 118;// 42类型div的left控制 popdivId = document.getElementById('T_' + this.Tformid + '_' + this.Trand + 'div');// 获取隐藏层属性 if (isTopFixed()) { //这里是针对单单只有面板并且没滚动条的情况 xin 2020-11-11 09:46:54 if ($("#tplt-grid").length > 0) { tp = e.offsetParent.offsetParent.offsetTop + e.offsetParent.offsetTop + 28; } else { tp = tp + 70; this.positionss = "fixed"; } } // 调用ajax从后台取数据,例子对应ShowDivForGrid方法 // 写的方法 var panInfo = panMain[index].panInfo; var pi = id.split("#"); var col = e.id; var biao = pi[0]; var waiziduan = pi[1]; benzi = pi[2].toLowerCase(); var SuggestFileds = pi[3]; var guangl = pi[4]; if (getDoc(col, '.readOnly')) { return; } if (SuggestFileds == "") { SuggestFileds = waiziduan; } // for(var p in panMain ){ var efilter = ""; for (var ef in panMain) { if (typeof (panMain[ef].panInfo[col]) != "undefined") { if (panMain[ef].panInfo[col].efilter != "") { efilter += panMain[ef].panInfo[col].efilter; } } } var tiaojian = this.getOutWhere(benzi, waiziduan, '', ' and ', col, true, guangl, efilter);// efilter获取自定义信息 var url = "/invAlldiv.do?id=" + biao + "&where=" + encodeURI(replacePageValue(tiaojian)) + "&sugg=" + SuggestFileds; //url = encodeURI(encodeURI(url));// 必须两次 var userAgents = navigator.userAgent; // 取得浏览器的userAgent字符串 var bols = ((userAgents.indexOf("Firefox") > -1 && event.keyCode == 8) ? true : event.keyCode == 8); div.timer = setTimeout(function () { var D = e.value// 当前值 if (bols && D == "") {// backespace建 删除关联字段信息(清空关联) var emptyref = panInfo[e.id].emptyrefdata.toLowerCase().split(";"); if (emptyref.length > 0) { for (var del in emptyref) setDoc(emptyref[del], ".value=''");// 赋字段值 } div.colseAll(); return; } if (D == "" || div.inputValue == D) { return; } div.inputValue = D; $.ajax({ type: "POST", async: false, // 设置同步方式 cache: false, url: url, // data:{"_gt_json":datas,"point":3,"formid":formId,"hasGrid":"1"}, dataType: 'text', success: function (date) { var cdiv = document.getElementById('T_' + div.Tformid + "_" + div.Trand + 'CDiv');// 内容Div div.removeRows(cdiv); div.popDiv(date, cdiv); }, error: function (data) { alert(data); } }); }, 2000); }, getOutWhere: function (ben, wai, zi, addFuHao, id, qianzhi, guangl, efilter) {// 条件(本身,外表,自定义,连接符,是否强制录入) openTree = true; var bens = ben.split(";"); var wais = wai.split(";"); var glian = guangl.split(";"); var where = ""; var col = ""; var value = ""; var colDan = ""; var gl = ""; for (i = 0; i < bens.length; i++) { col = bens[i].toLowerCase(); if (col.Trim() != "") { value = getDoc(col, ".value"); // 针对 300029 资金帐户 if (value == null) { value = ""; } // if (qianzhi) { // 强制判断 if (value != "") { if (value.indexOf("'") != -1) { value = value.replace(new RegExp("'", "g"), "''"); } where += wais[i] + " like '" + "@~" + value + "@~'" + addFuHao;// and } } } } if (guangl != "") { value = getDoc(id, ".value"); if (value.indexOf("'") != -1) { value = value.replace(new RegExp("'", "g"), "''"); } for (var g = 0; g < glian.length; g++) { col = glian[g].toLowerCase(); if (col.Trim() != "") { gl += col + " like '" + "@~" + value + "@~'" + " or "; } } gl = gl.substring(0, gl.length - 3); gl = " or (" + gl + ")"; } if (zi.Trim() != "") { where += zi + addFuHao;// 追加自定义条件 } where = where.substring(0, where.length - addFuHao.length); //where为空值的情况,让他在()里面成立。解决查询sql报错问题 where = (efilter == "" ? "" : "(") + "(" + (where == "" ? "1=1" : where) + ")" + gl + (efilter == "" ? "" : ") and (" + efilter + ")"); return where; }, close: function (div) { //新方法里面调用隐藏(格线用) xin 2021-3-24 10:57:20 var that=this; control42DivData.divClose(div, function (bol) { if (!bol) { that.inputValue = ""; div.parentElement.style.display = "none"; clearInterval(that.timer); that.timer = null; that.isclose = true; closeOther(); } }) }, colseAll: function () { var cdiv = document.getElementById('T_' + this.Tformid + '_' + this.Trand + 'CDiv');// 内容Div cdiv.inputValue = ""; cdiv.parentElement.style.display = "none"; clearInterval(cdiv.timer); cdiv.timer = null; cdiv.isclose = true; }, closediv: function (thisd, div) { this.inputValue = ""; popdivId = thisd; document.getElementById(div).style.display = "none"; closeOther(); }, //隐藏42控件的div层 popdivIdDisplay: function (panelId) { clearInterval(this.timer); this.timer = null; if (popdivId != "" && popdivId != null) { var div42 = popdivId.firstChild.id; panelId == null ? "" : panelId; if (panelId != div42) { if (document.getElementById(popdivId.id).style.display != "") { document.getElementById(popdivId.id).style.display = "none"; } } } }, // 格线 ShowDivForGrid: function (tg, elem, col) { var that=this; control42DivData.ShowDivForGrid(tg, elem, col, function (bol) { if (!bol) {//没发现是新的界面时候才执行下面的旧方法(兼容) xin 2021-3-25 10:06:37 that.Tgrid = tg; if (that.Tgrid == null) return; Trow = GT.rowIDp; that.Tformid = col.formid; that.Trand = col.rand; if (elem.offsetParent == null) return; var gheight = that.Tgrid.MainTag.clientHeight; //获取scroll的top位置,弹出层需要减去这个高度,避免位置出现偏差 by danaus 2020/11/7 17:23 var scrollTop = document.documentElement.scrollTop ? document.documentElement.scrollTop : document.body.scrollTop; tp = elem.offsetParent.offsetTop + elem.offsetParent.offsetHeight - scrollTop; lf = elem.offsetParent.offsetLeft; // 取数据 Tfield = col.Name; var A = col; if (A == undefined || A.toParm == null) { return } D = that.Tgrid.Edit.Tag.value + ""; if (D == "" || that.inputValue == D) { return; } that.inputValue = D; F = ""; I = A.toParm.split(";"); P = A.formParm.split(";"); M = A.sField.split(";"); N = A.dField.split(";"); O = A.eFilter; D = D.replace(/'/g, "''"); F = GT.threePop.setupParms(I, M, N, O, A.id, D + '', A.formParm, Trow, " like", false, true, true, true, that.Tgrid.Data.seInfo, null, null, A.refield, true); E = {}; E.Url = "/gtGrid.do?m=suggest"; E.Format = "JSON"; E.Data = "_pop_json"; E.isGt = 1; E.Method = "post"; D = D == "" ? "''" : D; var tab = document.getElementById('T_' + that.Tformid + "_" + that.Trand + 'CDiv'); var str = eval('(' + $(tab).attr("data") + ')');// json对象 G = that; C = "{"; C += "'formID':\"" + A.formid; C += "\",'where':\"" + F; C += "\",'parm':\"" + A.suggest; C += "\",'exp':\"" + that.prossParmer(str.exp.replace(/#/g, "'"), Trow); C += "\",'type':\"" + A.wtype; C += "\",'value':\"" + A.Name + ";" + D.replace("%", "@~").replace("%", "@~") + "\"}"; that.Tgrid.AjaxCall(E, C, function (Q, R) { var S; var cdiv = document.getElementById('T_' + G.Tformid + "_" + G.Trand + 'CDiv');// 内容Div if (that.timer) clearInterval(that.timer); G.Tgrid.curTab = cdiv; G.removeRows(cdiv); if (R != "") { if (R.indexOf("error;") > -1) { alert(R.split(";")[1]); G.Tgrid.threePop(S, I, Trow, null, -1) } else { // 设置格线需要的属性 cdiv.setAttribute("grid", "{index:" + G.Tgrid.Index + ",rowid:\"" + Trow.id + "\"}"); if (isTopFixed()) { tp = elem.offsetParent.offsetTop + elem.offsetParent.offsetHeight; } G.popDiv(R, cdiv); } } G.isclose = false; }); } }); }, prossParmer: function (filter, row) { var flg = false; if (filter instanceof Array) { flg = true; filter = filter.join(";"); }// 因为有存在是数组的情况,转为字符串 if (filter != "" && filter.match(/&.*?&/)) {// 存在&...&的字段才需要查找 var temp = filter.match(/&.*?&/g); for (var t = 0; t < temp.length; t++) {// 可能存在多个需要替换的字段 var va = temp[t]; var vas = va.toLowerCase().replace("&", "").replace("&", ""); var flgs = false; var vt = document.getElementById(vas); if (vt) {// 只要存在有,则取里面的值,不然才需要找格线里面的值 by 2014-725 // &&vt.value&&vt.value!=''&&vt.value!=='0' filter = filter.replace(new RegExp(va, "gm"), vt.value); flgs = true; } if (!flgs) { filter = filter.replace(va, row[vas]); } } } return filter; }, getRowsHeight: function (rows) { var height = 0; for (var r = 0; r < rows.length; r++) { height += rows[r].offsetHeight; } return height; }, popDiv: function (R, cdiv) {// 处理弹出列表,需要组装的代码,R为从后台读取返回的json数据 this.rowcount = 0; var obj = eval('(' + R + ')'); if (obj.error != undefined) { alert(obj.error); return; } var str = ""; var datas=(obj.data!=null?obj.data:obj);//新版本的返回格式 xin 2021-4-24 14:22:47 if (datas.length > 0) { for (var o = 0; o < datas.length; o++) { var ob = datas[o]; if (ob["hasNexPage"] != undefined) this.addRow_withInsert2(cdiv); else this.addRow_withInsert(cdiv, ob); } } var pd = document.getElementById('T_' + this.Tformid + '_' + this.Trand + 'div'); // var myscroll=new // IScroll('#T_'+Tformid+'div',{click:true,scrollbars:true}); if (this.Tgrid != null && this.Tgrid != undefined) { var gheight = this.Tgrid.MainTag.clientHeight + 40; // pd.style.height="300px"; pd.style.overflow = "auto"; if (cdiv.rows.length > 0) {// 有内容的情况 if (tp + 280 > gheight && (gheight - tp < 280) && cdiv.rows.length > 0) { if (cdiv.rows.length * 30 < 300) { pd.style.overflow = "hidden"; var h = this.getRowsHeight(cdiv.rows); pd.style.height = (h == 0 ? 500 : h) + "px"; } else { var temp = tp; tp = tp - 280 - 20 - 20; if (tp < 0) tp = temp; pd.style.height = "300px"; } } } else {// 没内容 // pd.style.height="30px"; pd.style.overflow = "hidden"; } } pd.style.display = "block"; pd.style.left = lf + 'px'; pd.style.top = tp + 'px'; pd.style.position = this.positionss; // pd.style.top=(isTopFixed()?(tp+70):tp)+'px'; // pd.style.position='fixed'; // pd.style.top=(tp+80)+'px';//+80是固定了头部,面板top属性+80,所以这里也要加 xin 2020-10-16 10:18:45 // pd.style.background="#99BBE8"; }, removeRows: function (table) { var rowCount = table.rows.length; if (rowCount > 1) { for (var i = 1; i < rowCount; i++) { table.deleteRow(i); rowCount = rowCount - 1; i = i - 1; } } }, addRow_withInsert2: function (table) { var row = table.insertRow(table.rows.length); var cell = row.insertCell(0); cell.innerHTML = "由于篇幅限制,部分搜索结果未予显示"; cell.colSpan = 50; cell.align = "center"; }, addRow_withInsert: function (table, ob) { var row = table.insertRow(table.rows.length); row.onmouseover = (function () { return function () { this.style.backgroundColor = '#ffff66'; } })(row); row.onmouseout = (function () { return function () { this.style.backgroundColor = '#d4e3e5'; } })(row); var rowCount = table.rows.length; var countCell = table.rows.item(0).cells.length; var i = 0; var str = eval('(' + $(table).attr("data").toLowerCase() + ')');// json对象 for (var item in ob) { if (item.indexOf("_expr") > 0) continue; var cell = row.insertCell(i); var vlu = ob[item] == 'null' ? "" : ob[item]; if (ob[item + "_expr"] == 0) { vlu = "***"; cell.hd = ob[item]; } cell.innerHTML = vlu; cell.id = "_" + item;// 增加id前加_是为了区别参数替换时和其他重名而取错数 if (str.data.indexOf(";" + item.toLowerCase() + ";") >= 0) { cell.style.display = "none"; } cell.onclick = (function () { return function () { if (navigator.userAgent.match(/iPad|iPhone|Android/i)) { // 返回值给格线,暂时只支持返回一行 var row = cell.parentElement; var js = eval('(' + $(table).attr("data").toLowerCase() + ')'); var fileds = js.form.split(";"); var ft = []; // 按需要返回的字段来生成对应的值,不然顺序乱就不对了 for (var r = 0; r < fileds.length; r++) { var flg = false; for (var v = 0; v < row.cells.length; v++) { var id = $(row.cells[v]).attr("id").toLowerCase(); if ("_" + fileds[r] == id) {// 符合条件,取出来 var txt = row.cells[v].innerText; if (typeof (row.cells[v].hd) != "undefined" && txt == "***") txt = row.cells[v].hd; ft.push(txt); flg = true; break; } } if (!flg) ft.push(""); } if ($(table).attr("grid") != undefined) {// 格线 var grid = eval('(' + $(table).attr("grid").toLowerCase() + ')'); var gd = Grids[grid.index]; // var row=gd.Rows[grid.rowid];//三点弹出的所在行 // st,to,row,index,fl,c,flag,orgCol gd.threePop(ft, js.to.split(";"), Trow, null, -1, null, null, Tfield); gd.EndEdit(0); this.inputValue = ""; } else {// 面板 // TODO,这里增加面板的处理代码 openValue42(ft, benzi.split(";"), true); } table.parentElement.style.display = "none"; } } } )(cell); cell.ondblclick = (function () { return function () { // 返回值给格线,暂时只支持返回一行 var row = cell.parentElement; var js = eval('(' + $(table).attr("data").toLowerCase() + ')'); var fileds = js.form.split(";"); var ft = []; // 按需要返回的字段来生成对应的值,不然顺序乱就不对了 for (var r = 0; r < fileds.length; r++) { var flg = false; for (var v = 0; v < row.cells.length; v++) { var id = $(row.cells[v]).attr("id").toLowerCase(); if ("_" + fileds[r].trim() == id) {// 符合条件,取出来 var txt = row.cells[v].innerHTML;// by danaus innerText会把值里中间的空格去掉一些; if (typeof (row.cells[v].hd) != "undefined" && txt == "***") txt = row.cells[v].hd; ft.push(txt); flg = true; break; } } if (!flg) ft.push(""); } if ($(table).attr("grid") != undefined) {// 格线 var grid = eval('(' + $(table).attr("grid").toLowerCase() + ')'); var gd = Grids[grid.index]; // var row=gd.Rows[grid.rowid];//三点弹出的所在行 gd.threePop(ft, js.to.split(";"), Trow, null, -1, null, null, Tfield); gd.EndEdit(0); this.inputValue = ""; } else {// 面板 // TODO,这里增加面板的处理代码 openValue42(ft, benzi.split(";"), true); } table.parentElement.style.display = "none"; } } )(cell); i++; } this.rowcount++; } }; return popdiv1; } function openValue42(st, get, boo) { if (st != undefined && st != null) { for (var n = 0; n < st.length; n++) { if (getDoc(get[n], "") == null) { if (!navigator.userAgent.match(/iPad|iPhone|Android/i)) { alert("返回字段设置" + get[n] + "在页面上没有!"); } else { var getvalue = get[n]; $(document.getElementById(getvalue)).attr("value", st[n]); } } else { setDoc(get[n], ".value ='" + (st[n] == "undefined" ? "" : st[n]) + "'"); var panInfo = panMain[panIndex].panInfo; if (panInfo != null && panInfo[get[n]] != undefined) {//特殊控件需要重新渲染 xin 2020-8-18 15:08:27 switch (panInfo[get[n]].controltype) { case "43": $("#" + get[n]).val(st[n]).trigger('change'); break; } } if (st[n] != '') {//针对31级联 getSelect31(get[n]); } } } } } var LayerObj = null; //格线弹出上传附件页面 function showLayerGrid_pic(url, obj) { LayerObj = createLayer_pic();//hotkey.js LayerObj.showLayer(url, obj); }; function createLayer_pic() { var lay = { layIndex: null,//弹出层引用ID _flg_: null, //弹出层 showLayer: function (str, flg) { this._flg_ = flg; this.layIndex = layer.open({ type: 2, title: false, maxmin: false, _flg_: flg, shift: 1, shadeClose: true, //点击遮罩关闭层 area: ['800px', '460px'], success:function(){ $('.layui-layer-iframe').find('iframe').contents().find('#scroller').css('overflow-x','hidden'); }, content: str //'/app/67/0/cnzh/110502/1/index.jsp' }); }, close: function () { layer.close(this.layIndex); if (this._flg_ == 2) mygrid.ReloadBody(); else location.reload(); } }; return lay; } function showLayerGrid(url, ref, width, height) { LayerObj = createLayer();//hotkey.js LayerObj.showLayer(url, ref, width, height); }; function createLayer() { var lay = { layIndex: null,//弹出层引用ID _flg_: null, //弹出层 showLayer: function (str, flg, width, height) { this._flg_ = flg; if(flg==-1 && str.indexOf("warehousing")!=-1){//是序列号扫码界面 xin 2021-8-3 10:17:22 openNewLayui.openWin(str); return; } this.layIndex = layer.open({ type: 2, title: false, maxmin: false, _flg_: flg, shift: 1, shadeClose: true, //点击遮罩关闭层 area: [width || '800px', height || '460px'], content: str, //'/app/67/0/cnzh/110502/1/index.jsp' end: function () { closeLoading(); }, success:function(){ $('.layui-layer-iframe').find('iframe').contents().find('#scroller').css('overflow-x','hidden'); } }); }, close: function () { layer.close(this.layIndex); //by danaus 2021/4/8 14:45 if(this._flg_ == 2) { if (mygrid) mygrid.ReloadBody(); }else if(this._flg_ == -1){ //表示是序列号扫码入库调用,不需要刷新页面 }else { if (location) location.reload(); } } }; return lay; } function codeScanning(state,formid,formtype,type){ var page = ""; if (type == "out") { page = "deliveryPage.jsp?"; } else if (type == "in") { page = "warehousing.jsp?"; } else if (type == "cyc") { page = "inventory.jsp?"; } var url = "/general/SerialNumber/" + page; var parm = "formid=" + formid + "&formtype=" + formtype + "&doccode=" + getDoc("doccode", ".value"); var isEdit = false; if (state != null) { var docstatePan = getDoc("docstatus", ".value"); if (state.indexOf(";") != -1) { isEdit = ($.inArray(docstatePan, state.split(";")) != -1 ? true : isEdit); } if (state == "" || docstatePan == state) { isEdit = true; } if (docstatePan == '100') {//确定单不可编辑 isEdit = false; } } url += encodeText(parm + "&isEdit=" + isEdit); openNewLayui.openWin(url); } var openNewLayui={ layer: (typeof (layui) != 'undefined' ? layui.layer : null), openWin: function (url) { var that=this; this.layer.open({ type: 2, area: ['800px', '550px'], title: false, content: url, cancel: function (index,layero) { var envt = $(layero).find("iframe")[0].contentWindow; if (envt != null) { if(envt.isChang){ if(confirm("界面有修改,是否执行扫完了再关闭?")){ that.setGrid(envt.vm.okSubmit(),true); }else{ layer.close(index); } }else{ layer.close(index); } } } }); }, setGrid:function(value,isSave){ // var envt = $(layero).find("iframe")[0].contentWindow; if (value != null) { // var value = envt.vm.okSubmit(); if (Grids != null && value != null) { var gr = Grids[value.T_id]; gr.EndEdit(true); var rowids = value.rowids; for (var r in rowids) { gr.setSerialNumber("serialnumbers", (rowids[r] != "" ? rowids[r].join(";") : ""), r); } if(isSave){//有改动过是需要保存 //处理保存自动执行事件 $("#tpSave").trigger("click"); // save(2);//执行保存 } } } layer.closeAll(); } } //38类型用到的弹出窗体 var LayerObjs = null; function showLayerGrids(url, ref) { LayerObjs = createLayers();//hotkey.js LayerObjs.showLayer(url, ref); }; function createLayers() { var lay = { layIndex: null,//弹出层引用ID _flg_: null, //弹出层 showLayer: function (str, flg) { this._flg_ = flg; this.layIndex = layer.open({ type: 2, title: false, maxmin: false, _flg_: flg, shift: 1, shadeClose: true, //点击遮罩关闭层 area: ['540px', '425px'], success:function(){ $('.layui-layer-iframe').find('iframe').contents().find('#scroller').css('overflow-x','hidden'); }, content: str //'/app/67/0/cnzh/110502/1/index.jsp' }); }, close: function () { layer.close(this.layIndex); if (this._flg_ == 2) mygrid.ReloadBody();//刷新表休 else location.reload();//刷新整个页面 } }; return lay; } //38类型的小弹窗 var LayerObjsi = null; function showLayerGridsi(url, ref) { LayerObjsi = createLayersi();//hotkey.js LayerObjsi.showLayer(url, ref); }; function createLayersi() { var lay = { layIndex: null,//弹出层引用ID _flg_: null, //弹出层 showLayer: function (str, flg) { this._flg_ = flg; this.layIndex = layer.open({ type: 2, title: false, maxmin: false, _flg_: flg, shift: 1, shadeClose: true, //点击遮罩关闭层 area: ['300px', '150px'], success:function(){ $('.layui-layer-iframe').find('iframe').contents().find('#scroller').css('overflow-x','hidden'); }, content: str //'/app/67/0/cnzh/110502/1/index.jsp' }); }, close: function () { layer.close(this.layIndex); if (this._flg_ == 2) mygrid.ReloadBody(); else location.reload(); } }; return lay; } function delemptyrefdata() { return; } //解决格线高度问题 function gridHeight() { try { var panelHeight = (top.panelHeight == 0 ? document.documentElement.clientHeight : top.panelHeight);// 获取页面的总高度 var panelType = top.myFresh.panel[top.tabindex];// 获取面板的类型 // let panelControlDiv=$('.panelControlDiv'); // if(panelControlDiv && panelControlDiv.eq(0)){//是否有这个div层 xin 2023-8-22 15:59:36 // //固定这个层的最大高度为自适应获取的高度,如果不固定为最大高度,在有42控件显示层的时候,如果42控件显示层大于这个层的高度话会把他撑高。 // panelControlDiv.eq(0).css("max-height",panelControlDiv.outerHeight(true)); // } // 有树形的特殊窗体处理 if (';2;3;4;20;30;301;302;303;304;'.indexOf(';' + panelType + ';') != -1) { if (gridId.length == 0) return; var panelWidth = document.documentElement.clientWidth; var treeWidth = $('#wrappers').outerWidth(true);// 树形的宽度 var treeHeight = $('#tplt-panels').outerHeight(true);// 树形的高度 $('#' + gridId[0]).css('height', (treeHeight - 30 - 20) + 'px');// 减去30是因为margin和padding的值 $('#' + gridId[0]).css('width', (panelWidth - treeWidth - 30) + 'px'); return; } // 清单列表页面 if (';1;9;10;15;17;18;19;497;499;'.indexOf(';' + panelType + ';') != -1 && typeof (formId) != 'undefined') { var topPanelHeight = $('#top_table').outerHeight(true);//这个是头部状态栏高度 if (topPanelHeight == null) {// 没有标题的高度 topPanelHeight = $('#tplt-top').outerHeight(true) + 10; } panelHeight = (panelHeight - topPanelHeight);//总高度 - 状态栏高度 if (panelType == 1) { $('#' + gridId[0]).css('height', (panelHeight - 50) + 'px');// 减去50是因为margin和padding的值 return; } panelHeight = (panelHeight - 60);//文字颜色说明占了50高 if (panelType == 10 || panelType == 18 || panelType == 19) { var panelTable0Height = $('#panelTable0').outerHeight(true); panelHeight = panelHeight - panelTable0Height + 5; $('#' + gridId[0]).css('margin-bottom', '0').css('margin-top', '0'); $('#' + gridId[0]).css('height', panelHeight + 'px');// 减去25是因为margin和padding的值 return; } var panelFormIdHeight = $('#panel_' + formId).outerHeight(true);//面板控件占用的高度 if (panelFormIdHeight == null) { panelFormIdHeight = $('.main_talbe').outerHeight(true); } panelHeight = (panelHeight - panelFormIdHeight);//总高度 - 面板控件占用的高度 panelHeight = (panelHeight - 25);//总高度 - 其他pdding等因素; //文字颜色说明高度 // let colorDescriptionContainer = $('.colorDescriptionContainer').outerHeight(true); // if (colorDescriptionContainer != null) { // colorDescriptionContainer = 40; // } // panelHeight = (panelHeight - colorDescriptionContainer);//总高度 - 文字颜色说明高度 $('#' + gridId[0]).css('height', panelHeight + 'px');// 减去50是因为margin和padding的值 return; } return; } catch (e) { console.log("调节格线高度出现错误异常。"+e); } } function isTopFixed() { var bol = false; if (top.myFresh!=null && ";5;8;16;496;".indexOf(";" + top.myFresh.panel[top.tabindex] + ";") != -1) { bol = true; } return bol; } //处理42控件显示层的数据加载 xin 2021-3-23 11:11:03 var control42DivData = { table42: null , Env42table: {} , Collection: {}//属性 , timer: null//时间 ,inputValue:null , ShowDivForPanel: function (elem, Info, rod) {//面板数据加载 var Cid = 'panel_table_' + rod; if (this.Collection[Cid] == null) {//第一次时进入 this.getPanelParam(elem, Info, rod, Cid);//获取通用属性 } this.PremissField(Info,this.Collection[Cid].wheres);//个别窗体需要添加条件进去 如 18窗体表号 xin 2023-2-8 08:46:12 // var scrollTop = document.documentElement.scrollTop ? document.documentElement.scrollTop : document.body.scrollTop; this.Collection[Cid].top = elem.offsetTop + 26;//elem.offsetParent.offsetParent.offsetTop + elem.offsetParent.offsetTop + 28 - scrollTop;// 42控件div的top控制 this.Collection[Cid].left = elem.offsetLeft;//elem.offsetParent.offsetParent.offsetLeft + elem.offsetParent.offsetLeft + 118;// 42类型div的left控制 //组装条件 this.getPanelWhere(Info.seekgroupid.toLowerCase(), Info.fk.toLowerCase(), '', ' and ', elem.id, true, this.Collection[Cid]); //执行渲染 this.render(this.Collection[Cid]); } , ShowDivForGrid: function (tg, elem, col,callback) {//格线数据加载 var Cid = 'grid_table_' + col.rand; var value=""; try { value = tg.Edit.Tag.value + ""; if (value == '' || this.inputValue == value) { return; } }catch (e){} this.inputValue=value; value = value.replace(/'/g, "''"); value = value == "" ? "''" : value; if (this.Collection[Cid] == null) {//第一次时进入 this.getGrideParam(tg, elem, col, Cid,callback);//获取通用属性 } if (this.Collection[Cid].isOld){ this.Collection[Cid]=null; return; } //获取scroll的top位置,弹出层需要减去这个高度,避免位置出现偏差 by danaus 2020/11/7 17:23 var scrollTop = document.documentElement.scrollTop ? document.documentElement.scrollTop : document.body.scrollTop; this.Collection[Cid].top = elem.offsetParent.offsetTop + elem.offsetParent.offsetHeight - scrollTop; this.Collection[Cid].left = elem.offsetParent.offsetLeft; if (this.isTopFixed()) { this.Collection[Cid].top = elem.offsetParent.offsetTop + elem.offsetParent.offsetHeight; } this.Collection[Cid]._pop_json.value = col.Name + ";" + value.replace("%", "@~").replace("%", "@~"); I = col.toParm.split(";"); P = col.formParm.split(";"); M = col.sField.split(";"); N = col.dField.split(";"); O = col.eFilter; this.Collection[Cid]._pop_json.where = GT.threePop.setupParms(I, M, N, O, col.id, value + '', col.formParm, GT.rowIDp, " like", false, true, true, true, tg.Data.seInfo, null, null, col.refield, true); this.Collection[Cid].wheres._pop_json = JSON.stringify(this.Collection[Cid]._pop_json); this.Collection[Cid].gridIndex = tg.Index; this.Collection[Cid].rowid = GT.rowIDp.id; this.render(this.Collection[Cid]);//执行渲染 } , getPanelParam: function (elem, Info, rod, Cid) {//面板需要到的属性 var list = {}; list.type = 0; list.fieldid = elem.id; this.getDefault(list, Info.ft, rod); list.url = '/panelControlData42.do'; list.relation = $(elem).data('relation').toLowerCase();//查询条件的字段 //条件 list.wheres = {}; list.wheres.sugg = $(elem).data('sugges').toLowerCase();//后台查询需要到的字段名 if (list.wheres.sugg == '') { list.wheres.sugg = Info.fk; } list.fk=Info.fk.toLowerCase().split(';'); list.seekgroupid=Info.seekgroupid.toLowerCase().split(';');//接收自身字段名 list._pop_json={}; list.parm=list.wheres.sugg.split(';'); list.wheres.ft = Info.ft; this.Collection[Cid] = list; } ,PremissField:function (Info,wheres) {//个别窗体需要 如:18类型表号 if (wheres != null && wheres != '') { let sPremissField = Info.spremissfield || '';//自身条件字段名 let dPremissField = Info.dpremissfield || '';//外表条件字段名 wheres.formType = Info.ftformtype || 0;//表号的窗体类型 wheres.parameter = ""; if (sPremissField != '' && dPremissField != '') { let a = []; sPremissField = sPremissField.split(";"); dPremissField = dPremissField.split(";"); for (let d = 0; d < dPremissField.length; d++) { a.push(dPremissField[d] + "=" + $("#" + sPremissField[d]).val() || ''); } wheres.parameter = a.join(";"); } } } , getGrideParam: function (tg, elem, col, Cid,callback) {//格线需要到的属性 var list = {}; list.type = 1; list.isOld=false; this.getDefault(list, col.formid, col.rand,callback); if (list.isOld){ this.Collection[Cid] = list; return; } tg.curTab=list.div42;//关联到关闭层(在旧方法引用) list.url = '/gtGrid.do?m=suggest'; list.Tfield = col.Name; //条件 list.wheres = {}; list._pop_json = {}; list._pop_json.formID = col.formid; list._pop_json.parm = col.suggest; list._pop_json.type = col.wtype; var str = eval('(' + $('#' + list.id).data("datas") + ')');// json对象 list._pop_json.exp = this.prossParmer(str.exp.replace(/#/g, "'"), GT.rowIDp); list.formfileds = str.form.split(';'); list.to=str.to.split(';'); list.data=str.data.split(';'); list.parm = col.suggest.split(';'); this.Collection[Cid] = list; } , getDefault: function (list, F, R,callback) {//通用默认属性 list.id = 'T_' + F + '_' + R + 'CDiv'; list.div42 = $('#T_' + F + '_' + R + 'div'); list.width = 820;//默认 list.array = []; var array = $('#' + list.id).data('title');//显示的字段名 if (typeof array == 'undefined'){//不是最新生成的界面 list.isOld=true; callback(false); }else{ if (array != null && array.length>0) { array = eval('(' + array + ')'); list.array=array; } else { $.messager.alert("提示", "获取不到显示标题列!请检查有没有设置了表号或有没有设置了显示字段名", "warning"); return; } } } , prossParmer: function (filter, row) { var flg = false; if (filter instanceof Array) { flg = true; filter = filter.join(";"); }// 因为有存在是数组的情况,转为字符串 if (filter != "" && filter.match(/&.*?&/)) {// 存在&...&的字段才需要查找 var temp = filter.match(/&.*?&/g); for (var t = 0; t < temp.length; t++) {// 可能存在多个需要替换的字段 var va = temp[t]; var vas = va.toLowerCase().replace("&", "").replace("&", ""); var flgs = false; var vt = document.getElementById(vas); if (vt) {// 只要存在有,则取里面的值,不然才需要找格线里面的值 by 2014-725 // &&vt.value&&vt.value!=''&&vt.value!=='0' filter = filter.replace(new RegExp(va, "gm"), vt.value); flgs = true; } if (!flgs) { filter = filter.replace(va, row[vas]); } } } return filter; } , getPanelWhere: function (ben, wai, zi, addFuHao, id, qianzhi, CEnvt) { // openTree = true; var bens = ben.split(";"); var wais = wai.split(";"); var glian = CEnvt.relation.split(";"); var where = ""; var col = ""; var value = ""; var gl = ""; var efilter = ''; for (var ef in panMain) { if (typeof (panMain[ef].panInfo[id]) != "undefined") { if (panMain[ef].panInfo[id].efilter != "") { efilter += panMain[ef].panInfo[id].efilter; } } } for (i = 0; i < bens.length; i++) { col = bens[i].toLowerCase(); if (col.Trim() != "") { value = getDoc(col, ".value"); // 针对 300029 资金帐户 if (value == null) { value = ""; } if (qianzhi) { // 强制判断 if (value != "") { if (value.indexOf("'") != -1) { value = value.replace(new RegExp("'", "g"), "''"); } where += wais[i] + " like '" + "@~" + value + "@~'" + addFuHao;// and } } } } if (CEnvt.relation != "") { value = getDoc(id, ".value"); if (value.indexOf("'") != -1) { value = value.replace(new RegExp("'", "g"), "''"); } for (var g = 0; g < glian.length; g++) { col = glian[g].toLowerCase(); if (col.Trim() != "") { gl += col + " like '" + "@~" + value + "@~'" + " or "; } } gl = gl.substring(0, gl.length - 3); gl = " or (" + gl + ")"; } if (zi.Trim() != "") { where += zi + addFuHao;// 追加自定义条件 } where = where.substring(0, where.length - addFuHao.length); //where为空值的情况,让他在()里面成立。解决查询sql报错问题 where = (efilter == "" ? "" : "(") + "(" + (where == "" ? "1=1" : where) + ")" + gl + (efilter == "" ? "" : ") and (" + efilter + ")"); CEnvt.wheres.where = encodeURI(replacePageValue(where)); } , render: function (list) {//渲染数据 var that=this; var cols=this.handle(list.array,list.parm);//这里处理权限和隐藏特殊设置的每一列字段值信息 if (this.Env42table[list.id] == null) { this.Env42table[list.id] = this.table42.render({//渲染 elem: '#' + list.id //层id名 , url: list.url //请求路径 , where: list.wheres //条件 , title: '数据信息' , height: 320 //高度 , width: (cols.length>5?900:((160*(cols.length))<590?590:(160*(cols.length)))) //列数超过7列时给一个固定值。 , cellMinWidth:150 //全局定义所有常规单元格的最小宽度(默认:60),一般用于列宽自动分配的情况。其优先级低于表头参数中的 minWidth , size: 'sm' , cols: [cols]//标题数组 , page: true , limit: 20 //默认每页显示20条数据 , page: { groups: 5 //连续出现的页码个数 } , parseData: function (res) { //res 即为原始返回的数据 if (res == null || res.msg != null) { console.log("获取数据失败!" + (res.msg != null ? res.msg : '')); layer.msg(res.msg); return { "code": 0,//res.status, //解析接口状态 "msg": '',//res.message, //解析提示文本 "count": 0,//res.total, //解析数据长度 "data": '',//.data.item //解析数据列表 }; } for(var i=0;i])*>/g) && (obj[o] + "").match(/]*>|]*>/g) == null) { obj[o + "_escape"] = obj[o]; obj[o] = (obj[o] + "").replace(//g, ">"); } } //--- by danaus 2023-07-27 14:43 list.array.forEach(function (item, index) { //处理5类型日期格式显示 if (item.field == o && (item.controlType != undefined && item.controlType == 5)) { var format = "yyyy-MM-dd"; if (item.displayformat != undefined && item.displayformat != null && item.displayformat != "") { format = item.displayformat; } if (typeof (formatDate) == "function") { obj[o] = formatDate(obj[o], format); } } }); } } if (res instanceof Array) { return { "code": 0,//res.status, //解析接口状态 "msg": '',//res.message, //解析提示文本 "count": res.length,//res.total, //解析数据长度 "data": res,//.data.item //解析数据列表 }; } return { "code": 0,//res.status, //解析接口状态 "msg": '',//res.message, //解析提示文本 "count": res.count,//res.total, //解析数据长度 "data": res.data,//.data.item //解析数据列表 }; } , done: function (res, curr, count) {//数据渲染完的回调 list.div42.css('top', list.top); list.div42.css('left', list.left); list.div42.css('background', 'white'); $('.layui-table-view').css('marginTop', 0); $('.layui-table-view').css('marginBottom', 0); that.div42Height(list); list.div42.show(); //手机或平板模式下触发 if (navigator.userAgent.match(/iPad|iPhone|Android/i)) { list.div42.find('.layui-table-body').find("table").find("tbody").children("tr").on('dblclick', function () { var id = JSON.stringify(list.div42.find('.layui-table-body').find("table").find("tbody").find(".layui-table-hover").data('index')); var obj = res.data[id]; that.SetValueData(list, obj); }) } },error:function (r) { console.log(r); // layer.msg(r); } }); this.table42.on('rowDouble(' + list.id + ')', function (obj) {//行双击事件。(手机或平板模式下失效) that.SetValueData(list,obj.data); }); $('input').click(function () { if (!list.div42.is(":hidden") && list.fieldid != this.id){ list.div42.hide(); } }) } else { //执行重载 this.Env42table[list.id].reload({ cols: [cols]//标题数组 ,page: { curr: 1 //重新从第 1 页开始 } , where: list.wheres //条件 }, 'data'); } } ,div42Height:function(list){//出现面板高度太低的情况,强行把面板高度提高 if ($("#tplt-grid").height() == null && list.type==0 && $(".istabs").height()==null) {//是面板上的控件执行才进入 var panelControlH = $('.panelControlDiv')[0]; if (panelControlH != null && $(panelControlH).height() < 400) { $(panelControlH).height(list.div42.height() + list.top); } } } ,handle:function (array,parm) {//处理 var i=0; var index=-1; for (var p in array){//遍历标题列,添加多一个templet属性,当加载数据回来填充时回调这个属性执行下面的方法并返回一个参数值d array[p].templet=function (d) {//d返回的是每一行的数据信息. if (index!=d.LAY_TABLE_INDEX){//LAY_TABLE_INDEX属性值为执行到的行数, index=d.LAY_TABLE_INDEX; i=0; } var id=parm[i]; i++; if (d[id + '_expr'] == 0) {//权限控制隐藏 return "***"; } return d[id]!=null?d[id]:''; }; } return array; } ,SetValueData: function (list, data) {//赋值 if (list.type == 0) {//面板 var fk = list.fk; var p=panMain[panIndex]; for (var i = 0; i < fk.length; i++) {//赋值给页面 if (typeof data[fk[i]] != 'undefined') { var v = (data[fk[i]] == null ? "" : data[fk[i]]); //处理值是html标签格式: 169 123W 123,因为显示时候做了转义,这里取值就需要还原 by danaus 2023-07-04 09:34 if(data[fk[i]+"_escape"]!=undefined){ v=data[fk[i]+"_escape"]; } setDoc(list.seekgroupid[i], ".value='" + v + "'"); if (p.select[list.seekgroupid[i]] != null) {//有级联到31控件的字段需要加载 xin 2021-5-10 14:55:33 getSelect31(list.seekgroupid[i]); } if (p.panInfo[list.seekgroupid[i]] != null && p.panInfo[list.seekgroupid[i]].controltype == 43) {//是43控件 $("#" + list.seekgroupid[i]).val(v).trigger('change'); } } } } else if (list.type == 1) {//格线 var fileds = list.formfileds; var V = []; for (var r = 0; r < fileds.length; r++) { if (typeof data[fileds[r]] != 'undefined') { //处理值是html标签格式: 169 123W 123,因为显示时候做了转义,这里取值就需要还原 by danaus 2023-07-04 09:34 var value=data[fileds[r]] != null ? data[fileds[r]] : ''; if(data[fileds[r]+"_escape"]!=undefined){ value=data[fileds[r]+"_escape"]; } V.push(value); } else { V.push(''); } } if (list.gridIndex != null) { var gd = Grids[list.gridIndex]; // var row=gd.Rows[list.rowid];//三点弹出的所在行 //清空关联 if (gd.Cols[list.Tfield]!=undefined&&gd.Cols[list.Tfield].emptyrefdata!=undefined &&gd.Cols[list.Tfield].emptyrefdata!="") { var ed = gd.Cols[list.Tfield].emptyrefdata.toLowerCase().split(";"); for(var i=0;i0){//旧版本调用的属性id return callback(false); }else{ this.inputValue=""; $(Envt).hide(); } } , loading: function () {//加载42控件 if (typeof layui != 'undefined') { this.table42 = layui.table; this.isControl42(); } else { // var that=this; // let u=location.hostname; // let url=location.port; // try { // $("").attr({ // rel: "stylesheet", // type: "text/css", // href: u+":"+url + "/layui/css/layui.css" // }).appendTo("head"); // $.getScript(u+":"+url + '/layui/layui.all.js', function () { // if (typeof layui == 'undefined') { // console.log('获取42控件插件层失败!'); // return null; // } // that.table42 = layui.table; // that.isControl42(); // }) // }catch (e) { // console.log('获取layui插件信息出现错误'); // } } } , isControl42: function () { var get = this; //页面42控件的keyup事件(面板调用) $('.isControl42').on('keyup', function () { if (this.readOnly || this.disabled){//只读 return; } clearTimeout(get.timer); var elem = this; var rod = $(elem).data('rod'); var index = $(elem).data('index'); var panInfo = panMain[index].panInfo; if (panInfo == null) { console.log("获取不到面板panInfo属性信息"); return; } if (elem.value == '') {//空值情况 var empty = panInfo[elem.id].emptyrefdata.toLowerCase();//清空关联字段 empty = empty.split(';'); for (var e = 0; e < empty.length; e++) { if (panInfo[empty[e]]!=null && panInfo[empty[e]].controltype == 43) {//43控件清空 $("#" + empty[e]).val('').trigger('change'); continue; } setDoc(empty[e], ".value=''");//清空 } $('#T_' + panInfo[elem.id].ft + '_' +rod + 'div').hide();//隐藏 return; } get.timer = setTimeout(function () { get.ShowDivForPanel(elem, panInfo[elem.id], rod); }, 1000); }); } }; //执行收款显示二维码或退款 function OpenPayAndRefund(doccode,type,formid){ if(type=="pay"){//显示二维码 let doc=doccode; var url = "/general/onlinePayment/payment.jsp?orderNo=" + doc+"&formId="+formid; layui.layer.open({ type: 2, area: ['700px', '500px'], title: false, content: url, cancel: function (index, layero) { var envt = $(layero).find("iframe")[0].contentWindow; if (envt != null) { if (!envt.isChang) { if (!confirm("还没有支付,确定关闭吗?")) { return false; } } if (envt.ws != null) { envt.ws.close(); } } layer.closeAll(); getReductionURL(doc); } }); }else{//确定 $.ajax({ url: "/gtGrid.do?m=newTran&formid="+formid+"&docCode="+doccode, type: "get", async: false, success: function (res) { if(res.state==-1) { layer.alert(res.msg,function (){location.reload();}); }else{ location.reload(); } }, error: function (e, h, a) { layer.alert(e.responseText,function (){location.reload();} ); } }); } } //针对收款二维码界面关闭的处理 xin 2021-9-8 10:09:33 function getReductionURL(doc){ var url = location.search; var parm = Base64().decode(url.substring(1, url.length)); if (parm.indexOf("&onlinePay=1") != -1) { parm = parm.replace("&onlinePay=1", ""); parm = "?" + encodeText(parm); location.replace(location.href.split("?")[0] + parm); } else { if (doc != null) { let docUrl = '?' + encodeText('doccode=' + doc); location.replace(location.href.split("?")[0] + docUrl); } else { location.reload(); } } layer.closeAll(); } //批量上传物料主数据主图片 xin 2021-9-17 09:51:37 function Batchupload(){ var url="/general/batchUpload/uploadIndex.jsp"; layui.layer.open({ type: 2, area: ['850px', '500px'], title: false, content: url, cancel: function (index, layero) { layer.closeAll(); } }); } function progressBar(e,value){ top.$(e).jQMeter({ goal: '100', raised: value+'', height: '24px', barColor:'#6699cc', bgColor: '#CCC' }); } function formatDate (str, format) { var d = new Date(toDate(str));//4位的数字不作为日期处理,直接返回 if (d==null||d.getFullYear() == '1970') return str; var o = { "M+": d.getMonth() + 1, //month "d+": d.getDate(), //day "H+": d.getHours(), //hour "m+": d.getMinutes(), //minute "s+": d.getSeconds(), //second "q+": Math.floor((d.getMonth() + 3) / 3), //quarter "S+": d.getMilliseconds() //millisecond } var format = format ? format : "yyyy-MM-dd HH:mm"; if (/(y+)/.test(format)) { format = format.replace(RegExp.$1, (d.getFullYear() + "").substr(4 - RegExp.$1.length)); } for (var k in o) { if (new RegExp("(" + k + ")").test(format)) { if (RegExp.$1 == "S") { format = format.replace(RegExp.$1, "000"); } else { format = format.replace(RegExp.$1, RegExp.$1.length == 1 ? o[k] : ("00" + o[k]).substr(("" + o[k]).length)); } } } return format; }; function toDate (dateStr) { var regex1 = /^\d{4}\/\d{1,2}\/\d{1,2}$|^\d{1,2}\/\d{1,2}\/\d{4}$|^\d{4}\/\d{1,2}\/\d{1,2} \d{1,2}:\d{1,2}:\d{1,2}$|^\d{1,2}\/\d{1,2}\/\d{4} \d{1,2}:\d{1,2}:\d{1,2}:\d{1,3}$/; var regex2 = /^\d{4}-\d{1,2}-\d{1,2}$/; var regex3 = /^\d{4}-\d{1,2}-\d{1,2} \d{1,2}:\d{1,2}$/; var regex4 = /^\d{4}-\d{1,2}-\d{1,2} \d{1,2}:\d{1,2}:\d{1,2}$/; var regex5 = /^\d{4}-\d{1,2}-\d{1,2} \d{1,2}:\d{1,2}:\d{1,2}.\d{1,3}$/; var regex6 = /^\d{4}-\d{1,2}$/; var regex7 = /^\d{4}$/; if (regex1.test(dateStr)) { return new Date(dateStr); } else if (regex2.test(dateStr)) { var arr = dateStr.split("-"); return new Date(arr[0], arr[1] - 1, arr[2]); } else if (regex3.test(dateStr)) { var arr1 = dateStr.split(" "); var arr2 = arr1[0].split("-"); var arr3 = arr1[1].split(":"); return new Date(arr2[0], arr2[1] - 1, arr2[2], arr3[0], arr3[1]) } else if (regex4.test(dateStr)) { var arr1 = dateStr.split(" "); var arr2 = arr1[0].split("-"); var arr3 = arr1[1].split(":"); return new Date(arr2[0], arr2[1] - 1, arr2[2], arr3[0], arr3[1], arr3[2]) } else if (regex5.test(dateStr)) { var arr1 = dateStr.split(" "); var arr2 = arr1[0].split("-"); var arr3 = arr1[1].split(":"); return new Date(arr2[0], arr2[1] - 1, arr2[2], arr3[0], arr3[1], arr3[2].replace(/\.\d+/g, "")); } else if (regex6.test(dateStr)) { var arr2 = dateStr.split("-"); return new Date(arr2[0], arr2[1] - 1) } else { var art2= timeFormat(dateStr,"yyyy-MM-dd HH:mm"); return art2; } }; function timeFormat(timeStr,formatStr){ if(timeStr==""||timeStr==null||!isNaN(timeStr)){ return null; } var arr = ['Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec']; var arrtime = timeStr.split(" "); var str = arrtime[2];//年 str += "-"; var flag=false; for(var i=0;i=10?(i+1):"0"+(i+1); flag=true; } } if(!flag){//不存在月份,表示不是这种格式的日期 return timeStr; } str += "-"; str += arrtime[1].substring(0,2);//日 if(formatStr == "yyyy-MM-dd"){ return str; } str += " "; var hh = arrtime[3].substring(0,2);//小时 if(formatStr == "yyyy-MM-dd HH:mm"){//小时分钟 if(timeStr.indexOf("PM")!=-1){ str += (parseInt(hh)+12); str += arrtime[3].substring(2,5); }else{ str += arrtime[3].substring(0,5); } } if(formatStr == "yyyy-MM-dd HH:mm:ss"){//小时分钟秒 if(timeStr.indexOf("PM")!=-1){ str += (parseInt(hh)+12); str += arrtime[3].substring(2,9); }else{ str += arrtime[3].substring(0,9); } } return str; } $(function () { //单据窗体头部固定 xin 2020-10-26 17:23:58 if (isTopFixed()) { $("#top_table").addClass("topTable"); if ($("#tool").height() > 40) {//头部按钮过多导致tool高度变高的时候。 $("#scroller").addClass("tpltPanelsss"); $("body").addClass("bodyScrollss");//设置滚动条样式 } else { $("#scroller").addClass("tpltPanels"); $("body").addClass("bodyScroll");//设置滚动条样式 } } //------下面的是关于42控件的处理------ control42DivData.loading(); //---end---关于42控件的处理结束------ //---------47控件类型加载---------- xin 2022-4-27 10:58:12 $(".progressBar47").each(function () { let id = $(this).data("id"); let value = $("#" + id).val();//获取控件Id的value值 value = value != null ? value : 0; if (isNaN(value) || value == "") {//不全是数字 value = 0; } if (value > 0 ) {//这种情况是1表示100%的值,那么0.1*100=10 // && value < 1 value = value * 100; } progressBar(this, value); }) })