Browse Source

智能居家

znjj
lzp 4 months ago
parent
commit
f3c98ea020
  1. 4
      .env.development
  2. 2
      .env.production
  3. 2
      .env.staging
  4. 2
      package.json
  5. 119
      src/views/index.vue
  6. 2
      src/views/login.vue
  7. 2
      src/views/register.vue
  8. 2
      vue.config.js

4
.env.development

@ -1,10 +1,10 @@
# 页面标题
VUE_APP_TITLE = 智能水温控制系统
VUE_APP_TITLE = 智能居家数据监护
# 开发环境配置
ENV = 'development'
# 智能水温控制系统/开发环境
# 智能居家数据监护/开发环境
VUE_APP_BASE_API = '/dev-api'
VUE_APP_IMG_URL = 'https://test.tall.wiki/commen/'
VUE_APP_API_QZURL = 'https://test.tall.wiki/commen/'

2
.env.production

@ -1,5 +1,5 @@
# 页面标题
VUE_APP_TITLE = 智能水温控制系统
VUE_APP_TITLE = 智能居家数据监护
# 生产环境配置
NODE_ENV = 'production'

2
.env.staging

@ -1,5 +1,5 @@
# 页面标题
VUE_APP_TITLE = 智能水温控制系统
VUE_APP_TITLE = 智能居家数据监护
# 生产环境配置
NODE_ENV = 'production'

2
package.json

@ -1,7 +1,7 @@
{
"name": "ruoyi",
"version": "3.8.9",
"description": "智能水温控制系统",
"description": "智能居家数据监护",
"author": "若依",
"license": "MIT",
"scripts": {

119
src/views/index.vue

@ -1,40 +1,36 @@
<template>
<div v-loading="loading"
style="padding: 16px;min-height: calc(100vh - 84px);display: flex; justify-content: center;align-items: center;">
<div style="padding: 16px;min-height: calc(100vh - 84px);display: flex; justify-content: center;align-items: center;">
<div class="div-box">
<div class="div-box-title"> 智能水温控制系统 </div>
<div class="div-box-title"> 智能居家数据监护 </div>
<div class="div-ul">
<div class="div-li">
<div>
<span>当前温度</span>{{ deviceInfo.temperature }}
<span>温度</span>22.2
</div>
<div>
<span>报警器</span>
<el-switch disabled v-model="value2" active-color="#13ce66" inactive-color="#ff4949">
</el-switch>
<div> <span>湿度</span>50%
</div>
</div>
<!-- ON开启 OFF关闭 -->
<div class="div-li">
<div>
<span>加热器</span>
<el-switch disabled v-model="value2" active-color="#13ce66" inactive-color="#ff4949">
</el-switch>
<span>CO</span>5PPM
</div>
<div class="div-tips">
<span>温度阈值设定</span>{{ deviceInfo.threshold }} <i class="el-icon-edit"
style="color: rgb(64, 158, 255);margin-left: 4px;cursor: pointer;" @click="handleSettings"></i>
<div>
<span>预警</span>
<el-switch v-model="value2" active-color="#13ce66" inactive-color="#ff4949">
</el-switch>
</div>
</div>
</div>
<div class="div-tips"><span>阈值设定</span>30 <i class="el-icon-edit"
style="color: rgb(64, 158, 255);margin-left: 4px;cursor: pointer;" @click="handleSettings"></i></div>
</div>
<!-- 添加或修改公告对话框 -->
<el-dialog title="温度阈值设定" :visible.sync="open" width="780px" append-to-body>
<el-dialog title="阈值设定" :visible.sync="open" width="780px" append-to-body>
<el-form ref="form" :model="form" :rules="rules" label-width="80px">
<el-form-item label="阈值" prop="threshold">
<el-input v-model="form.threshold" placeholder="请输入阈值" />
<el-form-item label="阈值" prop="noticeTitle">
<el-input v-model="form.noticeTitle" placeholder="请输入阈值" />
</el-form-item>
</el-form>
<div slot="footer" class="dialog-footer">
@ -46,103 +42,45 @@
</template>
<script>
import { queryProjectInfoByKey, deviceList, attributes, sendAttribute, sendCommand } from "@/api/school";
import { updateNotice } from "@/api/system/notice";
export default {
name: "Index",
data() {
return {
deviceId: "", // id
deviceInfo: {
temperature: 0, //
threshold: 0, //
},
open: false,
value2: false,
loading: false,
//
form: {},
//
rules: {
threshold: [
{ required: true, message: "阈值不能为空", trigger: "blur" }
noticeTitle: [
{ required: true, message: "公告标题不能为空", trigger: "blur" }
],
noticeType: [
{ required: true, message: "公告类型不能为空", trigger: "change" }
]
},
//
version: "3.8.9",
};
},
created() {
this.getqueryProjectInfoByKey() // keyid
},
methods: {
//
//
handleSettings() {
this.open = true;
this.form = {
threshold: this.deviceInfo.threshold,
noticeTitle: "30",
};
// this.$message.success('');
},
// keyid
getqueryProjectInfoByKey() {
this.loading = true;
queryProjectInfoByKey({
projectKey: "qKStHKKt"
}).then(res => {
this.getDeviceList(res.data.id) // id
});
},
// id
getDeviceList(_id) {
deviceList({
projectId: _id
}).then(res => {
const w2Device = res.rows.find(device => device.deviceName === "W2");
this.deviceId = w2Device.id;
this.getAttributes(this.deviceId); // id
})
},
// id
getAttributes(_id) {
attributes({
deviceId: _id,
}).then(res => {
this.loading = false;
// deviceInfo
let deviceAttributeRecordList = res.data.deviceAttributeRecordList
let temperature = deviceAttributeRecordList.find(row => row.id === 447236074165760).attributeValue;
let threshold = deviceAttributeRecordList.find(row => row.id === 447236078508288).attributeValue;
// threshold
if (threshold.indexOf("#") !== -1) {
threshold = threshold.slice(1); // #
}
this.deviceInfo = {
temperature: temperature,
threshold: threshold,
}
//
this.value2 = false;
if (temperature < threshold) {
this.value2 = true;
}
});
},
/** 下发属性 */
submitForm: function () {
/** 提交按钮 */
submitForm: function() {
this.$refs["form"].validate(valid => {
if (valid) {
let param = {"Wen":`#${this.form.threshold}`} //
sendAttribute({
"attributeParams": JSON.stringify(param), // JSON
"deviceId": this.deviceId // id
}).then(response => {
this.getAttributes(this.deviceId); // id
updateNotice(this.form).then(response => {
this.$modal.msgSuccess("操作成功");
this.open = false;
this.getList();
});
}
});
@ -153,7 +91,6 @@ export default {
<style scoped lang="scss">
.div-box {
transform: scale(1.4);
width: 500px;
box-sizing: border-box;
padding: 16px;
@ -193,10 +130,6 @@ export default {
}
}
.div-li:last-child {
margin-bottom: 0;
}
.div-tips {
font-size: 18px;
line-height: 22px;

2
src/views/login.vue

@ -8,7 +8,7 @@
>
<h3 class="title" style="margin-bottom: 0">
</h3>
<h3 class="title">智能水温控制系统</h3>
<h3 class="title">智能居家数据监护</h3>
<el-form-item prop="username">
<el-input
v-model="loginForm.username"

2
src/views/register.vue

@ -6,7 +6,7 @@
:rules="registerRules"
class="register-form"
>
<h3 class="title">智能水温控制系统</h3>
<h3 class="title">智能居家数据监护</h3>
<el-form-item prop="username">
<el-input
v-model="registerForm.username"

2
vue.config.js

@ -8,7 +8,7 @@ function resolve(dir) {
const CompressionPlugin = require("compression-webpack-plugin");
const name =
process.env.VUE_APP_TITLE || "智能水温控制系统"; // 网页标题
process.env.VUE_APP_TITLE || "智能居家数据监护"; // 网页标题
const port = process.env.port || process.env.npm_config_port || 80; // 端口

Loading…
Cancel
Save