<template>
  <div id="unit" class="flex-row">
    <div class="basic-main" @keyup.enter="search">
      <div class="flex" >

        <criteria-paged :model="model" v-ref:paged>
          <criteria partial='criteria' @condition-changed='$parent.selfSearch' v-ref:cri>
            <div novalidate class="form-horizontal select-overspread container-fluid auto" partial>
              <div class="row">
                <div class="col-sm-2 form-group">
                  <label for="startDate" class="font_normal_body" >开始日期</label>
                  <datepicker id="startDate" placeholder="开始日期" style="width:60%"
                              v-model="model.startDate"
                              :value.sync="model.startDate"
                              :format="'yyyy-MM-dd HH:mm:ss'"
                              :show-reset-button="true"
                              >
                  </datepicker>
                </div>
                <div class="col-sm-2 form-group">
                  <label for="endDate" class="font_normal_body" >结束日期</label>
                  <datepicker id="endDate" placeholder="结束日期" style="width:60%"
                              v-model="model.endDate"
                              :value.sync="model.endDate"
                              :format="'yyyy-MM-dd HH:mm:ss'"
                              :show-reset-button="true"
                             >
                  </datepicker>
                </div>
                <div class="span" style="float:right;">
                  <button class="button_search button_spacing" @click="search()">查询</button>
                  <button class="button_clear button_spacing" @click="$parent.$parent.clear()">清空</button>

<!--                  <export-excel :data="$parent.$parent.getCondition"-->
<!--                                :field="$parent.$parent.getfield"-->
<!--                                :header="$parent.$parent.other"-->
<!--                                sqlurl="api/af-revenue/logic/openapi/exportfile" sql-name="salesgasclassification" template-name='销售量分类'-->
<!--                                :choose-col="true"></export-excel>-->
<!--                  &lt;!&ndash;                  <div style="float: right"  class="button_spacing" :class="{'button_shrink_top':$parent.$parent.criteriaShow,'button_shrink_bottom':!$parent.$parent.criteriaShow}"    @click="$parent.$parent.hidden()"></div>&ndash;&gt;-->
<!--                </div>-->
              </div>
            </div>
            </div>
          </criteria>

          <data-grid :model="model" partial='list' class="list_area table_sy" v-ref:grid>
            <template partial='head'>
              <tr>
                <th>
                  <nobr>用气性质</nobr>
                </th>
                <th>
                  <nobr>区域</nobr>
                </th>
                <th>
                  <nobr>用户类型</nobr>
                </th>
                <th>
                  <nobr>本月开户</nobr>
                </th>
                <th>
                  <nobr>本年开户</nobr>
                </th>
                <th>
                  <nobr>开工累计</nobr>
                </th>
                <th>
                  <nobr>本月售气量</nobr>
                </th>
                <th>
                  <nobr>本年售气量</nobr>
                </th>
                <th>
                  <nobr>本月售气金额</nobr>
                </th>
                <th>
                  <nobr>本年售气金额</nobr>
                </th>
              </tr>
            </template>
            <template partial='body'>
              <td style="text-align: center;">
                <nobr>{{row.f_gasproperties}}</nobr>
              </td>
              <td style="text-align: center;">
                <nobr>{{row.f_residential_area}}</nobr>
              </td>
              <td style="text-align: center;">
                <nobr>{{row.f_usertype}}</nobr>
              </td>
              <td style="text-align: center;">
                <nobr>{{row.yuekaihu}}</nobr>
              </td>
              <td style="text-align: center;">
                <nobr>{{row.niankaihu}}</nobr>
              </td>
              <td style="text-align: center;">
                <nobr>{{row.kgleij}}</nobr>
              </td>
              <td style="text-align: center;">
                <nobr>{{row.f_yuepregas}}</nobr>
              </td>
              <td style="text-align: center;">
                <nobr>{{row.f_yuepreamount}}</nobr>
              </td>
              <td style="text-align: center;">
                <nobr>{{row.f_pregas}}</nobr>
              </td>
              <td style="text-align: center;">
                <nobr>{{row.f_preamount}}</nobr>
              </td>
            </template>
            <template partial='foot'></template>
          </data-grid>
        </criteria-paged>
      </div>
    </div>
  </div>
</template>

<script>
  import {PagedList} from 'vue-client'
  import defaultPrint from '../config/DefaultPrint'
  import exportConfig from '../config/exportConfig'
  let readySomething = async function (self) {

    console.log("self.login",self.$login)
    self.$refs.paged.$refs.cri.model.startDate = self.$login.toStandardDateString() + ' 00:00:00'
    self.$refs.paged.$refs.cri.model.endDate = self.$login.toStandardDateString() + ' 23:59:59'
    self.search()
  }
  export default {
    title: '销售量分类',
    data() {
      return {
        model: new PagedList('api/af-revenue/sql/salesgasclassification', 20, {f_start_date: 'this.model.startDate', f_end_date: 'this.model.endDate'}),
        orgCondtionStr: '',
      }
    },
    ready() {
      readySomething(this).then(() => {
        this.$emit('ready')
      }).catch((error) => {
        this.$emit('error', error)
      })
    },
    methods: {
      search(){
        this.$refs.paged.$refs.cri.search()
      },
      selfSearch(args) {
        debugger
        args.condition = `${args.condition}` + this.orgCondtionStr
        this.model.search(args.condition, args.model)
      }
    },
    watch: {
    },
    computed: {
      // getCondition() {
      //   return {condition: `${this.$refs.paged.$refs.cri.condition}` + this.orgCondtionStr}
      // },
      // getfield() {
      //   return exportConfig.exemptquery
      // },
    }
  }
</script>
