| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209 |
- let couponChart = null;
- let couponChartOption = {
- tooltip: {
- trigger: 'axis'
- },
- grid: {
- right: 35,
- bottom: 25
- },
- xAxis: {
- type: 'category',
- data: []
- },
- yAxis: [
- {
- type: 'value',
- splitLine: {
- show: true,
- lineStyle: {
- type: 'dashed',
- color: "#f0f3f6",
- opacity: 1
- }
- },
- axisLabel:{
- formatter:function(value,index){
- return value.toFixed(2)
- }
- }
- },
- {
- type: 'value',
- position: "right",
- splitLine: {
- show: true,
- lineStyle: {
- type: 'dashed',
- color: "#f0f3f6",
- opacity: 1
- }
- }
- }
- ],
- series: [{
- data: [],
- type: 'line'
- }]
- }
- const mixin = {
- mounted() {
- couponChart = echarts.init(this.$refs['couponChart']);
- couponChart.setOption(couponChartOption);
- this.getMemberIncomeData();
- this.getCouponStatisticsData();
- this.getCouponRankData();
- },
- data() {
- return {
- overall: {
- givenCoupon: 0,
- usedCoupon: 0,
- expiredCoupon: 0,
- receiveCoupon: 0
- },
- memberIncome: {
- dataTime: null,
- type:null,
- data: []
- },
- memberIncomeRank: {
- pagination: {
- pages: 1,
- limit: 10,
- total: 50
- },
- data: []
- },
- // 会员收入汇总
- search:{
- member_id:"",
- member:""
- },
- date:"",
- // 字段列表数据
- income_comment:[],
- dialogVisible:false,
- selectFielList:[],
- incomeSummary:[],
- choose_income:[]
- }
- },
- methods: {
- getMemberIncomeData() {
- this.fetchData(GetIncomeOverallDataUrl).then(res => {
- this.overall = res.statistics;
- });
- },
- getCouponStatisticsData(timeList) {
- couponChart.showLoading();
- this.fetchData(GetIncomeStatisticsDataUrl, {
- time: timeList !== undefined ? timeList.timeRange ? timeList.timeRange / 1000 : null : null,
- time_type: timeList !== undefined ? timeList.timeRangeType : null,
- }).then(data => {
- let legendData = [];
- let xAxisData = null;
- let series = [];
- let memberIncomeData = [];
- for (const key in data) {
- if (Object.hasOwnProperty.call(data, key)) {
- const dataItem = data[key];
- legendData.push(dataItem['name']);
- if (xAxisData === null) {
- xAxisData = dataItem['x_axis'];
- }
- memberIncomeData.push({
- title: dataItem.name,
- tip: dataItem.tips,
- count: dataItem.value,
- key,
- decimals:this.getDecimals(dataItem.value)
- })
- series.push({
- name: dataItem.name,
- data: dataItem.series,
- type: "line",
- })
- }
- }
- this.memberIncome.data = memberIncomeData;
- for(const item of series){
- if(item.name == "收入笔数"){
- item.yAxisIndex = 1
- }
- }
- couponChart.setOption({
- legend: {
- data: legendData
- },
- xAxis: {
- data: xAxisData
- },
- series
- });
- couponChart.hideLoading();
- });
- },
- getCouponRankData(page = this.memberIncomeRank.pagination.pages) {
- let loading = this.$loading({
- target: "#couponRankPanel"
- })
- this.memberIncomeRank.pagination.pages = page;
- this.fetchData(GetIncomeRankDataUrl, {
- page,
- search:{
- ...this.search,
- start_time:this.date !== null ? this.date[0] / 1000 : "",
- end_time:this.date !== null ? this.date[1] / 1000 : ""
- }
- }).then(({choose_income,income_comment,page_list}) => {
- let {data,total,per_page} = page_list
- this.memberIncomeRank.pagination.limit = per_page;
- this.memberIncomeRank.pagination.total = total;
- for (let index = 0; index < data.length; index++) {
- data[index]['rank'] = (this.memberIncomeRank.pagination.pages - 1) * this.memberIncomeRank.pagination.limit + index + 1;
- }
- this.memberIncomeRank.data = data;
- let income_comment_array = []
- for(let key in income_comment){
- income_comment[key].state = false
- income_comment_array.push(income_comment[key])
- }
- this.income_comment = income_comment_array
- this.choose_income = choose_income
- this.filterChooseIncome(choose_income,income_comment_array)
- loading.close();
- }).catch(() => {
- loading.close();
- })
- },
- // 处理默认的6个字段数据
- filterChooseIncome(choose_income,income_comment_array){
- if(this.selectFielList.length === 0){
- let newArray = income_comment_array.filter((item) => choose_income.some((item2) => item2 === item.type));
- this.selectFielList = newArray
- }else{
- let newArray = income_comment_array.filter((item) => this.selectFielList.some((item2) => item2.type === item.type));
- this.selectFielList = newArray
- }
- },
- // 选择列表字段
- selectField(){
- this.dialogVisible = true
- },
- getCheckFielList(data){
- this.dialogVisible = data.status
- this.selectFielList = data.data ? data.data : this.selectFielList
- },
- // 导出
- exportData(){
- let url = GetExportDataUrl +'&search[member_id]='+ this.search.member_id + '&search[member]=' + this.search.member + '&search[start_time]=' + `${ this.date ? this.date[0] / 1000 : ""}` + '&search[end_time]=' + `${this.date ? this.date[1] / 1000 : ""}`;
- window.location.href = url;
- },
- // 跳转到收入详情
- goIncomeDetail(id){
- let link = GoIncomeDetailUrl + `&search[member_id]=` +id ;
- window.location.href = link;
- }
- }
- }
|