From 8a2e9b1684e59d31cfbed96d8e278c1e496d7e09 Mon Sep 17 00:00:00 2001 From: liuwu <975499773@qq.com> Date: Fri, 11 Aug 2023 11:19:56 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E6=97=B6=E9=97=B4=E6=A0=A1?= =?UTF-8?q?=E5=87=86=E9=A1=B5=E9=9D=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pages/main.stml | 85 ++++++++++++++++++---------------- pages/main/fixTime.stml | 100 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 146 insertions(+), 39 deletions(-) create mode 100644 pages/main/fixTime.stml diff --git a/pages/main.stml b/pages/main.stml index 63aaf11..b834370 100644 --- a/pages/main.stml +++ b/pages/main.stml @@ -20,6 +20,8 @@ 设置 操作历史 + 时间校准 + {{currTime}} @@ -35,7 +37,7 @@ export default { listData:[], stopRead:true, sendStatus:true, - dianliuInte:null, + // dianliuInte:null, jidianqiInte:null, dianliu1:null, dianliu2:null, @@ -43,11 +45,17 @@ export default { dianliu4:null, map:new Map(), mapBefore:new Map(), + currTime:null }; }, //初始化 apiready(){ const vm = this + setInterval(function () { + setTimeout(function () { + vm.data.currTime = vm.currTimeFns(new Date()); + }, 0) + }, 1000); api.addEventListener({ name: 'myEvent' }, function(ret, err) { @@ -68,7 +76,6 @@ export default { initAll(){ const vm = this clearInterval(vm.data.jidianqiInte) - clearInterval(vm.data.dianliuInte) clearInterval(vm.data.dianliu1) clearInterval(vm.data.dianliu2) clearInterval(vm.data.dianliu3) @@ -98,12 +105,16 @@ export default { url:'./main/history.stml' }) }, + // 时间校准 + fixTime(){ + api.openWin({ + name: 'fixTime', + url:'./main/fixTime.stml' + }) + }, //创建设备表 initSb(db) { const vm = this; - // const uniqueId = 'id-' + new Date().getTime().toString(36) + '-' + Math.random().toString(36).substr(2, 9); - // dbUtils.execute(db, "INSERT INTO Sb (id,circuitName,current,typeName,isTypeOpen) VALUES ('"+uniqueId+"','test1','lw','"+vm.currTimeFn(new Date())+"','test');", function(ret, err) { - // }) dbUtils.select(db, 'SELECT * FROM Sb', function(ret, err) { var data = ret.data; if(undefined != data && data.length > 0){ @@ -117,10 +128,10 @@ export default { if (ret.status == false || err.status == false) { dbUtils.execute(db, 'CREATE TABLE Sb(id varchar(50), sbId varchar(10), circuitName varchar(50), current varchar(20), typeName varchar(30),isTypeOpen int(10))', function(ret, err) { if (ret.status == true) { - dbUtils.execute(db, "INSERT INTO Sb (Id,sbId,circuitName,current,typeName,isTypeOpen) VALUES ('1','0B','1','3.21','高压风冷',1);", function(ret, err) {}) - dbUtils.execute(db, "INSERT INTO Sb (Id,sbId,circuitName,current,typeName,isTypeOpen) VALUES ('2','0C','2','3.21','中压风冷',1);", function(ret, err) {}) - dbUtils.execute(db, "INSERT INTO Sb (Id,sbId,circuitName,current,typeName,isTypeOpen) VALUES ('3','0D','3','3.21','低压风冷',1);", function(ret, err) {}) - dbUtils.execute(db, "INSERT INTO Sb (Id,sbId,circuitName,current,typeName,isTypeOpen) VALUES ('4','0E','4','3.21','闭锁调压',1);", function(ret, err) {}) + dbUtils.execute(db, "INSERT INTO Sb (Id,sbId,circuitName,current,typeName,isTypeOpen) VALUES ('1','0B','1','3','高压风冷',1);", function(ret, err) {}) + dbUtils.execute(db, "INSERT INTO Sb (Id,sbId,circuitName,current,typeName,isTypeOpen) VALUES ('2','0C','2','3','中压风冷',1);", function(ret, err) {}) + dbUtils.execute(db, "INSERT INTO Sb (Id,sbId,circuitName,current,typeName,isTypeOpen) VALUES ('3','0D','3','3','低压风冷',1);", function(ret, err) {}) + dbUtils.execute(db, "INSERT INTO Sb (Id,sbId,circuitName,current,typeName,isTypeOpen) VALUES ('4','0E','4','3','闭锁调压',1);", function(ret, err) {}) console.log('创建设备表成功'); vm.initAll() } @@ -157,7 +168,6 @@ export default { serialPortUtil.closeSerial({ index: 0 }); serialPortUtil.openSerial({ index: 0, port: '/dev/ttyS0', baudRate: '9600'}, function (ret, err) {}) serialPortUtil.addEventListener({ index: 0, revType: 'hex', stopBits:1, flowCon:2 }, function (ret, err) { - // console.log(JSON.stringify(ret)); var data = vm.data.listData; var leng = data.length; if (ret.dataHex.startsWith("FE0101") && ret.dataHex.length > 8) { @@ -166,7 +176,6 @@ export default { jidianqi = parseInt(jidianqi, 16).toString(2); vm.data.jidianqi = vm.forJidianqi(jidianqi); jidianqi = vm.data.jidianqi; - // console.log("************main:"+jidianqi+"************"); vm.data.mapBefore.set("0B",jidianqi[3] === '1'); vm.data.mapBefore.set("0C",jidianqi[2] === '1'); @@ -254,20 +263,12 @@ export default { if(vm.data.stopRead){ vm.sendMsg('FE 01 00 00 00 08 29 C3'); } - },2000) - - // var cmdArr = []; - // vm.data.listData.forEach(s=>{ - // var cmd = s.sbId+" 03 00 48 00 02"; - // cmd = cmd + " " + CrcUt.GetCrc(cmd); - // cmdArr.push(cmd); - // }) + },1000) api.showProgress({ title: '正在初始化...', text: '请稍后...', modal: true }); - vm.data.dianliu1=setInterval(function () { if(vm.data.stopRead){ vm.data.stopRead = false @@ -278,7 +279,7 @@ export default { }, 80); }, 50); } - },500) + },250) vm.data.dianliu2=setInterval(function () { if(vm.data.stopRead){ vm.data.stopRead = false @@ -289,7 +290,7 @@ export default { }, 80); }, 50); } - },1000) + },500) vm.data.dianliu3=setInterval(function () { if(vm.data.stopRead){ vm.data.stopRead = false @@ -300,7 +301,7 @@ export default { }, 80); }, 50); } - },1500) + },750) vm.data.dianliu4=setInterval(function () { if(vm.data.stopRead){ vm.data.stopRead = false @@ -311,22 +312,10 @@ export default { }, 80); }, 50); } - },2000) - - // vm.data.dianliuInte=setInterval(function () { - // vm.data.listData.forEach(s=>{ - // var cmd = s.sbId+" 03 00 48 00 02"; - // cmd = cmd + " " + CrcUt.GetCrc(cmd); - // if(vm.data.sendStatus && vm.data.stopRead){ - // vm.data.sendStatus = false - // vm.sendMsg(cmd) - // console.log(cmd); - // } - // }) - // }, 2000); + },1000) setTimeout(() => { api.hideProgress(); - }, 3000); + }, 2000); }, sendMsg(cmd){ let ret = serialPortUtil.send({ @@ -419,6 +408,15 @@ export default { let _seconds = _date.getSeconds() < 10 ? '0' + _date.getSeconds() : _date.getSeconds(); // return _year + "." + _month + "." + _day + " " + _hour + ":" + _minutes + ":" + _seconds; return _year + "." + _month + "." + _day + " " + _hour + ":" + _minutes; + }, + currTimeFns(_date) { + let _year = _date.getFullYear(); + let _month = _date.getMonth() + 1 < 10 ? '0' + (_date.getMonth() + 1) : _date.getMonth() + 1; + let _day = _date.getDate() < 10 ? '0' + _date.getDate() : _date.getDate(); + let _hour = _date.getHours() < 10 ? '0' + _date.getHours() : _date.getHours(); + let _minutes = _date.getMinutes() < 10 ? '0' + _date.getMinutes() : _date.getMinutes(); + let _seconds = _date.getSeconds() < 10 ? '0' + _date.getSeconds() : _date.getSeconds(); + return _year + "." + _month + "." + _day + " " + _hour + ":" + _minutes + ":" + _seconds; } } }; @@ -525,7 +523,7 @@ export default { margin: 0 10px; } .index_footer{ - width: 80%; + width: 100%; margin: 50px auto 0; display: flex; flex-direction: row; @@ -534,6 +532,7 @@ export default { .footer_set{ font-size: 40px; font-weight: bold; + margin-left: 20px; box-sizing: border-box; padding: 10px 20px; color: #ffffff; @@ -541,7 +540,15 @@ export default { .footer_history{ font-size: 40px; font-weight: bold; - margin-left: 50px; + margin-left: 20px; + box-sizing: border-box; + padding: 10px 20px; + color: #ffffff; +} +.currTime{ + font-size: 30px; + font-weight: bold; + margin-left: 100px; box-sizing: border-box; padding: 10px 20px; color: #ffffff; diff --git a/pages/main/fixTime.stml b/pages/main/fixTime.stml new file mode 100644 index 0000000..8cf2876 --- /dev/null +++ b/pages/main/fixTime.stml @@ -0,0 +1,100 @@ + + + \ No newline at end of file