<template >
  <div class="flex">
    <div class="height:auto">
      <criteria-paged :model="model" v-ref:paged  >
        <criteria partial='criteria' v-ref:cri  @condition-changed='$parent.selfSearch'>

          <div novalidate class="form-horizontal select-overspread container-fluid auto" partial>
            <div class="row">
              <div class="col-sm-3" >
                <label class="font_normal_body">状态</label>
                <v-select :value.sync="model.f_state"
                          style="width:60%"
                          v-model="model.f_state"
                          :options='$parent.$parent.charge_state' placeholder='状态'
                          condition="f_state = '{}'"
                          close-on-select></v-select>
              </div>
              <div class="col-sm-3">
                <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'"
                            :show-reset-button="true"
                            condition="f_operate_date >= '{} 00:00:00'">
                </datepicker>
              </div>
              <div class="col-sm-3">
                <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'"
                            :show-reset-button="true"
                            condition="f_operate_date <= '{} 23:59:59'">
                </datepicker>
              </div>

            <div class="span" style = "float:right;">
              <button class="button_search button_spacing" @click="search()">查询</button>
            </div>
            </div>
          </div>

        </criteria>
        <data-grid :model="model" class="list_area table_sy" partial='list' 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>
              <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_times}}</nobr>
            </td>
            <td style="text-align: center;">
              <nobr>{{row.f_pregas}}</nobr>
            </td>
            <td style="text-align: center;">
              <nobr>{{row.f_preamount}}</nobr>
            </td>
            <td style="text-align: center;">
              <nobr>{{row.f_delaypay}}</nobr>
            </td>
            <td style="text-align: center;">
              <nobr>{{row.f_collection}}</nobr>
            </td>
            <td style="text-align: center;">
              <nobr>{{row.f_balance}}</nobr>
            </td>
            <td style="text-align: center;">
              <nobr>{{row.f_curbalance}}</nobr>
            </td>
            <td style="text-align: center;">
              <nobr>{{row.f_payment}}</nobr>
            </td>
            <td style="text-align: center;">
              <nobr>{{row.f_type}}</nobr>
            </td>
            <td style="text-align: center;">
              <nobr>{{row.f_state}}</nobr>
            </td>
            <td style="text-align: center;">
              <nobr>{{row.f_operate_date}}</nobr>
            </td>
            <td style="text-align: center;">
              <nobr>{{row.f_comments}}</nobr>
            </td>
            <td style="text-align: center;">
              <nobr>{{row.filltimes}}</nobr>
            </td>
            <td style="text-align: center;">
              <nobr>{{row.f_operator}}</nobr>
            </td>

          </template>
          <template partial='foot'>
            <td style="text-align: center;background-color: mistyrose ">
              <nobr>合计：</nobr>
            </td>
            <td style="text-align: center;background-color: mistyrose ">
              <nobr>{{model.sums.f_pregas}}</nobr>
            </td>
            <td style="text-align: center;background-color: mistyrose ">
              <nobr>{{model.sums.f_preamount}}</nobr>
            </td>
            <td style="text-align: center;background-color: mistyrose ">
              <nobr>{{model.sums.f_delaypay}}</nobr>
            </td>
            <td style="text-align: center;background-color: mistyrose ">
              <nobr>{{model.sums.f_collection}}</nobr>
            </td>
            <td style="text-align: center;background-color: mistyrose ">
              <nobr></nobr>
            </td>
            <td style="text-align: center;background-color: mistyrose ">
              <nobr></nobr>
            </td>
            <td style="text-align: center;background-color: mistyrose ">
              <nobr></nobr>
            </td>
            <td style="text-align: center;background-color: mistyrose ">
              <nobr></nobr>
            </td>
            <td style="text-align: center;background-color: mistyrose ">
              <nobr></nobr>
            </td>
            <td style="text-align: center;background-color: mistyrose ">
              <nobr></nobr>
            </td>
            <td style="text-align: center;background-color: mistyrose ">
              <nobr></nobr>
            </td>
            <td style="text-align: center;background-color: mistyrose ">
              <nobr></nobr>
            </td>
            <td style="text-align: center;background-color: mistyrose ">
              <nobr></nobr>
            </td>
          </template>
        </data-grid>
      </criteria-paged>
    </div>
  </div>
</template>

<script>
  import {PagedList} from 'vue-client'
  let readySomething = async function (self) {

    await self.$refs.paged.$refs.cri.search()
  }
  export default {
    title: '收费查询',
    data () {
      return {
        condition: '1=1',
        orgCondtionStr:'',
        model: new PagedList('api/af-revenue/sql/chargeQuery', 20,{ }, {
          f_pregas:0,
          f_preamount:0,
          f_delaypay:0,
          f_collection:0,

        })
        // fields:{'fee': '金额','gas':'气量','type': '类型'},
      }
    },
    props:
      {
        f_userinfo_id: ''
      },
    ready () {
      readySomething(this)
    },
    methods: {
      selfSearch (args) {
        if (!this.orgCondtionStr) {
          args.condition = `${args.condition}` + " and f_orgid = " + this.$login.f.orgid + " and f_userinfo_id = " + this.f_userinfo_id
        } else {
          args.condition = `${args.condition}` + this.orgCondtionStr
        }
        this.model.search(args.condition, args.model)
      }
    },
    computed: {
      getCondition(){
        return {condition: `${this.$refs.paged.$refs.cri.condition}`+this.orgCondtionStr}
      },
      charge_state() {
        return [{label: '全部', value: ''}, ...this.$appdata.getParam('收费状态')]
      }
    }
  }
</script>

