feat: 更新工作流分类选择组件,修复值回显问题并优化添加数据操作

This commit is contained in:
AN
2025-05-27 22:41:48 +08:00
parent 92b9c213d5
commit 14a29070c9
3 changed files with 15 additions and 6 deletions

View File

@ -1,8 +1,9 @@
<script setup lang="tsx">
import { useAttrs } from 'vue';
import { computed, useAttrs } from 'vue';
import type { TreeSelectProps } from 'naive-ui';
import { useLoading } from '@sa/hooks';
import { fetchGetCategoryTree } from '@/service/api/workflow';
import { isNull } from '@/utils/common';
defineOptions({ name: 'WorkflowCategorySelect' });
@ -12,12 +13,17 @@ interface Props {
defineProps<Props>();
const value = defineModel<CommonType.IdType | null>('value', { required: false });
const rawValue = 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();
/** 转换为strid可能是number类型或者String类型导致回显失败 */
const strValue = computed(() => {
return isNull(rawValue.value) ? null : rawValue.value?.toString();
});
async function getCategoryList() {
startLoading();
const { error, data } = await fetchGetCategoryTree();
@ -31,7 +37,7 @@ getCategoryList();
<template>
<NTreeSelect
v-model:value="value"
v-model:value="strValue"
filterable
class="h-full"
:loading="loading"