diff --git a/src/store/moduleSocketMechanics.ts b/src/store/moduleSocketMechanics.ts index 0e4a717..c0f9f1f 100644 --- a/src/store/moduleSocketMechanics.ts +++ b/src/store/moduleSocketMechanics.ts @@ -10,7 +10,7 @@ import { defineStore } from "pinia"; import { Names } from '@/store/storeName' import { gettime, clacendTime } from "@/utils/time" -export const useSocketStore = defineStore(Names.socketjixiefenchang, { +export const useSocketStore = defineStore(Names.socketMechanics, { // 使用方式 // const Index= useIndexStore() // 1、Index.{数据}++ @@ -19,23 +19,58 @@ export const useSocketStore = defineStore(Names.socketjixiefenchang, { // 4、通过action修改 state: () => { return { - // humiture: [ - // { "devId": "c6f036c0-33fc-11ed-a7e1-fd42bca6c8c6", "name": "精饰车间", "temp": "33.4", "humidity": "30.9" }, - // { "devId": "c651b930-3b15-11ed-b6af-15994988a6b3", "name": "精加车间", "temp": "26.1", "humidity": "47" }, - // { "devId": "9c4be1e0-33fb-11ed-a7e1-fd42bca6c8c6", "name": "焊接车间", "temp": "29.3", "humidity": "37.6" }, - // { "devId": "0e77f0b0-33fc-11ed-a7e1-fd42bca6c8c6", "name": "大件车间", "temp": "28.6", "humidity": "38.4" }, - // { "devId": "91f6d000-33fc-11ed-a7e1-fd42bca6c8c6", "name": "机加车间", "temp": "29.9", "humidity": "36.2" } - // ], - - humiture:{Humiture:[],bottom:{humidity:null,temp:null,name:null},top:{humidity:null,temp:null,name:null}}, //温湿度 + humiture: [ + { "devId": "c6f036c0-33fc-11ed-a7e1-fd42bca6c8c6", "name": "精饰车间", "temp": "33.4", "humidity": "30.9" }, + { "devId": "c651b930-3b15-11ed-b6af-15994988a6b3", "name": "精加车间", "temp": "26.1", "humidity": "47" }, + { "devId": "9c4be1e0-33fb-11ed-a7e1-fd42bca6c8c6", "name": "焊接车间", "temp": "29.3", "humidity": "37.6" }, + { "devId": "0e77f0b0-33fc-11ed-a7e1-fd42bca6c8c6", "name": "大件车间", "temp": "28.6", "humidity": "38.4" }, + { "devId": "91f6d000-33fc-11ed-a7e1-fd42bca6c8c6", "name": "机加车间", "temp": "29.9", "humidity": "36.2" } + ], + + // humiture:{Humiture:[],bottom:{humidity:null,temp:null,name:null},top:{humidity:null,temp:null,name:null}}, //温湿度 pm: [ - { "devId": "01336fd0-1fa0-11ed-9223-7db1174970a8", "name": "大件车间粉尘", "pm2": "26", "pm10": "33" }, - { "devId": "083e3900-3435-11ed-a7e1-fd42bca6c8c6", "name": "焊接车间粉尘", "pm2": "46", "pm10": "59" }, - { "devId": "270e1500-eee1-11ed-b2ee-2d727e0cafab", "name": "精加车间粉尘", "pm2": "131", "pm10": "155" }, - { "devId": "54058c30-eee3-11ed-b2ee-2d727e0cafab", "name": "机加车间粉尘", "pm2": "38", "pm10": "44" }, - { "devId": "76efb040-eee3-11ed-b2ee-2d727e0cafab", "name": "大件车间粉尘", "pm2": "52", "pm10": "67" }, - { "devId": "a6020310-eee3-11ed-b2ee-2d727e0cafab", "name": "大件车间粉尘", "pm2": "42", "pm10": "52" }, - { "devId": "bcbfb530-88b2-11ed-a926-570995ad0254", "name": "精饰车间粉尘", "pm2": "9", "pm10": "12" } + { + "devId": "01336fd0-1fa0-11ed-9223-7db1174970a8", + "name": "大件车间中部粉尘", + "pm25": "45", + "pm10": "53" + }, + { + "devId": "083e3900-3435-11ed-a7e1-fd42bca6c8c6", + "name": "焊接车间粉尘", + "pm25": "30", + "pm10": "36" + }, + { + "devId": "270e1500-eee1-11ed-b2ee-2d727e0cafab", + "name": "精加车间粉尘", + "pm25": "71", + "pm10": "84" + }, + { + "devId": "54058c30-eee3-11ed-b2ee-2d727e0cafab", + "name": "机加车间粉尘", + "pm25": "22", + "pm10": "26" + }, + { + "devId": "76efb040-eee3-11ed-b2ee-2d727e0cafab", + "name": "大件车间东部粉尘", + "pm25": "53", + "pm10": "60" + }, + { + "devId": "a6020310-eee3-11ed-b2ee-2d727e0cafab", + "name": "大件车间西部粉尘", + "pm25": "66", + "pm10": "75" + }, + { + "devId": "bcbfb530-88b2-11ed-a926-570995ad0254", + "name": "精饰车间粉尘", + "pm25": "6", + "pm10": "7" + } ], newVerticalNum: [ { @@ -173,24 +208,32 @@ export const useSocketStore = defineStore(Names.socketjixiefenchang, { * @param {*} val 温湿度数据 * @出口参数: * @函数备注: - */ - changeHumiture(val){ + */ + changeHumiture(val) { // console.log(this.humiture.Humiture); - - if(this.humiture.Humiture.length==0){ - this.humiture=val - }else{ - val.Humiture.forEach(res=>{ - this.humiture.Humiture.forEach(ele=>{ - if(res.name==ele.name){ - ele.humidity=res.humidity - ele.temp=res.temp - } - }) + + + val.Humiture.forEach(res => { + this.humiture.forEach(ele => { + if (res.devId == ele.devId) { + ele.humidity = res.humidity + ele.temp = res.temp + } }) - } + }) }, + /** + * 更新粉尘数据 + */ + changeDust(val) { + this.pm.forEach(res => { + if (res.devId == val.devId) { + res.pm25 = val.pm25 + res.pm10 = val.pm10 + } + }) + } } - + }) \ No newline at end of file diff --git a/src/store/storeName.ts b/src/store/storeName.ts index c479e52..97ae740 100644 --- a/src/store/storeName.ts +++ b/src/store/storeName.ts @@ -27,4 +27,5 @@ export const enum Names{ MechanicalViewJijia="MechanicalViewJijia", MechanicalViewJingjia="MechanicalViewJingjia", MechanicalViewJingshi="MechanicalViewJingshi", + socketMechanics='socketMechanics', } \ No newline at end of file diff --git a/src/views/generalEnvironmentMechanical/components/gas.vue b/src/views/generalEnvironmentMechanical/components/gas.vue index 59ebec5..136cd0c 100644 --- a/src/views/generalEnvironmentMechanical/components/gas.vue +++ b/src/views/generalEnvironmentMechanical/components/gas.vue @@ -21,6 +21,12 @@ const { proxy } = getCurrentInstance() as any; let props=defineProps<{ title:string, value:any; + color:{ + step0:string, + step1:string, + border:string + color:string + }; }>() let gas=ref() @@ -65,11 +71,11 @@ const setData=()=>{ colorStops: [ { offset: 0, - color: '#186945', + color: props.color.step0, }, { offset: 1, - color: '#1b7a4f', + color: props.color.step1, }, ], globalCoord: false, @@ -79,8 +85,8 @@ const setData=()=>{ amplitude: 10, //振幅 backgroundStyle: { borderWidth: 2, //边框大小 - borderColor:'rgba(8, 206, 120, 0.8)',//边框颜色 - color: 'rgba(8, 206, 120, 0.4)', + borderColor:props.color.border,//边框颜色 + color: props.color.color, //背景色 }, label: { normal: { diff --git a/src/views/generalEnvironmentMechanical/components/humidity.vue b/src/views/generalEnvironmentMechanical/components/humidity.vue index ce462aa..a9444a7 100644 --- a/src/views/generalEnvironmentMechanical/components/humidity.vue +++ b/src/views/generalEnvironmentMechanical/components/humidity.vue @@ -1,26 +1,46 @@ @@ -198,5 +228,39 @@ onMounted(() => { width: 100%; height: 100%; } + +.errList { + width: 100%; + height: 50px; + display: flex; + align-items: center; + justify-content: center; + flex-wrap: wrap; +} +.echartbox { + width: 100%; + height: calc(100% - 50px); +} + +.icon-red { + color: #e43961; + animation: redstart 2s infinite; + font-size: 14px; + /* position: relative; */ + /* top: -15px; */ +} +.err-item { + margin: 0 10px; +} + +@keyframes redstart { + 0% {} + + 50% { + text-shadow: #fff 1px 0 10px; + } + + 100% {} +} \ No newline at end of file diff --git a/src/views/generalEnvironmentMechanical/components/pm.vue b/src/views/generalEnvironmentMechanical/components/pm.vue index 2c5b850..8889907 100644 --- a/src/views/generalEnvironmentMechanical/components/pm.vue +++ b/src/views/generalEnvironmentMechanical/components/pm.vue @@ -1,27 +1,53 @@ diff --git a/src/views/generalEnvironmentMechanical/components/verticalNumLoop.vue b/src/views/generalEnvironmentMechanical/components/verticalNumLoop.vue index 6d94fcb..e8173f8 100644 --- a/src/views/generalEnvironmentMechanical/components/verticalNumLoop.vue +++ b/src/views/generalEnvironmentMechanical/components/verticalNumLoop.vue @@ -30,10 +30,14 @@ @@ -140,7 +144,10 @@ p { } .iconsmall-size { - font-size: 20px; + font-size: 14px; +} +.cursor { + cursor: pointer; } .icon-red { @@ -181,7 +188,7 @@ p { .icontip { display: flex; margin-top: -60px; - width: 100px; + width: 150px; flex-wrap: wrap; align-items: center; justify-content: center; diff --git a/src/views/generalEnvironmentMechanical/index.vue b/src/views/generalEnvironmentMechanical/index.vue index a39fae9..448aecf 100644 --- a/src/views/generalEnvironmentMechanical/index.vue +++ b/src/views/generalEnvironmentMechanical/index.vue @@ -9,34 +9,18 @@
-
- +
+
-
- - - +
+
-
- - - +
+
-
- - - - -
@@ -44,8 +28,24 @@
- - + + + +
+
+ + + + +
+
+ + +
@@ -61,6 +61,7 @@ import verticalNumLoop from './components/verticalNumLoop.vue' import power from './components/power2023.vue'; import pm from './components/pm.vue'; import humidityBar from './components/humidityBar.vue'; +import humidity from './components/humidity.vue'; import gas from './components/gas.vue' import pipe from './components/pipe.vue' import border13 from '@/components/border/Border13.vue' @@ -71,8 +72,9 @@ import { getPowerData, getconsumeDetail } from "@/http/energyConsume"; import { useSocketStore } from "@/store/moduleSocketMechanics"; import { connectWebsocket, closeWebsocket } from "@/utils/websocket"; import { gettime, clacendTime } from "@/utils/time" -import {useRouter} from 'vue-router' +import { useRouter } from 'vue-router' import { useI18n } from 'vue-i18n' +import { hu } from 'element-plus/es/locale'; let { t } = useI18n(); let router = useRouter() const store = useSocketStore(); @@ -104,34 +106,35 @@ const verticalType = { let powerData = ref({ value: { name: [] }, seriesVal: [], title: t('messages.Powerto2023') }) let gasData = ref(0) - +let waterData = ref(0) let pipeData = ref({ listData: [], top: 0 }) let headerref = ref() let verticalList: any[] = reactive([]) let pmtimer = null -let humittimer = null +let humidityTop = ref({}) +let humidityBottom = ref({}) /** * 跳转到趋势图 */ - function gotoTrendChart(value, unit) { - let ids = value.map((item) => item.devId).toString(); - ElMessageBox.confirm( - '即将跳转到传感器监测走势图页面,是否继续?', - '提示', - { - confirmButtonText: '确认', - cancelButtonText: '取消', - type: 'info', - } - ) - .then(() => { - router.push({ path: '/TrendChart', query: { ids: ids, unit: unit } }) - }) - .catch(() => { +function gotoTrendChart(value, unit) { + let ids = value.map((item) => item.devId).toString(); + ElMessageBox.confirm( + '即将跳转到传感器监测走势图页面,是否继续?', + '提示', + { + confirmButtonText: '确认', + cancelButtonText: '取消', + type: 'info', + } + ) + .then(() => { + router.push({ path: '/TrendChart', query: { ids: ids, unit: unit } }) + }) + .catch(() => { - }) + }) } @@ -194,10 +197,13 @@ async function gethumitureData() { if (result.code == 200) { store.$patch((state) => { - state.humiture = result.data + state.humiture = result.data.Humiture }) + humidityBottom.value = result.data.bottom + humidityTop.value = result.data.top } } +/**用电量柱状图 let humidityData = ref({}) let humidityBottom = ref({}) let humidityTop = ref({}) @@ -212,7 +218,7 @@ watch(() => store.humiture, (newVal, oldVal) => { humidityBottom.value = newVal.bottom; humidityTop.value = newVal.top; }, { deep: true, immediate: true }) - + */ //获取粉尘数据 let pmindex = ref(0); async function getPmData() { @@ -230,11 +236,11 @@ async function getPmData() { let data = {} if (resulttwo) { resulttwo.data.forEach(ele => { - if (arr.indexOf(ele.devId) > -1) { + if (arr.indexOf(ele.devId) > -1) { data[ele.devId] = { devId: ele.devId, - name: ele.name + '粉尘', - pm2: ele.value, + name: ele.devName.split('监测')[0], + pm25: ele.value, pm10: null } } @@ -249,15 +255,10 @@ async function getPmData() { }) } + store.$patch((state) => { state.pm = Object.values(data) }) - pmtimer = setInterval(() => { - pmindex.value++ - if (pmindex.value >= store.pm.length) { - pmindex.value = 0 - } - }, 5000) } //获取用电量数据 @@ -314,6 +315,10 @@ async function getPower_data() { powerData.value.title = '机械分厂用电量' } } + +let gascolor = {step0:'#186945',step1:'#1b7a4f',border:'rgba(8, 206, 120, 0.8)',color:'rgba(8, 206, 120, 0.4)'} +let watercolor = {step0:'#0D73B3',step1:'#1176C6',border:'#1E4D7B',color:'#0F2A57'} +//获取用气量数据 async function getconsumeDetailfun() { let result: any = await getconsumeDetail() if (result.code == 200) { @@ -321,6 +326,9 @@ async function getconsumeDetailfun() { if (res.deptName == '喷漆车间' && res.type == 'GasDetail') { gasData.value = res.usageNum } + if (res.deptName == '生产区' && res.type == 'WaterDetail') { + waterData.value = res.usageNum + } }) } @@ -334,7 +342,8 @@ async function getpipeDatafun() { pipeData.value.top = result.data.top } } - +/************************************************************ */ +//socket function getWebsocket(val) { headerref.value.HeadergetWebsocket(val) try { @@ -376,9 +385,12 @@ function getWebsocket(val) { store.changeHumiture(data.msg); } + if (data.type == "dust") { + store.changeDust(data.msg); + } + } catch (err) { - console.log(err, "报错了大哥", console.log(val) - ); + console.log(err, "报错了大哥", console.log(val)); } } @@ -399,7 +411,6 @@ onMounted(() => { }) onUnmounted(() => { closeWebsocket(); - clearInterval(pmtimer) }) @@ -424,15 +435,24 @@ onUnmounted(() => { .top-box { width: 1920px; - height: 290px; + height: 340px; display: flex; justify-content: space-between; align-items: center; } +.top-box-item { + width: 12%; + height: 300px; + margin-bottom: 10px; + display: flex; + align-items: center; + justify-content: space-evenly; +} + .bottom-box { width: 1920px; - height: 630px; + height: 580px; display: flex; justify-content: space-between; align-items: center;