Commit 1125cab3 authored by “yiyousong”'s avatar “yiyousong”
parents 5663e5bb 18e8421d
<template> <template>
<!-- 路径分析 --> <!-- 路径分析 -->
<div class="page"> <div class="page">
<a-form-model :model="queryform" :label-col="labelCol" :wrapper-col="wrapperCol" layout="inline"> <a-form-model
:model="queryform"
:label-col="labelCol"
:wrapper-col="wrapperCol"
layout="inline"
>
<a-form-model-item> <a-form-model-item>
<a-select v-model="queryform.productId" style="width: 200px" placeholder="选择产品"> <a-select
<a-select-option :value="item.id" v-for="(item,index) in product" :key="index"> v-model="queryform.productId"
{{item.title}} style="width: 200px"
placeholder="选择产品"
>
<a-select-option
:value="item.id"
v-for="(item, index) in product"
:key="index"
>
{{ item.title }}
</a-select-option> </a-select-option>
</a-select> </a-select>
</a-form-model-item> </a-form-model-item>
<a-form-model-item> <a-form-model-item>
<a-range-picker valueFormat="yyyy-MM-DD" v-model="time" style="width: 300px" :allowClear="false"/> <a-range-picker
valueFormat="yyyy-MM-DD"
v-model="time"
style="width: 300px"
:allowClear="false"
/>
</a-form-model-item> </a-form-model-item>
<a-form-model-item> <a-form-model-item>
<a-button type="primary" class="addclass" @click="getData"> <a-button type="primary" class="addclass" @click="getData">
...@@ -23,89 +41,115 @@ ...@@ -23,89 +41,115 @@
</template> </template>
<script> <script>
import * as echarts from 'echarts' import * as echarts from "echarts";
import product from "../mixins/product" import product from "../mixins/product";
import {getWayAccessAnalyse} from '@/api/dataActuary.js' import { getWayAccessAnalyse } from "@/api/dataActuary.js";
import moment from 'moment'; import moment from "moment";
export default { export default {
mixins:[product], mixins: [product],
data() { data() {
return { return {
queryform: { queryform: {
productId: 1, productId: 1,
dateTimeStart:moment().format('yyyy-MM-DD'), dateTimeStart: moment().format("yyyy-MM-DD"),
dateTimeEnd:moment().format('yyyy-MM-DD') dateTimeEnd: moment().format("yyyy-MM-DD"),
}, },
time:[moment().format('yyyy-MM-DD'),moment().format('yyyy-MM-DD')], time: [moment().format("yyyy-MM-DD"), moment().format("yyyy-MM-DD")],
product:[{ product: [
title:'排队机', {
id:1 title: "排队机",
}], id: 1,
},
],
labelCol: { labelCol: {
span: 1 span: 1,
}, },
wrapperCol: { wrapperCol: {
span: 14 span: 14,
}, },
} myChart: null,
};
}, },
mounted() { created() {
this.getData() this.$nextTick(() => {
this.getData();
});
}, },
methods: { methods: {
getData() { getData() {
this.queryform.dateTimeStart = this.time ? this.time[0] : null this.queryform.dateTimeStart = this.time ? this.time[0] : null;
this.queryform.dateTimeStart = this.time ? this.time[1] : null this.queryform.dateTimeStart = this.time ? this.time[1] : null;
getWayAccessAnalyse(this.queryform).then(res=>{ getWayAccessAnalyse(this.queryform).then((res) => {
let data = res.data.data.map(item=>({name:item.name})) let data = res.data.data.map((item, i) =>
let links = res.data.links.map(item=>({ item.code != "/sceneSignIn"
source:item.sourceName, ? {
target:item.targetName, name: item.name,
value:item.value,
lineStyle:{
color:'source'
} }
})) : ""
this.init(data,links) );
}) let links = res.data.links.map((item) => ({
source: item.sourceName,
target: item.targetName,
value: item.value,
lineStyle: {
color: "source",
}, },
uniqueFunc(arr, uniId){ }));
data = data.filter((v) => v);
links = links.filter((v) => v.target != "首页");
this.init(data, links);
});
},
uniqueFunc(arr, uniId) {
const res = new Map(); const res = new Map();
return arr.filter((item) => !res.has(item[uniId]) && res.set(item[uniId], 1)); return arr.filter(
(item) => !res.has(item[uniId]) && res.set(item[uniId], 1)
);
}, },
init(data,links) { init(data, links) {
let chartDom = document.getElementById('path') if (
let myChart = echarts.init(chartDom); this.myChart != null &&
myChart.setOption({ this.myChart != "" &&
this.myChart != undefined
) {
this.myChart.dispose(); //销毁
}
this.myChart = echarts.init(document.getElementById("path"));
this.myChart.setOption({
series: { series: {
type: 'sankey', type: "sankey",
layout: 'none', layout: "none",
emphasis: { emphasis: {
focus: 'adjacency' focus: "adjacency",
}, },
color:['#FFCAC4','#6D86DE','#409AFE','#4DB3EA','#07CF8C'], color: ["#FFCAC4", "#6D86DE", "#409AFE", "#4DB3EA", "#07CF8C"],
nodeWidth:10, nodeWidth: 10,
data: data, data: data,
links: links links: links,
} },
}) });
} window.addEventListener("resize", () => {
if (this.myChart) {
this.myChart.resize();
} }
}; });
},
},
};
</script> </script>
<style lang="less" scoped> <style lang="less" scoped>
.page{ .page {
height: calc(100% - 50px); height: calc(100% - 50px);
display: flex; display: flex;
flex-direction: column; flex-direction: column;
/deep/.ant-form { /deep/.ant-form {
padding: 15px; padding: 15px;
} }
#path{ #path {
flex: 1; flex: 1;
width: 70%; width: 70%;
margin: 0 auto; margin: 0 auto;
} }
} }
</style> </style>
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