|
|
@ -12,7 +12,7 @@ |
|
|
|
</div> |
|
|
|
|
|
|
|
<div style="min-height: 150px"> |
|
|
|
<ns-tree v-if="treeData?.length" v-bind="getBindValue" v-model:selectedKeys="selectedKeys"> |
|
|
|
<ns-tree v-if="treeData?.length" v-bind="getBindValue" :selectedKeys="selectedKeys"> |
|
|
|
<template #[item]="data" v-for="(item, index) in Object.keys($slots)" :key="index"> |
|
|
|
<slot :name="item" v-bind="{ ...data, formModel } || {}"></slot> |
|
|
|
</template> |
|
|
@ -27,7 +27,7 @@ |
|
|
|
import { TreeDataItem } from 'ant-design-vue/es/tree/Tree'; |
|
|
|
import { useApi } from '/nerv-lib/use/use-api'; |
|
|
|
import { AxiosRequestConfig } from 'axios'; |
|
|
|
import { get } from 'lodash-es'; |
|
|
|
import { get, isEmpty } from 'lodash-es'; |
|
|
|
import { useRoute } from 'vue-router'; |
|
|
|
import { debounce } from 'lodash-es'; |
|
|
|
import { treeProps, treeFormProps } from '/nerv-lib/component/tree/props'; |
|
|
@ -35,7 +35,7 @@ |
|
|
|
defineOptions({ |
|
|
|
name: 'NsTreeApi', |
|
|
|
}); |
|
|
|
const emit = defineEmits(['update:treeData']); |
|
|
|
const emit = defineEmits(['update:treeData', 'select']); |
|
|
|
// const model = defineModel('treeData'); |
|
|
|
|
|
|
|
const formElRef = ref(); |
|
|
@ -69,14 +69,25 @@ |
|
|
|
const isSticky: any = computed(() => { |
|
|
|
return props.isSticky ? 'sticky' : 'static'; |
|
|
|
}); |
|
|
|
|
|
|
|
const formFinish = debounce((data: object) => { |
|
|
|
selectedKeys.value = []; |
|
|
|
getData(data); |
|
|
|
}, 200); |
|
|
|
|
|
|
|
const handleSelect = (keys: any, selectedRows: any) => { |
|
|
|
if (props.cancelable || !isEmpty(keys)) { |
|
|
|
selectedKeys.value = keys; |
|
|
|
// props.onSelect && props.onSelect(keys, selectedRows); |
|
|
|
emit('select', keys, selectedRows); |
|
|
|
} |
|
|
|
}; |
|
|
|
|
|
|
|
const getBindValue = computed(() => ({ |
|
|
|
...attrs, |
|
|
|
...props, |
|
|
|
treeData: treeData.value, |
|
|
|
onSelect: handleSelect, |
|
|
|
})); |
|
|
|
const setLoading = (loading: boolean) => { |
|
|
|
treeState.loading = loading; |
|
|
|