<template>
  <div>
    <div style="flex: 1.5" class="flex">
      <div class="flex">
        <criteria-paged :model="model" v-ref:paged>
          <criteria partial='criteria' v-ref:criteria @condition-changed="$parent.selfSearch">
            <div novalidate class="form-inline auto" partial>
            </div>
          </criteria>
          <data-grid :model="model" v-ref:grid class="list_area table_sy" partial='list'>
            <template partial='head'>
              <tr>
                <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>{{$index + 1}}</nobr></td>
              <td style="text-align: center;"><nobr>{{row.f_type}}</nobr></td>
              <td style="text-align: center;"><nobr>{{row.f_loss_type}}</nobr></td>
              <td style="text-align: center;"><nobr>{{row.f_number}}</nobr></td>
              <td style="text-align: center;"><nobr>{{row.f_unitprice}}</nobr></td>
            </template>
          </data-grid>
        </criteria-paged>

      </div>
    </div>
  </div>
</template>

<script>

  import {HttpResetClass, PagedList} from 'vue-client'
  import Vue from 'vue'
  let readyGen = async function (self) {
    console.log("看看selectrow：",self.selectrow)
    self.search()
  }
  export default {
    title: '气损收费查看',
    data () {
      return {
        model: new PagedList('rs/sql/singleTable_OrderBy', 20, {items: '"*"', tablename: '"t_gasloss_detail"', orderitem: '"id desc"'}),

      }
    },
    props: ['selectrow'],
    ready () {
      readyGen(this)
    },

    methods: {
      clean(){
        this.$dispatch('clean')
      },
      async confirm () {
        let http = new HttpResetClass()
        await http.load('POST', 'rs/logic/editGasLoss', this.selectrows, {resolveMsg: '气损收费成功', rejectMsg: '气损收费失败'})

      },
      search () {
        this.$refs.paged.$refs.criteria.search()
      },
      selfSearch (args) {
        if (this.selectrow.id) {
          args.condition = ` f_gasloss_id=${this.selectrow.id}  `
          this.model.search(args.condition, args.model)
        }
      }
    },
    computed: {
    },
    watch:{
      // 'selectrow'(val){
      //   console.log("----------------selectrow:--------------",val)
      //   if(val){
      //     this.selectrow.gaslossdetails = JSON.parse(JSON.stringify(this.selectrow.gaslossdetail))
      //
      //   }
      // }
    }
  }
</script>

<style>
</style>
