@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" />
100 lines (95 loc) • 3.78 kB
JavaScript
'use strict';
Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: 'Module' } });
const bgLight = require('./images/bg-light.png.js');
const bg = require('./images/bg.png.js');
const vue = require('vue');
const request = require('../../service/request.js');
const utils = require('../../../utils.js');
const hooks = require('../../utils/hooks.js');
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__ */ vue.createElementVNode("div", { class: "label" }, " 设备总数 ", -1);
const _hoisted_7 = { class: "value" };
const _hoisted_8 = { class: "number" };
const _hoisted_9 = /* @__PURE__ */ vue.createElementVNode("span", { class: "unit" }, "个", -1);
const _hoisted_10 = { class: "row" };
const _hoisted_11 = /* @__PURE__ */ vue.createElementVNode("div", { class: "label" }, " 设备在线率 ", -1);
const _hoisted_12 = { class: "value" };
const _hoisted_13 = { class: "number percent" };
const _hoisted_14 = /* @__PURE__ */ vue.createElementVNode("span", { class: "unit" }, "%", -1);
const __default__ = {
name: "DvIpesOnlineMonitor",
title: "监测预警"
};
const _sfc_main = /* @__PURE__ */ vue.defineComponent({
...__default__,
setup(__props) {
const { isDark } = utils.useThemeHook();
const info = vue.ref({
total: 0,
percent: 0
});
const getImg = (isDark2) => {
return new URL((/* #__PURE__ */ Object.assign({"./images/bg-light.png": bgLight.default,"./images/bg.png": bg.default}))[`./images/bg${isDark2 ? "" : "-light"}.png`], self.location).href;
};
async function getInfoData() {
try {
const res = await request.default({
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);
}
}
vue.onMounted(() => {
getInfoData();
});
hooks.setIntervalData(getInfoData, 5 * 60 * 1e3);
return (_ctx, _cache) => {
return vue.openBlock(), vue.createElementBlock("div", _hoisted_1, [
vue.createElementVNode("div", _hoisted_2, [
vue.createElementVNode("img", {
src: getImg(vue.unref(isDark))
}, null, 8, _hoisted_3),
vue.createElementVNode("div", _hoisted_4, [
vue.createElementVNode("div", _hoisted_5, [
_hoisted_6,
vue.createElementVNode("div", _hoisted_7, [
vue.createElementVNode("span", _hoisted_8, vue.toDisplayString(info.value.total), 1),
_hoisted_9
])
]),
vue.createElementVNode("div", _hoisted_10, [
_hoisted_11,
vue.createElementVNode("div", _hoisted_12, [
vue.createElementVNode("span", _hoisted_13, vue.toDisplayString(info.value.percent), 1),
_hoisted_14
])
])
])
])
]);
};
}
});
exports.default = _sfc_main;