Commit e962056f authored by “yiyousong”'s avatar “yiyousong”

perf: 整体优化业务数据分析

parent 203d692d
...@@ -65,3 +65,8 @@ export function pageLlist(params) { ...@@ -65,3 +65,8 @@ export function pageLlist(params) {
export function userSiteBus(params) { export function userSiteBus(params) {
return http.get(`${BASEURL}/inter/statistic/busIdForName`, params); return http.get(`${BASEURL}/inter/statistic/busIdForName`, params);
} }
// 获取排号业务列表
export function businessPtree(params) {
return http.get(`${BASEURL}/admin/business/businessPtree`, params);
}
...@@ -79,3 +79,19 @@ export class SessionCrypto { ...@@ -79,3 +79,19 @@ export class SessionCrypto {
window.sessionStorage.removeItem(key); window.sessionStorage.removeItem(key);
} }
} }
// 扁平化树形结构(有子数组返回子数组否则返回本身)
export function filterarrays(arr, field = "children") {
let data = [];
function recursiveSearch(subArr) {
for (let item of subArr) {
if (item[field] && item[field].length) {
recursiveSearch(item[field]);
} else {
data.push(item);
}
}
}
recursiveSearch(arr);
return data;
}
<template> <template>
<div> <div>
<div :id="id" :style="{height: this.height+'px', width: this.width+'px'}"></div> <div
</div> :id="id"
:style="{ height: this.height + 'px', width: this.width + 'px' }"
></div>
</div>
</template> </template>
<script> <script>
import * as echarts from 'echarts' import * as echarts from "echarts";
let myChart= null
export default { export default {
props: { props: {
id: { id: {
type: String type: String,
}, },
height: { height: {
type: String | Number type: String | Number,
}, },
width:{ width: {
type: String | Number, type: String | Number,
},
datas: Object
}, },
data() { datas: Object,
return { },
} data() {
return {
myChart: null,
};
},
watch: {
datas: function (obj) {
let arr = [];
if (obj) {
obj.dataList.map((item) => {
let obj = {
name: "",
type: "line",
emphasis: {
focus: "series",
},
data: [],
};
if (item) {
obj.name = item.name;
obj.data = item.data;
arr.push(obj);
}
});
this.lineInit(obj.title, obj.legend, obj.xData, arr, obj);
}
},
},
methods: {
autoResize() {
this.myChart && this.myChart.resize();
},
lineInit(title, legend, xData, data, datas) {
if (!this.myChart) {
this.myChart = echarts.init(document.getElementById(this.id));
}
let option = {
title: {
text: title,
textStyle: {
fontSize: "14",
},
},
tooltip: {
trigger: "axis",
},
legend: {
data: legend,
},
dataZoom: {
type: "inside",
startValue: datas.startValue ? datas.startValue : 0,
endValue: datas.endValue ? datas.endValue : 16,
},
grid: {
left: "3%",
right: "4%",
bottom: "3%",
containLabel: true,
},
xAxis: [
{
type: "category",
boundaryGap: false,
data: xData,
},
],
yAxis: [
{
type: "value",
},
],
series: data,
};
this.myChart.setOption(option);
// 让图表跟随屏幕自动的去适应
window.addEventListener("resize", this.autoResize);
}, },
watch:{ },
datas: function(obj){ beforeDestroy() {
let arr= [] window.removeEventListener("resize", this.autoResize);
if(obj){ },
obj.dataList.map((item)=>{ };
let obj= {
name: '',
type: 'line',
emphasis: {
focus: 'series'
},
data: []
}
if(item){
obj.name= item.name
obj.data= item.data
arr.push(obj)
}
})
this.lineInit(obj.title, obj.legend, obj.xData, arr)
}
}
},
methods: {
lineInit(title, legend, xData, data) {
myChart = echarts.init(document.getElementById(this.id))
let option = {
title: {
text: title,
textStyle: {
fontSize: '14'
}
},
tooltip: {
trigger: 'axis'
},
legend: {
data: legend
},
grid: {
left: '3%',
right: '4%',
bottom: '3%',
containLabel: true
},
xAxis: [
{
type: 'category',
boundaryGap: false,
data: xData
}
],
yAxis: [
{
type: 'value'
}
],
series: data
}
myChart.setOption(option)
// 让图表跟随屏幕自动的去适应
window.addEventListener('resize', function () {
myChart.resize()
})
}
}
}
</script> </script>
<style lang="less" scoped> <style lang="less" scoped></style>
</style>
\ No newline at end of file
...@@ -151,11 +151,7 @@ ...@@ -151,11 +151,7 @@
<span slot="index" slot-scope="text, record, index"> <span slot="index" slot-scope="text, record, index">
{{ index + 1 }} {{ index + 1 }}
</span> </span>
<span <span slot="nums" slot-scope="text" style="display: flex">
slot="nums"
slot-scope="text, record, index"
style="display: flex"
>
<a-progress <a-progress
:percent="text" :percent="text"
:showInfo="false" :showInfo="false"
...@@ -198,11 +194,7 @@ ...@@ -198,11 +194,7 @@
<span slot="index" slot-scope="text, record, index"> <span slot="index" slot-scope="text, record, index">
{{ index + 1 }} {{ index + 1 }}
</span> </span>
<span <span slot="nums" slot-scope="text" style="display: flex">
slot="nums"
slot-scope="text, record, index"
style="display: flex"
>
<a-progress <a-progress
:percent="text" :percent="text"
:showInfo="false" :showInfo="false"
...@@ -247,11 +239,7 @@ ...@@ -247,11 +239,7 @@
<span slot="index" slot-scope="text, record, index"> <span slot="index" slot-scope="text, record, index">
{{ index + 1 }} {{ index + 1 }}
</span> </span>
<span <span slot="nums" slot-scope="text" style="display: flex">
slot="nums"
slot-scope="text, record, index"
style="display: flex"
>
<a-progress <a-progress
:percent="text" :percent="text"
:showInfo="false" :showInfo="false"
...@@ -294,11 +282,7 @@ ...@@ -294,11 +282,7 @@
<span slot="index" slot-scope="text, record, index"> <span slot="index" slot-scope="text, record, index">
{{ index + 1 }} {{ index + 1 }}
</span> </span>
<span <span slot="nums" slot-scope="text" style="display: flex">
slot="nums"
slot-scope="text, record, index"
style="display: flex"
>
<a-progress <a-progress
:percent="text" :percent="text"
:showInfo="false" :showInfo="false"
...@@ -315,7 +299,7 @@ ...@@ -315,7 +299,7 @@
</div> </div>
</template> </template>
<script > <script>
import Pie from "../Component/emptyPie/index.vue"; import Pie from "../Component/emptyPie/index.vue";
import axios from "axios"; import axios from "axios";
import { import {
...@@ -761,4 +745,4 @@ export default { ...@@ -761,4 +745,4 @@ export default {
.mb_15 { .mb_15 {
margin-bottom: 0.9375rem; margin-bottom: 0.9375rem;
} }
</style> </style>
\ No newline at end of file
...@@ -7,7 +7,35 @@ ...@@ -7,7 +7,35 @@
</div> </div>
<div class="searchBox"> <div class="searchBox">
<a-space> <a-space>
<a-auto-complete <a-select
style="width: 35.625rem"
allowClear
showSearch
v-model="business"
optionFilterProp="label"
placeholder="请输入业务名称搜索"
>
<a-select-option
v-for="v in businessList"
:key="v.id"
:value="String(v.id)"
:label="v.name + '--' + v.flownum"
>
{{ `${v.name}--${v.flownum}` }}
</a-select-option>
</a-select>
<a-button type="primary" class="addclass" @click="startAnalysis"
>开始分析</a-button
>
<a-button
type="primary"
class="addclass"
v-if="btnShow"
@click="backBase"
>返回</a-button
>
<!-- <a-auto-complete
v-model="businessName" v-model="businessName"
:data-source="dataSource" :data-source="dataSource"
optionLabelProp="value" optionLabelProp="value"
...@@ -25,7 +53,7 @@ ...@@ -25,7 +53,7 @@
> >
<a-button type="primary" class="addclass" v-else @click="backBase" <a-button type="primary" class="addclass" v-else @click="backBase"
>返回</a-button >返回</a-button
> > -->
</a-space> </a-space>
</div> </div>
</div> </div>
...@@ -37,9 +65,10 @@ ...@@ -37,9 +65,10 @@
</template> </template>
<script> <script>
import _ from "lodash"; import _ from "lodash";
import axios from "axios"; // import axios from "axios";
import Breadcrumb from "./breadcrumb/index.vue"; import Breadcrumb from "./breadcrumb/index.vue";
import { userSiteBus } from "@/api/dataActuary"; import { userSiteBus, businessPtree } from "@/api/dataActuary";
import { filterarrays } from "@/utils";
export default { export default {
components: { components: {
Breadcrumb, Breadcrumb,
...@@ -47,39 +76,50 @@ export default { ...@@ -47,39 +76,50 @@ export default {
data() { data() {
return { return {
// 搜索框 // 搜索框
businessName: "", // businessName: "",
business: undefined,
businessList: [],
dataSource: [], dataSource: [],
sourceList: [], sourceList: [],
// dataList: [], // dataList: [],
btnShow: false,
}; };
}, },
mounted() { mounted() {
// this.getList() // this.getList()
}, },
created() {}, created() {
computed: {}, this.businessPtree();
},
computed: {
btnShow() {
return this.$route.path == "/home/dataActuary/business/analysiscontent";
},
},
methods: { methods: {
// 获取排号业务列表
async businessPtree() {
let res = await businessPtree({
page: 1,
size: -1,
});
if (res.code == 1) {
this.businessList = filterarrays(res.data.data, "children");
this.business = this.$route.query.id;
}
},
startAnalysis() { startAnalysis() {
if (!this.businessName) { if (!this.business) {
this.$message.error("请输入业务名称搜索"); this.$message.warning("请先选择业务");
} else { } else {
let item = this.sourceList.filter((i) => { this.$router.push({
return i.name == this.businessName; path: "analysiscontent",
})[0]; query: { id: this.business },
if (item) { });
this.$router.push({
path: "analysiscontent",
query: { id: item.id },
});
this.btnShow = true;
}
} }
}, },
backBase() { backBase() {
this.$router.push({ path: "basecontent" }); this.$router.push({ path: "basecontent" });
this.btnShow = false; this.business = undefined;
this.businessName = "";
}, },
// async getList(){ // async getList(){
// await axios.get('http://192.168.0.98:8090/inter/statistic/busList',{params: {siteid: 1}}).then((res)=>{ // await axios.get('http://192.168.0.98:8090/inter/statistic/busList',{params: {siteid: 1}}).then((res)=>{
...@@ -90,29 +130,33 @@ export default { ...@@ -90,29 +130,33 @@ export default {
// } // }
// }) // })
// }, // },
onSearch: _.debounce(function (val) { // onSearch: _.debounce(function (val) {
this.dataSource = []; // this.dataSource = [];
userSiteBus({ // userSiteBus({
siteid: localStorage.getItem("siteId"), // siteid: localStorage.getItem("siteId"),
bus_name: val, // bus_name: val,
}).then((res) => { // page: 1,
if (res.code == 1) { // size: -1,
this.sourceList = res.data; // }).then((res) => {
res.data.forEach((r) => { // if (res.code == 1) {
this.dataSource.push(r.name); // this.sourceList = res.data;
}); // console.log(res.data);
} // res.data.forEach((r) => {
}); // this.dataSource.push(r.name);
}, 0), // });
onSelect(val) { // }
this.businessName = val; // });
}, // }, 0),
// onSelect(val) {
// this.businessName = val;
// },
}, },
}; };
</script> </script>
<style lang="less" scoped> <style lang="less" scoped>
@headerH: 4.5rem; @headerH: 4.5rem;
.Container { .Container {
width: 100%;
height: 100% !important; height: 100% !important;
// background: #fac; // background: #fac;
background: #f5f5f5; background: #f5f5f5;
......
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