
<template >
  <div class="auto">
    <modal :show.sync="showdetail" title="详细记录" v-ref:modal large backdrop="false">
      <article slot="modal-body" class="modal-body">
          <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>
              </tr>
            </template>
            <template partial='body' partial='list' v-ref:grid>
              <tr >
                <td style="text-align:center;">{{$index+1}}</td>
                <th style="text-align:center">{{row.f_brand_spec}}</th>
                <th style="text-align:center">{{row.f_number}}</th>
                <th style="text-align:center">{{row.f_unitprice}}</th>
                <th style="text-align:center">{{(row.f_number-0)*(row.f_unitprice-0)}}</th>
                <th style="text-align:center">{{row.f_typename}}</th>
                <th style="text-align:center">{{row.f_typenumber}}</th>

              </tr>
            </template>
            <template partial='foot'></template>
          </data-grid>
      </article>
      <footer slot="modal-footer" class="modal-footer">
      </footer>
    </modal>
  </div>
</template>

<script>
  export default {
    title: '抄表',
    data () {
      return {
        model: {
          rows: []
        }

      }
    },
    props: ['otherchargeid', 'showdetail'],
    ready () {
      this.search()
    },
    methods: {
      async search () {
        // 获取这个气价的所有记录
        this.model.rows = []
        let data = {
          tablename: `t_othercharge_detail`,
          items: '*',
          condition: '1=1',
          orderitem: 'id'
        }
        if (this.otherchargeid) {
          data.condition = `f_othercharge_id = '${this.otherchargeid}'`
        }

        let res = await this.$resetpost('rs/sql/singleTable_OrderBy', {data: data}, {rejectMsg: '获取气价记录出错', resolveMsg: null})
        this.model.rows = res.data
      }

    },
    watch: {
      'showdetail' (val) {
        if (val) {
          this.search()
        }
      }
    }
  }
</script>
