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

94 lines (91 loc) 3.23 kB
import { defineComponent, ref, onMounted, watch, openBlock, createElementBlock, normalizeClass, createVNode, unref, withCtx, createElementVNode, Fragment, renderList, toDisplayString } from 'vue'; import { FpiElRolling } from '@ued_fpi/element-plus-expand'; import { getSiteMonitorTypeTree } from './api/index.mjs'; const _hoisted_1 = { class: "list flex-between-center" }; const _hoisted_2 = { key: 0, class: "name" }; const _hoisted_3 = ["title"]; const _hoisted_4 = { class: "num" }; const _hoisted_5 = { class: "pre" }; const clsfix = "dv-aims-environment-monitor"; const _sfc_main = /* @__PURE__ */ defineComponent({ __name: "index", props: { isUseBuiltInApi: { type: Boolean, default: true }, apiParams: { default: () => ({ showCount: true, withPms: true }) }, data: {} }, setup(__props) { const props = __props; const siteTypeList = ref([]); const fetchData = async () => { getSiteMonitorTypeTree(props.apiParams).then((res) => { if (!res) return; const allList = []; getAllChildrenData(res.filter((item) => item.code === "ENV_MONITOR"), allList); siteTypeList.value = allList; }); }; const getAllChildrenData = (data, allList) => { data.forEach((item) => { if (item.children?.length) { getAllChildrenData(item.children, allList); return; } allList.push(item); }); }; onMounted(() => { if (props.isUseBuiltInApi) fetchData(); }); watch([() => props.apiParams], () => { if (props.isUseBuiltInApi) fetchData(); }); watch(() => props.data, () => { if (!props.isUseBuiltInApi && props.data) siteTypeList.value = props.data; }); return (_ctx, _cache) => { return openBlock(), createElementBlock("div", { class: normalizeClass(`${clsfix}-container`) }, [ createVNode(unref(FpiElRolling), { direction: "x", "scroll-able": "", time: siteTypeList.value.length * 2 }, { default: withCtx(() => [ createElementVNode("div", _hoisted_1, [ (openBlock(true), createElementBlock(Fragment, null, renderList(siteTypeList.value, (item) => { return openBlock(), createElementBlock("div", { key: item.code, class: "item" }, [ item.name.length < 6 ? (openBlock(), createElementBlock("div", _hoisted_2, toDisplayString(item.name), 1)) : (openBlock(), createElementBlock("div", { key: 1, class: "name", title: item.name }, toDisplayString(`${item.name.slice(0, 4)}...`), 9, _hoisted_3)), createElementVNode("div", _hoisted_4, [ createElementVNode("span", _hoisted_5, toDisplayString(item.onlineCount), 1), createElementVNode("span", null, "/" + toDisplayString(item.totalCount), 1) ]) ]); }), 128)) ]) ]), _: 1 }, 8, ["time"]) ], 2); }; } }); export { _sfc_main as default };