<template>
  <law-case-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">
      <LawCasePickerSourceTree ref="tree" v-bind="{ ...$props, ...scope }" />
    </template>
  </law-case-value-picker>
</template>

<script>
import pickerMixinInternal from './picker-mixin-internal'
import LawCasePickerSourceTree from './law-case-picker-source-tree.vue'
import lawCaseValuePicker from './law-case-value-picker.vue'
import components from './_import-components/law-case-tree-picker-import'

/**
 * input框，通过弹出对话框，从树形结构中选择数据
 * @displayName SdTreePicker 树选择器
 */
export default {
  name: 'LawCaseTreePicker',
  components: {
    ...components,
    LawCasePickerSourceTree,
    lawCaseValuePicker,
  },
  mixins: [pickerMixinInternal],
  props: {
    selectclick: {
      type: Function,
      default: null,
    },
    /**
     * 根节点{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,
    },
    // 特殊树不需要获取节点
    selectchecked: {
      type: Boolean,
      default: false,
    },
    // 加载子节点
    loadChildrenData: {
      type: Function,
      default: undefined,
    },
  },
}
</script>

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