<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 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_changemeter_date >= '{} 00:00:00'">
                </datepicker>
              </div>
              <div class="col-sm-3">
                <label 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_changemeter_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" partial='list' class="list_area table_sy" v-ref:grid @dblclick="$parent.$parent.toBusiness">
          <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>
              <th>
                <nobr>人员</nobr>
              </th>

            </tr>
          </template>
          <template partial='body'>

            <td style="text-align: center;">
              <nobr>{{row.f_type}}</nobr>
            </td>
            <td style="text-align: center;">
              <nobr>{{row.f_changemeter_fee}}</nobr>
            </td>
            <td style="text-align: center;">
              <nobr>{{row.f_total_gas}}</nobr>
            </td>
            <td style="text-align: center;">
              <nobr>{{row.f_using_base}}</nobr>
            </td>
            <td style="text-align: center;">
              <nobr>{{row.f_card_id}}</nobr>
            </td>
            <td style="text-align: center;">
              <nobr>{{row.f_newcard_id}}</nobr>
            </td>
            <td style="text-align: center;">
              <nobr>{{row.f_meter_classify}}</nobr>
            </td>
            <td style="text-align: center;">
              <nobr>{{row.f_newmeter_classify}}</nobr>
            </td>
            <td style="text-align: center;">
              <nobr>{{row.f_old_meter_brand}}</nobr>
            </td>
            <td style="text-align: center;">
              <nobr>{{row.f_new_meter_brand}}</nobr>
            </td>
            <td style="text-align: center;">
              <nobr>{{row.f_comments}}</nobr>
            </td>
            <td style="text-align: center;">
              <nobr>{{row.f_change_operator}}</nobr>
            </td>
            <td style="text-align: center;">
              <nobr>{{row.f_state}}</nobr>
            </td>
            <td style="text-align: center;">
              <nobr>{{row.f_changemeter_date}}</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_changemeter_fee}}</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>
            <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',
        model: new PagedList('rs/sql/changeMeterQuery', 15,{},{
          f_changemeter_fee:0
        }),
        // row: null,
        orgCondtionStr:''
      }
    },
    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)
      }
    },
    watch:{
      getCondition(){
        return {condition: `${this.$refs.paged.$refs.cri.condition}`+this.orgCondtionStr}
      }
    },
    computed: {
      charge_state() {
        return [{label: '全部', value: ''}, ...this.$appdata.getParam('收费状态')]
      }
    }
  }
</script>
