<template>
  <div id="unit" class="flex-row">
    <div class="flex" style="flex: 1; width:70%">
      <cardallot-list v-ref:allotlist  @select-changed="selected"></cardallot-list>
      <carddeatil-list v-ref:detaillist v-if='detaillistshow' :row='detailrow' @select-changed="detailselected"></carddeatil-list>
    </div>
    <div v-if= 'alloteditshow || detaileditshow' style="width:35%">
      <cardallot-edit v-if= 'alloteditshow' :data = 'allotrow'></cardallot-edit>
      <carddeatil-edit v-if= 'detaileditshow' :data = 'detaileditrow'></carddeatil-edit>
    </div>
  </div>
</template>
<script>
/**
*发票分配汇总组件
*/

export default {
  title: '发卡管理',
  data () {
    return {
      row: null,
      // allotlistshow: false,
      alloteditshow: false,
      detaillistshow: false,
      detaileditshow: false,
      isadd: false,
      allotrow: null,
      detailrow: null,
      detaileditrow: null
    }
  },
  watch: {
  },
  methods: {
    selected (obj) {
      console.log(obj.val)
      this.allotrow = obj.val
      this.detailrow = obj.val
      this.detaillistshow = true
      this.detaileditshow = false
      this.alloteditshow = true
    },
    detailselected (obj) {
      this.detaileditrow = obj.val
      this.detaileditshow = true
      this.alloteditshow = false
    }
  },
  events: {
    'allotlistsearch' () {
      this.$refs.allotlist.$refs.paged.$refs.cri.search()
      this.alloteditshow = true
      this.detaillistshow = false
      this.detaileditshow = false
    },
    'refrash' () {
      this.$refs.allotlist.$refs.paged.$refs.cri.search()
    },
    'success' (name, row, res) {

    },
    'clean' (row) {

    },
    'error' (name, row, res) {

    },
    'addallot' (type) {
      this.allotrow = {}
      this.alloteditshow = true
    },
    // 卡详细信息 确认事件 取消事件
    'detailsave' (type) {
      if (type === 'success') {
        this.$refs.detaillist.$refs.paged.$refs.cri.search()
      }
      this.alloteditshow = true
      this.detaileditshow = false
    }
  }
}
</script>
