Commit a0043311 authored by 吕超's avatar 吕超

fix: 自动化添加部分全局组件

parent 9702c210
...@@ -25,37 +25,37 @@ ...@@ -25,37 +25,37 @@
<script> <script>
// #144683 // #144683
export default { export default {
name: 'statusControl', name: "statusControl",
props: { props: {
list: { list: {
type: Array, type: Array,
default: function () { default: function () {
return [] return [];
} },
}, },
statusStyle: { statusStyle: {
type: [Object, String], type: [Object, String],
default: '' default: "",
}, },
value: { value: {
type: Object, type: Object,
default: function () { default: function () {
return {} return {};
} },
} },
}, },
data() { data() {
return { return {
isShow: false isShow: false,
} };
}, },
methods: { methods: {
onStatusChange(item) { onStatusChange(item) {
this.$emit('input', item) this.$emit("input", item);
this.isShow = false this.isShow = false;
} },
} },
} };
</script> </script>
<style scoped lang="less"> <style scoped lang="less">
......
import Vue from "vue";
/*
* 1. 引入各个模块下公用组件
* 2. 各个模块下vue文件名为命名空间,
* 3. 在组件中使用公用组件:StatusControl.vue => <StatusControl></StatusControl> 建议全部大驼峰
* */
// const commonComponents = {};
const moduleContext = require.context("./components/", true, /\.vue$/);
moduleContext.keys().forEach((key) => {
const name = key.split("/").pop().replace(".vue", "");
Vue.component(
name.slice(0, 1).toUpperCase() + name.slice(1),
moduleContext(key).default
);
});
// export default {
// install() {
// },
// };
...@@ -4,6 +4,7 @@ import router from "./router"; ...@@ -4,6 +4,7 @@ import router from "./router";
import store from "./store"; import store from "./store";
import mapboxgl from "mapbox-gl"; import mapboxgl from "mapbox-gl";
import apis from "./api/index"; import apis from "./api/index";
import "./components/common/index.js";
import ElementUI from "element-ui"; import ElementUI from "element-ui";
import "element-ui/lib/theme-chalk/index.css"; import "element-ui/lib/theme-chalk/index.css";
......
...@@ -26,7 +26,6 @@ ...@@ -26,7 +26,6 @@
</template> </template>
<script> <script>
import PartWrap from "@/components/PartWrap/PartWrap.vue";
import { BiomassData } from "../config/biomass.config.js"; import { BiomassData } from "../config/biomass.config.js";
export default { export default {
name: "leftPart", name: "leftPart",
...@@ -42,9 +41,7 @@ export default { ...@@ -42,9 +41,7 @@ export default {
data: [], data: [],
}; };
}, },
components: { components: {},
PartWrap,
},
created() { created() {
this.getEnergyWarm(); this.getEnergyWarm();
}, },
......
...@@ -20,7 +20,6 @@ ...@@ -20,7 +20,6 @@
</template> </template>
<script> <script>
import PartWrap from "@/components/PartWrap/PartWrap.vue";
import Echart from "@/components/Echart/Echarts.vue"; import Echart from "@/components/Echart/Echarts.vue";
import { BiomassData } from "../config/biomass.config.js"; import { BiomassData } from "../config/biomass.config.js";
export default { export default {
...@@ -38,7 +37,6 @@ export default { ...@@ -38,7 +37,6 @@ export default {
}; };
}, },
components: { components: {
PartWrap,
Echart, Echart,
}, },
computed: { computed: {
......
...@@ -30,7 +30,6 @@ ...@@ -30,7 +30,6 @@
</template> </template>
<script> <script>
import PartWrap from "@/components/PartWrap/PartWrap.vue";
import { BiomassData } from "../config/biomass.config.js"; import { BiomassData } from "../config/biomass.config.js";
export default { export default {
name: "biogasTable", name: "biogasTable",
...@@ -44,9 +43,7 @@ export default { ...@@ -44,9 +43,7 @@ export default {
default: () => [], default: () => [],
}, },
}, },
components: { components: {},
PartWrap,
},
data() { data() {
return {}; return {};
}, },
......
...@@ -44,93 +44,89 @@ ...@@ -44,93 +44,89 @@
</template> </template>
<script> <script>
import PartWrap from '@/components/PartWrap/PartWrap.vue' import Echart from "@/components/Echart/Echarts.vue";
import Echart from '@/components/Echart/Echarts.vue' import Legend from "@/components/Lengend/Lengend.vue";
import StatusControl from '@/components/statusControl/index.vue' import { getCodeOfName } from "@/config/city.config";
import Legend from '@/components/Lengend/Lengend.vue' import BiogasManureMap from "./components/biogasManureMap.vue";
import { getCodeOfName } from '@/config/city.config' import LeftPart from "./components/leftPart.vue";
import BiogasManureMap from './components/biogasManureMap.vue' import SortList from "./components/sortList.vue";
import LeftPart from './components/leftPart.vue' import Table from "./components/table.vue";
import SortList from './components/sortList.vue' import { BiomassData } from "./config/biomass.config.js";
import Table from './components/table.vue' import { color, colorLabel } from "./config/legend.config";
import { BiomassData } from './config/biomass.config.js' import { mapGetters } from "vuex";
import { color, colorLabel } from './config/legend.config'
import { mapGetters } from 'vuex'
export default { export default {
name: 'BiomassEnergyWarm', name: "BiomassEnergyWarm",
data() { data() {
return { return {
statusControlList: [ statusControlList: [
{ key: 'gn', value: '打捆直燃集中供暖' }, { key: "gn", value: "打捆直燃集中供暖" },
{ key: 'ghcx', value: '固化成型' }, { key: "ghcx", value: "固化成型" },
{ key: 'rj', value: '热解气化' }, { key: "rj", value: "热解气化" },
{ key: 'th', value: '碳化' } { key: "th", value: "碳化" },
], ],
statusValue: { key: 'gn', value: '打捆直燃集中供暖' }, statusValue: { key: "gn", value: "打捆直燃集中供暖" },
dataSetCode: 'ra_energy_heating', dataSetCode: "ra_energy_heating",
data: [], data: [],
color, color,
colorLabel, colorLabel,
provinceCode: '', provinceCode: "",
allItemValue: { key: 'gn_local', value: '数量(处)' } allItemValue: { key: "gn_local", value: "数量(处)" },
} };
}, },
components: { components: {
PartWrap,
Echart, Echart,
BiogasManureMap, BiogasManureMap,
LeftPart, LeftPart,
StatusControl,
SortList, SortList,
Table, Table,
Legend Legend,
}, },
computed: { computed: {
getItemOfType() { getItemOfType() {
return BiomassData[this.statusValue.key].find( return BiomassData[this.statusValue.key].find(
item => item.type === 'aggregation' (item) => item.type === "aggregation"
) );
}, },
getAllItemOfType() { getAllItemOfType() {
return BiomassData[this.statusValue.key] return BiomassData[this.statusValue.key];
}, },
getValOfdata() { getValOfdata() {
const res = { const res = {
[this.getItemOfType.key]: [] [this.getItemOfType.key]: [],
} };
this.data.forEach(item => { this.data.forEach((item) => {
res[this.getItemOfType.key].push({ res[this.getItemOfType.key].push({
xAxis: item.properties.pname, xAxis: item.properties.pname,
yAxis: item.properties[this.getItemOfType.key] yAxis: item.properties[this.getItemOfType.key],
}) });
}) });
return res return res;
}, },
setOptionOfEchart() { setOptionOfEchart() {
return function (type) { return function (type) {
const data = this.getValOfdata[type] const data = this.getValOfdata[type]
.filter(item => item.yAxis) .filter((item) => item.yAxis)
.sort((a, b) => b.yAxis - a.yAxis) .sort((a, b) => b.yAxis - a.yAxis);
const xData = data.map(item => item.xAxis) const xData = data.map((item) => item.xAxis);
const yData = data.map(item => item.yAxis) const yData = data.map((item) => item.yAxis);
const option = { const option = {
title: {}, title: {},
color: ['#d65108'], color: ["#d65108"],
tooltip: { tooltip: {
show: true, show: true,
trigger: 'axis' trigger: "axis",
}, },
grid: { grid: {
left: '3%', left: "3%",
right: '3%', right: "3%",
top: '10%', top: "10%",
bottom: '3%', bottom: "3%",
containLabel: true containLabel: true,
}, },
yAxis: [ yAxis: [
{ {
type: 'value', type: "value",
// splitLine: { // splitLine: {
// lineStyle: { // lineStyle: {
// color: "rgba(255,255,255,.15)", // color: "rgba(255,255,255,.15)",
...@@ -138,102 +134,102 @@ export default { ...@@ -138,102 +134,102 @@ export default {
// }, // },
axisLine: { axisLine: {
lineStyle: { lineStyle: {
color: '#fff' color: "#fff",
} },
} },
} },
], ],
xAxis: [ xAxis: [
{ {
position: 'bottom', position: "bottom",
type: 'category', type: "category",
data: xData, data: xData,
axisTick: { axisTick: {
show: false show: false,
}, },
axisLine: { axisLine: {
show: false show: false,
}, },
axisLabel: { axisLabel: {
color: '#fff' color: "#fff",
} },
} },
], ],
series: [ series: [
{ {
name: '', name: "",
type: 'bar', type: "bar",
barWidth: `50%`, barWidth: `50%`,
data: yData, data: yData,
label: { label: {
show: true, show: true,
position: 'top' position: "top",
}, },
itemStyle: { itemStyle: {
color: '#d8ee2c' color: "#d8ee2c",
// emphasis: { // emphasis: {
// color: "rgba(201,59,60)", // color: "rgba(201,59,60)",
// }, // },
} },
} },
] ],
} };
return option return option;
} };
}, },
// 获取所有值 // 获取所有值
getRandomLabel() { getRandomLabel() {
const obj = BiomassData[this.statusValue.key].find( const obj = BiomassData[this.statusValue.key].find(
item => item.key === this.allItemValue.key (item) => item.key === this.allItemValue.key
) );
const res = [] const res = [];
this.data.forEach(item => { this.data.forEach((item) => {
res.push(item.properties[obj.key]) res.push(item.properties[obj.key]);
}) });
return [...new Set(res)].filter(item => item).sort((a, b) => a - b) return [...new Set(res)].filter((item) => item).sort((a, b) => a - b);
}, },
// 根据值生产颜色段 // 根据值生产颜色段
getRandomColorLabel() { getRandomColorLabel() {
const labels = this.getRandomLabel const labels = this.getRandomLabel;
const min = labels[0] const min = labels[0];
const max = labels[labels.length - 1] const max = labels[labels.length - 1];
const colorLabels = [] const colorLabels = [];
const part = (max - min) / 4 const part = (max - min) / 4;
for (let i = 1; i <= 4; i++) { for (let i = 1; i <= 4; i++) {
colorLabels.push(Number((part * i - 1).toFixed(4))) colorLabels.push(Number((part * i - 1).toFixed(4)));
} }
return colorLabels return colorLabels;
}, },
...mapGetters(['getMsgOfProvince']) ...mapGetters(["getMsgOfProvince"]),
}, },
created() { created() {
this.getEnergyWarm() this.getEnergyWarm();
}, },
methods: { methods: {
getEnergyWarm() { getEnergyWarm() {
const param = { const param = {
filter: ['!=', 'pcode', 10] filter: ["!=", "pcode", 10],
} };
this.$api.layer.query(this.dataSetCode, param).then(res => { this.$api.layer.query(this.dataSetCode, param).then((res) => {
this.data = res.data.features this.data = res.data.features;
this.getValOfdata this.getValOfdata;
}) });
}, },
barClick(name) { barClick(name) {
console.log(name) console.log(name);
const code = getCodeOfName(name.name) const code = getCodeOfName(name.name);
code && (this.provinceCode = code) code && (this.provinceCode = code);
} },
}, },
watch: { watch: {
statusValue: { statusValue: {
handler(val) { handler(val) {
this.allItemValue = BiomassData[val.key][0] this.allItemValue = BiomassData[val.key][0];
}, },
deep: true deep: true,
} },
} },
} };
</script> </script>
<style scoped lang="less"> <style scoped lang="less">
......
This diff is collapsed.
...@@ -21,7 +21,6 @@ ...@@ -21,7 +21,6 @@
<script> <script>
import { mapGetters } from "vuex"; import { mapGetters } from "vuex";
import PartWrap from "@/components/PartWrap/PartWrap.vue";
export default { export default {
name: "filterProvince", name: "filterProvince",
data() { data() {
...@@ -29,9 +28,7 @@ export default { ...@@ -29,9 +28,7 @@ export default {
search: "", search: "",
}; };
}, },
components: { components: {},
PartWrap,
},
created() {}, created() {},
computed: { computed: {
getData() { getData() {
......
...@@ -14,7 +14,6 @@ ...@@ -14,7 +14,6 @@
<script> <script>
import { mapGetters } from "vuex"; import { mapGetters } from "vuex";
import PartWrap from "@/components/PartWrap/PartWrap.vue";
import Echart from "@/components/Echart/Echarts.vue"; import Echart from "@/components/Echart/Echarts.vue";
export default { export default {
name: "sortList", name: "sortList",
...@@ -35,7 +34,6 @@ export default { ...@@ -35,7 +34,6 @@ export default {
}; };
}, },
components: { components: {
PartWrap,
Echart, Echart,
}, },
computed: { computed: {
......
...@@ -24,7 +24,6 @@ ...@@ -24,7 +24,6 @@
</template> </template>
<script> <script>
import PartWrap from "@/components/PartWrap/PartWrap.vue";
import { mapGetters } from "vuex"; import { mapGetters } from "vuex";
export default { export default {
name: "biogasTable", name: "biogasTable",
...@@ -41,9 +40,7 @@ export default { ...@@ -41,9 +40,7 @@ export default {
type: [String, Number], type: [String, Number],
}, },
}, },
components: { components: {},
PartWrap,
},
data() { data() {
return { return {
tableColumn: [ tableColumn: [
......
...@@ -44,40 +44,38 @@ ...@@ -44,40 +44,38 @@
</template> </template>
<script> <script>
import { mapActions, mapState } from 'vuex' import { mapActions, mapState } from "vuex";
import PartWrap from '@/components/PartWrap/PartWrap.vue'
// import StatusControl from '@/components/statusControl/index.vue' // import StatusControl from '@/components/statusControl/index.vue'
import { getCodeOfName } from '@/config/city.config' import { getCodeOfName } from "@/config/city.config";
import DateWidget from '@/components/DateWidget/DateWidget.vue' import DateWidget from "@/components/DateWidget/DateWidget.vue";
import EnergyVillageMap from './components/energyVillageMap.vue' import EnergyVillageMap from "./components/energyVillageMap.vue";
// import Table from "./components/table.vue"; // import Table from "./components/table.vue";
import FilterProvince from './components/filterProvince.vue' import FilterProvince from "./components/filterProvince.vue";
import SortList from './components/sortList.vue' import SortList from "./components/sortList.vue";
// import PicPopup from './components/picPopup.vue' // import PicPopup from './components/picPopup.vue'
export default { export default {
name: 'RenewableEnergyVillage', name: "RenewableEnergyVillage",
components: { components: {
PartWrap,
EnergyVillageMap, EnergyVillageMap,
// Table, // Table,
// StatusControl, // StatusControl,
SortList, SortList,
FilterProvince, FilterProvince,
DateWidget DateWidget,
// PicPopup // PicPopup
}, },
created() { created() {
this.getData() this.getData();
}, },
data() { data() {
return { return {
statusControlList: [{ key: 'province', value: '省份筛选' }], statusControlList: [{ key: "province", value: "省份筛选" }],
showFilter: '', showFilter: "",
statusValue: { value: '全国' }, statusValue: { value: "全国" },
yearRange: [], yearRange: [],
yearValue: '', yearValue: "",
showPopup: false, showPopup: false,
popupId: '', popupId: "",
imageUrl: `${process.env.VUE_APP_BASE_URL}/images/14_basic_info1.jpg`, imageUrl: `${process.env.VUE_APP_BASE_URL}/images/14_basic_info1.jpg`,
srcList: [ srcList: [
`${process.env.VUE_APP_BASE_URL}/images/14_basic_info1.jpg`, `${process.env.VUE_APP_BASE_URL}/images/14_basic_info1.jpg`,
...@@ -85,68 +83,67 @@ export default { ...@@ -85,68 +83,67 @@ export default {
`${process.env.VUE_APP_BASE_URL}/images/14_basic_info3.jpg`, `${process.env.VUE_APP_BASE_URL}/images/14_basic_info3.jpg`,
`${process.env.VUE_APP_BASE_URL}/images/14_technical_patterns.jpg`, `${process.env.VUE_APP_BASE_URL}/images/14_technical_patterns.jpg`,
`${process.env.VUE_APP_BASE_URL}/images/14_goal_achievement.jpg`, `${process.env.VUE_APP_BASE_URL}/images/14_goal_achievement.jpg`,
`${process.env.VUE_APP_BASE_URL}/images/14_eco_benefits.jpg` `${process.env.VUE_APP_BASE_URL}/images/14_eco_benefits.jpg`,
] ],
} };
}, },
computed: { computed: {
getYearRange() { getYearRange() {
let yearRange = [] let yearRange = [];
this.data.features.forEach(item => { this.data.features.forEach((item) => {
let year = item.properties.vliiage_year let year = item.properties.vliiage_year;
if (!yearRange.find(item => item === year)) { if (!yearRange.find((item) => item === year)) {
yearRange.push(year) yearRange.push(year);
} }
}) });
let max = Math.max(...yearRange) let max = Math.max(...yearRange);
let min = Math.min(...yearRange) let min = Math.min(...yearRange);
return [String(min), String(max)] return [String(min), String(max)];
}, },
getCount() { getCount() {
return this.data.features.filter( return this.data.features.filter(
item => item.properties.vliiage_year === this.yearValue (item) => item.properties.vliiage_year === this.yearValue
) );
}, },
...mapState('energyVillage', ['data']) ...mapState("energyVillage", ["data"]),
}, },
methods: { methods: {
onStatusChange() { onStatusChange() {
// if (e.key === this.showFilter.key) { // if (e.key === this.showFilter.key) {
// this.showFilter = {} // this.showFilter = {}
// } else { // } else {
this.showFilter = true this.showFilter = true;
// } // }
}, },
barClick(name) { barClick(name) {
const code = getCodeOfName(name.name) const code = getCodeOfName(name.name);
code && (this.statusValue = { key: code, value: name }) code && (this.statusValue = { key: code, value: name });
}, },
onAddressChange(item) { onAddressChange(item) {
this.statusValue = { this.statusValue = {
key: item.province_code, key: item.province_code,
value: item.province value: item.province,
} };
this.showFilter = false this.showFilter = false;
}, },
dateChange(e) { dateChange(e) {
this.yearValue = e this.yearValue = e;
}, },
isShowPopup() { isShowPopup() {
this.$refs.myImg.showViewer = true this.$refs.myImg.showViewer = true;
console.log(this.$refs.myImg) console.log(this.$refs.myImg);
// this.popupId = id // this.popupId = id
// if (id === '14') { // if (id === '14') {
// this.showPopup = true // this.showPopup = true
// } // }
}, },
...mapActions('energyVillage', ['getData']) ...mapActions("energyVillage", ["getData"]),
} },
} };
</script> </script>
<style lang="less" scoped> <style lang="less" scoped>
.enetgyVillage { .enetgyVillage {
height: inherit; height: inherit;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment