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

156 lines (153 loc) 5.45 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, watch, onMounted, toRefs, openBlock, createElementBlock, createElementVNode, createVNode, unref, withCtx, Fragment, renderList, toDisplayString } from 'vue'; import { maxBy } from 'lodash-es'; import dayjs from 'dayjs'; import _sfc_main$2 from '../common/ProgressBar.vue.mjs'; import '../common/ProgressBar.vue2.mjs'; import _sfc_main$1 from '../common/select-panel.vue.mjs'; import '../common/select-panel.vue2.mjs'; import { pomsAlarm } from './api/index.mjs'; const _hoisted_1 = { class: "dv-wgms-pollution-source" }; const _hoisted_2 = { class: "dv-wgms-key-source" }; const _hoisted_3 = { class: "dv-wgms-title-text" }; const _hoisted_4 = /* @__PURE__ */ createElementVNode("div", { class: "dv-wgms-text" }, " 重点源超标前三 ", -1); const _hoisted_5 = { class: "dv-wgms-select" }; const _hoisted_6 = { class: "dv-wgms-top" }; const _hoisted_7 = { class: "dv-wgms-left" }; const _hoisted_8 = { class: "dv-wgms-right" }; const _hoisted_9 = { class: "dv-wgms-bar" }; const _sfc_main = /* @__PURE__ */ defineComponent({ ...{ name: "DvWgmsPollutionSourceControl", title: "污染源管控-重点源超标前三" }, __name: "index", props: { factorList: { type: Array, default: () => [] }, params: { type: Object, default: () => { return { distance: 5e3, startTime: dayjs().startOf("year").valueOf(), endTime: dayjs().endOf("year").valueOf(), latitude: 30, longitude: 120, timeType: "day" }; } }, isLazy: { type: Boolean, default: false }, data: { type: Array, default: void 0 } }, emits: ["factorChange"], setup(__props, { expose: __expose, emit: emits }) { const props = __props; const pollutionData = reactive({ companyList: [], curSelectFactor: "", overCountMax: 0 }); watch([ () => props.params, () => props.data, () => props.isLazy ], () => { if (props.isLazy) return; keyPollutionData(); }); const keyFactorsCheck = (item, index) => { if (pollutionData.curSelectFactor === item.code) return; pollutionData.curSelectFactor = item.code; emits("factorChange", item.code); keyPollutionData(); }; onMounted(() => { if (props.isLazy) return; keyPollutionData(); }); const keyPollutionData = async () => { let resData; if (props.data) { resData = props.data; } else { const params = { ...props.params, factor: pollutionData.curSelectFactor, factorFlag: pollutionData.curSelectFactor === "" }; const res = await pomsAlarm(params); resData = res?.data ?? []; } if (resData.length) { pollutionData.companyList = resData.slice(0, 3); const maxObj = maxBy(pollutionData.companyList, "overCount"); pollutionData.overCountMax = maxObj.overCount; } else { pollutionData.companyList = []; } }; const { companyList, overCountMax, curSelectFactor } = toRefs(pollutionData); __expose({ reload: keyPollutionData }); return (_ctx, _cache) => { const _component_el_scrollbar = ElScrollbar; return openBlock(), createElementBlock("div", _hoisted_1, [ createElementVNode("div", _hoisted_2, [ createElementVNode("div", _hoisted_3, [ _hoisted_4, createElementVNode("div", _hoisted_5, [ createVNode(_sfc_main$1, { option: __props.factorList, "default-value": unref(curSelectFactor), onChange: keyFactorsCheck }, null, 8, ["option", "default-value"]) ]) ]), createVNode(_component_el_scrollbar, { class: "dv-wgms-key-list" }, { default: withCtx(() => [ (openBlock(true), createElementBlock(Fragment, null, renderList(unref(companyList), (item, index) => { return openBlock(), createElementBlock("div", { key: index, class: "dv-wgms-key-one" }, [ createElementVNode("div", _hoisted_6, [ createElementVNode("div", _hoisted_7, [ createElementVNode("span", null, toDisplayString(item.rank), 1), createElementVNode("span", null, toDisplayString(item.pomsName), 1) ]), createElementVNode("div", _hoisted_8, toDisplayString(item.overCount), 1) ]), createElementVNode("div", _hoisted_9, [ createVNode(_sfc_main$2, { "active-color": "linear-gradient(270deg, var(--dv-color-danger) 0%, var(--dv-color-danger-30) 100%)", "handle-style": { background: "var(--dv-color-danger)" }, percentage: item.overCount / unref(overCountMax) * 100 }, null, 8, ["handle-style", "percentage"]) ]) ]); }), 128)) ]), _: 1 }) ]) ]); }; } }); export { _sfc_main as default };