function CheckFileExt(extstr, exg) { var extstr = extstr.substring(extstr.lastIndexOf(".")).toLowerCase(); if (!extstr.match(exg)) { return false; } return true; } function DateToStr(dt){ var str=""; if(dt.getFullYear){ var y,m,d; y=formatNumber(dt.getFullYear(),'0000'); m=formatNumber((dt.getMonth()+1),'00'); //01-12 d=formatNumber(dt.getDate(),'00'); str= y+"-"+m+"-"+d; } return str; } function DateTimeToStr(dt){ var str=""; if(dt.getFullYear){ var y,m,d,h,mi,s; y=formatNumber(dt.getFullYear(),'0000'); m=formatNumber((dt.getMonth()+1),'00'); //01-12 d=formatNumber(dt.getDate(),'00'); h=formatNumber(dt.getHours(),'00'); mi=formatNumber(dt.getMinutes(),'00'); s=formatNumber(dt.getSeconds(),'00'); str= y+"-"+m+"-"+d+" "+h+":"+mi+":"+s; } return str; } function StrToDate(str){ var arys= new Array(); arys=str.split('-'); var newDate=new Date(arys[0],arys[1]-1,arys[2]); return newDate; } //重写fixed函数,令其四舍五入算法正常 Number.prototype.toFixed = function (len) { var add = 0; var s, temp; var s1 = this + ""; var start = s1.indexOf("."); if (start >= 0) { s1 = s1 + "0"; if (s1.substr(start + len + 1, 1) >= 5) add = 1; var temp = Math.pow(10, len); s = Math.floor(this.mul(temp)) + add; return s / temp; } else return this; } /* 数字格式化函数 “,” (半角的豆号) 如果有的话,看豆号到小数点(如果有的话)前有几位,则按几位划分整数部分 “0”(数字零) 如果该位上没有数字,就补0 “#”(井号) 如果该位上有数字就输出数字,没有则不输出 */ function formatNumber(number,pattern){ var str = number.toString(); var strInt; var strFloat; var formatInt; var formatFloat; if(/\./g.test(pattern)){ formatInt = pattern.split('.')[0]; formatFloat = pattern.split('.')[1]; }else{ formatInt = pattern; formatFloat = null; } if(/\./g.test(str)){ if(formatFloat!=null){ var tempFloat = Math.round(parseFloat('0.'+str.split('.')[1])*Math.pow(10,formatFloat.length))/Math.pow(10,formatFloat.length); strInt = (Math.floor(number)+Math.floor(tempFloat)).toString(); strFloat = /\./g.test(tempFloat.toString())?tempFloat.toString().split('.')[1]:'0'; }else{ strInt = Math.round(number).toString(); strFloat = '0'; } }else{ strInt = str; strFloat = '0'; } if(formatInt!=null){ var outputInt = ''; var zero = formatInt.match(/0*$/)[0].length; var comma = null; if(/,/g.test(formatInt)){ comma = formatInt.match(/,[^,]*/)[0].length-1; } var newReg = new RegExp('(\\d{'+comma+'})','g'); if(strInt.length0 && str.charAt(j-1)==" " ; j--) ; if(i>j) return ""; return str.substring(i,j); } function ExportExcel(gridPanel, config) { if (gridPanel) { var tmpStore = gridPanel.getStore(); var tmpExportContent = ''; //以下处理分页grid数据导出的问题,从服务器中获取所有数据,需要考虑性能 var tmpParam = Ext.ux.clone(tmpStore.lastOptions); //此处克隆了原网格数据源的参数信息 if (tmpParam && tmpParam.params) { delete (tmpParam.params[tmpStore.paramNames.start]); //删除分页参数 delete (tmpParam.params[tmpStore.paramNames.limit]); } var tmpAllStore = new Ext.data.GroupingStore({//重新定义一个数据源 proxy: tmpStore.proxy, reader: tmpStore.reader }); tmpAllStore.on('load', function (store) { config.store = store; tmpExportContent = gridPanel.getExcelXml(false, config); //此方法用到了一中的扩展 if (Ext.isIE || Ext.isSafari || Ext.isSafari2 || Ext.isSafari3) {//在这几种浏览器中才需要,IE8测试不能直接下载了 if (!Ext.fly('frmDummy')) { var frm = document.createElement('form'); frm.id = 'frmDummy'; frm.name = id; frm.className = 'x-hidden'; document.body.appendChild(frm); } Ext.Ajax.request({ //将生成的xml发送到服务器端,需特别注意这个页面的地址 url: '/CommMng/PubSys/ExportGrid', method: 'POST', form: Ext.fly('frmDummy'), callback: function (o, s, r) { //alert(r.responseText); }, isUpload: true, params: { ExportContent: tmpExportContent, ExportFile: gridPanel.id + '.xls' } }); } else { document.location = 'data:application/vnd.ms-excel;base64,' + Base64.encode(tmpExportContent); } }); tmpAllStore.load(tmpParam); //获取所有数据 } }; function GridExportExcelPage(grid) { var vExportContent = grid.getExcelXml(); if (Ext.isIE6 || Ext.isIE7 || Ext.isIE8 || Ext.isIE9 || Ext.isSafari || Ext.isSafari2 || Ext.isSafari3 || Ext.isChrome) { if (!Ext.fly('frmDummy')) { var frm = document.createElement('form'); frm.id = 'frmDummy'; frm.name = ''; //id; frm.className = 'x-hidden'; document.body.appendChild(frm); } Ext.Ajax.request({ url: '/CommMng/PubSys/ExportGrid', method: 'POST', form: Ext.fly('frmDummy'), callback: function (o, s, r) { //alert(r.responseText); }, isUpload: true, params: { ExportContent: Base64.encode(vExportContent), ExportFile: '导出数据.xls' } }); } else { document.location = 'data:application/vnd.ms-excel;base64,' + Base64.encode(vExportContent); } } function PrintComm(printType, sql1, sql2, sql3, sql4, sql5, sql6) { Ext.Msg.wait('正在准备打印数据, 请稍侯..'); Ext.Ajax.request({ waitMsg: '正在准备打印数据...', url: '/CommMng/Print/GetPrintInfo', scope: this, params: { type: printType, sql1: sql1, sql2: sql2, sql3: sql3, sql4: sql4, sql5: sql5, sql6: sql6 }, callback: function (options, success, response) { if (success) { Ext.MessageBox.hide(); var jsonresult = Ext.JSON.decode(response.responseText); if (jsonresult.Success) { var printUrl = "print://?comp=" + jsonresult.CompanyID + "&type=" + printType + "&dbid=" + jsonresult.DbSourceID + "&uid=" + jsonresult.UserId; //alert(printUrl); if (jsonresult.PrServer != NaN && jsonresult.PrServer != null && jsonresult.PrServer != "") printUrl = "print://?comp=" + jsonresult.CompanyID + "&type=" + printType + "&dbid=" + jsonresult.DbSourceID + "&uid=" + jsonresult.UserId + "&PrServer=" + jsonresult.PrServer + "&dbStr=" + jsonresult.dbStr; //alert(printUrl); window.location.href = window.location.href; location.href = printUrl; } else { Ext.Msg.show({ title: '错误', msg: jsonresult.Message, icon: Ext.Msg.ERROR, buttons: Ext.Msg.OK }); } } else { Ext.Msg.show({ title: '请重试', msg: '服务器响应出错', icon: Ext.Msg.ERROR, buttons: Ext.Msg.OK }); } } }); } function GridExportExcel(gridPanel, config) { if (!config) { config = { store: null, //因为后续可能需要处理分页,因此此处一般不直接传递GridPanel的数据源 title: '', //需要显示标题 limit: 4000 }; } if (gridPanel) { var tmpStore = gridPanel.getStore(); var vExportContent = ''; //以下处理分页grid数据导出的问题,从服务器中获取所有数据,需要考虑性能 var tmpParam = Ext.ux.constructor(tmpStore.lastOptions); //此处克隆了原网格数据源的参数信息 //alert(tmpParam.params[tmpStore.paramNames.limit]); //此处作者原先为Ext.ux.clone(tmpStore.lastOptions)方法,但不好使 var tmpAllStore = new Ext.data.GroupingStore({//重新定义一个数据源 proxy: tmpStore.proxy, reader: tmpStore.reader }); tmpParam.params[tmpStore.paramNames.limit] = config.limit; tmpAllStore.load(tmpParam); //获取所有数据 tmpAllStore.on('load', function (store) { config.store = store; vExportContent = gridPanel.getExcelXml(false, config); //此方法用到了一中的扩展 if (Ext.isIE6 || Ext.isIE7 || Ext.isIE8 || Ext.isSafari || Ext.isSafari2 || Ext.isSafari3) { if (!Ext.fly('frmDummy')) { var frm = document.createElement('form'); frm.id = 'frmDummy'; frm.name = id; frm.className = 'x-hidden'; document.body.appendChild(frm); } Ext.Ajax.request({ url: '/PubSys/ExportGrid', method: 'POST', form: Ext.fly('frmDummy'), callback: function (o, s, r) { }, isUpload: true, params: { ExportContent: Base64.encode(vExportContent), ExportFile: '导出数据.xls' } }); } else { document.location = 'data:application/vnd.ms-excel;base64,' + Base64.encode(vExportContent); } }); } }; Ext.define('WorkFlow_Step', { extend: 'Ext.data.Model', idProperty: 'id', fields: [ { name: 'GID', type: 'string' }, { name: 'NAME', type: 'string' }, { name: 'STEPNO', type: 'string' }, { name: 'ISLAST', type: 'string' } ] }); function GetWorkFlowStep(WorkflowID, USERID) { var storeWorkFlow_Step = Ext.create('Ext.data.Store', { model: 'WorkFlow_Stepmb', remoteSort: false, pruneModifiedRecords: true, proxy: { type: 'ajax', url: '/OA/BasicDataRef/GetWorkFlowStep', reader: { id: 'GID', root: 'data', totalProperty: 'totalCount' } } }); storeWorkFlow_Step.load({ params: { WorkflowID: WorkflowID, USERID: USERID} }); return storeWorkFlow_Step; }; Ext.define('WorkFlow_Usingmb', { extend: 'Ext.data.Model', idProperty: 'id', fields: [ { name: 'BSNO', type: 'string' }, { name: 'WORKFLOWID', type: 'string' }, { name: 'STEPNO', type: 'string' }, { name: 'REJECTOR_ID', type: 'string' }, { name: 'REJECT_TIME', type: 'string' }, { name: 'FINISHED', type: 'string' }, { name: 'ISDELETE', type: 'string' }, { name: 'DELETEUSER', type: 'string' }, { name: 'DELETETIME', type: 'string' } ] }); function GetWorkFlowCanDo(WorkflowID, StepNo, USERID) { var storeWorkFlow_Using = Ext.create('Ext.data.Store', { model: 'WorkFlow_Usingmb', remoteSort: false, pruneModifiedRecords: true, proxy: { type: 'ajax', url: '/OA/BasicDataRef/GetWorkFlowState', reader: { id: 'BSNO', root: 'data', totalProperty: 'totalCount' } } }); //WorkflowID, StepNo, USERID this.storeWorkFlow_Using.load({ params: { WorkflowID: WorkflowID, StepNo: parseInt(StepNo), USERID: USERID} }); }; //除法函数,用来得到精确的除法结果 //说明:javascript的除法结果会有误差,在两个浮点数相除的时候会比较明显。这个函数返回较为精确的除法结果。 //调用:accDiv(arg1,arg2) //返回值:arg1除以arg2的精确结果 function accDiv(arg1, arg2) { var t1 = 0, t2 = 0, r1, r2; try { t1 = arg1.toString().split(".")[1].length } catch (e) { } try { t2 = arg2.toString().split(".")[1].length } catch (e) { } with (Math) { r1 = Number(arg1.toString().replace(".", "")) r2 = Number(arg2.toString().replace(".", "")) return (r1 / r2) * pow(10, t2 - t1); } } //给Number类型增加一个div方法,调用起来更加方便。 Number.prototype.div = function (arg) { return accDiv(this, arg); } //乘法函数,用来得到精确的乘法结果 //说明:javascript的乘法结果会有误差,在两个浮点数相乘的时候会比较明显。这个函数返回较为精确的乘法结果。 //调用:accMul(arg1,arg2) //返回值:arg1乘以arg2的精确结果 function accMul(arg1, arg2) { var m = 0, s1 = arg1.toString(), s2 = arg2.toString(); try { m += s1.split(".")[1].length } catch (e) { } try { m += s2.split(".")[1].length } catch (e) { } return Number(s1.replace(".", "")) * Number(s2.replace(".", "")) / Math.pow(10, m) } //给Number类型增加一个mul方法,调用起来更加方便。 Number.prototype.mul = function (arg) { return accMul(arg, this); } //加法函数,用来得到精确的加法结果 //说明:javascript的加法结果会有误差,在两个浮点数相加的时候会比较明显。这个函数返回较为精确的加法结果。 //调用:accAdd(arg1,arg2) //返回值:arg1加上arg2的精确结果 function accAdd(arg1, arg2) { var r1, r2, m; try { r1 = arg1.toString().split(".")[1].length } catch (e) { r1 = 0 } try { r2 = arg2.toString().split(".")[1].length } catch (e) { r2 = 0 } m = Math.pow(10, Math.max(r1, r2)) return accDiv((accMul(arg1 , m) + accMul(arg2 , m)) , m) } //给Number类型增加一个add方法,调用起来更加方便。 Number.prototype.add = function (arg) { return accAdd(arg, this); } function Add(a, b, length) { if ((typeof (length) == undefined) || (length == null)) { length = 2; } var _r = parseFloat(a).add(parseFloat(b)).toFixed(parseInt(length)); return parseFloat(_r); } function Cut(a, b, length) { if ((typeof (length) == undefined) || (length == null)) { length = 2; } var _r = parseFloat(a).add(parseFloat(0) - parseFloat(b)).toFixed(parseInt(length)); return parseFloat(_r); } function Mul(a, b, length) { if ((typeof (length) == undefined) || (length == null)) { length = 2; } var _r = parseFloat(a).mul(parseFloat(b)) var _r2 = _r.toFixed(parseInt(length)); return parseFloat(_r2); } function Mul3(a, b, c, length) { if ((typeof (length) == undefined) || (length == null)) { length = 2; } var _r = (parseFloat(a).mul(parseFloat(b)).mul(parseFloat(c))).toFixed(parseInt(length)); return parseFloat(_r); } function Mul4(a, b, c, d, length) { if ((typeof (length) == undefined) || (length == null)) { length = 2; } var _r = (parseFloat(a).mul(parseFloat(b)).mul(parseFloat(c)).mul(parseFloat(d))).toFixed(parseInt(length)); return parseFloat(_r); } function Mul5(a, b, c, d, e, length) { if ((typeof (length) == undefined) || (length == null)) { length = 2; } var _r = (parseFloat(a).mul(parseFloat(b)).mul(parseFloat(c)).mul(parseFloat(d)).mul(parseFloat(e))).toFixed(parseInt(length)); return parseFloat(_r); } function Div(a, b, length) { if ((typeof (length) == undefined) || (length == null)) { length = 2; } var _r = parseFloat(a).div(parseFloat(b)).toFixed(parseInt(length)); return parseFloat(_r); } function newGuid() { var guid = ""; for (var i = 1; i <= 32; i++) { var n = Math.floor(Math.random() * 16.0).toString(16); guid += n; if ((i == 8) || (i == 12) || (i == 16) || (i == 20)) guid += "-"; } return guid.toUpperCase(); } function GetStatus(status) { if (status == 0) { return '审核通过'; } else if (status == 1) { return '录入状态'; } else if (status == 10) { return '申请融资'; } else if (status == 11) { return '融资完毕'; } else if (status == 2) { return '提交审核'; } else if (status == 3) { return '申请修改'; } else if (status == 4) { return '申请删除'; } else if (status == 5) { return '取消申请'; } else if (status == 6) { return '驳回提交'; } else if (status == 7) { return '驳回申请'; } else if (status == 8) { return '部分结算'; } else if (status == 9) { return '结算完毕'; } else return ""; }