feat(BasicTree): 支持设置加载中
This commit is contained in:
parent
1e0ede09a2
commit
fb43e54847
|
|
@ -14,7 +14,7 @@
|
||||||
onMounted,
|
onMounted,
|
||||||
} from 'vue';
|
} from 'vue';
|
||||||
import TreeHeader from './TreeHeader.vue';
|
import TreeHeader from './TreeHeader.vue';
|
||||||
import { Tree, Empty } from 'ant-design-vue';
|
import { Tree, Spin, Empty } from 'ant-design-vue';
|
||||||
import { TreeIcon } from './TreeIcon';
|
import { TreeIcon } from './TreeIcon';
|
||||||
import { ScrollContainer } from '/@/components/Container';
|
import { ScrollContainer } from '/@/components/Container';
|
||||||
import { omit, get, difference, cloneDeep } from 'lodash-es';
|
import { omit, get, difference, cloneDeep } from 'lodash-es';
|
||||||
|
|
@ -426,10 +426,16 @@
|
||||||
{extendSlots(slots)}
|
{extendSlots(slots)}
|
||||||
</TreeHeader>
|
</TreeHeader>
|
||||||
)}
|
)}
|
||||||
<ScrollContainer style={scrollStyle} v-show={!unref(getNotFound)}>
|
<Spin spinning={unref(props.loading)} tip="加载中...">
|
||||||
<Tree {...unref(getBindValues)} showIcon={false} treeData={treeData.value} />
|
<ScrollContainer style={scrollStyle} v-show={!unref(getNotFound)}>
|
||||||
</ScrollContainer>
|
<Tree {...unref(getBindValues)} showIcon={false} treeData={treeData.value} />
|
||||||
<Empty v-show={unref(getNotFound)} image={Empty.PRESENTED_IMAGE_SIMPLE} class="!mt-4" />
|
</ScrollContainer>
|
||||||
|
<Empty
|
||||||
|
v-show={unref(getNotFound)}
|
||||||
|
image={Empty.PRESENTED_IMAGE_SIMPLE}
|
||||||
|
class="!mt-4"
|
||||||
|
/>
|
||||||
|
</Spin>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -130,6 +130,10 @@ export const treeProps = buildProps({
|
||||||
checkOnSearch: Boolean,
|
checkOnSearch: Boolean,
|
||||||
// 搜索完成自动select所有结果
|
// 搜索完成自动select所有结果
|
||||||
selectedOnSearch: Boolean,
|
selectedOnSearch: Boolean,
|
||||||
|
loading: {
|
||||||
|
type: Boolean,
|
||||||
|
default: false,
|
||||||
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
export type TreeProps = ExtractPropTypes<typeof treeProps>;
|
export type TreeProps = ExtractPropTypes<typeof treeProps>;
|
||||||
|
|
|
||||||
|
|
@ -32,7 +32,7 @@
|
||||||
:load-data="onLoadData"
|
:load-data="onLoadData"
|
||||||
/>
|
/>
|
||||||
</Col>
|
</Col>
|
||||||
<Col :span="16">
|
<Col :span="8">
|
||||||
<Card title="异步数据,默认展开">
|
<Card title="异步数据,默认展开">
|
||||||
<template #extra>
|
<template #extra>
|
||||||
<a-button @click="loadTreeData" :loading="treeLoading">加载数据</a-button>
|
<a-button @click="loadTreeData" :loading="treeLoading">加载数据</a-button>
|
||||||
|
|
@ -42,6 +42,14 @@
|
||||||
</Spin>
|
</Spin>
|
||||||
</Card>
|
</Card>
|
||||||
</Col>
|
</Col>
|
||||||
|
<Col :span="8">
|
||||||
|
<Card title="BasicTree内置加载">
|
||||||
|
<template #extra>
|
||||||
|
<a-button @click="loadTreeData2" :loading="treeLoading">请求数据</a-button>
|
||||||
|
</template>
|
||||||
|
<BasicTree ref="loadTreeRef" :treeData="tree2" :loading="treeLoading" />
|
||||||
|
</Card>
|
||||||
|
</Col>
|
||||||
</Row>
|
</Row>
|
||||||
</PageWrapper>
|
</PageWrapper>
|
||||||
</template>
|
</template>
|
||||||
|
|
@ -58,6 +66,7 @@
|
||||||
setup() {
|
setup() {
|
||||||
const asyncTreeRef = ref<Nullable<TreeActionType>>(null);
|
const asyncTreeRef = ref<Nullable<TreeActionType>>(null);
|
||||||
const asyncExpandTreeRef = ref<Nullable<TreeActionType>>(null);
|
const asyncExpandTreeRef = ref<Nullable<TreeActionType>>(null);
|
||||||
|
const loadTreeRef = ref<Nullable<TreeActionType>>(null);
|
||||||
const tree2 = ref<TreeItem[]>([]);
|
const tree2 = ref<TreeItem[]>([]);
|
||||||
const treeLoading = ref(false);
|
const treeLoading = ref(false);
|
||||||
|
|
||||||
|
|
@ -79,6 +88,15 @@
|
||||||
});
|
});
|
||||||
}, 2000);
|
}, 2000);
|
||||||
}
|
}
|
||||||
|
function loadTreeData2() {
|
||||||
|
treeLoading.value = true;
|
||||||
|
// 以下是模拟异步获取数据
|
||||||
|
setTimeout(() => {
|
||||||
|
// 设置数据源
|
||||||
|
tree2.value = cloneDeep(treeData);
|
||||||
|
treeLoading.value = false;
|
||||||
|
}, 2000);
|
||||||
|
}
|
||||||
|
|
||||||
const tree = ref([
|
const tree = ref([
|
||||||
{
|
{
|
||||||
|
|
@ -119,9 +137,11 @@
|
||||||
onLoadData,
|
onLoadData,
|
||||||
asyncTreeRef,
|
asyncTreeRef,
|
||||||
asyncExpandTreeRef,
|
asyncExpandTreeRef,
|
||||||
|
loadTreeRef,
|
||||||
tree2,
|
tree2,
|
||||||
loadTreeData,
|
loadTreeData,
|
||||||
treeLoading,
|
treeLoading,
|
||||||
|
loadTreeData2,
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue