<template>
    <div id="unit" class="flex-row">
        <div :class="{'basic-main':!useraddressShow,'binary-left':useraddressShow}" v-show="isSelect" style="height: 100%;border-radius: 0;margin: 0;">
          <tab-button v-ref:tabbutton>
            <tabs header="未关联表具" v-ref:tabs1>
              <concentrator-userfiles-list v-show="showmone"  :is-select="isSelect" :fileinfo="fileinfo" :f_filialeid.sync="f_filialeid"
                                                 @address-valid="doNothing"  v-ref:userfilesadd ></concentrator-userfiles-list>
           </tabs>
            <tabs header="已关联表具" v-ref:tabs2>
              <concentrator-userfiles-list2 :is-select="isSelect" :fileinfo="fileinfo" :f_filialeid.sync="f_filialeid"
                                           @address-valid="doNothing"  v-ref:userfilesadd2 ></concentrator-userfiles-list2>
            </tabs>
          </tab-button>
        </div>
      <work-busy :is-busy="iswork" v-show="iswork"></work-busy>
    </div>
</template>

<script>
  import TabButton from './common/TabButton'
import Tabs from './common/Tabs'

export default {
    title: '交账确认',
    components: {Tabs, TabButton},
    data () {
      return {
        show: [true],
        isSelect: true,
        useraddressShow: false,
        addressId: null,
        row: {},
        isSpecial: false,
        oldrow: {},
        newmodel: [],
        showmone: false,
        iswork: false,
        nopushsize: 0,
        nopushrows: [],
        areamodelnew: {}
      }
    },
        // props:['model','searchcondition','orgiddepid'],
    props: ['f_filialeid', 'fileinfo'],
    ready () {
      this.newmodel = []
      this.showmone = true
      this.areamodelnew = this.$parent.$parent.$refs.addareamsg.areamodel
    },
    methods: {
      closepushadd1 () {
        this.$emit('closemodel')
      },
      refresh () {
        this.addressId = null
        this.useraddressShow = false
      },
      initData (val) {
        if (val.f_address) {
          this.useraddressShow = true
          this.addressId = val.id
          this.row = Object.assign({}, this.row, val)
        } else {
          this.useraddressShow = false
        }
      }
    },
    events: {
      'add' (val) {
        this.useraddressShow = true
        this.$dispatch('hiddentogglefooter')
      },
      'openconfimbutton' () {
        this.$dispatch('openbutton')
      },
      'closeconfimbutton' () {
        this.$dispatch('closebutton')
      },
      'confirm' () {
        this.$dispatch('confirmcolse')
        this.$dispatch('showtogglefooter')
      },
      'cancel' () {
        this.useraddressShow = false
        this.row = {}
        this.$dispatch('showtogglefooter')
      },
      'addrecord' (addmodel) {
        this.newmodel.push(addmodel)
        this.useraddressShow = false
        this.$dispatch('showtogglefooter')
        this.$showAlert('添加成功!', 'success', 1000)
        this.row = {}
        if (this.$refs.pushconfirmmegerlist) {
          this.$refs.pushconfirmmegerlist.$refs.paged.$refs.cri.search()
        }
        if (this.$refs.pushconfirmlist) {
          this.$refs.pushconfirmlist.$refs.paged.$refs.cri.search()
        }
      },
      'updaterow' (row) {
        this.row = row
        this.oldrow = row
        row.edit = 1
        this.useraddressShow = true
        this.$dispatch('hiddentogglefooter')
      },
      'updaterecord' (row) {
              // this.$refs.newpushconfirmlist.sumalldata();
        this.newmodel.pop(this.oldrow)
        this.newmodel.push(row)
        this.useraddressShow = false
        this.$dispatch('showtogglefooter')
        this.$showAlert('修改成功!', 'success', 1000)
        this.row = {}
        this.oldrow = {}
        if (this.$refs.pushconfirmmegerlist) {
          this.$refs.pushconfirmmegerlist.$refs.paged.$refs.cri.search()
        }
        if (this.$refs.pushconfirmlist) {
          this.$refs.pushconfirmlist.$refs.paged.$refs.cri.search()
        }
      },
      'deleterow' (row) {
        this.newmodel.pop(row)
      },
      'closecancel' () {
        if (this.useraddressShow) {
          this.$refs.pushconfirmadd.clear()
        }
        this.$dispatch('confirmcolse')
      },
      'errorclose' () {
        this.$dispatch('confirmcolse')
      }
    }
  }
</script>
<style scoped>
  .showp{
    text-align: right; padding-right: 29px;color:rgb(111,5,0);font-weight:700;    position: relative;
    top: 18px;
    height: 0px;
  }
</style>
