let str = window.location.href.substr(window.location.href.indexOf('?') + 1) let json = new Object() const arr = str.split('&') for(let i = 0; i < arr.length; i++) { let item = arr[i].split('=') json[item[0]] = item[1] } var mixin={ methods:{ onmouseMove(){//屏幕鼠标移动循环播放 clearInterval(this.global.polling); this.global.polling=setInterval(()=>{ this.global.pollingIndex>=1?this.global.pollingIndex=0:this.global.pollingIndex++ this.$forceUpdate(); },this.global.timer)//根据自定义Vue全局变量进行操作 }, onmouseMove2(){//屏幕鼠标移动循环播放 clearInterval(this.global.polling); this.global.polling=setInterval(()=>{ this.global.pollingIndex>=2?this.global.pollingIndex=0:this.global.pollingIndex++ this.$forceUpdate(); },this.global.timer)//根据自定义Vue全局变量进行操作 }, async connects(gongneng,sql,flag,num){ let param = new URLSearchParams(); param.append("gongneng",gongneng); param.append("sql",sql); param.append("flag",flag); param.append("anquanma","anquanma1"); await this.$http.post( '../mysqlInsert/mysql.jsp',param) .then(function (response) { if(num==1){ result=response.data; index = result.indexOf("[["); if(index>-1){ if(result.indexOf("[[anquanmaerr]]")>-1){ //alert('请先登录后操作'); window.parent.location.href='../login/index.jsp'; }else{ result=result.substring(index).trim() alert(result); window.location.reload(); } }else{ alert(gongneng+"成功!") window.location.reload(); } } }) .catch(function (error) { alert('Error: ' + "服务器数据发生错误!"); }); }, async loadAjxss(gongneng,sql,flag,vals){ let param = new URLSearchParams(); param.append("yemian","123"); param.append("gongneng",gongneng); param.append("sql",sql); param.append("flag",flag); param.append("anquanma","anquanma1"); await this.$http.post( '../mysqlInsert/mysql.jsp',param) .then(function (response) { if(flag==2){ let result=response.data; let index = result.indexOf("[{"); //console.log('....'+index); if(index>-1){ result=result.substring(index).trim(); app.$data[vals]=JSON.parse(result); console.log(vals+":"); console.log(app.$data[vals]); }else if(result.indexOf("[[anquanmaerr]]")>-1){ //alert('请先登录后操作'); window.parent.location.href='../login/index.jsp'; } } }) .catch(function (error) { if(this.global.errorFlag==0){ this.global.errorFlag=1 alert('Error: ' + "服务器数据发生错误!") } }); }, async returnloadAjxss(parameter){//fa let param = new URLSearchParams(); param.append("yemian","123"); param.append("gongneng",parameter.gongneng); param.append("sql",parameter.sql); param.append("flag",parameter.flag); param.append("anquanma","anquanma1"); let results='' await this.$http.post( '../mysqlInsert/mysql.jsp',param) .then(function (response) { let result=response.data; let index = result.indexOf("[{"); if(index>-1){ result=result.substring(index).trim(); results=JSON.parse(result); console.log(parameter.vals+":"); console.log(results); }else if(result.indexOf("[[anquanmaerr]]")>-1){ //alert('请先登录后操作'); window.parent.location.href='../login/index.jsp'; } }) .catch(function (error) { if(this.global.errorFlag==0){ this.global.errorFlag=1 alert('Error: ' + "服务器数据发生错误!") } }); return results }, async interValLoadAjxs(gongneng,sql,flag,vals,timer){//定时器拿数据报错后清除定时器 let param = new URLSearchParams(); param.append("yemian","循环数据"); param.append("gongneng",gongneng); param.append("sql",sql); param.append("flag",flag); param.append("anquanma","anquanma1"); await this.$http.post( '../mysqlInsert/mysql.jsp',param) .then(function (response) { if(flag==2){ let result=response.data let index = result.indexOf("[{"); if(index>-1){ result=result.substring(index).trim(); app.$data[vals]=JSON.parse(result); //console.log(vals+":"); //console.log(app.$data[vals]); }else if(result.indexOf("[[anquanmaerr]]")>-1){ //alert('请先登录后操作'); window.parent.location.href='../login/index.jsp'; } } }) .catch( (error)=> { clearInterval(timer) if(this.global.errorFlag==0){ this.global.errorFlag=1 alert('Error: ' + "服务器数据发生错误!") window.location.reload() } // if(this.global.getTableDataTimer){ // clearInterval(this.global.getTableDataTimer) // } // if(this.global.getMachineElectricTimer){ // clearInterval(this.global.getMachineElectricTimer) // } // if(this.global.getMachineWaterTimer){ // clearInterval(this.global.getMachineWaterTimer) // } //alert('Error: ' + "服务器数据发生错误!") }); }, async getTableData(machineType){//大屏显示 查询订单数据 //this.global.getTableDataTimer= let getTableDataTimer=await setInterval(()=>{ let canshu={ machineType:machineType,//机器类型 } let sql="{call AXJ_a_largeScreen_order_machineType_select(?,?)}~"+JSON.stringify(canshu); this.interValLoadAjxs('表数据查询',sql,2,"tableData",getTableDataTimer) },5000) }, async getMachineElectric(machineType,group){//大屏显示 查询机器用电量 //this.global.getMachineElectricTimer= let getMachineElectricTimer=await setInterval(()=>{ let canshu={ machineType:machineType,//机器类型 group:group //电表组别 } let sql="{call AXJ_a_largeScreen_electric_select(?,?,?)}~"+JSON.stringify(canshu); this.interValLoadAjxs('大屏显示钻孔查询',sql,2,"machineElectric",getMachineElectricTimer) },5000) }, async getMachineWater(machineType,group){ //this.global.getMachineWaterTimer= let getMachineWaterTimer=await setInterval(()=>{ let canshu={ machineType:machineType,//机器类型 group:group //水表组别 } let sql="{call AXJ_a_largeScreen_water_select(?,?,?)}~"+JSON.stringify(canshu); this.interValLoadAjxs('大屏显示钻孔水表查询',sql,2,"machineWater",getMachineWaterTimer) },5000) } } } //gongneng:自定义,sql存储过程,flag标志(0,是用张工之前功能插入,1存储过程查询,2存储过程插入),vals:vue里data参数 function loadAjxs(gongneng,sql,flag,vals){ $.post("../mysqlInsert/mysql.jsp", {"yemian":"123","gongneng":gongneng,"sql":sql,'flag':flag,'anquanma':"anquanma1"}, function(result){ if(flag==2){ result=$(result).text(); index = result.indexOf("[{"); if(index>-1){ result=result.substring(index).trim(); app.$data[vals]=JSON.parse(result); console.log(vals+":"); console.log(app.$data[vals]); }else if(result.indexOf("[[anquanmaerr]]")>-1){ //alert('请先登录后操作'); window.parent.location.href='../login/index.jsp'; } } }) .fail(function(response) { alert('Error: ' + "服务器数据发生错误!"); }); }