<template>
  <div class="span">
    <data-grid :model="model" 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'>
        <tr>
          <td style="text-align:center">{{row.id}}</td>
          <td style="text-align:center">{{row.f_price_id}}</td>
          <td style="text-align:center">{{row.f_price_type}}</td>
          <td style="text-align:center">{{row.f_price_name}}</td>
          <td style="text-align:center">{{row.f_perform_date}}</td>
          <td style="text-align:center">{{row.f_end_date}}</td>
          <td style="text-align:center">{{row.f_state==='有效' ? '使用中' : (row.f_state==='待审核' ?  '待审核' : '已作废')}}</td>
        </tr>
      </template>
      <template partial='foot'></template>
    </data-grid>
  </div>
</template>

<script>
  /**
   *阶梯气价相关信息组件
   */

  export default {
    props: ['data', 'parentData'],
    data () {
      return {
        model: {
          rows: []
        }
      }
    },
    watch: {
      'parentData' (val) {
        this.f_price_id = this.data.f_price_id
        this.getUpdate()
      }
    },
    ready () {
      this.f_price_id = this.data.f_price_id
      this.getUpdate()
    },
    methods: {
      getUpdate () {
        let tablename = 't_stairprice'
        let condition = `f_price_id = '${this.f_price_id}' and f_filialeids = '${this.$login.f.f_orgids}'`
        this.$SqlService.singleTable(tablename, condition)
          .then(
            (res) => {
              this.model.rows = res.data
            }
          ).catch(
          (error) => this.$dispatch('error', '气价修改记录', this.data, error)
        )
      }
    }
  }
</script>
<style>

</style>
