<template>
  <ic-value-picker ref="picker" v-bind="$props" :selectclick="selectclick" v-on="$listeners">
    <template v-if="$scopedSlots.suffixIcon" v-slot:suffixIcon>
      <!-- @slot input框最后的图标 -->
      <slot name="suffixIcon" />
    </template>
    <template v-slot:targetListHeader="scope">
      <!--
    @slot 右侧列表顶部<p>8.0.7 新增</p>
    @binding targetKeys {array} 右侧列表所有项目的 key 值
    @binding targetValues {array} 右侧列表所有项目的完整 Object 值
       -->
      <slot
        :targetKeys="scope.targetKeys"
        :targetValues="scope.targetValues"
        name="targetListHeader"
      />
    </template>
    <template v-slot="scope">
      <IcPickerSourceTree ref="tree" v-bind="{ ...$props, ...scope }" />
    </template>
  </ic-value-picker>
</template>

<script>
import pickerMixinInternal from './picker-mixin-internal'
import IcPickerSourceTree from './ic-picker-source-tree.vue'
import icValuePicker from './ic-value-picker.vue'
import components from './_import-components/ic-tree-picker-import'

/**
 * input框，通过弹出对话框，从树形结构中选择数据
 * @displayName SdTreePicker 树选择器
 */
export default {
  name: 'IcTreePicker',
  components: {
    ...components,
    IcPickerSourceTree,
    icValuePicker,
  },
  mixins: [pickerMixinInternal],
  props: {
    selectclick: {
      type: Function,
      default: null,
    },
    versionId: {
      type: String,
      default: '',
    },
    orgId: {
      type: String,
      default: '',
    },
    selecttype: {
      type: String,
      default: 'control',
    },
    types: {
      type: String,
      default: 'NK',
    },
    /**
     * 根节点{code:'200000',name:'西安分公司'}
     */
    rootNode: {
      type: [Object, Array],
      default: undefined,
    },
    /**
     * <p>获取数据的回调，获取根节点时，parentId为undefined</p>
     * <pre>(parentId,parent) => childrenItems</pre>
     */
    loadTreeData: {
      type: Function,
      required: true,
    },
    /**
     * <p>搜索数据的回调</p>
     * <pre>(searchText) => items</pre>
     * @since 8.0.2
     */
    searchTreeData: {
      type: Function,
      default: undefined,
    },
    /**
     * 默认展开指定的树节点
     * @since 8.0.7
     */
    defaultExpandedKeys: {
      type: Array,
      default: undefined,
    },
    moduleId: {
      type: String,
      default: undefined,
    },
    isAbandonment: {
      type: String,
      default: 'NO',
    },
  },
  data() {
    return {
      v3: [],
    }
  },
}
</script>

<style module lang="scss">
@use '@/common/design' as *;
</style>
