<template>
  <div id="unit" class="row" :class="{'binary':showItem}">
    <div :class="{'basic-main':!showItem,'binary-left':showItem}" style="height:98%;" :style="{width: showItem?'50%':'100%'}">
      <insurance-lists @select-changed="idsearch" v-if="stepControl"
                       v-ref:insurancelist></insurance-lists>
    </div>
    <div class="binary-right" v-if="showItem" :style="{width: showItem?'50%':'auto'}">
      <insurance-detail :recordlist="recordlist" :model="model" v-show="showItem"
      ></insurance-detail>
    </div>
  </div>
</template>

<script>
import {HttpResetClass} from 'vue-client'

export default {
  title: '保险收费',
  name: 'InsuranceManage',
  data () {
    return {
      recordlist: [],
      model: {},
      // 单选数据
      row: {},
      // 多选数据
      rowsdata: [],
      rowsdata1: {},
      stepControl: true,
      warehousename: '',
      showItem: false
    }
  },
  created () {
  },
  ready () {

  },
  methods: {
    selected (row) {
      this.row = row.val
    },

    idsearch (row) {
      this.showItem = true
      row.val.f_state = '有效'
      this.model = JSON.parse(JSON.stringify(row.val))
      this.getGroupData()
    },
    async getGroupData () {
      console.log('获取记录')
      let condition = "ufe.f_userinfo_id = " + this.model.f_userinfo_id
      let res = await this.$resetpost('rs/sql/getInsuranceRecord', {data: {condition: condition}}, {
        resolveMsg: null,
        rejectMsg: '获取记录出错'
      })
      this.recordlist = res.data
    }
  },
  events: {
    // 重新查询
    'refresh' () {
      this.getGroupData()
      this.$refs.insurancelist.search()
    },
    'close' () {
      this.showItem = false
      this.$refs.insurancelist.search()
    }

  }
}
</script>

<style lang="less">

</style>
