review:【INFRA】表单构建的代码意见
This commit is contained in:
@@ -41,17 +41,14 @@ const dictTag = computed(() => {
|
||||
switch (colorType) {
|
||||
case 'danger': {
|
||||
colorType = 'error';
|
||||
|
||||
break;
|
||||
}
|
||||
case 'info': {
|
||||
colorType = 'default';
|
||||
|
||||
break;
|
||||
}
|
||||
case 'primary': {
|
||||
colorType = 'processing';
|
||||
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
|
||||
@@ -13,11 +13,7 @@ import {
|
||||
SelectOption,
|
||||
} from 'ant-design-vue';
|
||||
|
||||
import {
|
||||
getBoolDictOptions,
|
||||
getIntDictOptions,
|
||||
getStrDictOptions,
|
||||
} from '#/utils/dict';
|
||||
import { getDictObj, getIntDictOptions, getStrDictOptions } from '#/utils/dict';
|
||||
|
||||
defineOptions({ name: 'DictSelect' });
|
||||
|
||||
@@ -29,10 +25,11 @@ const props = withDefaults(defineProps<DictSelectProps>(), {
|
||||
const attrs = useAttrs();
|
||||
|
||||
// 获得字典配置
|
||||
// TODO @dhb:可以使用 getDictOptions 替代么?
|
||||
const getDictOptions = computed(() => {
|
||||
switch (props.valueType) {
|
||||
case 'bool': {
|
||||
return getBoolDictOptions(props.dictType);
|
||||
return getDictObj(props.dictType, 'bool');
|
||||
}
|
||||
case 'int': {
|
||||
return getIntDictOptions(props.dictType);
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
import { onMounted, ref } from 'vue';
|
||||
|
||||
import { buildUUID } from '@vben/utils';
|
||||
|
||||
import cloneDeep from 'lodash.clonedeep';
|
||||
import { buildUUID, cloneDeep } from '@vben/utils';
|
||||
|
||||
import * as DictDataApi from '#/api/system/dict/type';
|
||||
import {
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
import type { SelectRuleOption } from '#/components/form-create/typing';
|
||||
|
||||
import { buildUUID } from '@vben/utils';
|
||||
|
||||
import cloneDeep from 'lodash.clonedeep';
|
||||
import { buildUUID, cloneDeep } from '@vben/utils';
|
||||
|
||||
import {
|
||||
localeProps,
|
||||
|
||||
@@ -1,21 +1,21 @@
|
||||
import type { Rule } from '@form-create/ant-design-vue';
|
||||
|
||||
// 数据字典 Select 选择器组件 Props 类型
|
||||
/** 数据字典 Select 选择器组件 Props 类型 */
|
||||
export interface DictSelectProps {
|
||||
dictType: string; // 字典类型
|
||||
valueType?: 'bool' | 'int' | 'str'; // 字典值类型
|
||||
valueType?: 'bool' | 'int' | 'str'; // 字典值类型 TODO @芋艿:'boolean' | 'number' | 'string';需要和 vue3 一起统一!
|
||||
selectType?: 'checkbox' | 'radio' | 'select'; // 选择器类型,下拉框 select、多选框 checkbox、单选框 radio
|
||||
formCreateInject?: any;
|
||||
}
|
||||
|
||||
// 左侧拖拽按钮
|
||||
/** 左侧拖拽按钮 */
|
||||
export interface MenuItem {
|
||||
label: string;
|
||||
name: string;
|
||||
icon: string;
|
||||
}
|
||||
|
||||
// 左侧拖拽按钮分类
|
||||
/** 左侧拖拽按钮分类 */
|
||||
export interface Menu {
|
||||
title: string;
|
||||
name: string;
|
||||
@@ -24,6 +24,7 @@ export interface Menu {
|
||||
|
||||
export type MenuList = Array<Menu>;
|
||||
|
||||
// TODO @dhb52:MenuList、Menu、MenuItem、DragRule 这几个,是不是没用到呀?
|
||||
// 拖拽组件的规则
|
||||
export interface DragRule {
|
||||
icon: string;
|
||||
@@ -40,7 +41,7 @@ export interface DragRule {
|
||||
props(v: any, v1: any): Rule[];
|
||||
}
|
||||
|
||||
// 通用下拉组件 Props 类型
|
||||
/** 通用 API 下拉组件 Props 类型 */
|
||||
export interface ApiSelectProps {
|
||||
name: string; // 组件名称
|
||||
labelField?: string; // 选项标签
|
||||
@@ -49,7 +50,7 @@ export interface ApiSelectProps {
|
||||
isDict?: boolean; // 是否字典选择器
|
||||
}
|
||||
|
||||
// 选择组件规则配置类型
|
||||
/** 选择组件规则配置类型 */
|
||||
export interface SelectRuleOption {
|
||||
label: string; // label 名称
|
||||
name: string; // 组件名称
|
||||
|
||||
@@ -157,11 +157,10 @@ const initOptions = computed((): InitOptions => {
|
||||
const { httpRequest } = useUpload();
|
||||
httpRequest(file)
|
||||
.then((url) => {
|
||||
// console.log('tinymce 上传图片成功:', url);
|
||||
resolve(url);
|
||||
})
|
||||
.catch((error) => {
|
||||
// console.error('tinymce 上传图片失败:', error);
|
||||
console.error('tinymce 上传图片失败:', error);
|
||||
reject(error.message);
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user