<template lang="html">
  <div id="charts">
    <div id="CompanyUser" :style="{width:'100%',height:'100%'}"></div>
  </div>
</template>

<script>
  import * as Util from '../../Util'
  import * as Des from '../../stores/DrillECharts'
  import co from 'co'

  export default {
    name:'CompanyUser',
    props: {
      startdate: {
        type: String,
        default: Util.toStandardDateString()
      },
      enddate: {
        type: String,
        default: Util.toStandardDateString()
      },
      f_orgstr: {
        type: String,
        default: ''
      }
    },
    data () {
      title: '站点管理'
      return {
        texttile: '',
        xc: '',
        sqlobtaindata:[],
      }
    },
    methods: {
      searchdata () {
        var sqlcondition={
          items: 'f_user_type type,f_filiale name,count(f_userinfo_id) value',
          tablename: 't_userinfo',
          condition: 'f_user_state=\'正常\' and f_filialeids LIKE \'%'+this.f_orgstr+'%\' GROUP BY f_user_type,f_filiale'
        }
        console.log(sqlcondition,'sql条件')
        let getData=Des.getData(this,sqlcondition)
        co(getData)

      }
    },
    ready () {
      var name='sadsda'
      var strname=name.toString().split('.')
      var orgname=strname[strname.length-1]
      console.log(strname,orgname,'ceshi ')
       name='sad.sda'
       strname=name.toString().split('.')
       orgname=strname[strname.length-1]
      console.log(strname,orgname,'ceshi1 ')
    //   console.log(this.f_orgstr,'测试')
    // this.searchdata()
    //    let data=[{name:'a公司',type:'民用',value:1000},{name:'a公司',type:'非民用',value:1000},{name:'b公司',type:'民用',value:1000},{name:'b公司',type:'非民用',value:1000}]
    //    let result=Des.DataIntegration(data)
    //    Des.setBar(this,'CompanyUser',result,'分公司用户数','公司名称','用户数量')

      // this.searchdata()
    },
    watch: {
      'startdate' (val) {
        this.searchdata()
      },
      'enddate' (val) {
        this.searchdata()
      },
      'f_orgstr' (val) {
        console.log(this.f_orgstr,'测试')
        this.searchdata()
      },
      'sqlobtaindata':{
        deep:true,
        handler(val){
          console.log(this.sqlobtaindata,'返回参数')
          if(this.sqlobtaindata.length<1){
            return
          }

          let result=Des.DataIntegration(this.sqlobtaindata)
          console.log(result,'测试')
          Des.setBar(this,'CompanyUser',result,'用户分布直方图','公司名称','用户数量')
        }
      }
    }

  }
</script>

