<template>
  <div id="unit" class="flex-row " :class="{'binary':areaShow}">
    <div :class="{'basic-main':!areaShow,'binary-left':areaShow}">
      <circle-list @select-changed="selected" :f_filialeids.sync="f_filialeids" :f_filiale.sync="f_filiale"  v-ref:circlelist></circle-list>
    </div>
    <div v-show="areaShow" class="binary-right">
       <add-circle-filiale v-ref:addcirclefiliale :operation='operation' :f_filialeids.sync="f_filialeids" :f_filiale.sync="f_filiale" :row="row"></add-circle-filiale>
    </div>
  </div>
</template>

<script>
  export default {
    title: '安检周期管理',
    data () {
      return {
        //分公司id串
        f_filialeids: this.$login.f.orgid,
        areaShow:false,
        f_filiale:this.$login.f.orgs,
      }
    },
    props:{

    },
    methods:{
      selected(obj){
        if(obj.val&&obj.val.id){
          // if (obj.val.f_filialeid != this.f_filialeids) {
          //   this.refresh()
          //   return
          // }
          this.$refs.addcirclefiliale.cleardara()
          this.areaShow=true
          this.$refs.addcirclefiliale.operation='modify'
          this.$refs.addcirclefiliale.circlemodel=Object.assign({},obj.val)
        }
      },
      async refresh () {
    this.areaShow = false
    await this.$refs.circlelist.$refs.paged.$refs.cri.search()
  }
  },
  events:{
    'add'(){
      this.style='col-sm-3 '
      this.areaShow=true
      this.$refs.addcirclefiliale.cleardara()
      this.$refs.addcirclefiliale.operation='add'
    },
    'modify'(area){
      this.style='col-sm-2 '
    },
    'confirm' () {
      this.style='col-sm-2 '

      this.refresh()
    },
    'cancel' () {
      this.style='col-sm-2 '

      this.areaShow = false
      this.$refs.circlelist.$refs.paged.$refs.cri.search()
    },
  }
  }
</script>


