<template >
  <div class="flex" style="justify-content: space-between;">
    <div @keyup.enter="search" style="">
      <criteria-paged :model="model" v-ref:paged>
        <criteria @condition-changed='$parent.search' partial='criteria' v-ref:criteria>
          <div class="form-horizontal select-overspread container-fluid auto" novalidate 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"
                            condition="f_operate_date >= '{}'">
                </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"
                            condition="f_operate_date <= '{}'">
                </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>
              </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>
              <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.id}}</nobr>
            </td>
            <td style="text-align: center;">
              <nobr>{{row.f_meter_brand}}</nobr>
            </td>

            <td style="text-align: center;">
              <nobr>{{row.f_old_price}}</nobr>
            </td>
            <td style="text-align: center;">
              <nobr>{{row.f_new_price}}</nobr>
            </td>
            <td style="text-align: center;">
              <nobr>{{row.f_change_price}}</nobr>
            </td>
            <td style="text-align: center;">
              <nobr>{{row.f_real_amount}}</nobr>
            </td>
            <td style="text-align: center;">
              <nobr>{{row.f_surplus_fee}}</nobr>
            </td>
            <td style="text-align: center;">
              <nobr>{{row.f_qujian}}</nobr>
            </td>
            <td style="text-align: center;">
              <nobr>{{row.f_whether_pay}}</nobr>
            </td>
            <td style="text-align: center;">
              <nobr>{{row.last_hand_date}}</nobr>
            </td>
            <td style="text-align: center;">
              <nobr>{{row.f_hand_date}}</nobr>
            </td>

            <td style="text-align: center;">
              <nobr>{{row.f_start_date}}</nobr>
            </td>
            <td style="text-align: center;">
              <nobr>{{row.f_end_date}}</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_surplus_gas}}</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_operator}}</nobr>
            </td>
            <td style="text-align: center;">
              <nobr>{{row.f_depname}}</nobr>
            </td>
            <td style="text-align: center;">
              <nobr>{{row.f_orgname}}</nobr>
            </td>
          </template>
          <template partial='foot'></template>
        </data-grid>
      </criteria-paged>
    </div>
  </div>
</template>

<script>
import {PagedList} from 'vue-client'
import co from 'co'
export default {
  title: '调价补差查询',
  data () {
    return {
      condition: '1=1',
      model: new PagedList('rs/sql/sale_surplusQueryUser', 10, {}),
      // 控制单选
      radio: [],
      // 选中的页
      all: [],
      // row数据
      rowsdata: [],
    }
  },
  props: ['row'],
  ready () {
    this.$refs.paged.$refs.criteria.search()
  },
  methods: {
    clear () {
      this.model.endDate = ''
      this.model.startDate = ''
    },
    search () {
      this.condition = `${this.$refs.paged.$refs.criteria.condition} and f_userinfo_id = '${this.row.f_userinfo_id}'`
      this.model.search(this.condition, this.model)
    },
    // 多选框初始化
    // selectInit () {
    //   this.rowsdata = []
    //   this.all = []
    //   this.radio = []
    // },
    // select () {
    //   let index = this.model.pageIndex - 1
    //   if (!this.radio[index]) {
    //     this.radio.$set(index, [])
    //   }
    //   if (this.all[index]) {
    //     // 数据
    //     this.rowsdata[index] = Object.assign([], this.model.rows)
    //     // 勾选
    //     for (var i = 0; i < this.model.rows.length; i++) {
    //       this.radio[index].$set(i, true)
    //     }
    //   } else {
    //     // 数据
    //     this.rowsdata[index] = []
    //     // 不勾选
    //     for (var i = 0; i < this.model.rows.length; i++) {
    //       this.radio[index].$set(i, false)
    //     }
    //   }
    //   let z = 0
    //   for (let i = 0; i < this.all.length; i++) {
    //     for (let j = 0; this.rowsdata[i] && j < this.rowsdata[i].length; j++) {
    //       this.printModel.rows[z++] = this.rowsdata[i][j]
    //     }
    //   }
    // },
    // selectOne (event, row, i) {
    //   let index = this.model.pageIndex - 1
    //   if (!this.rowsdata[index]) {
    //     this.rowsdata[index] = []
    //   }
    //   if (!this.radio[index]) {
    //     this.radio.$set(index, [])
    //   }
    //   if (event.target.checked) {
    //     // 数据
    //     this.rowsdata[index][i] = row
    //     // 勾选
    //     this.radio[index].$set(i, true)
    //     // 判断是否全部选中
    //     var allState = true
    //     if (this.model.rows.length != this.radio[index].length) {
    //       allState = false
    //     }
    //     for (var state of this.radio[index]) {
    //       if (!state) {
    //         allState = false
    //       }
    //     }
    //     if (allState) {
    //       this.all.$set(index, true)
    //     } else {
    //       this.all.$set(index, false)
    //     }
    //   } else {
    //     // 数据
    //     this.rowsdata[index][i] = []
    //     // 不勾选
    //     this.radio[index].$set(i, false)
    //     // 任意取消一个则全选状态设为false
    //     this.all.$set(index, false)
    //   }
    //   let z = 0
    //   this.printModel.rows = []
    //   for (let i = 0; i < this.all.length; i++) {
    //     for (let j = 0; this.rowsdata[i] && j < this.rowsdata[i].length; j++) {
    //       if (this.rowsdata[i][j] && this.rowsdata[i][j].f_user_id) {
    //         this.printModel.rows[z++] = this.rowsdata[i][j]
    //       }
    //     }
    //   }
    // }
  },
  computed: {
    // ischecked () {
    //   return function (index, i) {
    //     if (!this.radio[index]) {
    //       return false
    //     }
    //     return this.radio[index][i]
    //   }
    // }
  }
}
</script>

