<template>
  <n-options-tree ref="options" v-model="isFocus" v-bind="{disabled, state, pasterOptions, options, maxHeight, autoClose: false, builders, multiple}"
                  @click="onOptionSelect" @select-all="onSelectAll">
    <n-form-refer class="n-select-tree" v-model="isFocus"
                  v-bind="{name, values, state, multiple, size, border,  disabled, placeholder,clearable, builder: builders.value}"
                  @u-update="onReferUpdateValues"></n-form-refer>
  </n-options-tree>
</template>
<script>
import NSelect from '@uif/next/lib/components/select'
import NOptionsTree from '@uif/next/lib/components/options-tree'
import {optionsSelectAll} from '_common/formUtils'

export default {
  inheritAttrs: false,
  name: 'n-select-tree',
  extends: NSelect,
  components: {
    NOptionsTree
  },
  methods: {
    // 点击全选
    onSelectAll (options, isSelected) {
      optionsSelectAll(this.nValue, options, isSelected)
      this.state.updateValuesByValue(this.values, this.nValue)
      this.$emit('u-update', this.nValue)
    }
  }
}
</script>
