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

<script>
  import * as Util from '../../Util'
  import * as Des from '../../stores/DrillECharts'
  import co from 'co'
  import {HttpResetClass } from 'vue-client'
  export default {
    name:'BusinessHall',
    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: 's.*',
          tablename: '(SELECT \'笔数\' type, a.name name, a.bi value from (select  f_outlets name,COUNT(id) bi' +
          ' from t_sellinggas where f_charge_state=\'有效\' and f_outlets is not null and ' +
          ' f_delivery_date>=\''+this.startdate+'\' and  f_delivery_date<=\''+this.enddate+'\'' +
          'and f_orgstr like \'%'+this.f_orgstr+'%\' and f_user_name not like \'%测试%\' group by f_outlets) a  union SELECT \'金额\' type, c.name, c.money_value value\n' +
          'from (select  f_outlets name, SUM(f_preamount) money_value from t_sellinggas where f_user_name not like \'%测试%\' and f_charge_state=\'有效\' ' +
          'and f_outlets is not null and  f_delivery_date>=\''+this.startdate+'\' and  f_delivery_date<=\''+this.enddate+'\' and f_orgstr like \'%'+this.f_orgstr+'%\' group by f_outlets)c)s',
          condition: '1=1'
        }
        console.log(sqlcondition,'sql条件')
        let getData=Des.getData(this,sqlcondition)
        co(getData)
      }
    },
    ready () {
    },
    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,'测试1')
          Des.setBar(this,'BusinessHall',result,'营业厅笔数金额直方图','营业厅','金额')
        }
      }
    }

  }
</script>

