ruoyi-plus-soybean/src/components/custom/workflow-category-select.vue

47 lines
1.1 KiB
Vue
Raw Normal View History

2025-05-22 22:56:59 +08:00
<script setup lang="tsx">
import { useAttrs } from 'vue';
import type { TreeSelectProps } from 'naive-ui';
import { useLoading } from '@sa/hooks';
import { fetchGetCategoryTree } from '@/service/api/workflow';
defineOptions({ name: 'WorkflowCategorySelect' });
interface Props {
[key: string]: any;
}
defineProps<Props>();
const value = defineModel<CommonType.IdType | null>('value', { required: false });
const options = defineModel<Api.Common.CommonTreeRecord>('options', { required: false, default: [] });
const attrs: TreeSelectProps = useAttrs();
const { loading, startLoading, endLoading } = useLoading();
async function getCategoryList() {
startLoading();
const { error, data } = await fetchGetCategoryTree();
if (error) return;
options.value = data;
endLoading();
}
getCategoryList();
</script>
<template>
<NTreeSelect
v-model:value="value"
filterable
class="h-full"
:loading="loading"
key-field="id"
label-field="label"
:options="options as []"
:default-expanded-keys="[0]"
v-bind="attrs"
/>
</template>
<style scoped></style>