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

139 lines (136 loc) 5.54 kB
import { ElEmpty } from 'element-plus/es'; import 'element-plus/es/components/base/style/css'; import 'element-plus/es/components/empty/style/css'; import { defineComponent, reactive, ref, onMounted, nextTick, openBlock, createElementBlock, createElementVNode, Fragment, renderList, toDisplayString, normalizeStyle, createBlock, unref, toRefs } from 'vue'; import requestControl from '../../service/request.mjs'; import noDataImg from './images/new-nodata.svg.mjs'; const _hoisted_1 = { class: "dv-ipes-air-pollution" }; const _hoisted_2 = { class: "discharge-total" }; const _hoisted_3 = /* @__PURE__ */ createElementVNode("div", { class: "discharge-title" }, [ /* @__PURE__ */ createElementVNode("span", null, "年度累计排放总量 "), /* @__PURE__ */ createElementVNode("span", { class: "unit" }, "(吨)") ], -1); const _hoisted_4 = /* @__PURE__ */ createElementVNode("div", { class: "discharge-label flex" }, [ /* @__PURE__ */ createElementVNode("div", null, " 污染物 "), /* @__PURE__ */ createElementVNode("div", null, " 排放量/允许排放量 ") ], -1); const _hoisted_5 = { key: 0, class: "box" }; const _hoisted_6 = { class: "chart-statistics-head" }; const _hoisted_7 = ["title"]; const _hoisted_8 = { class: "statistics-head-number" }; const _hoisted_9 = /* @__PURE__ */ createElementVNode("span", { class: "separator" }, " / ", -1); const _hoisted_10 = ["title"]; const _hoisted_11 = { class: "chart-statistics-body" }; const _hoisted_12 = { class: "chart-statistics-body-box" }; const __default__ = { name: "DvIpesAirPollutionDischarge", title: "大气污染物排放" }; const _sfc_main = /* @__PURE__ */ defineComponent({ ...__default__, setup(__props) { const chartStatistics = reactive([]); const discharge = reactive({ companyNum: 0, monitorCompanyNum: 0 }); ref(); const fetchData = async () => { try { const result = await requestControl({ method: "get", url: "/ipes-iacp-server/api/v2/gis-panel-data/discharge" }); const data = result.data; const objs = toRefs(data); Object.assign(discharge, objs); const arr = data.factorList.slice(0, 3).map((item) => { let flag = parseInt(item.factorValue) / parseInt(item.targetValue) * 100; if (flag <= 80) item.color = "var(--dv-color-success)"; else if (flag > 80 && flag <= 100) item.color = "var(--dv-color-warning)"; else if (flag > 100) item.color = "var(--dv-color-danger)"; isNaN(flag) && (flag = 0); item.percent = flag > 100 ? 100 : flag; return item; }); chartStatistics.splice(0, chartStatistics.length, ...arr); const seriesData = [ ["在线监测", data.monitorCompanyNum], [ "非在线监测", data.companyNum - data.monitorCompanyNum ] ]; } catch (error) { console.log(error); } }; onMounted(async () => { await nextTick(); fetchData(); }); return (_ctx, _cache) => { const _component_el_empty = ElEmpty; return openBlock(), createElementBlock("div", _hoisted_1, [ createElementVNode("div", _hoisted_2, [ _hoisted_3, _hoisted_4, chartStatistics.length ? (openBlock(), createElementBlock("div", _hoisted_5, [ (openBlock(true), createElementBlock(Fragment, null, renderList(chartStatistics, (item, index) => { return openBlock(), createElementBlock("div", { key: index, class: "chart-statistics" }, [ createElementVNode("div", _hoisted_6, [ createElementVNode("div", { class: "statistics-head-name", title: item.factorName }, toDisplayString(item.factorName), 9, _hoisted_7), createElementVNode("div", _hoisted_8, [ createElementVNode("span", { class: "statistics-head-number-left", style: normalizeStyle({ color: item.color }) }, toDisplayString(item.factorValue || "0"), 5), _hoisted_9, createElementVNode("span", { title: item.targetValue }, toDisplayString(item.targetValue), 9, _hoisted_10) ]) ]), createElementVNode("div", _hoisted_11, [ createElementVNode("div", _hoisted_12, [ createElementVNode("div", { class: "statistics-body-left", style: normalizeStyle({ backgroundColor: item.color, width: `${item.percent}%` }) }, null, 4), createElementVNode("div", { class: "statistics-body-right", style: normalizeStyle({ width: `${100 - item.percent}%` }) }, null, 4) ]) ]) ]); }), 128)) ])) : (openBlock(), createBlock(_component_el_empty, { key: 1, "image-size": 100, image: unref(noDataImg), description: "" }, null, 8, ["image"])) ]) ]); }; } }); export { _sfc_main as default };