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

154 lines (151 loc) 5.6 kB
import { defineComponent, reactive, ref, watch, onMounted, toRefs, openBlock, createElementBlock, createElementVNode, toDisplayString, unref, createVNode, Fragment, renderList, normalizeStyle } from 'vue'; import dayjs from 'dayjs'; import { pollutionSourcePieOptions } from '../../utils/echarts/echartsOptions.mjs'; import _sfc_main$1 from '../../utils/echarts/BaseECharts.vue.mjs'; import { pomsFactorAlarm } from './api/index.mjs'; const _hoisted_1 = { class: "dv-wgms-pollution-source", style: { "width": "auto" } }; const _hoisted_2 = { class: "dv-wgms-statistic-content" }; const _hoisted_3 = { class: "dv-wgms-statistic-box" }; const _hoisted_4 = /* @__PURE__ */ createElementVNode("div", { class: "dv-wgms-text" }, " 重点源超标统计 ", -1); const _hoisted_5 = { class: "dv-wgms-total-content" }; const _hoisted_6 = /* @__PURE__ */ createElementVNode("div", { class: "dv-wgms-left" }, " 总数 ", -1); const _hoisted_7 = { class: "dv-wgms-right" }; const _hoisted_8 = { class: "dv-wgms-num" }; const _hoisted_9 = { class: "dv-wgms-legend" }; const _hoisted_10 = { class: "dv-wgms-left" }; const _hoisted_11 = { class: "dv-wgms-name" }; const _hoisted_12 = { class: "dv-wgms-right" }; const _hoisted_13 = /* @__PURE__ */ createElementVNode("span", null, "/", -1); const _sfc_main = /* @__PURE__ */ defineComponent({ ...{ name: "DvWgmsPollutionSourceControlStatistics", title: "污染源管控-重点源超标统计" }, __name: "index", props: { params: { type: Object, default: () => { return { distance: 5e3, startTime: dayjs().startOf("year").valueOf(), endTime: dayjs().endOf("year").valueOf(), factor: "", factorFlag: true, latitude: 30, longitude: 120, timeType: "day" }; } }, isLazy: { type: Boolean, default: false }, data: { type: Object, default: void 0 } }, setup(__props, { expose: __expose }) { const props = __props; const staticData = reactive({ chartDetail: [], colorList: ["var(--dv-color-danger)", "var(--dv-color-primary)", "var(--dv-color-success)"], totalCount: 0 }); const statChart = ref(null); watch([ () => props.params, () => props.data, () => props.isLazy ], () => { if (props.isLazy) return; keyPollutionStatistic(); }); const option = ref(); onMounted(() => { if (props.isLazy) return; keyPollutionStatistic(); }); const keyPollutionStatistic = async () => { let resData; if (props.data) { resData = props.data; } else { const res = await pomsFactorAlarm(props.params); resData = res.data; } const total = resData?.totalCount ?? 0; staticData.totalCount = total; const dataList = [ { name: "氮超标", value: resData?.ncount ?? "--", percent: resData?.npercent ?? "--" }, { name: "磷超标", value: resData?.pcount ?? "--", percent: resData?.ppercent ?? "--" }, { name: "其他", value: resData?.otherCount ?? "--", percent: resData?.otherPercent ?? "--" } ]; staticData.chartDetail = dataList.map((item, index) => { return { ...item, itemStyle: { color: staticData.colorList[index] } }; }); const seriesData = [ ...staticData.chartDetail ]; option.value = pollutionSourcePieOptions(seriesData); }; const { colorList, totalCount, chartDetail } = toRefs(staticData); __expose({ reload: keyPollutionStatistic }); return (_ctx, _cache) => { return openBlock(), createElementBlock("div", _hoisted_1, [ createElementVNode("div", _hoisted_2, [ createElementVNode("div", _hoisted_3, [ _hoisted_4, createElementVNode("div", _hoisted_5, [ _hoisted_6, createElementVNode("div", _hoisted_7, [ createElementVNode("div", _hoisted_8, toDisplayString(unref(totalCount)), 1), createElementVNode("div", { ref_key: "statChart", ref: statChart, class: "dv-wgms-chart" }, [ createVNode(_sfc_main$1, { options: option.value }, null, 8, ["options"]) ], 512) ]) ]), createElementVNode("div", _hoisted_9, [ (openBlock(true), createElementBlock(Fragment, null, renderList(unref(chartDetail), (item, index) => { return openBlock(), createElementBlock("div", { key: index, class: "dv-wgms-legend-one" }, [ createElementVNode("div", _hoisted_10, [ createElementVNode("div", { class: "dv-wgms-circle", style: normalizeStyle({ background: unref(colorList)[index] }) }, null, 4), createElementVNode("div", _hoisted_11, toDisplayString(item.name || "--"), 1) ]), createElementVNode("div", _hoisted_12, [ createElementVNode("span", null, toDisplayString(item.value ?? "--"), 1), _hoisted_13, createElementVNode("span", null, toDisplayString(item.percent ?? "--") + "%", 1) ]) ]); }), 128)) ]) ]) ]) ]); }; } }); export { _sfc_main as default };