UNPKG

@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" />

78 lines (75 loc) 2.66 kB
import { defineComponent, ref, computed, onMounted, openBlock, createElementBlock, Fragment, renderList, createElementVNode, toDisplayString, normalizeStyle } from 'vue'; import requestControl from '../../service/request.mjs'; import { setIntervalData } from '../../utils/hooks.mjs'; const _hoisted_1 = { class: "dv-ipes-dual-prevention-mechanism" }; const _hoisted_2 = { class: "name" }; const __default__ = { name: "DvIpesDualPreventionMechanism", title: "双重预防机制运行" }; const _sfc_main = /* @__PURE__ */ defineComponent({ ...__default__, props: { dataList: { type: Array, default: () => ["excellentCount", "fineCount", "middlingCount", "badCount"] } }, setup(__props) { const props = __props; const data = ref({ excellentCount: null, fineCount: null, middlingCount: null, badCount: null, nodBuildCount: null }); const levels = ref([ { name: "优", key: "excellentCount", color: "--dv-color-success" }, { name: "良", key: "fineCount", color: "--dv-color-warning" }, { name: "中", key: "middlingCount", color: "--dv-color-index" }, { name: "差", key: "badCount", color: "--dv-color-danger" }, { name: "未建设", key: "nodBuildCount", color: "--dv-color-text-primary" } ]); const levelsView = computed(() => { return levels.value.filter((item) => { return props.dataList.includes(item.key); }); }); function getShowData(value) { return value == null || isNaN(+value) ? "--" : value; } async function getData() { try { const res = await requestControl({ method: "get", url: "/ipes-srip-server/api/v4/statistics/mechanism-operation" }); data.value = res.data; } catch (error) { console.log(error); } } onMounted(() => { getData(); }); setIntervalData(getData, 5 * 60 * 1e3); return (_ctx, _cache) => { return openBlock(), createElementBlock("div", _hoisted_1, [ (openBlock(true), createElementBlock(Fragment, null, renderList(levelsView.value, (item) => { return openBlock(), createElementBlock("div", { key: item.key, class: "level-item" }, [ createElementVNode("div", _hoisted_2, toDisplayString(item.name), 1), createElementVNode("div", { class: "value", style: normalizeStyle({ color: `var(${item.color})` }) }, toDisplayString(getShowData(data.value[item.key])), 5) ]); }), 128)) ]); }; } }); export { _sfc_main as default };