<template>
  <div id="unit" class="flex-row" :class="{'binary':showItem}">
    <div :class="{'basic-main':!showItem,'binary-left':showItem}">
      <gongjian-apply-list @select-changed="idsearch" :styles="showItem?'col-sm-3':'col-sm-2'" v-if="stepControl"
                            v-ref:jgDeviceAlarmlist @add="add"></gongjian-apply-list>
    </div>
    <div class="binary-right"  v-show="showItem">
      <gongjian-apply-dispose :recordlist="recordlist" :model="model" :oldmodel="oldmodel"
                               :f_distribution_state="f_distribution_state" :row="row" :rowsdata="rowsdata1"
                               :warehousename="warehousename"
      ></gongjian-apply-dispose>
    </div>
  </div>
</template>

<script>
export default {
  title: '政府报建',
  components: {},
  data() {
    return {
      f_alarmId: '',
      row: {},
      model: {},
      oldmodel: {},
      showItem: false,
      stepControl: true,

      // 分公司id串
      width: '100%',
      f_filialeids: "榆林."+this.$login.f.orgs,
      areaShow: false,
      areatype: '小区',
      arearow: {},
      style: 'col-sm-2'
    }
  },
  methods: {
    selected(obj) {
      this.style = 'col-sm-3 '
      if (obj.val && obj.val.id) {
        console.log('对比分公司', obj.val.f_filialeid, this.f_filialeids)
        if (obj.val.f_filialeid !== this.f_filialeids) {
          this.refresh()
          return
        }
        this.areaShow = true
        this.$refs.addareamsg.cleardara()
        this.$refs.addareamsg.operation = 'modify'
        this.$refs.addareamsg.areatype = '小区'
        this.$refs.addareamsg.areamodel = Object.assign({}, obj.val)
        if (obj.val.f_slice_area && obj.val.f_area_code) {
          this.$refs.addareamsg.areamodel.slice_area = [{
            name: this.$refs.addareamsg.areamodel.f_slice_area,
            code: this.$refs.addareamsg.areamodel.f_area_code
          }]
        }
        this.$refs.addareamsg.initdata(obj.val)
      }
    },
    add (a) {
      console.log('新增')
      this.showItem = true
      this.model = {}
      this.model.f_national_standard_industry='2017'
      this.oldmodel = {}
    },
    refresh() {
      this.areaShow = false
      this.showItem = false
      this.$refs.arealist.$refs.paged.$refs.cri.search()
    },
    idsearch(row) {
      this.showItem = true
      this.model = JSON.parse(JSON.stringify(row.val))
      this.oldmodel = JSON.parse(JSON.stringify(row.val))
    },
    getAlarmData () {
      let data = {}
    }
  },
  events: {
    'close'() {
      this.showItem = false
      this.$refs.stocklist.search()
      console.log('this.$refs', this.$refs)
      console.log('showitem', this.showItem)
    },
  }
}
</script>

