export const CmsFormSelectTree = {
  data() {
    return {
      defaultSelectParams: {
        multiple: false,
        clearable: true,
        placeholder: '请输入内容'
      },
      defaultTreeParams: {
        // 开启虚拟滚动
        height: 300,
        filterable: false,
        clickParent: true,
        'check-strictly': true,
        'default-expand-all': false,
        'expand-on-click-node': false,
        data: [],
      }
    }
  },
  computed: {
    inputValue: {
      get() {
        return this.value
      },
      set(val) {
        console.log('================', val);
        this.$emit('input', val);
      }
    },
    newDefaultSelectParams: {
      get() {
        return Object.assign(this.defaultSelectParams, this.selectParams, {
          placeholder: this.placeholder,
          clearable: this.clearable
        })
      }
    },
    newDefaultTreeParams: {
      get() {
        const config = Object.assign(this.defaultTreeParams, this.treeParams, {
          defaultExpandAll: this.defaultExpandAll,
          props: this.defaultProps
        });
        return config;
      }
    }
  },
  props: {
    // v-model绑定
    value: [ String, Array, Boolean, Number ],
    placeholder: {
      type: String,
      default: () => {
        return '请选择'
      }
    },
    styles: {
      type: Object,
      default: () => {
        return {}
      }
    },
    selectClass: {
      type: String,
      default: () => {
        return undefined
      }
    },
    popoverClass: {
      type: String,
      default: () => {
        return undefined
      }
    },
    // 文本框参数，几乎支持el-select所有的API 取消参数：
    // 设定下拉框的弹出框隐藏：:popper-append-to-body="false"
    // 搜索从弹出框里面执行 filterable="false"
    selectParams: {
      type: Object,
      default: () => {
        return {}
      }
    },
    treeParams: {
      type: Object,
      default: () => {
        return {}
      }
    },
    multiple: Boolean,
    disabled: Boolean,
    clearable: {
      type: Boolean,
      default: () => {
        return true
      }
    },
    filterable: {
      type: Boolean,
      default: () => {
        return true
      }
    },
    remoteSearch: {
      type: Boolean,
      default: () => {
        return false
      }
    },
    placement: {
      type: String,
      default: () => {
        return "bottom"
      }
    },
    /**
     * 查询参数
     */
    extraData: {
      type: Object,
      default: () => {
        return {}
      }
    },
    // 数据源配置
    requestCall: {
      type: [ Array, Function, Object ],
      default: () => {
        return undefined
      }
    },
    // 树渲染方法，具体参考el-tree Function(h, { node, data, store }) {}
    treeRenderFun: Function,
    // 搜索过滤方法，具体参考el-tree Function(h, { value, data, node }) {}
    filterNodeMethod: Function,
    /**
     * 默认是否全部展开
     */
    defaultExpandAll: {
      type: Boolean,
      default: false,
    },
    /**
     * 默认是否全部展开
     */
    expandOnClickNode: {
      type: Boolean,
      default: false,
    },
    /**
     * 设置label value属性 tree的props配置
     */
    defaultProps: {
      type: Object,
      default: () => {
        return {
          value: 'id', // ID字段名
          label: 'name', // 显示名称
          children: 'children' // 子级字段名
        }
      }
    },
    groupName: {
      type: String,
      default: undefined,
    },
    formModel: {
      type: Object,
      default: {}
    },
    // 匹配元素
    matchKey: {
      type: Object,
      default: () => {
        return undefined
      }
    },
  }
}