@ued_fpi/data-visual
Version:
<br /> <br /> <div style="text-align:center"> <b style="font-size:30px">@ued_fpi/data-visual</b> <p>基于Vite4+TypeScript的Vue3大屏组件库开发框架</p> <img style="display:inline" src="https://img.shields.io/npm/v/@ued_fpi/data-visual" />
96 lines (93 loc) • 3.7 kB
JavaScript
import __vite_glob_0_0 from './images/bg-light.png.mjs';
import __vite_glob_0_1 from './images/bg.png.mjs';
import { defineComponent, ref, onMounted, openBlock, createElementBlock, createElementVNode, unref, toDisplayString } from 'vue';
import requestControl from '../../service/request.mjs';
import { useThemeHook } from '../../../utils.mjs';
import { setIntervalData } from '../../utils/hooks.mjs';
const _hoisted_1 = { class: "dv-ipes-online-monitor" };
const _hoisted_2 = { class: "monitor-box" };
const _hoisted_3 = ["src"];
const _hoisted_4 = { class: "info" };
const _hoisted_5 = { class: "row" };
const _hoisted_6 = /* @__PURE__ */ createElementVNode("div", { class: "label" }, " 设备总数 ", -1);
const _hoisted_7 = { class: "value" };
const _hoisted_8 = { class: "number" };
const _hoisted_9 = /* @__PURE__ */ createElementVNode("span", { class: "unit" }, "个", -1);
const _hoisted_10 = { class: "row" };
const _hoisted_11 = /* @__PURE__ */ createElementVNode("div", { class: "label" }, " 设备在线率 ", -1);
const _hoisted_12 = { class: "value" };
const _hoisted_13 = { class: "number percent" };
const _hoisted_14 = /* @__PURE__ */ createElementVNode("span", { class: "unit" }, "%", -1);
const __default__ = {
name: "DvIpesOnlineMonitor",
title: "监测预警"
};
const _sfc_main = /* @__PURE__ */ defineComponent({
...__default__,
setup(__props) {
const { isDark } = useThemeHook();
const info = ref({
total: 0,
percent: 0
});
const getImg = (isDark2) => {
return new URL((/* #__PURE__ */ Object.assign({"./images/bg-light.png": __vite_glob_0_0,"./images/bg.png": __vite_glob_0_1}))[`./images/bg${isDark2 ? "" : "-light"}.png`], self.location).href;
};
async function getInfoData() {
try {
const res = await requestControl({
method: "get",
url: "/ipes-monitor-server/api/v2/datastatistics/all-run-status-statistics?monitorTypes=hazards"
});
const totalCollection = ["normal", "abnormal", "exceed", "offline"];
const onlineCollection = ["normal", "abnormal", "exceed"];
let total = 0;
let online = 0;
res?.data?.forEach((e) => {
if (totalCollection.includes(e.runStatusCode))
total += e.count;
if (onlineCollection.includes(e.runStatusCode))
online += e.count;
});
if (total !== void 0 && online !== void 0) {
info.value = {
total,
percent: total === 0 ? 0 : +(online / total * 100).toFixed(2)
};
}
} catch (error) {
console.log(error);
}
}
onMounted(() => {
getInfoData();
});
setIntervalData(getInfoData, 5 * 60 * 1e3);
return (_ctx, _cache) => {
return openBlock(), createElementBlock("div", _hoisted_1, [
createElementVNode("div", _hoisted_2, [
createElementVNode("img", {
src: getImg(unref(isDark))
}, null, 8, _hoisted_3),
createElementVNode("div", _hoisted_4, [
createElementVNode("div", _hoisted_5, [
_hoisted_6,
createElementVNode("div", _hoisted_7, [
createElementVNode("span", _hoisted_8, toDisplayString(info.value.total), 1),
_hoisted_9
])
]),
createElementVNode("div", _hoisted_10, [
_hoisted_11,
createElementVNode("div", _hoisted_12, [
createElementVNode("span", _hoisted_13, toDisplayString(info.value.percent), 1),
_hoisted_14
])
])
])
])
]);
};
}
});
export { _sfc_main as default };