feat: 测试代码生成

This commit is contained in:
xlsea
2024-09-09 15:40:38 +08:00
parent 74529144aa
commit 07e30bd591
26 changed files with 673 additions and 143 deletions

View File

@ -0,0 +1,28 @@
<script setup lang="ts">
import { useDict } from '@/hooks/business/dict';
defineOptions({ name: 'DictRadio' });
interface Props {
dictCode: string;
immediate?: boolean;
}
const props = withDefaults(defineProps<Props>(), {
immediate: true
});
const value = defineModel<string | null>('value', { required: false });
const { options } = useDict(props.dictCode, props.immediate);
</script>
<template>
<NRadioGroup v-model:value="value">
<NSpace>
<NRadio v-for="option in options" :key="option.value" :value="option.value" :label="option.label" />
</NSpace>
</NRadioGroup>
</template>
<style scoped></style>

View File

@ -1,46 +1,30 @@
<script setup lang="tsx">
import { ref, useAttrs } from 'vue';
import { useLoading } from '@sa/hooks';
import type { SelectOption, SelectProps } from 'naive-ui';
import { fetchGetDictTypeOption } from '@/service/api/system';
<script setup lang="ts">
import { useAttrs } from 'vue';
import type { SelectProps } from 'naive-ui';
import { useDict } from '@/hooks/business/dict';
defineOptions({ name: 'DictSelect' });
interface Props {
dictCode: string;
immediate?: boolean;
[key: string]: any;
}
defineProps<Props>();
const props = withDefaults(defineProps<Props>(), {
immediate: true
});
const value = defineModel<string>('value', { required: true });
const value = defineModel<string | null>('value', { required: true });
const attrs: SelectProps = useAttrs();
const options = ref<SelectOption[]>([]);
const { loading, startLoading, endLoading } = useLoading();
async function getDeptOptions() {
startLoading();
const { error, data } = await fetchGetDictTypeOption();
if (error) return;
options.value = data.map(dict => ({
value: dict.dictType!,
label: () => (
<div class="w-520px flex justify-between">
<span>{dict.dictType}</span>
<span>{dict.dictName}</span>
</div>
)
}));
endLoading();
}
getDeptOptions();
const { options } = useDict(props.dictCode, props.immediate);
</script>
<template>
<NSelect
v-model:value="value"
:loading="loading"
:loading="!options.length"
:options="options"
:clear-filter-after-select="false"
v-bind="attrs"