From fedb07902d62aa40892a9c47ad7f3fd5ead30b37 Mon Sep 17 00:00:00 2001 From: zhangzengfei <zhangzengfei@smartai.com> Date: 星期一, 18 七月 2022 10:42:13 +0800 Subject: [PATCH] 添加数据上报应用 --- src/pages/dataReport/index/main.ts | 13 + src/pages/dataReport/index/App.vue | 369 ++++++++++++++++++++++++++++++++++++++++++++++ public/apps.json | 27 +++ src/pages/dataReport/index/api.ts | 32 ++++ 4 files changed, 439 insertions(+), 2 deletions(-) diff --git a/public/apps.json b/public/apps.json index f882d26..b533e04 100644 --- a/public/apps.json +++ b/public/apps.json @@ -162,7 +162,7 @@ "isUpgrade": false, "progressMsg": "" }, - + { "id": "f45474ee-70cf-4ed2-8a06-c17429fbb70a", "name": "缁熻鏌ヨ", @@ -645,8 +645,31 @@ "installed": true, "isUpgrade": false, "progressMsg": "" + }, + { + "id": "fa5674ee-70cf-4e22-2dr6-c17426fb737", + "name": "鏁版嵁浜ゆ崲", + "package": "dataReport", + "type": "2", + "url": "/view/dataReport/", + "title": "鏁版嵁浜ゆ崲", + "width": 810, + "height": 780, + "iconBlob": "", + "icon": "../../images/app-mid/visual.png", + "version": "1.0.0", + "create_time": "2020-10-09 14:00:08", + "create_by": "", + "update_time": "", + "update_by": "", + "isDelete": 0, + "isDefault": false, + "remoteVersion": "", + "installed": true, + "isUpgrade": false, + "progressMsg": "" } ], "msg": "璇锋眰澶勭悊鎴愬姛", "success": true -} \ No newline at end of file +} diff --git a/src/pages/dataReport/index/App.vue b/src/pages/dataReport/index/App.vue new file mode 100644 index 0000000..4af138f --- /dev/null +++ b/src/pages/dataReport/index/App.vue @@ -0,0 +1,369 @@ +<template> + <div class="s-system-manage"> + <div class="s-basic-setting"> + <el-tabs + id="e-basic-setting" + v-model="activeName" + v-loading="loading" + :element-loading-text="loadingText" + type="border-card" + @tab-click="hanleTabClick" + > + <el-tab-pane label="淇℃伅涓婃姤閰嶇疆" name="device"> + <div class="divider"> + 璁惧鍩虹淇℃伅 + </div> + <div style="width: 600px"> + <!-- 璁惧鍩虹淇℃伅璁剧疆 --> + <el-form :model="device" :rules="rules" label-width="80px" ref="device"> + <el-form-item label="璁惧ID" prop="devId"> + <el-input v-model="device.devId" placeholder="璇疯緭鍏�36浣峌UID" size="small"></el-input> + </el-form-item> + + <el-form-item label="璁惧缂栫爜" prop="code"> + <el-input v-model="device.code" placeholder="璇疯緭鍏ヨ澶囩紪鐮�" size="small"></el-input> + </el-form-item> + + <el-form-item label="鎵�灞炰紒涓�" prop="company"> + <el-input v-model="device.company" placeholder="璇疯緭鍏ヤ紒涓氬悕绉�" size="small"></el-input> + </el-form-item> + <el-form-item label="璁惧鍚嶇О" prop="name"> + <el-input v-model="device.name" placeholder="璇疯緭鍏ヨ澶囧悕绉�" size="small"></el-input> + </el-form-item> + <el-form-item label="璁惧鎻忚堪"> + <el-input type="textarea" v-model="device.desc" size="small"></el-input> + </el-form-item> + + <el-form-item style="text-align: right"> + <el-button type="primary" @click="submitDeviceInfo" size="small">淇濆瓨</el-button> + </el-form-item> + </el-form> + </div> + + <div class="divider"> + 鏇存柊棰戠巼閰嶇疆 + </div> + <div style="width: 600px"> + <!-- 鏇存柊棰戠巼閰嶇疆 --> + <el-form :model="device" ref="inteval"> + <el-form-item label="璁惧淇℃伅鏇存柊闂撮殧"> + <el-input + v-model.number="deviceInterval" + size="small" + style="width: 60px; margin-left: -300px;" + ></el-input> + <el-select + v-model="deviceUnit" + placeholder="璇烽�夋嫨" + size="small" + style="width: 80px" + @change="resetDevInterval" + > + <el-option v-for="item in intervalOptions" :key="item.value" :label="item.label" :value="item.value"> + </el-option> + </el-select> + </el-form-item> + + <el-form-item label="璁惧鐘舵�佹洿鏂伴棿闅�" prop="code"> + <el-input + v-model.number="stateInterval" + size="small" + style="width: 60px; margin-left: -300px;" + ></el-input> + <el-select + v-model="stateUnit" + placeholder="璇烽�夋嫨" + size="small" + style="width: 80px" + @change="resetStatInterval" + > + <el-option v-for="item in intervalOptions" :key="item.value" :label="item.label" :value="item.value"> + </el-option> + </el-select> + </el-form-item> + <el-form-item style="float: right"> + <el-button type="primary" @click="submitIntervalConfig" size="small">淇濆瓨</el-button> + </el-form-item> + </el-form> + </div> + </el-tab-pane> + + <!-- <el-tab-pane label="涓婃姤鏃ュ織鏌ヨ" name="logs" > </el-tab-pane> --> + </el-tabs> + </div> + </div> +</template> + +<script> +import { getDevInfo, setDevInfo, getInterval, setInterval } from "./api" + +import { isPort, isIPv4 } from "@/scripts/validate" +export default { + name: "dataReport", + directives: { + focus: { + inserted: function(el) { + el.querySelector("input").focus() + } + } + }, + + data() { + return { + activeName: "device", + loading: false, + loadingText: "", + device: {}, + deviceInterval: 0, + stateInterval: 0, + deviceUnit: 1, + stateUnit: 1, + rules: { + devId: [ + { + required: true, + message: "淇℃伅涓嶈兘涓虹┖", + trigger: "change" + }, + { trigger: "change" } + ], + code: [ + { + required: true, + message: "淇℃伅涓嶈兘涓虹┖", + trigger: "change" + }, + { trigger: "change" } + ], + company: [ + { + required: true, + message: "淇℃伅涓嶈兘涓虹┖", + trigger: "change" + }, + { trigger: "change" } + ], + name: [ + { + required: true, + message: "淇℃伅涓嶈兘涓虹┖", + trigger: "change" + }, + { trigger: "change" } + ] + }, + intervalOptions: [ + { + value: 1, + label: "鍒嗛挓" + }, + { + value: 60, + label: "灏忔椂" + }, + { + value: 1440, + label: "澶�" + } + ] + } + }, + watch: { + stateInterval(val, o) { + if (this.stateUnit == 1 && val > 60) { + this.stateInterval = 60 + } + + if (this.stateUnit == 60 && val > 24) { + this.stateInterval = 24 + } + }, + deviceInterval(val, o) { + if (this.deviceUnit == 1 && val > 60) { + this.deviceInterval = 60 + } + + if (this.deviceUnit == 60 && val > 24) { + this.deviceInterval = 24 + } + } + }, + mounted() { + this.initConf() + }, + methods: { + hanleTabClick(tab, event) { + if (this.activeName == "logs") { + } + }, + + initConf() { + getDevInfo().then((rsp) => { + if (rsp && rsp.success) { + if (rsp.data.id == "") { + rsp.data.id = "default" + } + this.device = rsp.data + } + }) + + getInterval().then((rsp) => { + if (rsp && rsp.success) { + let rspDevInteral = rsp.data.devInfo + let rspStatInteral = rsp.data.DevState + + if (rspDevInteral > 1440) { + this.deviceInterval = rspDevInteral / 1440 + this.deviceUnit = 1440 + } else if (rspDevInteral > 60) { + this.deviceInterval = rspDevInteral / 60 + this.deviceUnit = 60 + } else { + this.deviceInterval = rspDevInteral + this.deviceUnit = 1 + } + + if (rspStatInteral > 1440) { + this.stateInterval = rspStatInteral / 1440 + this.stateUnit = 1440 + } else if (rspStatInteral > 60) { + this.stateInterval = rspStatInteral / 60 + this.stateUnit = 60 + } else { + this.stateInterval = rspStatInteral + this.stateUnit = 1 + } + } + }) + }, + submitDeviceInfo() { + this.$refs["device"].validate((valid) => { + if (valid) { + setDevInfo(this.device).then((rsp) => { + if (rsp && rsp.success) { + this.$notify({ + type: "success", + message: "璁剧疆淇濆瓨鎴愬姛" + }) + this.initConf() + } + }) + } else { + console.log("error submit!!") + return false + } + }) + }, + submitIntervalConfig() { + let infoIntervalMin = this.deviceInterval * this.deviceUnit + let statIntervalMin = this.stateInterval * this.stateUnit + + setInterval({ id: "default", devInfo: infoIntervalMin, DevState: statIntervalMin }).then((rsp) => { + if (rsp && rsp.success) { + this.$notify({ + type: "success", + message: "璁剧疆淇濆瓨鎴愬姛" + }) + this.initConf() + } + }) + }, + + resetStatInterval() { + this.stateInterval = 1 + }, + resetDevInterval() { + this.deviceInterval = 1 + } + } +} +</script> +<style lang="scss"> +.s-system-manage { + width: 800px; + // min-width: 800px; + height: 100%; + box-sizing: border-box; + padding: 10px; + background-color: #f8f9fb; + .s-system-manage-breadcrumb { + height: 5%; + box-sizing: border-box; + border: 1px solid #e4e7ed; + box-shadow: #e4e7ed 0px 0px 9px inset; + box-shadow: #e4e7ed 0px 0px 9px inset; + border-radius: 5px; + } + + .el-tabs--border-card { + border: 0px solid #dcdfe6; + -webkit-box-shadow: none; + box-shadow: none; + .el-tabs__header { + border: 0px solid #dcdfe6; + .el-tabs__item { + padding: 5px 50px; + height: 50px; + font-family: PingFangSC-Regular; + font-size: 15px; + color: #222222; + text-align: center; + border: 0px solid transparent; + } + .el-tabs__item:nth-child(2) { + padding-left: 50px !important; + } + .el-tabs__item:last-child { + padding-right: 50px !important; + } + .el-tabs__item.is-active { + color: #3d68e1; + + // border-right-color: #fff; + // border-left-color: #fff; + } + .el-tabs__item:not(.is-disabled):hover { + color: #3d68e1; + } + } + } + .el-tabs__header { + margin-bottom: 0; + } + .el-tabs__content { + height: calc(100% - 64px); + box-sizing: border-box; + overflow-y: auto; + padding: 20px 40px !important; + background: #fff; + .el-tab-pane { + width: 100%; + .s-title { + text-align: left; + padding: 15px 0px; + font-size: 16px; + } + } + } + + .s-table { + border: 1px solid #e8e8e9; + margin-top: 40px; + } + + .el-button--text { + color: #3d68e1; + text-decoration: underline; + } + + .divider { + height: 30px; + background-color: #eceaf5; + color: black; + text-align: left; + font-weight: 600; + line-height: 30px; + padding: 0 10px; + } +} +</style> diff --git a/src/pages/dataReport/index/api.ts b/src/pages/dataReport/index/api.ts new file mode 100644 index 0000000..411cf41 --- /dev/null +++ b/src/pages/dataReport/index/api.ts @@ -0,0 +1,32 @@ +import request from "@/scripts/httpRequest" + +export const getDevInfo = () => { + return request({ + url: "/data/api-v/report/getDevInfo", + method: "get" + }) +} + +export const setDevInfo = (query: any) => { + return request({ + url: "/data/api-v/report/setDevInfo", + method: "post", + data: query + }) +} + +export const getInterval = (query: any) => { + return request({ + url: "/data/api-v/report/getInterval", + method: "get", + params: query + }) +} + +export const setInterval = (query: any) => { + return request({ + url: "/data/api-v/report/setInterval", + method: "post", + data: query + }) +} diff --git a/src/pages/dataReport/index/main.ts b/src/pages/dataReport/index/main.ts new file mode 100644 index 0000000..c5ec2c2 --- /dev/null +++ b/src/pages/dataReport/index/main.ts @@ -0,0 +1,13 @@ +import Vue from 'vue'; +import App from './App.vue'; + + +import ElementUI from 'element-ui'; +import 'element-ui/lib/theme-chalk/index.css'; +import "@/assets/css/element-variables.scss"; +Vue.use(ElementUI) + +new Vue({ + el: '#app', + render: h => h(App) +}) -- Gitblit v1.8.0