<template>
  <div id="flex" style="width: 98%">
    <criteria-paged :model="model" v-ref:paged>
      <data-grid :model="model"  partial='list' v-ref:grid :classname="$parent.classname">
        <template partial='head'>
            <th v-for=" a in $parent.$parent.$parent.headdata">
              {{a}}
            </th>
        </template>
        <template partial='body'>
          <tr>
            <td style="text-align: center;" v-for=" columnname in $parent.$parent.$parent.param"> {{row[columnname]}} </td>
          </tr>
        </template>
      </data-grid>
    </criteria-paged>
  </div>
</template>
<script>
  import * as Util from '../../Util'
  import { PagedList } from 'vue-client'
  export default {
    name: 'list',
    props: {
      condition: String,
      startdate: {
        type: String,
        default: Util.toStandardDateString()
      },
      enddate: {
        type: String,
        default: Util.toStandardDateString()
      },
      echartslist:{
        detailurl:Array,
        headData:Array,
        bodyData:Array,
      }
    },
    data () {
      return {
        model:new PagedList(),
        detailcondition:'', //钻取的字段对应的值
        barparam:'',
        echarts:false,
        pageurl:[],
        classname: 'table table-bordered table table-hover',
        param:'',
        colspan:'',
        headdata:'',
      }
    },
    methods: {
      query () {
        this.param=this.echartslist.bodyData
        this.colspan=this.echartslist.bodyData.length+1
        this.headdata=this.echartslist.headData
        if(this.echartslist.detailurl.length>1){
          this.pageurl=this.echartslist.detailurl
          this.model=new PagedList(this.pageurl[0],this.pageurl[1],this.pageurl[2])
          this.selfSearch()
        }

      },
      search(args) {
        this.model.rows = []
        this.model.search(args.condition, args.model)
      },
      selfSearch () {
        this.model.search('1=1')
      },
    },
    computed:{
    },
    watch:{
      'echartslist': {
        deep: true,
        handler(val) {
            console.log(this.echartslist,"list变化")
            this.query()
        }
      },
    },
    ready () {
    }
  }
</script>

