| | |
| | | import FlexBox from "@/components/FlexBox.vue"; |
| | | import {DArrowRight, CaretTop} from "@element-plus/icons-vue"; |
| | | import HdwLight from "@/components/HdwLight.vue"; |
| | | import {watch} from "vue"; |
| | | import {ref, watch} from "vue"; |
| | | |
| | | import runMonitorModule from "@/views/airConditioning/js/runMonitorModule"; |
| | | const {runMonitorData, setRunMonitorData} = runMonitorModule(); |
| | |
| | | import airMonitorData from "@/views/airConditioning/js/airMonitorData"; |
| | | const {monitorData, airState} = airMonitorData(); |
| | | |
| | | import airControlModule from "@/views/airConditioning/js/airControlModule"; |
| | | import setAirParam from "@/views/airConditioning/components/setAirParam.vue"; |
| | | |
| | | const { |
| | | airParam, |
| | | getParam, |
| | | } = airControlModule(); |
| | | const setParamVisible = ref(false); |
| | | |
| | | const showSetParamDialog = ()=>{ |
| | | setParamVisible.value = true; |
| | | }; |
| | | |
| | | const setParamClose = ()=>{ |
| | | setParamVisible.value = false; |
| | | }; |
| | | |
| | | watch(monitorData, (data)=>{ |
| | | setRunMonitorData(data); |
| | |
| | | <div class="handle-tools"> |
| | | <div class="tools-btn-list"> |
| | | <div class="tools-btn-item"> |
| | | <el-button type="primary" @click="getParam">空调参数设置</el-button> |
| | | <el-button type="primary" @click="showSetParamDialog">空调参数设置</el-button> |
| | | </div> |
| | | </div> |
| | | <div class="tools-btn-list"> |
| | |
| | | </div> |
| | | </div> |
| | | </div> |
| | | <el-dialog |
| | | class="center-dialog" |
| | | title="空调参数设置" |
| | | width="auto" |
| | | v-model="setParamVisible" |
| | | align-center |
| | | :close-on-click-modal="false" |
| | | :modal-append-to-body="false"> |
| | | <set-air-param v-if="setParamVisible" @close="setParamClose"></set-air-param> |
| | | </el-dialog> |
| | | </template> |
| | | |
| | | <style lang="less" scoped> |
New file |
| | |
| | | <script setup> |
| | | import airControlModule from "@/views/airConditioning/js/airControlModule"; |
| | | import {onMounted, reactive} from "vue"; |
| | | const { |
| | | isCanSet, |
| | | airParam, |
| | | getParam, |
| | | setParam, |
| | | } = airControlModule(); |
| | | |
| | | const layout = reactive({ |
| | | gutter: 16, |
| | | span: 24 |
| | | }); |
| | | |
| | | const emits = defineEmits(['close']); |
| | | |
| | | const setAirParam = async ()=>{ |
| | | const isSuccess = await setParam(); |
| | | console.log(isSuccess); |
| | | if(isSuccess) { |
| | | emits('close', false); |
| | | } |
| | | } |
| | | |
| | | // onMounted(()=>{ |
| | | // getParam(); |
| | | // }); |
| | | </script> |
| | | |
| | | <template> |
| | | <div class="el-dialog-container"> |
| | | <div class="el-dialog-content"> |
| | | <el-form |
| | | ref="formRef" |
| | | label-position="top" |
| | | :model="airParam"> |
| | | <el-row :gutter="layout.gutter"> |
| | | <el-col :span="layout.span"> |
| | | <el-form-item label="空调温度(℃)"> |
| | | <el-input v-model="airParam.stTemp" /> |
| | | </el-form-item> |
| | | </el-col> |
| | | <el-col :span="layout.span"> |
| | | <el-form-item label="空调湿度(%RH)"> |
| | | <el-input v-model="airParam.stHumid" /> |
| | | </el-form-item> |
| | | </el-col> |
| | | </el-row> |
| | | </el-form> |
| | | </div> |
| | | <div class="el-dialog-footer"> |
| | | <el-button type="primary" @click="getParam">读取</el-button> |
| | | <el-button type="success" :disabled="!isCanSet" @click="setAirParam">设置</el-button> |
| | | <el-button type="success" @click="setAirParam">设置</el-button> |
| | | </div> |
| | | </div> |
| | | </template> |
| | | |
| | | <style lang="less" scoped> |
| | | .el-dialog-container { |
| | | width: 400px; |
| | | box-sizing: border-box; |
| | | background-color: #FFFFFF; |
| | | } |
| | | .el-dialog-content { |
| | | box-sizing: border-box; |
| | | padding: 8px 16px; |
| | | } |
| | | .el-dialog-footer { |
| | | padding: 8px; |
| | | text-align: right; |
| | | background-color: #f5f4f4; |
| | | } |
| | | </style> |
| | |
| | | import {ref} from "vue"; |
| | | import {reactive, ref} from "vue"; |
| | | import air from "@/assets/js/const/air"; |
| | | import {getAirParam} from "@/views/airConditioning/js/api"; |
| | | import {getAirParam, setAirParam} from "@/views/airConditioning/js/api"; |
| | | import {ElLoading, ElMessage} from "element-plus"; |
| | | |
| | | const airControlModule = ()=>{ |
| | | const cmd = air.cmd; |
| | | const airParam = ref({ |
| | | const isCanSet = ref(false); |
| | | const airParam = reactive({ |
| | | num: 1, |
| | | devId: 210000001, |
| | | opCmd: 0, |
| | | stHumid: 0, |
| | | stTemp: 0, |
| | | }); |
| | | /** |
| | | * 读取放电参数 |
| | | */ |
| | | const getParam = ()=>{ |
| | | const loading = ElLoading.service({ |
| | | lock: false, |
| | | text: '数据加装中', |
| | | background: 'rgba(0, 0, 0, 0.3)', |
| | | }); |
| | | getAirParam(210000001).then(res=>{ |
| | | let rs = res.data; |
| | | let data = { |
| | | num: 0, |
| | | devId: 0, |
| | | opCmd: 0, |
| | | stHumid: 0, |
| | | stTemp: 0, |
| | | }; |
| | | if(rs.code === 1 && rs.data) { |
| | | ElMessage({ |
| | | showClose: true, |
| | | message: '读取成功', |
| | | type: 'success', |
| | | }); |
| | | data = rs.data2; |
| | | isCanSet.value = true; |
| | | }else { |
| | | ElMessage({ |
| | | showClose: true, |
| | | message: '读取失败', |
| | | type: 'error', |
| | | }); |
| | | isCanSet.value = false; |
| | | } |
| | | // 设置值 |
| | | airParam.stTemp = data.stTemp; |
| | | airParam.stHumid =data.stHumid; |
| | | airParam.devId = data.devId; |
| | | airParam.num = data.num; |
| | | |
| | | /** |
| | | * 读取放电参数 |
| | | */ |
| | | const getParam = ()=>{ |
| | | getAirParam(210000001).then(res=>{ |
| | | loading.close(); |
| | | console.log(res); |
| | | }).catch(error=>{ |
| | | isCanSet.value = false; |
| | | loading.close(); |
| | | console.log(error); |
| | | }); |
| | | } |
| | | |
| | | const setParam = async ()=>{ |
| | | const loading = ElLoading.service({ |
| | | lock: false, |
| | | text: '数据加装中', |
| | | background: 'rgba(0, 0, 0, 0.3)', |
| | | }); |
| | | airParam.opCmd = cmd.set; |
| | | try { |
| | | const res = await setAirParam(airParam); |
| | | loading.close(); |
| | | let rs = res.data; |
| | | if(rs.code === 1 && rs.data) { |
| | | ElMessage({ |
| | | showClose: true, |
| | | message: '设置成功', |
| | | type: 'success', |
| | | }); |
| | | return Promise.resolve(true); |
| | | }else { |
| | | ElMessage({ |
| | | showClose: true, |
| | | message: '设置失败', |
| | | type: 'error', |
| | | }); |
| | | return Promise.resolve(false); |
| | | } |
| | | }catch (error) { |
| | | loading.close(); |
| | | console.log(error); |
| | | return Promise.resolve(false); |
| | | } |
| | | } |
| | | |
| | | return { |
| | | isCanSet, |
| | | airParam, |
| | | getParam, |
| | | setParam, |
| | | }; |
| | | } |
| | | export default airControlModule; |
| | |
| | | |
| | | /** |
| | | * 读取参数 |
| | | * @return {*} |
| | | * @param devId 设备ID |
| | | * @return {Promise<axios.AxiosResponse<any>> | *} |
| | | */ |
| | | export const getAirParam = (devId)=>{ |
| | | return axios({ |
| | |
| | | devId |
| | | } |
| | | }); |
| | | }; |
| | | } |
| | | |
| | | /** |
| | | * 设置空调参数 |
| | | * @param data |
| | | * @return {Promise<axios.AxiosResponse<any>> | *} |
| | | */ |
| | | export const setAirParam = (data)=>{ |
| | | return axios({ |
| | | method: "POST", |
| | | url: "/envirParam/updateAir", |
| | | data, |
| | | }); |
| | | } |