Browse Source

同步框架修改

znhyg
lzp 4 months ago
parent
commit
1e88a95628
  1. 151
      src/views/index.vue

151
src/views/index.vue

@ -1,151 +1,48 @@
<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">
<span>除湿</span>
<el-switch v-model="value2" active-color="#13ce66" inactive-color="#ff4949">
</el-switch>
</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>AE0B01 </div>
</div>
<!-- 添加或修改公告对话框 -->
<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>
</el-form>
<div slot="footer" class="dialog-footer">
<el-button type="primary" @click="submitForm"> </el-button>
<el-button @click="open = false"> </el-button>
</div>
</el-dialog>
</div>
</template>
<script>
import { queryProjectInfoByKey, deviceList, attributes, sendAttribute, sendCommand } from "@/api/school";
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" }
],
},
//
version: "3.8.9",
};
},
created() {
this.getqueryProjectInfoByKey() // keyid
},
methods: {
//
handleSettings() {
this.open = true;
this.form = {
threshold: this.deviceInfo.threshold,
};
// 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 () {
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
this.$modal.msgSuccess("操作成功");
this.open = false;
});
}
});
goTarget(href) {
window.open(href, "_blank");
},
},
};
@ -153,7 +50,6 @@ export default {
<style scoped lang="scss">
.div-box {
transform: scale(1.4);
width: 500px;
box-sizing: border-box;
padding: 16px;
@ -181,30 +77,17 @@ export default {
display: flex;
justify-content: space-between;
margin-bottom: 12px;
div {
flex: 1;
align-items: center;
flex: 1
}
span {
color: #666;
}
}
}
.div-li:last-child {
margin-bottom: 0;
}
.div-tips {
font-size: 18px;
line-height: 22px;
display: flex;
align-items: center;
.div-tips{
span {
color: #666;
}
color: #666;
}
}
</style>

Loading…
Cancel
Save