@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" />
104 lines (101 loc) • 4.01 kB
JavaScript
import { defineComponent, ref, onMounted, watch, openBlock, createElementBlock, Fragment, renderList, unref, createElementVNode, normalizeStyle, toDisplayString, normalizeClass, withDirectives, vShow } from 'vue';
import dayjs from 'dayjs';
import { useThemeHook } from '../../../utils.mjs';
import { getFollowUpEvaluationEmergency, handleOverCountStatByDay } from './api/index.mjs';
const _hoisted_1 = { class: "evaluation-box" };
const _hoisted_2 = { class: "bar-box" };
const _hoisted_3 = { class: "bar-title" };
const _hoisted_4 = { class: "count" };
const _sfc_main = /* @__PURE__ */ defineComponent({
...{
name: "DvWgmsAlgaeTopicsFollowUpEvaluation",
title: "最近三天藻类预警变化(1.4)"
},
__name: "index",
props: {
treeId: { default: "3301" },
stationType: { default: "002" },
data: { default: null },
timeObj: { default: () => {
return {
periodBeginTime: dayjs().startOf("year").valueOf(),
periodEndTime: dayjs().endOf("year").valueOf(),
currentTime: dayjs().valueOf(),
currentType: "dailyControl",
upToDate: true
};
} },
isLazy: { type: Boolean, default: false }
},
setup(__props, { expose: __expose }) {
const props = __props;
const list = ref([]);
const { isDark } = useThemeHook();
const getAlgaeThreeData = async () => {
if (props.data) {
list.value = props.data;
return;
}
const { beginTime, endTime } = getParamsTime();
const api = props.stationType === "002" ? getFollowUpEvaluationEmergency : handleOverCountStatByDay;
const params = {
beginTime,
endTime,
queryTimeType: "day",
stationCodeList: [1, 40],
treeId: props.treeId,
treeType: 1,
isDataTime: true
};
const res = await api(params);
const resData = res.data || [];
const total = Math.max(...resData.map((cur) => cur.count));
list.value = resData.map((item) => ({ ...item, timeStr: item.timeStr.split("-").slice(1).join("-"), percent: total ? item.count / total * 100 : 0 })).reverse();
};
const getParamsTime = () => {
const currTime = props.timeObj.currentTime || dayjs().valueOf();
const isToday = dayjs().isSame(currTime, "d");
const beginTime = dayjs(currTime).add(isToday ? -3 : -2, "days").startOf("day").valueOf();
const endTime = dayjs(currTime).add(isToday ? -1 : 0, "days").endOf("day").valueOf();
return {
beginTime,
endTime
};
};
onMounted(async () => {
!props.isLazy && getAlgaeThreeData();
});
watch([() => props.treeId, () => props.data, () => props.timeObj, () => props.stationType, () => props.isLazy], () => {
!props.isLazy && getAlgaeThreeData();
}, { deep: true });
__expose({
reload: getAlgaeThreeData
});
return (_ctx, _cache) => {
return openBlock(), createElementBlock("div", _hoisted_1, [
(openBlock(true), createElementBlock(Fragment, null, renderList(unref(list), (item) => {
return openBlock(), createElementBlock("div", {
key: item.timeStr,
class: "evaluation-progress"
}, [
createElementVNode("span", {
class: "time",
style: normalizeStyle({ color: unref(isDark) ? "#fff" : "#303133" })
}, toDisplayString(item.timeStr), 5),
createElementVNode("div", _hoisted_2, [
createElementVNode("div", {
class: normalizeClass(unref(isDark) ? "bar-center" : "bar-center-light"),
style: normalizeStyle({ width: `${item.percent}%` })
}, null, 6),
withDirectives(createElementVNode("div", _hoisted_3, null, 512), [
[vShow, item.percent]
])
]),
createElementVNode("span", _hoisted_4, toDisplayString(item.count), 1)
]);
}), 128))
]);
};
}
});
export { _sfc_main as default };