From e63ee924d43a7ffe1424561ef4152e94f3d0bd23 Mon Sep 17 00:00:00 2001 From: "CSSC-WORK\\murmur" Date: Mon, 1 Jul 2024 17:30:56 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0table-view=E6=95=88=E6=9E=9C?= =?UTF-8?q?=20=E6=B7=BB=E5=8A=A0=E7=8B=AC=E7=AB=8Bbar.json?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- main.aardio | 14 ++++ res/bar.json | 91 +++++++++++++++++++++++++ res/cfg.json | 187 +++++++++++++++++++++++++++++++++++++++++++++++---- 3 files changed, 280 insertions(+), 12 deletions(-) create mode 100644 res/bar.json diff --git a/main.aardio b/main.aardio index 71b718e..e91669e 100644 --- a/main.aardio +++ b/main.aardio @@ -121,6 +121,10 @@ getStatus = function(){ return {state={math.random(-1,1),math.random(-1,1),math.random(-1,1)}}; } +loadSchema = function(s){ + var jsonstr = string.load("/res/"++s++".json"); + return web.json.parse(jsonstr); +} import wsock.tcp.asynHttpServer; @@ -129,6 +133,16 @@ var httpServer = wsock.tcp.asynHttpServer(); httpServer.run( //此处添加函数 + ["/loadSchema"] = function(response,request){ + //console.varDump(request) + var data = request.get["schema"];//读取表单请求发送的数据,已解析为 aardio 对象 + var rst = loadSchema(data) + + response.write({ + "status": 0, + "data": rst + }) + }; ["/sendPair"] = function(response,request){ //console.varDump(request) diff --git a/res/bar.json b/res/bar.json new file mode 100644 index 0000000..44506d9 --- /dev/null +++ b/res/bar.json @@ -0,0 +1,91 @@ + { + "type": "table-view", + "trs": [ + { + "background": "#F7F7F7", + "tds": [ + { + "body": { + "type": "tpl", + "wrapperComponent": "", + "tpl": "模块", + "id": "u:19f87144bbea" + }, + "id": "u:fddabc45cb59", + "align": "center", + "valign": "middle" + }, + { + "body": { + "type": "tpl", + "wrapperComponent": "", + "tpl": "最后一分钟状态", + "id": "u:420e9a9f9353" + }, + "id": "u:6ffa039534e7", + "align": "center", + "valign": "middle" + }, + { + "body": { + "type": "tpl", + "wrapperComponent": "", + "tpl": "最近一次状态", + "id": "u:2dfafcf526f9" + }, + "id": "u:fe0dab630536", + "align": "center", + "valign": "middle" + } + ], + "id": "u:37a706fd866d" + }, + { + "tds": [ + { + "body": { + "type": "tpl", + "wrapperComponent": "", + "tpl": "TT", + "id": "u:518882ea6114" + }, + "id": "u:897aee319eb4", + "align": "center", + "valign": "middle" + }, + { + "body": { + "type": "each", + "name": "items", + "items": { + "type": "tpl", + "tpl": "
", + "style": { + "display": "inline-block", + "marginRight": "5px", + "marginBottom": "-5px" + } + } + }, + "id": "u:4804d1216011", + "width": "80%", + "align": "center", + "valign": "middle" + }, + { + "body": { + "type": "tpl", + "wrapperComponent": "", + "tpl": "
", + "id": "u:20d501a115fc" + }, + "id": "u:ba272dd0e407", + "align": "center", + "valign": "middle" + } + ], + "id": "u:42c47c152e5f" + } + ], + "id": "u:18e5f253165a" + } \ No newline at end of file diff --git a/res/cfg.json b/res/cfg.json index 9a7b6a0..d297689 100644 --- a/res/cfg.json +++ b/res/cfg.json @@ -149,8 +149,29 @@ { "type": "switch", "label": "天通", - "option": "说明", - "name": "switch", + "mode": "inline", + "name": "switchTT", + "falseValue": false, + "trueValue": true, + "id": "u:bd2f8c0b2176", + "onEvent": { + "change": { + "weight": 0, + "actions": [ + { + "ignoreError": false, + "actionType": "custom", + "script": "const buttonText = context.props.label + (!context.props.value?'开':'关');\ndoAction({\n actionType: 'ajax',\n args: {\n api: {\n url: '/sendData',\n method: 'post',\n data: {\n buttonLabel: buttonText\n },\n successMessage: '请求成功',\n errorMessage: '请求失败'\n }\n }\n});\n" + } + ] + } + } + }, + { + "type": "switch", + "label": "超短波", + "mode": "inline", + "name": "switchCDB", "falseValue": false, "trueValue": true, "id": "u:bd2f8c0b2176", @@ -177,41 +198,183 @@ { "type": "service", "interval": 1500, // 每1.5秒刷新一次 - silentPolling: true + "silentPolling": true, "api": "/api/getStatus", // API接口 "data": { "maxBarCnt":"60", "width":"5px", "height":"30px", + "powerdown":"#808080", + "alive":"#00ff00", + "dead":"#ff0000", "items": [ - //{"color": "#808080"}, - //{"color": "#808080"}, - //{"color": "#808080"}, - //{"color": "#808080"}, + {"color": ["${powerdown}","${powerdown}","${powerdown}"]}, + {"color": ["${powerdown}","${powerdown}","${powerdown}"]}, + {"color": ["${powerdown}","${powerdown}","${powerdown}"]}, + {"color": ["${powerdown}","${powerdown}","${powerdown}"]}, + {"color": ["${powerdown}","${powerdown}","${powerdown}"]}, + {"color": ["${powerdown}","${powerdown}","${powerdown}"]}, + {"color": ["${powerdown}","${powerdown}","${powerdown}"]}, + {"color": ["${powerdown}","${powerdown}","${powerdown}"]}, + {"color": ["${powerdown}","${powerdown}","${powerdown}"]}, + {"color": ["${powerdown}","${powerdown}","${powerdown}"]}, + {"color": ["${powerdown}","${powerdown}","${powerdown}"]}, + {"color": ["${powerdown}","${powerdown}","${powerdown}"]}, + {"color": ["${powerdown}","${powerdown}","${powerdown}"]}, + {"color": ["${powerdown}","${powerdown}","${powerdown}"]}, + {"color": ["${powerdown}","${powerdown}","${powerdown}"]}, + {"color": ["${powerdown}","${powerdown}","${powerdown}"]}, + {"color": ["${powerdown}","${powerdown}","${powerdown}"]}, + {"color": ["${powerdown}","${powerdown}","${powerdown}"]}, + {"color": ["${powerdown}","${powerdown}","${powerdown}"]}, + {"color": ["${powerdown}","${powerdown}","${powerdown}"]}, + {"color": ["${powerdown}","${powerdown}","${powerdown}"]}, + {"color": ["${powerdown}","${powerdown}","${powerdown}"]}, + {"color": ["${powerdown}","${powerdown}","${powerdown}"]}, + {"color": ["${powerdown}","${powerdown}","${powerdown}"]}, + {"color": ["${powerdown}","${powerdown}","${powerdown}"]}, + {"color": ["${powerdown}","${powerdown}","${powerdown}"]}, + {"color": ["${powerdown}","${powerdown}","${powerdown}"]}, + {"color": ["${powerdown}","${powerdown}","${powerdown}"]}, + {"color": ["${powerdown}","${powerdown}","${powerdown}"]}, + {"color": ["${powerdown}","${powerdown}","${powerdown}"]}, + {"color": ["${powerdown}","${powerdown}","${powerdown}"]}, + {"color": ["${powerdown}","${powerdown}","${powerdown}"]}, + {"color": ["${powerdown}","${powerdown}","${powerdown}"]}, + {"color": ["${powerdown}","${powerdown}","${powerdown}"]}, + {"color": ["${powerdown}","${powerdown}","${powerdown}"]}, + {"color": ["${powerdown}","${powerdown}","${powerdown}"]}, + {"color": ["${powerdown}","${powerdown}","${powerdown}"]}, + {"color": ["${powerdown}","${powerdown}","${powerdown}"]}, + {"color": ["${powerdown}","${powerdown}","${powerdown}"]}, + {"color": ["${powerdown}","${powerdown}","${powerdown}"]}, + {"color": ["${powerdown}","${powerdown}","${powerdown}"]}, + {"color": ["${powerdown}","${powerdown}","${powerdown}"]}, + {"color": ["${powerdown}","${powerdown}","${powerdown}"]}, + {"color": ["${powerdown}","${powerdown}","${powerdown}"]}, + {"color": ["${powerdown}","${powerdown}","${powerdown}"]}, + {"color": ["${powerdown}","${powerdown}","${powerdown}"]}, + {"color": ["${powerdown}","${powerdown}","${powerdown}"]}, + {"color": ["${powerdown}","${powerdown}","${powerdown}"]}, + {"color": ["${powerdown}","${powerdown}","${powerdown}"]}, + {"color": ["${powerdown}","${powerdown}","${powerdown}"]}, + {"color": ["${powerdown}","${powerdown}","${powerdown}"]}, + {"color": ["${powerdown}","${powerdown}","${powerdown}"]}, + {"color": ["${powerdown}","${powerdown}","${powerdown}"]}, + {"color": ["${powerdown}","${powerdown}","${powerdown}"]}, + {"color": ["${powerdown}","${powerdown}","${powerdown}"]}, + {"color": ["${powerdown}","${powerdown}","${powerdown}"]}, + {"color": ["${powerdown}","${powerdown}","${powerdown}"]}, + {"color": ["${powerdown}","${powerdown}","${powerdown}"]}, + {"color": ["${powerdown}","${powerdown}","${powerdown}"]}, + {"color": ["${powerdown}","${powerdown}","${powerdown}"]}, ] }, - "body": [ + //"schemaApi": "/loadSchema?schema=bar" + "body":[ + { + "type": "table-view", + "trs": [ + { + "background": "#F7F7F7", + "tds": [ { + "body": { + "type": "tpl", + "wrapperComponent": "", + "tpl": "模块", + "id": "u:19f87144bbea" + }, + "id": "u:fddabc45cb59", + "align": "center", + "valign": "middle" + }, + { + "body": { + "type": "tpl", + "wrapperComponent": "", + "tpl": "最后一分钟状态", + "id": "u:420e9a9f9353" + }, + "id": "u:6ffa039534e7", + "align": "center", + "valign": "middle" + }, + { + "body": { + "type": "tpl", + "wrapperComponent": "", + "tpl": "最近一次状态", + "id": "u:2dfafcf526f9" + }, + "id": "u:fe0dab630536", + "align": "center", + "valign": "middle" + } + ], + "id": "u:37a706fd866d" + }, + { + "tds": [ + { + "body": { + "type": "tpl", + "wrapperComponent": "", + "tpl": "TT", + "id": "u:518882ea6114" + }, + "id": "u:897aee319eb4", + "align": "center", + "valign": "middle" + }, + { + "body": { "type": "each", "name": "items", "items": { "type": "tpl", - "tpl": "


", + "tpl": "
", "style": { "display": "inline-block", "marginRight": "5px", - "marginBottom": "5px" + "marginBottom": "-5px" } } } + "id": "u:4804d1216011", + "width": "80%", + "align": "center", + "valign": "middle" + }, + { + "body": { + "type": "tpl", + "wrapperComponent": "", + "tpl": "
", + "id": "u:20d501a115fc" + }, + "id": "u:ba272dd0e407", + "align": "center", + "valign": "middle" + } ], + "id": "u:42c47c152e5f" + }, + +], + "id": "u:18e5f253165a" +} + + ] + , "onEvent": { "fetchInited": { "actions": [ { "actionType": "custom", - "script": "const colorMap=['#808080','#ff0000','#00ff00'];\n const ncolor = [colorMap[event.data.responseData.state[0]+1],colorMap[event.data.responseData.state[1]+1],colorMap[event.data.responseData.state[2]+1]];\n console.log(event.data.responseData.state,ncolor);\ncontext.props.data.items.push({'color':ncolor})\nif (context.props.data.items.length > context.props.data.maxBarCnt) {\n context.props.data.items.shift(); // Remove the oldest value\n};" - } + "script": "const colorMap=[context.props.data.powerdown,context.props.data.dead,context.props.data.alive];\n const ncolor = [colorMap[event.data.responseData.state[0]+1],colorMap[event.data.responseData.state[1]+1],colorMap[event.data.responseData.state[2]+1]];\n console.log(event.data.responseData.state,ncolor);\ncontext.props.data.items.push({'color':ncolor})\nif (context.props.data.items.length > context.props.data.maxBarCnt) {\n context.props.data.items.shift(); // Remove the oldest value\n};" + }, + ] } }