@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" />
110 lines (107 loc) • 3.84 kB
JavaScript
import { defineComponent, ref, onMounted, openBlock, createElementBlock, createElementVNode, toDisplayString, Fragment, renderList, normalizeStyle } 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-sensing-equipment" };
const _hoisted_2 = { class: "equipment-header" };
const _hoisted_3 = /* @__PURE__ */ createElementVNode("div", { class: "equipment-title" }, " 传感设备 ", -1);
const _hoisted_4 = /* @__PURE__ */ createElementVNode("span", { class: "equipment-count" }, "总数", -1);
const _hoisted_5 = { class: "equipment-value" };
const _hoisted_6 = { class: "equipment-content" };
const _hoisted_7 = { class: "flex flex-s" };
const _hoisted_8 = { class: "value" };
const __default__ = {
name: "DvIpesSensingEquipment",
title: "传感设备"
};
const _sfc_main = /* @__PURE__ */ defineComponent({
...__default__,
props: {
monitorTypes: { default: "" }
},
setup(__props) {
const props = __props;
useThemeHook();
const total = ref(0);
const countData = ref({
normal: 0,
// 正常
abnormal: 0,
// 异常
offline: 0,
// 离线
stop_using: 0,
// 停用
exceed: 0
// 超标
});
const Infos = ref([
{ title: "正常", key: "normal", color: "var(--dv-color-success)" },
{ title: "异常", key: "abnormal", color: "var(--abnormal)" },
{ title: "离线", key: "offline", color: "var(--offline)" },
{ title: "停用", key: "stop_using", color: "var(--dv-color-warning)" },
{ title: "超标", key: "exceed", color: "var(--dv-color-danger)" }
]);
async function getData() {
try {
const res = await requestControl({
method: "get",
url: "/ipes-monitor-server/api/v2/datastatistics/all-run-status-statistics",
params: props
});
const obj = {};
res?.data.forEach((e) => {
const key = e.runStatusCode;
obj[key] = e.count;
});
const { normal = 0, abnormal = 0, offline = 0, stop_using = 0, exceed = 0 } = obj;
total.value = normal + abnormal + offline + stop_using + exceed;
countData.value = {
normal,
abnormal,
offline,
stop_using,
exceed
};
} catch (error) {
console.log(error);
}
}
function getShowData(value) {
return value == null ? "0" : value;
}
onMounted(() => {
getData();
});
setIntervalData(getData, 5 * 60 * 1e3);
return (_ctx, _cache) => {
return openBlock(), createElementBlock("div", _hoisted_1, [
createElementVNode("div", _hoisted_2, [
_hoisted_3,
createElementVNode("div", null, [
_hoisted_4,
createElementVNode("span", _hoisted_5, toDisplayString(getShowData(total.value)), 1)
])
]),
createElementVNode("div", _hoisted_6, [
(openBlock(true), createElementBlock(Fragment, null, renderList(Infos.value, (item) => {
return openBlock(), createElementBlock("div", {
key: item.key,
class: "item"
}, [
createElementVNode("div", _hoisted_7, [
createElementVNode("div", {
class: "dot",
style: normalizeStyle({ backgroundColor: item.color })
}, null, 4),
createElementVNode("div", null, toDisplayString(item.title), 1)
]),
createElementVNode("div", _hoisted_8, toDisplayString(getShowData(countData.value[item.key])), 1)
]);
}), 128))
])
]);
};
}
});
export { _sfc_main as default };