{
    template:'${tmpl}',
    data:function(){
        return {
          isboss:false,
          isbizemp:false,
          isfiemp:false,
          isdiliver:false,
          isdev:false,
          multipleSelection: [],
          bossProfit:[],
          bossOrder:[],
          bossAccount:[],
          bardata:{},
          bardata2:{},
          bardata3:{},
          officialCount:{officialCount:0,wscCount:0},
          shCount:{yshCount:0,wshCount:0},
          yshCount:{monthyshCount:0,allyshCount:0},
          profitorderdata:{
            title: {
                text: '近十二个月毛利订单变动图',
                left:'center'
            },
            tooltip : {
              trigger: 'axis'
            },
            calculable : true,
            legend: {
                top:10,
                data:['','','毛利','订单']
            },
            xAxis:[{
                type: 'category',
                data: []
            }],
            yAxis:  [
              {
                  type : 'value',
                  name : '利润（元）',
                  axisLabel : {
                      formatter: '{value} '
                  }
              },
              {
                  type : 'value',
                  name : '订单量（单）',
                  axisLabel : {
                      formatter: '{value} '
                  }
              }
            ],
            series: [
                {
                    name:'毛利',
                    type:'bar',
                    barWidth:40,
                    data:[]
                },
                {
                    name:'订单',
                    type:'line',
                    yAxisIndex: 1,
                    data:[]
                }
            ]
          },
          recvexpensedata:{
            title: {
                text: '近十二个月回款费用变动图',
                left:'left',
                y: '20',
                textStyle:{
                  fontStyle:'normal',
                  fontWeight:'bolder',
                  fontFamily:'MicrosoftYaHei-Bold',
          　　　　 fontSize:14
                }
            },
            tooltip : {
              trigger: 'axis'
            },
            color:['#2692FF', '#29D8DA','#5ACE39'],
            calculable : true,
            legend: {
                top: '10%',
                left:'right',
                data:['回款','费用']
            },
            grid: {
                left: '0%',
                top: '20%',
                right: '3%',
                bottom: '10%',
                containLabel: true
            },
            xAxis: [{
              type: 'category',
              boundaryGap : false,
              data: []
            }],
            yAxis: {
                type: 'value'
            },
            series: [{
                  name:"回款",
                  data: [],
                  type: 'line',
                  smooth: true
              },{
                name:"费用",
                data: [],
                type: 'line',
                smooth: true
            }]
          },
          productpieprofitdata:{
            
            title: {
                text: '产品毛利贡献度',
                left: 'left',
                y: '10',
                textStyle:{
                  fontStyle:'normal',
                  fontWeight:'bolder',
                  fontFamily:'MicrosoftYaHei-Bold',
          　　　　 fontSize:14
                }
            },
            tooltip : {
                trigger: 'item',
                formatter: "{a} <br/>{b} : {c} ({d}%)"
            },
            color:['#2692FF', '#29D8DA','#5ACE39'],
            legend: {
                orient: 'vertical',
                x: 10,
                data: [] 
            },
            series : [
                {
                    name:"",
                    type: 'pie',
                    radius : '60%',
                    center: ['50%', '55%'],
                    selectedMode: 'single',
                    data:[],
                    itemStyle: {
                        emphasis: {
                            shadowBlur: 10,
                            shadowOffsetX: 0,
                            shadowColor: 'rgba(0, 0, 0, 0.5)'
                        }
                    }
                }
            ]
          },
          productpieorderdata:{
            title: {
                text: '产品订单贡献度',
                left: 'left',
                y: '10',
                textStyle:{
                  fontStyle:'normal',
                  fontWeight:'bolder',
                  fontFamily:'MicrosoftYaHei-Bold',
          　　　　 fontSize:14
                }
            },
            tooltip : {
                trigger: 'item',
                formatter: "{a} <br/>{b} : {c} ({d}%)"
            },
            color:['#2692FF', '#29D8DA','#5ACE39'],
            legend: {
                bottom: 10,
                left: 'center',
                data: []
            },
            series : [
                {
                    name:"",
                    type: 'pie',
                    radius : '60%',
                    center: ['50%', '55%'],
                    selectedMode: 'single',
                    data:[],
                    itemStyle: {
                        emphasis: {
                            shadowBlur: 10,
                            shadowOffsetX: 0,
                            shadowColor: 'rgba(0, 0, 0, 0.5)'
                        }
                    }
                }
            ]

          },
          salesmanProfit:[],
          salesmanEarnMoney:[],
          salesmanOrder:[],
          salesmandata:{
            title: {
                text: '近十二个月个人毛利、回款、订单变动图',
                left:'center'
            },
            tooltip : {
              trigger: 'axis'
            },
            calculable : true,
            legend: {
              top:10,
              data:['','','毛利','回款','订单量']
            },
            xAxis : [
              {
                type : 'category',
                data : []
              }
            ],
            yAxis : [
              {
                type : 'value',
                name : '毛利/汇款（元）',
                axisLabel : {
                   formatter: '{value} '
                }
              },
              {
                type : 'value',
                name : '订单量（单）',
                axisLabel : {
                   formatter: '{value} '
                }
              }
           ],
           series : [
              {
                  name:'毛利',
                  type:'bar',
                  data:[]
              },
              {
                  name:'回款',
                  type:'bar',
                  data:[]
              },
              {
                  name:'订单量',
                  type:'line',
                  yAxisIndex: 1,
                  data:[]
              }
            ]
          },
          financeReceive:[],
          financeExpense:[],
          developerData:[],
          problemBardata:{
            title: {
                text: '系统问题个人统计',
                left:'center'
            },
            tooltip : {
              trigger: 'axis'
            },
            legend: {
              top:10,
              data: ['','','待解决', '处理中','已解决']
            },
            calculable : true,
            xAxis:[ {
                type: 'category',
                data: []
            }],
            yAxis:  [
              {
                  type : 'value',
                  name : '问题个数（个）',
                  axisLabel : {
                      formatter: '{value} '
                  }
              }
            ],
            series: [
                {
                    name:'待解决',
                    type:'bar',
                    barWidth:20,
                    data:[]
                },
                {
                    name:'处理中',
                    type:'bar',
                    barWidth:20,
                    data:[]
                },
                {
                    name:'已解决',
                    type:'bar',
                    barWidth:20,
                    data:[]
                }
            ]
          },
          businessStatisticForBoss:{},
          businessStatisticForSalesman:{},
          currentMonthBsForBoss:{},
          currentMonthBsForSalesman:{},
        }
    },
    mounted:function(){
      var self=this;
      var f=function(){
        var own=self;
        var t=setTimeout(()=>{
          if(own.$root.currentCompany){
            own.fetchProAndOrderPie();
            own.roleviewServicesitem();
          }else{
            f();
          }
        },1000);
      };
      /*var isboss=this.$root.currentUser.roles.indexOf("boss");
      var isqd=this.$root.currentUser.roles.indexOf("qd01");
      var isbizemp=this.$root.currentUser.roles.indexOf("bizemp");*/
      this.isboss=true;
      this.fetchProAndOrderForBoss();
      this.fetchRecvExpense();
      this.fetchProAndOrderPie();

      /*this.fetchAccountForBoss();
      this.fetchProfitAndOrder();
      this.getBusinessStatisticForBoss();
      this.getCurrentMonthBusinessStatisticForBoss();
      f();*/
    },
    created:function(){
      /*var isboss=this.$root.currentUser.roles.indexOf("boss");
      var isqd=this.$root.currentUser.roles.indexOf("qd01");
      if(isboss>=0 || isqd>=0 || isbizemp>=0){
        this.isboss=true;
          this.fetchProAndOrderForBoss();
          this.fetchAccountForBoss();
          this.fetchProfitAndOrder();
          this.fetchProAndOrderPie();
          this.fetchRecvExpense();
          this.getBusinessStatisticForBoss();
          this.getCurrentMonthBusinessStatisticForBoss();
      }*/
      var isbizemp=this.$root.currentUser.roles.indexOf("bizemp");
      /*if(isbizemp>=0){
        this.isbizemp=true;
        this.fetchForSalesman();
        this.fetchPicForSalesman();
        this.getBusinessStatisticForSalesman();
        this.getCurrentMonthBusinessStatisticForSalesman();
      }
      var isfiemp=this.$root.currentUser.roles.indexOf("fiemp");
      if(isfiemp>=0){
        this.isfiemp=true;
        this.fetchForFinance();
      }

      var isdiliver=this.$root.currentUser.roles.indexOf("diliver");
      if(isdiliver>=0){
        this.isdiliver=true;
        this.officialCountByCompany();
        this.shCountByCompany();
        this.yshCountByCompany();
      }
      var dev=this.$root.currentUser.roles.indexOf("dev");
      var kfjl=this.$root.currentUser.roles.indexOf("kfjl");
      var yfbmjl=this.$root.currentUser.roles.indexOf("yfbmjl");
      if(dev>=0 || kfjl>=0 || yfbmjl>=0){
        this.isdev=true;
        this.fetchQuestionForDev();
      }else{
        this.isdev=false;
      }*/
      var option1 = {
          title: {
              text: '毛利'
          },
          tooltip: {},
          legend: {
              data:['毛利']
          },
          xAxis: {
              data: ["上周","本周","上月","本月"]
          },
          yAxis: {},
          series: [{
              name: '毛利',
              type: 'bar',
              data: [1500, 2000, 12000, 15000]
          }]
      };
      var option2 = {
        title: {
            text: '订单'
        },
        tooltip: {},
        legend: {
            data:['订单']
        },
        xAxis: {
            data: ["上周","本周","上月","本月"]
        },
        yAxis: {},
        series: [{
            name: '订单',
            type: 'bar',
            data: [1500, 2000, 12000, 15000]
        }]
      };
      var option3 = {
        title: {
            text: '账户余额'
        },
        tooltip: {},
        legend: {
            data:['账户余额']
        },
        xAxis: {
            data: ["中国银行","交通银行","微信"]
        },
        yAxis: {},
        series: [{
            name: '账户余额',
            type: 'bar',
            data: [2000, 1500, 50000]
        }]
      };
      this.bardata=option1;
      this.bardata2=option2;
      this.bardata3=option3;
    },
    methods:{
      roleviewServicesitem() {

      },
      getBusinessStatisticForBoss(){
        var that=this;
        var obj={};
        that.$root.getReq("/web/businesscompanyCtl/getBusinessStatisticForBoss",obj).then(function(d){
          console.log(d);
          if(d&&d.code==1){
            that.businessStatisticForBoss=d.data;
          }
        })
      },
      getBusinessStatisticForSalesman(){
        var that=this;
        var obj={};
        that.$root.getReq("/web/businesscompanyCtl/getBusinessStatisticForSalesman",obj).then(function(d){
          console.log(d);
          if(d&&d.code==1){
            that.businessStatisticForSalesman=d.data;
          }
        })
      },
      getCurrentMonthBusinessStatisticForBoss(){
        var that=this;
        var obj={statisticType:2};
        that.$root.getReq("/web/businesscompanyCtl/getBusinessStatisticForBoss",obj).then(function(d){
          console.log(d);
          if(d&&d.code==1){
            that.currentMonthBsForBoss=d.data;
          }
        })
      },
      getCurrentMonthBusinessStatisticForSalesman(){
        var that=this;
        var obj={statisticType:2};
        that.$root.getReq("/web/businesscompanyCtl/getBusinessStatisticForSalesman",obj).then(function(d){
          console.log(d);
          if(d&&d.code==1){
            that.currentMonthBsForSalesman=d.data;
          }
        })
      },
      fetchQuestionForDev(){
        var that=this;
        var obj={};
        that.$root.postReq("/web/pmquestionCtl/fetchQuestionForDev",obj).then(function(d){
          console.log(d);
          if(d.status==0&&d.data){
            that.developerData=d.data.obj1;
            var data=that.$refs.problemBar.getEchartObj();
            if(data){
              var option = data.getOption();
              option.xAxis[0].data=d.data.obj2;
              option.series[0].data = d.data.obj3;
              option.series[1].data = d.data.obj4;
              option.series[2].data = d.data.obj5;
              data.setOption(option);
              window.addEventListener("resize",function(){
                  data.resize();
              });
            }
          }
        })
      },
      fetchProAndOrderForBoss(){
        var that=this;
        var obj={};
        that.$root.postReq("/web/orderCtl/fetchProAndOrderForBoss",obj).then(function(d){
          if(d.status==0&&d.data){
            that.bossProfit=d.data.profit;
            that.bossOrder=d.data.order;
          }
        });
      },
      fetchAccountForBoss(){
        var that=this;
        var obj={};
        that.$root.postReq("/web/moneyaccountCtl/fetchAccountForBoss",obj).then(function(d){
          if(d.status==0){
            that.bossAccount=d.data;
          }
        });
      },
      fetchProfitAndOrder(){
        var that=this;
        var obj={};
      },
      fetchProAndOrderPie(){
        var that=this;
        var obj={};
        
        that.$root.postReq("/web/orderCtl/fetchProAndOrderPie",obj).then(function(d){
          console.log(d,'///////////////////////////////////');
          if(d.status==0&&d.data){
            var data1=that.$refs.profitPie.getEchartObj();
            if(data1){
              var option = data1.getOption();
              option.legend.data=d.data.bottomData;
              option.series[0].data = d.data.obj1;
              data1.setOption(option);
              window.addEventListener("resize",function(){
                  data1.resize();
              });
            }
            var data2=that.$refs.orderPie.getEchartObj();
            if(data2){
              var option2 = data2.getOption();
              option2.legend.data=d.data.bottomData;
              option2.series[0].data = d.data.obj2;
              data2.setOption(option2);
              window.addEventListener("resize",function(){
                  data2.resize();
              });
            }
          }else {

          }
        });
      },
      fetchRecvExpense(){
        var that=this;
        var obj={};
        that.$root.postReq("/web/moneyjourneyCtl/fetchRecvExpense",obj).then(function(d){
          if(d.status==0&&d.data){
            let data=that.$refs.RecvExpenline.getEchartObj();
            if(data){
              console.log(d.data);
              var option = data.getOption();
              option.xAxis[0].data=d.data.month;
              option.series[0].data = d.data.obj2;
              option.series[1].data = d.data.obj1;
              data.setOption(option);
              data.resize();
              window.addEventListener("resize",function(){
                  data.resize();
              });
            }
          }
        })
      },

      fetchForSalesman(){
        var that=this;
        var obj={};
        that.$root.postReq("/web/orderCtl/fetchForSalesman",obj).then(function(d){
          if(d.status==0&&d.data){
            that.salesmanProfit=d.data.profit;
            that.salesmanEarnMoney=d.data.receiveMoney;
            that.salesmanOrder=d.data.order;
          }
        });
      },
      fetchPicForSalesman(){
        /*var that=this;
        var obj={};
        that.$root.postReq("/web/orderCtl/fetchPicForSalesman",obj).then(function(d){
          console.log("------------fetchPicForSalesman----------------");
          console.log(d);
          if(d.status==0&&d.data){
            var data=that.$refs.TwolineBar.getEchartObj();
            if(data){
              var option = data.getOption();
              option.xAxis[0].data=d.data.month;
              option.series[0].data = d.data.obj1;
              option.series[1].data = d.data.obj2;
              option.series[2].data = d.data.obj3;
              data.setOption(option);
              window.addEventListener("resize",function(){
                data.resize();
              });
            }
          }
        })*/
      },

      fetchForFinance(){
        var that=this;
        var obj={};
        that.$root.postReq("/web/expensevoucherCtl/fetchForFinance",obj).then(function(d){
          if(d.code==1&&d.data){
            that.financeReceive=d.data.receive;
            that.financeExpense=d.data.expense;
          }
        })
      },
      officialCountByCompany(){
        var that=this;
        var obj={};
        that.$root.postReq("/web/orderCtl/officialCountByCompany",obj).then(function(d){
          if(d.code==1&&d.data){
            that.officialCount.officialCount=d.data.officialCount;
            that.officialCount.wscCount=d.data.wscCount;
          }
        })
      },
      shCountByCompany(){
        var that=this;
        var obj={};
        that.$root.postReq("/web/orderCtl/shCountByCompany",obj).then(function(d){
          if(d.code==1&&d.data){
            that.shCount.yshCount=d.data.yshCount;
            that.shCount.wshCount=d.data.wshCount;
          }
        })
      },
      yshCountByCompany(){
        var that=this;
        var obj={};
        that.$root.postReq("/web/orderCtl/yshCountByCompany",obj).then(function(d){
          if(d.code==1&&d.data){
            that.yshCount.monthyshCount=d.data.monthyshCount;
            that.yshCount.allyshCount=d.data.allyshCount;
            
          }
        })
      },
      onColFormater(row,column,cellvalue,index){
         return cellvalue;
       },
      handleSelectionChange:function(val){
         this.multipleSelection = val;
         console.log(val);
       },
      onRowClick(row,key,e){
           if(key=="stopUser"){

           }
      },
      gengduo () {
        this.$alert('更多功能敬请期待', '提示', {
          confirmButtonText: '确定',
          callback: action => {
            this.$message({
              type: 'info',
              message: `action: ${ action }`
            });
          }
      });
      }

    },
    computed: Vuex.mapState({
      count:state=>state.count,
      headStyle:function(){
        return {"background-color":"white"};
      }
    }),
    vname:"gsb_roleview"
}
