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

161 lines (158 loc) 5.87 kB
import { ElScrollbar } from 'element-plus/es'; import 'element-plus/es/components/base/style/css'; import 'element-plus/es/components/scrollbar/style/css'; import { defineComponent, reactive, ref, onMounted, watch, toRefs, openBlock, createElementBlock, createElementVNode, Fragment, renderList, normalizeClass, normalizeStyle, toDisplayString, createVNode, withCtx, unref } from 'vue'; import dayjs from 'dayjs'; import { getDateEndTime } from '../../utils/tools.mjs'; import { queryFactorGroup, pollutionSourceElements } from './api/index.mjs'; const _hoisted_1 = { class: "dv-wgms-pollution-sources-elements" }; const _hoisted_2 = { class: "custom-table" }; const _hoisted_3 = { class: "custom-table-header" }; const _hoisted_4 = /* @__PURE__ */ createElementVNode("div", { style: { "width": "46px" }, class: "fixed-width" }, " 序号 ", -1); const _hoisted_5 = { class: "custom-table-cell fixed-width", style: { "width": "46px" } }; const _sfc_main = /* @__PURE__ */ defineComponent({ ...{ name: "DvWgmsPollutionSourcesElements", title: "各要素详情-污染源" }, __name: "index", props: { params: { type: Object, default: () => { return { queryTimeType: "day", beginTime: 170136e7, endTime: 1701964799999, alarmTime: 1701964799999, factor: 1, // 因子ID longitude: 119.168, latitude: 30.183, distance: 12e4, limit: -1, minWave: 2 }; } }, isLazy: { type: Boolean, default: false } }, setup(__props, { expose: __expose }) { const props = __props; const state = reactive({ tableData: [] }); const tableProps = ref([ { label: "名称", prop: "name" }, { label: "预警次数", prop: "alarmCount", width: "60px" }, { label: "距离(km)", prop: "distance", width: "70px" }, { label: "波动率", prop: "bdl", width: "70px" } ]); const getDateTime = () => { const timeType = props?.params?.queryTimeType || "hour"; const dateType = props?.params?.queryTimeType === "day" ? "days" : props?.params?.queryTimeType === "hour" ? "hours" : props?.params?.queryTimeType; const dataTime = props?.params?.queryTimeType === "hour" || props?.params?.queryTimeType === "day" ? props?.params?.alarmTime : dayjs(props?.params?.alarmTime).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 getData = async () => { const resp = await queryFactorGroup({ code: "companyPollutionSource" }); const factorsObj = resp && resp.length ? resp[0] : null; const params = { queryTimeType: props?.params?.queryTimeType, beginTime: props?.params?.beginTime, // 分析时间开始 endTime: getDateEndTime(props?.params?.queryTimeType, props.params?.endTime), factorFlag: true, factor: factorsObj?.id, longitude: props?.params?.longitude, latitude: props?.params?.latitude, distance: props?.params?.distance / 1e3, limit: props?.params?.limit, minWave: props?.params?.minWave, waveBeginTime: getDateTime().startTime, waveEndTime: getDateTime().endTime, waveFactorFlag: false, waveFactor: props?.params?.factor }; const res = await pollutionSourceElements(params); state.tableData = res?.data || []; }; onMounted(async () => { !props.isLazy && getData(); }); watch([() => props.params, () => props.isLazy], () => { !props.isLazy && getData(); }, { deep: true }); __expose({ reload: getData }); const { tableData } = toRefs(state); return (_ctx, _cache) => { const _component_el_scrollbar = ElScrollbar; return openBlock(), createElementBlock("div", _hoisted_1, [ createElementVNode("div", _hoisted_2, [ createElementVNode("div", _hoisted_3, [ _hoisted_4, (openBlock(true), createElementBlock(Fragment, null, renderList(tableProps.value, (item) => { return openBlock(), createElementBlock("div", { key: item.prop, class: normalizeClass(item.width ? "fixed-width" : "auto-width"), style: normalizeStyle({ width: item.width }) }, toDisplayString(item.label), 7); }), 128)) ]), createVNode(_component_el_scrollbar, { class: "custom-table-body" }, { default: withCtx(() => [ (openBlock(true), createElementBlock(Fragment, null, renderList(unref(tableData), (item, index) => { return openBlock(), createElementBlock("div", { key: item.id, class: "custom-table-row" }, [ createElementVNode("div", _hoisted_5, toDisplayString(index + 1), 1), (openBlock(true), createElementBlock(Fragment, null, renderList(tableProps.value, (prop) => { return openBlock(), createElementBlock("div", { key: prop.prop, class: normalizeClass(["custom-table-cell", [prop.width ? "fixed-width" : "auto-width"]]), style: normalizeStyle({ width: prop.width }) }, toDisplayString(item[prop.prop] || item[prop.prop] === 0 ? item[prop.prop] : "--"), 7); }), 128)) ]); }), 128)) ]), _: 1 }) ]) ]); }; } }); export { _sfc_main as default };