review:【INFRA】表单构建的代码意见
parent
8e1c75833c
commit
bf75f0f789
|
@ -49,14 +49,12 @@
|
||||||
"crypto-js": "catalog:",
|
"crypto-js": "catalog:",
|
||||||
"dayjs": "catalog:",
|
"dayjs": "catalog:",
|
||||||
"highlight.js": "catalog:",
|
"highlight.js": "catalog:",
|
||||||
"lodash.clonedeep": "catalog:",
|
|
||||||
"pinia": "catalog:",
|
"pinia": "catalog:",
|
||||||
"vue": "catalog:",
|
"vue": "catalog:",
|
||||||
"vue-dompurify-html": "catalog:",
|
"vue-dompurify-html": "catalog:",
|
||||||
"vue-router": "catalog:"
|
"vue-router": "catalog:"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@types/crypto-js": "catalog:",
|
"@types/crypto-js": "catalog:"
|
||||||
"@types/lodash.clonedeep": "catalog:"
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -58,6 +58,7 @@ async function bootstrap(namespace: string) {
|
||||||
setupFormCreate(app);
|
setupFormCreate(app);
|
||||||
|
|
||||||
// vue-dompurify-html
|
// vue-dompurify-html
|
||||||
|
// TODO @dhb52:VueDOMPurifyHTML 是不是不用引入哈?
|
||||||
app.use(VueDOMPurifyHTML);
|
app.use(VueDOMPurifyHTML);
|
||||||
|
|
||||||
// 配置Motion插件
|
// 配置Motion插件
|
||||||
|
|
|
@ -41,17 +41,14 @@ const dictTag = computed(() => {
|
||||||
switch (colorType) {
|
switch (colorType) {
|
||||||
case 'danger': {
|
case 'danger': {
|
||||||
colorType = 'error';
|
colorType = 'error';
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case 'info': {
|
case 'info': {
|
||||||
colorType = 'default';
|
colorType = 'default';
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case 'primary': {
|
case 'primary': {
|
||||||
colorType = 'processing';
|
colorType = 'processing';
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
default: {
|
default: {
|
||||||
|
|
|
@ -13,11 +13,7 @@ import {
|
||||||
SelectOption,
|
SelectOption,
|
||||||
} from 'ant-design-vue';
|
} from 'ant-design-vue';
|
||||||
|
|
||||||
import {
|
import { getDictObj, getIntDictOptions, getStrDictOptions } from '#/utils/dict';
|
||||||
getBoolDictOptions,
|
|
||||||
getIntDictOptions,
|
|
||||||
getStrDictOptions,
|
|
||||||
} from '#/utils/dict';
|
|
||||||
|
|
||||||
defineOptions({ name: 'DictSelect' });
|
defineOptions({ name: 'DictSelect' });
|
||||||
|
|
||||||
|
@ -29,10 +25,11 @@ const props = withDefaults(defineProps<DictSelectProps>(), {
|
||||||
const attrs = useAttrs();
|
const attrs = useAttrs();
|
||||||
|
|
||||||
// 获得字典配置
|
// 获得字典配置
|
||||||
|
// TODO @dhb:可以使用 getDictOptions 替代么?
|
||||||
const getDictOptions = computed(() => {
|
const getDictOptions = computed(() => {
|
||||||
switch (props.valueType) {
|
switch (props.valueType) {
|
||||||
case 'bool': {
|
case 'bool': {
|
||||||
return getBoolDictOptions(props.dictType);
|
return getDictObj(props.dictType, 'bool');
|
||||||
}
|
}
|
||||||
case 'int': {
|
case 'int': {
|
||||||
return getIntDictOptions(props.dictType);
|
return getIntDictOptions(props.dictType);
|
||||||
|
|
|
@ -1,8 +1,6 @@
|
||||||
import { onMounted, ref } from 'vue';
|
import { onMounted, ref } from 'vue';
|
||||||
|
|
||||||
import { buildUUID } from '@vben/utils';
|
import { buildUUID, cloneDeep } from '@vben/utils';
|
||||||
|
|
||||||
import cloneDeep from 'lodash.clonedeep';
|
|
||||||
|
|
||||||
import * as DictDataApi from '#/api/system/dict/type';
|
import * as DictDataApi from '#/api/system/dict/type';
|
||||||
import {
|
import {
|
||||||
|
|
|
@ -1,8 +1,6 @@
|
||||||
import type { SelectRuleOption } from '#/components/form-create/typing';
|
import type { SelectRuleOption } from '#/components/form-create/typing';
|
||||||
|
|
||||||
import { buildUUID } from '@vben/utils';
|
import { buildUUID, cloneDeep } from '@vben/utils';
|
||||||
|
|
||||||
import cloneDeep from 'lodash.clonedeep';
|
|
||||||
|
|
||||||
import {
|
import {
|
||||||
localeProps,
|
localeProps,
|
||||||
|
|
|
@ -1,21 +1,21 @@
|
||||||
import type { Rule } from '@form-create/ant-design-vue';
|
import type { Rule } from '@form-create/ant-design-vue';
|
||||||
|
|
||||||
// 数据字典 Select 选择器组件 Props 类型
|
/** 数据字典 Select 选择器组件 Props 类型 */
|
||||||
export interface DictSelectProps {
|
export interface DictSelectProps {
|
||||||
dictType: string; // 字典类型
|
dictType: string; // 字典类型
|
||||||
valueType?: 'bool' | 'int' | 'str'; // 字典值类型
|
valueType?: 'bool' | 'int' | 'str'; // 字典值类型 TODO @芋艿:'boolean' | 'number' | 'string';需要和 vue3 一起统一!
|
||||||
selectType?: 'checkbox' | 'radio' | 'select'; // 选择器类型,下拉框 select、多选框 checkbox、单选框 radio
|
selectType?: 'checkbox' | 'radio' | 'select'; // 选择器类型,下拉框 select、多选框 checkbox、单选框 radio
|
||||||
formCreateInject?: any;
|
formCreateInject?: any;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 左侧拖拽按钮
|
/** 左侧拖拽按钮 */
|
||||||
export interface MenuItem {
|
export interface MenuItem {
|
||||||
label: string;
|
label: string;
|
||||||
name: string;
|
name: string;
|
||||||
icon: string;
|
icon: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 左侧拖拽按钮分类
|
/** 左侧拖拽按钮分类 */
|
||||||
export interface Menu {
|
export interface Menu {
|
||||||
title: string;
|
title: string;
|
||||||
name: string;
|
name: string;
|
||||||
|
@ -24,6 +24,7 @@ export interface Menu {
|
||||||
|
|
||||||
export type MenuList = Array<Menu>;
|
export type MenuList = Array<Menu>;
|
||||||
|
|
||||||
|
// TODO @dhb52:MenuList、Menu、MenuItem、DragRule 这几个,是不是没用到呀?
|
||||||
// 拖拽组件的规则
|
// 拖拽组件的规则
|
||||||
export interface DragRule {
|
export interface DragRule {
|
||||||
icon: string;
|
icon: string;
|
||||||
|
@ -40,7 +41,7 @@ export interface DragRule {
|
||||||
props(v: any, v1: any): Rule[];
|
props(v: any, v1: any): Rule[];
|
||||||
}
|
}
|
||||||
|
|
||||||
// 通用下拉组件 Props 类型
|
/** 通用 API 下拉组件 Props 类型 */
|
||||||
export interface ApiSelectProps {
|
export interface ApiSelectProps {
|
||||||
name: string; // 组件名称
|
name: string; // 组件名称
|
||||||
labelField?: string; // 选项标签
|
labelField?: string; // 选项标签
|
||||||
|
@ -49,7 +50,7 @@ export interface ApiSelectProps {
|
||||||
isDict?: boolean; // 是否字典选择器
|
isDict?: boolean; // 是否字典选择器
|
||||||
}
|
}
|
||||||
|
|
||||||
// 选择组件规则配置类型
|
/** 选择组件规则配置类型 */
|
||||||
export interface SelectRuleOption {
|
export interface SelectRuleOption {
|
||||||
label: string; // label 名称
|
label: string; // label 名称
|
||||||
name: string; // 组件名称
|
name: string; // 组件名称
|
||||||
|
|
|
@ -157,11 +157,10 @@ const initOptions = computed((): InitOptions => {
|
||||||
const { httpRequest } = useUpload();
|
const { httpRequest } = useUpload();
|
||||||
httpRequest(file)
|
httpRequest(file)
|
||||||
.then((url) => {
|
.then((url) => {
|
||||||
// console.log('tinymce 上传图片成功:', url);
|
|
||||||
resolve(url);
|
resolve(url);
|
||||||
})
|
})
|
||||||
.catch((error) => {
|
.catch((error) => {
|
||||||
// console.error('tinymce 上传图片失败:', error);
|
console.error('tinymce 上传图片失败:', error);
|
||||||
reject(error.message);
|
reject(error.message);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -1,5 +0,0 @@
|
||||||
{
|
|
||||||
"copy": "Copy",
|
|
||||||
"copySuccess": "Copy Success",
|
|
||||||
"copyError": "Copy Error"
|
|
||||||
}
|
|
|
@ -1,5 +0,0 @@
|
||||||
{
|
|
||||||
"copy": "复制",
|
|
||||||
"copySuccess": "复制成功",
|
|
||||||
"copyError": "复制失败"
|
|
||||||
}
|
|
|
@ -95,6 +95,7 @@ function getDictOptions(
|
||||||
return dictOptions.length > 0 ? dictOptions : [];
|
return dictOptions.length > 0 ? dictOptions : [];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO @dhb52:下面的一系列方法,看看能不能复用 getDictOptions 方法
|
||||||
export const getIntDictOptions = (dictType: string): NumberDictDataType[] => {
|
export const getIntDictOptions = (dictType: string): NumberDictDataType[] => {
|
||||||
// 获得通用的 DictDataType 列表
|
// 获得通用的 DictDataType 列表
|
||||||
const dictOptions = getDictOptions(dictType) as DictDataType[];
|
const dictOptions = getDictOptions(dictType) as DictDataType[];
|
||||||
|
@ -110,6 +111,7 @@ export const getIntDictOptions = (dictType: string): NumberDictDataType[] => {
|
||||||
return dictOption;
|
return dictOption;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// TODO @dhb52:下面的一系列方法,看看能不能复用 getDictOptions 方法
|
||||||
export const getStrDictOptions = (dictType: string) => {
|
export const getStrDictOptions = (dictType: string) => {
|
||||||
// 获得通用的 DictDataType 列表
|
// 获得通用的 DictDataType 列表
|
||||||
const dictOptions = getDictOptions(dictType) as DictDataType[];
|
const dictOptions = getDictOptions(dictType) as DictDataType[];
|
||||||
|
@ -125,6 +127,7 @@ export const getStrDictOptions = (dictType: string) => {
|
||||||
return dictOption;
|
return dictOption;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// TODO @dhb52:下面的一系列方法,看看能不能复用 getDictOptions 方法
|
||||||
export const getBoolDictOptions = (dictType: string) => {
|
export const getBoolDictOptions = (dictType: string) => {
|
||||||
const dictOption: DictDataType[] = [];
|
const dictOption: DictDataType[] = [];
|
||||||
const dictOptions = getDictOptions(dictType) as DictDataType[];
|
const dictOptions = getDictOptions(dictType) as DictDataType[];
|
||||||
|
|
|
@ -14,7 +14,6 @@ import xml from 'highlight.js/lib/languages/java';
|
||||||
import json from 'highlight.js/lib/languages/json';
|
import json from 'highlight.js/lib/languages/json';
|
||||||
|
|
||||||
import { useFormCreateDesigner } from '#/components/form-create';
|
import { useFormCreateDesigner } from '#/components/form-create';
|
||||||
import { $t } from '#/locales';
|
|
||||||
|
|
||||||
import 'highlight.js/styles/github.css';
|
import 'highlight.js/styles/github.css';
|
||||||
|
|
||||||
|
@ -121,10 +120,10 @@ const copy = async (text: string) => {
|
||||||
if (isSupported) {
|
if (isSupported) {
|
||||||
await copy();
|
await copy();
|
||||||
if (unref(copied)) {
|
if (unref(copied)) {
|
||||||
message.success($t('common.copySuccess'));
|
message.success('复制成功');
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
message.error($t('common.copyError'));
|
message.error('复制失败');
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -173,9 +172,7 @@ onMounted(async () => {
|
||||||
<!-- 弹窗:表单预览 -->
|
<!-- 弹窗:表单预览 -->
|
||||||
<Modal :title="dialogTitle" :footer="false" :fullscreen-button="false">
|
<Modal :title="dialogTitle" :footer="false" :fullscreen-button="false">
|
||||||
<div>
|
<div>
|
||||||
<Button style="float: right" @click="copy(formData)">
|
<Button style="float: right" @click="copy(formData)"> 复制 </Button>
|
||||||
{{ $t('common.copy') }}
|
|
||||||
</Button>
|
|
||||||
<div>
|
<div>
|
||||||
<pre><code v-dompurify-html="highlightedCode(formData)" class="hljs"></code></pre>
|
<pre><code v-dompurify-html="highlightedCode(formData)" class="hljs"></code></pre>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -743,9 +743,6 @@ importers:
|
||||||
highlight.js:
|
highlight.js:
|
||||||
specifier: 'catalog:'
|
specifier: 'catalog:'
|
||||||
version: 11.11.1
|
version: 11.11.1
|
||||||
lodash.clonedeep:
|
|
||||||
specifier: 'catalog:'
|
|
||||||
version: 4.5.0
|
|
||||||
pinia:
|
pinia:
|
||||||
specifier: ^2.3.1
|
specifier: ^2.3.1
|
||||||
version: 2.3.1(typescript@5.8.3)(vue@3.5.13(typescript@5.8.3))
|
version: 2.3.1(typescript@5.8.3)(vue@3.5.13(typescript@5.8.3))
|
||||||
|
|
Loading…
Reference in New Issue