<template>
  <div class="auto">
    <validator name='v'>
      <form novalidate class="form-horizontal">
        <p class="bg-info text-center" style="padding: 8px;font-size: 20px">操作记录</p>
        <data-grid :model="{rows: recordlist, state:1}" class="list_area table_sy" partial='list' v-ref:grid>
          <template partial='head'>
            <tr>
              <th style="text-align: center">
                <nobr>序号</nobr>
              </th>
              <th style="text-align: center">
                <nobr> 费用类型</nobr>
              </th>
              <th style="text-align: center">
                <nobr> 险种</nobr>
              </th>
              <th style="text-align: center">
                <nobr> 金额</nobr>
              </th>
              <th style="text-align: center">
                <nobr> 收款方式</nobr>
              </th>
              <th style="text-align: center">
                <nobr> 保险时间</nobr>
              </th>
              <th style="text-align: center">
              <nobr> 购买期数</nobr>
            </th>
              <th style="text-align: center">
                <nobr> 保险状态</nobr>
              </th>
              <th style="text-align: center">
                <nobr> 缴费时间</nobr>
              </th>
              <th style="text-align: center">
                <nobr> 操作人</nobr>
              </th>
              <th style="text-align: center">
                <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_fee_type}}</nobr>
            </td>
            <td style="text-align: center;">
              <nobr> {{row.f_insurance_type}}</nobr>
            </td>
            <td style="text-align: center;">
              <nobr> {{row.f_money}}</nobr>
            </td>
            <td style="text-align: center;">
              <nobr> {{row.f_payment}}</nobr>
            </td>
            <td style="text-align: center;">
              <nobr> {{row.ins_date}}</nobr>
            </td>
            <td style="text-align: center;">
              <nobr> {{row.f_salecount}}</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>
                <button type="button" name="button" class="btn btn-link" v-if="row.maxid===row.id"
                        @click="$parent.$parent.cancelinsurance(row)">冲正
                </button>
              </nobr>
            </td>
          </template>
          <template partial='foot'></template>
        </data-grid>
      </form>

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

<script>
  export default {
    name: 'insuranceRecord',
    data () {
      return {}
    },
    props: {
      recordlist: Array
    },
    created () {
    },
    ready () {
    },
    methods: {
      // 最后一条才能冲正
      cancelinsurance (row) {
        this.$showMessage('冲正后不可恢复，确认冲正吗？', ['confirm', 'cancel']).then((res) => {
          if (res === 'confirm') {
            row.f_operator = this.$login.f.name
            row.f_operatorid = this.$login.f.id
            row.f_orgid = this.$login.f.orgid
            row.f_orgname = this.$login.f.orgs
            row.f_depid = this.$login.f.depids
            row.f_depname = this.$login.f.deps
            this.$resetpost('rs/logic/cancelInsurance', {data: row}).then(() => {
              this.$dispatch('refresh')
              this.search()
            })
          }
        })
      }
    },
    watch: {}
  }
</script>

<style lang="less">
</style>
