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

150 lines (147 loc) 4.34 kB
import { defineComponent, ref, reactive, openBlock, createElementBlock, normalizeStyle, createBlock, unref, createCommentVNode } from 'vue'; import { useCssVar } from '@vueuse/core'; import dayjs from 'dayjs'; import _sfc_main$1 from '../common/Echarts.vue.mjs'; import '../common/Echarts.vue2.mjs'; import requestControl from '../../service/request.mjs'; import _sfc_main$2 from '../common/NoData.vue.mjs'; import '../common/NoData.vue2.mjs'; import { setIntervalData } from '../../utils/hooks.mjs'; const __default__ = { name: "DvIpesHomeworkVolumeTrend", title: "作业量趋势" }; const _sfc_main = /* @__PURE__ */ defineComponent({ ...__default__, props: { // 作业量趋势 getHomeworkVolumeTrendApi: { type: String, default: "/ipes-srip-server/api/v3/special-operation-statistics/operation-total" }, // 开始时间 beginTime: { type: Number, default: dayjs().startOf("year").valueOf() }, // 结束时间 endTime: { type: Number, default: Date.now() }, // 高度 height: { type: String, default: "112px" } }, setup(__props) { const props = __props; const xlabelEl = ref(null); const xlabelColor = useCssVar("--dv-color-text-primary", xlabelEl); const ylabelEl = ref(null); const ylabelColor = useCssVar("--dv-color-text-secondary", ylabelEl); const splitLineEl = ref(null); const splitLineElColor = useCssVar("--dv-color-border-light", splitLineEl); const chartOption = reactive({ options: { tooltip: { show: true, trigger: "axis" }, grid: { top: "20px", left: "40px", right: "20px", bottom: "30px" }, xAxis: { type: "category", axisLabel: { color: xlabelColor.value, fontFamily: "var(--dv-font-family-number)", fontSize: "var(--dv-text-number2)" }, axisTick: { show: false }, axisLine: { lineStyle: { color: splitLineElColor.value } }, data: [] }, yAxis: { type: "value", axisLabel: { color: ylabelColor.value, fontFamily: "var(--dv-font-family-number)", fontSize: "var(--dv-text-number2)" }, splitLine: { lineStyle: { color: splitLineElColor.value }, show: true } }, series: [ { data: [], type: "line", itemStyle: { color: "#F95EB1", lineStyle: { color: "#F95EB1", borderWidth: 8 } } } ] } }); const isInit = ref(false); const isNoData = ref(false); async function getHomeworkVolumeTrend() { try { const res = await requestControl({ method: "get", url: props.getHomeworkVolumeTrendApi, params: { beginTime: props.beginTime, endTime: props.endTime } }); isInit.value = true; if (res.success) setOptions(res.data); else isNoData.value = true; } catch (error) { console.log(error); } } getHomeworkVolumeTrend(); function setOptions(data) { chartOption.options.xAxis.data = data.map((ele, index) => `${index + 1}月`); chartOption.options.series[0].data = data; } setIntervalData(getHomeworkVolumeTrend, 5 * 60 * 1e3); return (_ctx, _cache) => { return openBlock(), createElementBlock("div", { class: "dv-ipes-homework-volume-trend", style: normalizeStyle({ height: __props.height }) }, [ isInit.value && !isNoData.value ? (openBlock(), createBlock(_sfc_main$1, { key: 0, "full-options": unref(chartOption), loading: false, height: __props.height }, null, 8, ["full-options", "height"])) : createCommentVNode("", true), isInit.value && isNoData.value ? (openBlock(), createBlock(_sfc_main$2, { key: 1 })) : createCommentVNode("", true) ], 4); }; } }); export { _sfc_main as default };