<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_hand_state"
                          style="width:60%"
                          v-model="model.f_hand_state"
                          :options='$parent.$parent.meterstate' placeholder='状态'
                          condition="f_hand_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_hand_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_hand_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 :classname="$parent.classname">
          <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>
              <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_meternumber}}</nobr>
            </td>
            <td style="text-align: center;">
              <nobr>{{row.f_last_tablebase}}</nobr>
            </td>
            <td style="text-align: center;">
              <nobr>{{row.f_tablebase}}</nobr>
            </td>
            <td style="text-align: center;">
              <nobr>{{row.f_oughtamount}}</nobr>
            </td>
            <td style="text-align: center;">
              <nobr>{{row.f_oughtfee}}</nobr>
            </td>
            <td style="text-align: center;">
              <nobr>{{row.f_stair1amount}}</nobr>
            </td>
            <td style="text-align: center;">
              <nobr>{{row.f_stair1price}}</nobr>
            </td>
            <td style="text-align: center;">
              <nobr>{{row.f_stair1fee}}</nobr>
            </td>
            <td style="text-align: center;">
              <nobr>{{row.f_stair2amount}}</nobr>
            </td>
            <td style="text-align: center;">
              <nobr>{{row.f_stair2price}}</nobr>
            </td>
            <td style="text-align: center;">
              <nobr>{{row.f_stair2fee}}</nobr>
            </td>
            <td style="text-align: center;">
              <nobr>{{row.f_stair3amount}}</nobr>
            </td>
            <td style="text-align: center;">
              <nobr>{{row.f_stair3price}}</nobr>
            </td>
            <td style="text-align: center;">
              <nobr>{{row.f_stair3fee}}</nobr>
            </td>
            <td style="text-align: center;">
              <nobr>{{row.f_inputtor}}</nobr>
            </td>
            <td style="text-align: center;">
              <nobr>{{row.f_hand_date}}</nobr>
            </td>
            <td style="text-align: center;">
              <nobr>{{row.f_input_date}}</nobr>
            </td>
            <td style="text-align: center;">
              <nobr>{{row.f_meter_state}}</nobr>
            </td>
            <td style="text-align: center;">
              <nobr>{{row.f_hand_state}}</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></nobr>
            </td>
            <td style="text-align: center;background-color: mistyrose ">
              <nobr></nobr>
            </td>
            <td style="text-align: center;background-color: mistyrose ">
              <nobr>{{model.sums.f_oughtamount}}</nobr>
            </td>
            <td style="text-align: center;background-color: mistyrose ">
              <nobr>{{model.sums.f_oughtfee}}</nobr>
            </td>
            <td style="text-align: center;background-color: mistyrose ">
              <nobr>{{model.sums.f_stair1amount}}</nobr>
            </td>
            <td style="text-align: center;background-color: mistyrose ">
              <nobr></nobr>
            </td>
            <td style="text-align: center;background-color: mistyrose ">
              <nobr>{{model.sums.f_stair1fee}}</nobr>
            </td>
            <td style="text-align: center;background-color: mistyrose ">
              <nobr>{{model.sums.f_stair2amount}}</nobr>
            </td>
            <td style="text-align: center;background-color: mistyrose ">
              <nobr></nobr>
            </td>
            <td style="text-align: center;background-color: mistyrose ">
              <nobr>{{model.sums.f_stair2fee}}</nobr>
            </td>
            <td style="text-align: center;background-color: mistyrose ">
              <nobr>{{model.sums.f_stair3amount}}</nobr>
            </td>
            <td style="text-align: center;background-color: mistyrose ">
              <nobr></nobr>
            </td>
            <td style="text-align: center;background-color: mistyrose ">
              <nobr>{{model.sums.f_stair3fee}}</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('api/af-revenue/sql/handplanQuery', 20,{},{
          f_oughtamount:0,
          f_oughtfee:0,
          f_stair1amount:0,
          f_stair1fee:0,
          f_stair2amount:0,
          f_stair2fee:0,
          f_stair3amount:0,
          f_stair3fee:0


        }),
        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: {
      meterstate() {
        return [{label: '全部', value: ''}, ...this.$appdata.getParam('抄表状态')]
      },
    }
  }
</script>

