@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" />
86 lines (83 loc) • 3.21 kB
JavaScript
import { defineComponent, ref, onMounted, watch, openBlock, createElementBlock, createBlock, unref, withCtx, createElementVNode, normalizeStyle, Fragment, renderList, normalizeClass, toDisplayString } from 'vue';
import { get } from 'lodash-es';
import { FpiElRolling } from '@ued_fpi/element-plus-expand';
import { useThemeHook } from '../../../utils.mjs';
import { allConfigList } from './api/index.mjs';
const _hoisted_1 = { class: "monitor-content" };
const _hoisted_2 = { class: "name" };
const _hoisted_3 = { class: "value" };
const _hoisted_4 = { class: "onlineCount" };
const _hoisted_5 = /* @__PURE__ */ createElementVNode("span", { class: "slash" }, "/", -1);
const _hoisted_6 = { class: "totalCount" };
const _hoisted_7 = {
key: 1,
class: "empty-data"
};
const _sfc_main = /* @__PURE__ */ defineComponent({
...{
name: "DvWgmsWaterOnlineEnvironmentalMonitor",
title: "环境在线监测(1.4)"
},
__name: "index",
props: {
code: { default: "011" },
data: { default: null },
isLazy: { type: Boolean, default: false }
},
setup(__props, { expose: __expose }) {
const props = __props;
const time = ref(15);
const list = ref([]);
const { isDark } = useThemeHook();
const getData = async () => {
if (props.data) {
list.value = props.data;
return;
}
const res = await allConfigList(props.code);
list.value = get(res, "data[0].children[0].children") || [];
time.value = list.value.length * 2.5;
};
onMounted(async () => {
!props.isLazy && getData();
});
watch([() => props.code, () => props.data, () => props.isLazy], () => {
!props.isLazy && getData();
}, { deep: true });
__expose({
reload: getData
});
return (_ctx, _cache) => {
return openBlock(), createElementBlock("div", _hoisted_1, [
list.value.length > 0 ? (openBlock(), createBlock(unref(FpiElRolling), {
key: 0,
"scroll-able": "",
time: time.value
}, {
default: withCtx(() => [
createElementVNode("div", {
class: "roll-box",
style: normalizeStyle({ width: list.value.length < 4 ? "374px" : "" })
}, [
(openBlock(true), createElementBlock(Fragment, null, renderList(list.value, (item) => {
return openBlock(), createElementBlock("div", {
key: item.uniqueKey,
class: normalizeClass(["item_bg", unref(isDark) ? "item-bg-dark" : "item-bg-light"])
}, [
createElementVNode("div", _hoisted_2, toDisplayString(item.name), 1),
createElementVNode("div", _hoisted_3, [
createElementVNode("span", _hoisted_4, toDisplayString(item.onlineCount), 1),
_hoisted_5,
createElementVNode("span", _hoisted_6, toDisplayString(item.totalCount), 1)
])
], 2);
}), 128))
], 4)
]),
_: 1
}, 8, ["time"])) : (openBlock(), createElementBlock("div", _hoisted_7, " 暂无数据 "))
]);
};
}
});
export { _sfc_main as default };