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

104 lines (101 loc) 3.34 kB
import { defineComponent, reactive, onMounted, watch, toRefs, openBlock, createElementBlock, createElementVNode, Fragment, renderList, unref, toDisplayString } from 'vue'; import dayjs from 'dayjs'; import { analysisResult } from './api/index.mjs'; const _hoisted_1 = { class: "dv-wgms-auxiliary-judgment" }; const _hoisted_2 = { class: "conclusion-box" }; const _sfc_main = /* @__PURE__ */ defineComponent({ ...{ name: "DvWgmsAuxiliaryJudgment", title: "辅助研判" }, __name: "index", props: { params: { type: Object, default: () => { return { beginTime: 16858944e5, endTime: 16858944e5, distance: 1e4, factorId: 9, // 因子ID longitude: 120.445633, latitude: 30.120086, siteCode: "YYZDSTGG00S330127_0012A", surroundingStationCodes: "1", // 需要找的周边类型编码 timeStamp: 1688313541e3, // 统计事件数量的时间点 timeType: "week", siteCodeList: [] // 站点code }; } }, returnData: { type: Array, default: () => { return []; } }, isLazy: { type: Boolean, default: false } }, setup(__props, { expose: __expose }) { const props = __props; const data = reactive({ resultTable: [] // 研判结论返回 }); const getDateTime = () => { const timeType = props?.params?.timeType; const dateType = props?.params?.timeType === "day" ? "days" : props?.params?.timeType === "hour" ? "hours" : props?.params?.timeType; const dataTime = props?.params?.timeType === "hour" || props?.params?.timeType === "day" ? props?.params.timeStamp : dayjs(props?.params.timeStamp).startOf(timeType).valueOf(); return { startTime: dayjs(dataTime).add(-23, dateType).startOf(timeType).format("x"), endTime: dayjs(dataTime).add(1, dateType).startOf(timeType).format("x") }; }; const getConclusion = () => { if (props.returnData && props.returnData.length) { data.resultTable = props.returnData; return; } const { startTime, endTime } = getDateTime(); const params = { ...props?.params, distance: props?.params?.distance / 1e3, waveBeginTime: startTime, waveEndTime: endTime }; analysisResult(params).then((res) => { data.resultTable = res?.data ?? []; }); }; onMounted(async () => { !props.isLazy && getConclusion(); }); watch([() => props.params, () => props.returnData, () => props.isLazy], () => { !props.isLazy && getConclusion(); }, { deep: true }); __expose({ reload: getConclusion }); const { resultTable } = toRefs(data); return (_ctx, _cache) => { return openBlock(), createElementBlock("div", _hoisted_1, [ createElementVNode("div", _hoisted_2, [ (openBlock(true), createElementBlock(Fragment, null, renderList(unref(resultTable), (item, index) => { return openBlock(), createElementBlock("div", { key: index, class: "conclusion-text" }, toDisplayString(item), 1); }), 128)) ]) ]); }; } }); export { _sfc_main as default };