screenFront/src/views/Offsite/child/childContent/center.vue

220 lines
5.4 KiB
Vue

<!--
* @FilePath: \screenFront\src\views\Offsite\child\childContent\center.vue
* @Author: 王路平
* @文件版本: V1.0.0
* @Date: 2023-04-12 08:46:57
* @Description:
*
* 版权信息 : 2023 by ${再登软件}, All Rights Reserved.
-->
<template>
<div class="content-center">
<el-row>
<el-col>
<!-- <offsitegateway
ref="offsitegatewayref"
:title="'东莞-物联网关状态'"
></offsitegateway> -->
<div style="display: flex">
<topTitle ref="topTitleRef" :title="t('messages.DevPreviewChart')"></topTitle>
<topTitle ref="topTitleRef2" :title="t('messages.DevPreviewChart')"></topTitle>
<topTitle ref="topTitleRef3" :title="t('messages.DevPreviewChart')"></topTitle>
</div>
</el-col>
<el-col>
<div class="tableBoxDiv">
<table1
:title="tabledata.title"
:data="tabledata"
ref="tableref"
></table1>
</div>
</el-col>
</el-row>
</div>
</template>
<script setup lang="ts">
import { onMounted, reactive, ref, watch } from "vue";
import { calcWH } from "@/components/ts/selfAdaption";
import offsitegateway from "./chart/offsitegateway.vue";
import topTitle from "./chart/topTitle.vue";
import table1 from "@/components/assembly/RotationTable.vue";
import { useI18n } from 'vue-i18n'
let {t} = useI18n();
let props = defineProps<{
width: number;
height: number;
}>();
let topTitleRef = ref();
let topTitleRef2 = ref();
let topTitleRef3 = ref();
let tableref = ref();
let offsitegatewayref = ref();
let data1 = [
{
title: t('messages.offline'),
num: 0,
},
{
title: t('messages.onLine'),
num: 0,
},
];
let tabledata = reactive({
title: t('messages.DevList'),
data: {
header: [
t('messages.SerialNum'),
t('messages.DevName'),
t('messages.model'),
t('messages.RackNum'),
t('messages.type'),
t('messages.Ex_factoryDate'),
t('messages.DevStatus'),
// t('messages.Devsignal'),
],
data: [],
headerBGC: "#3469F3",
oddRowBGC: "#100C2A",
evenRowBGC: "#100C2A",
rowNum: 10,
waitTime: 3000,
carousel: "page",
hoverPause: true,
columnWidth:null,
align: [
"center",
"center",
"center",
"center",
"center",
"center",
"center",
"center",
// "center",
],
},
});
const listWH = reactive({
height: 0,
width: 0,
});
watch(
() => props,
(newVal, oldVal) => {
//监听父组件宽高变化,随时重置本组件尺寸
reset(newVal);
},
{ immediate: true, deep: true, flush: "post" }
);
//---------------------------
function reset(val: any) {
//宽高为0时跳出该方法
if (!val.width && !val.height) return;
box(val.width, val.height);
}
const box = (width: any, height: any) => {
let a = calcWH(height, width, 4, 3, 0);
// a.oHeight=a.oHeight
//修改高度
topTitleRef.value.setchartWH(a.oWidth, a.oHeight);
topTitleRef2.value.setchartWH(a.oWidth, a.oHeight);
topTitleRef3.value.setchartWH(a.oWidth, a.oHeight);
tableref.value.setchartWH(a.oWidth * 3, a.oHeight * 3);
listWH.width=a.oWidth * 3
// offsitegatewayref.value.setchartWH(a.oWidth, a.oHeight);
};
function changedevlist(val: any) {
let list = [];
console.log(listWH.width);
val.forEach((res, index) => {
list.push([
index + 1,
res.name,
res.model,
res.label,
res.deviceType,
res.realityDate,
JSON.parse(res.deviceStatus)
? `<span style="color:#20aec5;">${t('messages.onLine')}</span>`
: `<span style="color:rgb(228, 57, 97);">${t('messages.offline')}</span>`,
// "",
]);
});
if(list.length<10){
let listlengthData=10-list.length
for(let i=0;i<listlengthData;i++){
list.push([
'',
'',
'',
'',
'',
"",
// JSON.parse(res.deviceStatus)
// ? '<span style="color:#9fe6b8;">在线</span>'
// : "<span style='color:#fb7293;'>离线</span>",
"",
"",
])
}
}
tabledata.data.data = list;
tabledata.data.rowNum = 10;
tabledata.data.waitTime = 3000;
// listWH.width?tabledata.data.columnWidth=[60,240,110,110,60,100,100,100]:''
listWH.width?tabledata.data.columnWidth=[listWH.width*0.1,listWH.width*0.2,listWH.width*0.15,listWH.width*0.15,listWH.width*0.1,listWH.width*0.15,listWH.width*0.15,]:''
tableref.value.changeData(tabledata.data);
}
function setDataList(val: any) {
console.log(val);
let tipdata = { ison: 0, isall: 0, isoff: 0 };
//计算设备总量
val.devnum.forEach((res) => {
tipdata.isall += res.counts;
});
//获取在线离线数量
val.statusnum.forEach((res) => {
if (JSON.parse(res.name)) {
tipdata.ison = res.counts;
} else {
tipdata.isoff = res.counts;
}
});
//设置页面数据
topTitleRef.value.setData({ title: t('messages.OnlineNum'), num: tipdata.ison });
topTitleRef2.value.setData({ title: t('messages.TOTAL'), num: tipdata.isall });
topTitleRef3.value.setData({ title: t('messages.OffNum'), num: tipdata.isoff ,color:'rgb(228, 57, 97)' });
changedevlist(val.citylist);
}
onMounted(() => {
// offsitegatewayref.value.setData(data1);
// devImageRef.value.setData(data2);
});
defineExpose({
setDataList,
});
</script>
<style scoped>
.content-center {
width: 100%;
}
.tableBoxDiv :deep(.ceil) {
font-size: 1.2rem;
}
.tableBoxDiv :deep(.header-item) {
font-size: 1.2rem;
}
</style>