import Tree from '@/components/Tree/index.vue'
import { useDaodan } from './ddHooks'
import { NButton } from 'naive-ui'

export default defineComponent({
  setup() {
    const { treeData, isLoading, showOrHideDdConfig } = useDaodan()

    const renderSuffix = ({ option }) => {
      if (!option.data) {
        return undefined
      }
      return (
        <>
          <NButton
            type="info"
            text
            size="tiny"
            onClick={() => showOrHideDdConfig(option.data)}
          >
            试验配置
          </NButton>
        </>
      )
    }
    return () => (
      <div class="w-h-full" v-loading={isLoading.value}>
        <Tree
          data={treeData.value}
          key-field="dataId"
          label-field="nodeName"
          // v-model:checked="checkedKeys"
          // defaultCheckedKeys="allKeys"
          checkable={false}
          showSearch
          renderSuffix={renderSuffix}
          // nodeProps={nodeProps}
        />
      </div>
    )
  },
})
