Commit aed3dbfd authored by 姬鋆屾's avatar 姬鋆屾

pref:优化首页统计图展示,重新对接接口数据

parent 58b91050
...@@ -7,31 +7,31 @@ ...@@ -7,31 +7,31 @@
<div class="header"> <div class="header">
<div class="hc-itme"> <div class="hc-itme">
<div class="i-title">企业总量(家)</div> <div class="i-title">企业总量(家)</div>
<div class="i-num">{{enterpriseNums}}</div> <div class="i-num">{{ enterpriseNums }}</div>
</div> </div>
<div class="hc-itme"> <div class="hc-itme">
<div class="i-title">产品数量(个)</div> <div class="i-title">产品数量(个)</div>
<div class="i-num">{{productNums}}</div> <div class="i-num">{{ productNums }}</div>
</div> </div>
<div class="hc-itme"> <div class="hc-itme">
<div class="i-title">员工数量(人)</div> <div class="i-title">员工数量(人)</div>
<div class="i-num">{{staffNums}}</div> <div class="i-num">{{ staffNums }}</div>
</div> </div>
<div class="hc-itme"> <div class="hc-itme">
<div class="i-title">新闻数量(篇)</div> <div class="i-title">新闻数量(篇)</div>
<div class="i-num">{{newsNums}}</div> <div class="i-num">{{ newsNums }}</div>
</div> </div>
<div class="hc-itme"> <div class="hc-itme">
<div class="i-title">反馈数量(次)</div> <div class="i-title">反馈数量(次)</div>
<div class="i-num">{{feedbackNums}}</div> <div class="i-num">{{ feedbackNums }}</div>
</div> </div>
<div class="hc-itme"> <div class="hc-itme">
<div class="i-title">用户数量(次)</div> <div class="i-title">用户数量(次)</div>
<div class="i-num">{{customerNums}}</div> <div class="i-num">{{ customerNums }}</div>
</div> </div>
</div> </div>
</div> </div>
...@@ -40,19 +40,34 @@ ...@@ -40,19 +40,34 @@
<div class="card pie"> <div class="card pie">
<div class="cardtitle">产品分布</div> <div class="cardtitle">产品分布</div>
<div class="piecard"> <div class="piecard">
<Pie class="echarts" :info="cpfbDayValue" ref="ageChild" style="width:100%;height:100%" /> <Pie
class="echarts"
:info="cpfbDayValue"
ref="ageChild"
style="width: 100%; height: 100%"
/>
</div> </div>
</div> </div>
<div class="card pie"> <div class="card pie">
<div class="cardtitle">名片分布</div> <div class="cardtitle">名片分布</div>
<div class="piecard"> <div class="piecard">
<Pie class="echarts" :info="mpfbDayValue" ref="ageChild" style="width:100%;height:100%" /> <Pie
class="echarts"
:info="mpfbDayValue"
ref="ageChild"
style="width: 100%; height: 100%"
/>
</div> </div>
</div> </div>
<div class="card pie"> <div class="card pie">
<div class="cardtitle">新闻分布</div> <div class="cardtitle">新闻分布</div>
<div class="piecard"> <div class="piecard">
<Pie class="echarts" :info="xwfbDayValue" ref="ageChild" style="width:100%;height:100%" /> <Pie
class="echarts"
:info="xwfbDayValue"
ref="ageChild"
style="width: 100%; height: 100%"
/>
</div> </div>
</div> </div>
</div> </div>
...@@ -67,7 +82,7 @@ ...@@ -67,7 +82,7 @@
<div class="card linebar"> <div class="card linebar">
<div class="cardtitle">员工累计发送名片次数</div> <div class="cardtitle">员工累计发送名片次数</div>
<div class="linebarcar"> <div class="linebarcar">
<CBar class="echarts" :info="barDayValue" /> <CBar class="echarts" :info="barDayValue" :type="'staff'" />
</div> </div>
</div> </div>
</div> </div>
...@@ -82,12 +97,12 @@ export default { ...@@ -82,12 +97,12 @@ export default {
computed: { computed: {
userData() { userData() {
return this.$store.state.userData.currUserName; return this.$store.state.userData.currUserName;
} },
}, },
components: { components: {
Pie, Pie,
CLine, CLine,
CBar CBar,
}, },
data() { data() {
return { return {
...@@ -102,7 +117,7 @@ export default { ...@@ -102,7 +117,7 @@ export default {
staffNums: "--", staffNums: "--",
newsNums: "--", newsNums: "--",
feedbackNums: "--", feedbackNums: "--",
customerNums: "--" customerNums: "--",
}; };
}, },
created() { created() {
...@@ -110,7 +125,7 @@ export default { ...@@ -110,7 +125,7 @@ export default {
}, },
methods: { methods: {
getData() { getData() {
this.$post("/company/stat").then(res => { this.$post("/company/stat").then((res) => {
const { data, code } = res; const { data, code } = res;
if (code == 1) { if (code == 1) {
this.enterpriseNums = data.enterpriseNums; this.enterpriseNums = data.enterpriseNums;
...@@ -121,52 +136,51 @@ export default { ...@@ -121,52 +136,51 @@ export default {
this.customerNums = data.customerNums; this.customerNums = data.customerNums;
this.lineDayValue = data.accessStatList ? data.accessStatList : []; this.lineDayValue = data.accessStatList ? data.accessStatList : [];
this.barDayValue = data.businessCardDistributionList this.barDayValue = data.sendCardStaffList
? data.businessCardDistributionList ? data.sendCardStaffList
: []; : [];
if (data.newsDistributionList.length > 0) { if (data.newsDistributionList.length > 0) {
let arr = []; let arr = [];
data.newsDistributionList.forEach(item => { data.newsDistributionList.forEach((item) => {
arr.push({ arr.push({
name: item.name, name: item.name,
value: item.newsNums value: item.newsNums,
}); });
}); });
this.xwfbDayValue = arr this.xwfbDayValue = arr;
} else { } else {
this.xwfbDayValue = []; this.xwfbDayValue = [];
} }
if (data.productDistributionList.length > 0) { if (data.productDistributionList.length > 0) {
let arr = []; let arr = [];
data.productDistributionList.forEach(item => { data.productDistributionList.forEach((item) => {
arr.push({ arr.push({
name: item.companyName, name: item.companyName,
value: item.productNums value: item.productNums,
}); });
}); });
this.cpfbDayValue = arr this.cpfbDayValue = arr;
} else { } else {
this.cpfbDayValue = []; this.cpfbDayValue = [];
} }
if (data.businessCardDistributionList.length > 0) { if (data.businessCardDistributionList.length > 0) {
let arr = []; let arr = [];
data.businessCardDistributionList.forEach(item => { data.businessCardDistributionList.forEach((item) => {
arr.push({ arr.push({
name: item.companyName, name: item.companyName,
value: item.businessCardNums value: item.businessCardNums,
}); });
}); });
this.mpfbDayValue = arr this.mpfbDayValue = arr;
} else { } else {
this.mpfbDayValue = []; this.mpfbDayValue = [];
} }
} }
}); });
} },
} },
}; };
</script> </script>
<style scoped lang="less"> <style scoped lang="less">
......
...@@ -2,6 +2,8 @@ ...@@ -2,6 +2,8 @@
<div style="width: 100%; height: 100%"></div> <div style="width: 100%; height: 100%"></div>
</template> </template>
<script> <script>
import { type } from "../../assets/utils";
// import { deepClone } from "@/utils/js/common.js"; // import { deepClone } from "@/utils/js/common.js";
// import lodash from "lodash"; // import lodash from "lodash";
// import { getStatisticAges } from "@/api/dataAdmin.js"; // import { getStatisticAges } from "@/api/dataAdmin.js";
...@@ -19,10 +21,14 @@ export default { ...@@ -19,10 +21,14 @@ export default {
type: String, type: String,
default: () => "0", default: () => "0",
}, },
type: {
type: String,
default: "",
},
}, },
watch: { watch: {
info() { info() {
this.getData() this.getData();
}, },
}, },
async mounted() { async mounted() {
...@@ -30,8 +36,16 @@ export default { ...@@ -30,8 +36,16 @@ export default {
}, },
methods: { methods: {
async getData() { async getData() {
let label = this.info.map((item) => item.companyName); let label = [];
let value = this.info.map((item) => item.businessCardNums); let value = [];
if (this.type == "staff") {
label = this.info.map((item) => item.name);
value = this.info.map((item) => item.sendBusinessCardTimes);
console.log(this.info);
} else {
label = this.info.map((item) => item.companyName);
value = this.info.map((item) => item.businessCardNums);
}
this._initEcharts(label, value); this._initEcharts(label, value);
}, },
_initEcharts(label, value) { _initEcharts(label, value) {
...@@ -63,29 +77,29 @@ export default { ...@@ -63,29 +77,29 @@ export default {
axisLabel: { axisLabel: {
//x轴文字的配置 //x轴文字的配置
show: true, show: true,
interval: 0,//使x轴文字显示全 interval: 0, //使x轴文字显示全
// rotate: '15',// 刻度标签旋转的角度 // rotate: '15',// 刻度标签旋转的角度
formatter: function(value) { formatter: function (value) {
var texts = value var texts = value;
if(label.length>3 && label.length<=6){ if (label.length > 3 && label.length <= 6) {
if (texts.length > 10) { if (texts.length > 10) {
// 限制长度自设 // 限制长度自设
texts = texts.substr(0, 10) + '...' texts = texts.substr(0, 10) + "...";
} }
} }
if(label.length>6 && label.length<=10){ if (label.length > 6 && label.length <= 10) {
if (texts.length > 6) { if (texts.length > 6) {
// 限制长度自设 // 限制长度自设
texts = texts.substr(0, 6) + '...' texts = texts.substr(0, 6) + "...";
} }
} }
if(label.length>10){ if (label.length > 10) {
if (texts.length > 3) { if (texts.length > 3) {
// 限制长度自设 // 限制长度自设
texts = texts.substr(0, 3) + '...' texts = texts.substr(0, 3) + "...";
} }
} }
return texts return texts;
}, },
// formatter: function(params) { // formatter: function(params) {
// var newParamsName = ""; // var newParamsName = "";
...@@ -109,8 +123,7 @@ export default { ...@@ -109,8 +123,7 @@ export default {
// } // }
// return newParamsName; // return newParamsName;
// } // }
} },
}, },
yAxis: { yAxis: {
type: "value", type: "value",
......
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