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

export default defineComponent({
  setup() {
    const { treeData, isLoading, showOrHideDdConfig, getDaodanTreeData } =
      useDaodan()
    onMounted(() => {
      getDaodanTreeData()
    })
    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}>
        {/* <NButton type="primary" onClick={showOrHideDdConfig}>
          aaaaa
        </NButton> */}

        <Tree
          data={treeData.value}
          key-field="dataId"
          label-field="nodeName"
          // v-model:checked="checkedKeys"
          // defaultCheckedKeys="allKeys"
          checkable={false}
          showSearch
          renderSuffix={renderSuffix}
          // nodeProps={nodeProps}
        />
      </div>
    )
  },
})
