mirror of
https://github.com/vbenjs/vue-vben-admin.git
synced 2025-08-27 14:31:41 +08:00
chore: add some notes
This commit is contained in:
@@ -1,2 +1,8 @@
|
||||
import type { App } from 'vue';
|
||||
import Authority from './src/index.vue';
|
||||
export default Authority;
|
||||
|
||||
export default (app: App): void => {
|
||||
app.component(Authority.name, Authority);
|
||||
};
|
||||
|
||||
export { Authority };
|
||||
|
@@ -1,17 +1,28 @@
|
||||
<!--
|
||||
* @Author: Vben
|
||||
* @Description:Access control component for fine-grained access control.
|
||||
-->
|
||||
<script lang="ts">
|
||||
import type { PropType } from 'vue';
|
||||
import { defineComponent, computed, unref } from 'vue';
|
||||
|
||||
import { PermissionModeEnum } from '/@/enums/appEnum';
|
||||
import { RoleEnum } from '/@/enums/roleEnum';
|
||||
|
||||
import { usePermission } from '/@/hooks/web/usePermission';
|
||||
import { appStore } from '/@/store/modules/app';
|
||||
|
||||
import { getSlot } from '/@/utils/helper/tsxHelper';
|
||||
|
||||
export default defineComponent({
|
||||
name: 'Authority',
|
||||
props: {
|
||||
// 指定角色可见
|
||||
/**
|
||||
* Specified role is visible
|
||||
* When the permission mode is the role mode, the value value can pass the role value.
|
||||
* When the permission mode is background, the value value can pass the code permission value
|
||||
* @default ''
|
||||
*/
|
||||
value: {
|
||||
type: [Number, Array, String] as PropType<RoleEnum | RoleEnum[] | string | string[]>,
|
||||
default: '',
|
||||
@@ -23,7 +34,7 @@
|
||||
});
|
||||
|
||||
/**
|
||||
* 渲染角色按钮
|
||||
* Render role button
|
||||
*/
|
||||
function renderRoleAuth() {
|
||||
const { value } = props;
|
||||
@@ -34,10 +45,8 @@
|
||||
return hasPermission(value) ? getSlot(slots) : null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 渲染编码按钮
|
||||
* 这里只判断是否包含,具体实现可以根据项目自行写逻辑
|
||||
*/
|
||||
// Render coding button
|
||||
// Here only judge whether it is included, the specific implementation can be written according to the project logic
|
||||
function renderCodeAuth() {
|
||||
const { value } = props;
|
||||
if (!value) {
|
||||
@@ -49,12 +58,12 @@
|
||||
|
||||
return () => {
|
||||
const mode = unref(getModeRef);
|
||||
// 基于角色渲染
|
||||
// Role-based value control
|
||||
if (mode === PermissionModeEnum.ROLE) {
|
||||
return renderRoleAuth();
|
||||
}
|
||||
|
||||
// 基于后台编码渲染
|
||||
// Based on background role permission control
|
||||
if (mode === PermissionModeEnum.BACK) {
|
||||
return renderCodeAuth();
|
||||
}
|
||||
|
@@ -1,3 +1,7 @@
|
||||
<!--
|
||||
* @Author: Vben
|
||||
* @Description: Arrow component with animation
|
||||
-->
|
||||
<template>
|
||||
<span :class="getClass">
|
||||
<RightOutlined />
|
||||
|
@@ -71,9 +71,6 @@
|
||||
return props.absolute ? props.position : {};
|
||||
});
|
||||
|
||||
/**
|
||||
* @description: 渲染内容
|
||||
*/
|
||||
const renderTitle = () => {
|
||||
const list = props.text;
|
||||
if (isString(list)) {
|
||||
@@ -89,6 +86,7 @@
|
||||
|
||||
return () => {
|
||||
return h(
|
||||
// @ts-ignores
|
||||
Tooltip,
|
||||
{
|
||||
title: h(
|
||||
|
@@ -12,33 +12,19 @@
|
||||
|
||||
import { defineComponent, computed } from 'vue';
|
||||
import { Button } from 'ant-design-vue';
|
||||
// import { extendSlots } from '/@/utils/helper/tsxHelper';
|
||||
// import { useThrottle } from '/@/hooks/core/useThrottle';
|
||||
// import { isFunction } from '/@/utils/is';
|
||||
import Icon from '/@/components/Icon';
|
||||
export default defineComponent({
|
||||
name: 'AButton',
|
||||
inheritAttrs: false,
|
||||
components: { Button, Icon },
|
||||
props: {
|
||||
// 按钮类型
|
||||
type: {
|
||||
type: String as PropType<'primary' | 'default' | 'danger' | 'dashed' | 'link'>,
|
||||
default: 'default',
|
||||
},
|
||||
// 节流防抖类型 throttle debounce
|
||||
// throttle: {
|
||||
// type: String as PropType<'throttle' | 'debounce'>,
|
||||
// default: 'throttle',
|
||||
// },
|
||||
color: {
|
||||
type: String as PropType<'error' | 'warning' | 'success' | ''>,
|
||||
},
|
||||
// // 防抖节流时间
|
||||
// throttleTime: {
|
||||
// type: Number as PropType<number>,
|
||||
// default: 50,
|
||||
// },
|
||||
loading: {
|
||||
type: Boolean as PropType<boolean>,
|
||||
default: false,
|
||||
@@ -58,42 +44,15 @@
|
||||
const getIsCircleBtn = computed(() => {
|
||||
return attrs.shape === 'circle';
|
||||
});
|
||||
// const getListeners = computed(() => {
|
||||
// const { throttle, throttleTime = 0 } = props;
|
||||
// // 是否开启节流防抖
|
||||
// const throttleType = throttle!.toLowerCase();
|
||||
// const isDebounce = throttleType === 'debounce';
|
||||
// const openThrottle = ['throttle', 'debounce'].includes(throttleType) && throttleTime > 0;
|
||||
// if (!openThrottle) {
|
||||
// return {
|
||||
// ...attrs,
|
||||
// };
|
||||
// }
|
||||
|
||||
// const on: {
|
||||
// onClick?: Fn;
|
||||
// } = {};
|
||||
|
||||
// if (attrs.onClick && isFunction(attrs.onClick) && openThrottle) {
|
||||
// const [handler] = useThrottle(attrs.onClick as any, throttleTime!, {
|
||||
// debounce: isDebounce,
|
||||
// immediate: false,
|
||||
// });
|
||||
// on.onClick = handler;
|
||||
// }
|
||||
|
||||
// return {
|
||||
// ...attrs,
|
||||
// ...on,
|
||||
// };
|
||||
// });
|
||||
|
||||
const getColor = computed(() => {
|
||||
const res: string[] = [];
|
||||
const { color, disabled } = props;
|
||||
color && res.push(`ant-btn-${color}`);
|
||||
disabled && res.push('is-disabled');
|
||||
return res;
|
||||
return [
|
||||
{
|
||||
[`ant-btn-${color}`]: !!color,
|
||||
[`is-disabled`]: disabled,
|
||||
},
|
||||
];
|
||||
});
|
||||
|
||||
const getBindValue = computed((): any => {
|
||||
|
@@ -22,7 +22,8 @@
|
||||
import { defineComponent, reactive, onMounted, ref, toRef, toRefs } from 'vue';
|
||||
|
||||
import { Skeleton } from 'ant-design-vue';
|
||||
import { useTimeoutFn, useIntersectionObserver } from '@vueuse/core';
|
||||
import { useTimeoutFn } from '@vueuse/core';
|
||||
import { useIntersectionObserver } from '/@/hooks/event/useIntersectionObserver';
|
||||
interface State {
|
||||
isInit: boolean;
|
||||
loading: boolean;
|
||||
|
@@ -43,23 +43,22 @@
|
||||
},
|
||||
name: 'CollapseContainer',
|
||||
props: {
|
||||
// 标题
|
||||
title: {
|
||||
type: String as PropType<string>,
|
||||
default: '',
|
||||
},
|
||||
// 是否可以展开
|
||||
// Can it be expanded
|
||||
canExpan: {
|
||||
type: Boolean as PropType<boolean>,
|
||||
default: true,
|
||||
},
|
||||
// 标题右侧温馨提醒
|
||||
// Warm reminder on the right side of the title
|
||||
helpMessage: {
|
||||
type: [Array, String] as PropType<string[] | string>,
|
||||
default: '',
|
||||
},
|
||||
// 展开收缩的时候是否触发window.resize,
|
||||
// 可以适应表格和表单,当表单收缩起来,表格触发resize 自适应高度
|
||||
// Whether to trigger window.resize when expanding and contracting,
|
||||
// Can adapt to tables and forms, when the form shrinks, the form triggers resize to adapt to the height
|
||||
triggerWindowResize: {
|
||||
type: Boolean as PropType<boolean>,
|
||||
default: false,
|
||||
@@ -68,12 +67,12 @@
|
||||
type: Boolean as PropType<boolean>,
|
||||
default: false,
|
||||
},
|
||||
// 延时加载
|
||||
// Delayed loading
|
||||
lazy: {
|
||||
type: Boolean as PropType<boolean>,
|
||||
default: false,
|
||||
},
|
||||
// 延时加载时间
|
||||
// Delayed loading time
|
||||
lazyTime: {
|
||||
type: Number as PropType<number>,
|
||||
default: 0,
|
||||
@@ -82,14 +81,14 @@
|
||||
setup(props) {
|
||||
const showRef = ref(true);
|
||||
/**
|
||||
* @description: 处理开展事件
|
||||
* @description: Handling development events
|
||||
*/
|
||||
function handleExpand() {
|
||||
const hasShow = !unref(showRef);
|
||||
showRef.value = hasShow;
|
||||
|
||||
if (props.triggerWindowResize) {
|
||||
// 这里200毫秒是因为展开有动画,
|
||||
// 200 milliseconds here is because the expansion has animation,
|
||||
useTimeoutFn(triggerWindowResize, 200);
|
||||
}
|
||||
}
|
||||
|
@@ -9,25 +9,23 @@ export const props = {
|
||||
type: Object as PropType<Event>,
|
||||
default: null,
|
||||
},
|
||||
// 样式
|
||||
styles: {
|
||||
type: Object as PropType<any>,
|
||||
default: null,
|
||||
},
|
||||
showIcon: {
|
||||
// 是否显示icon
|
||||
type: Boolean as PropType<boolean>,
|
||||
default: true,
|
||||
},
|
||||
axis: {
|
||||
// 鼠标右键点击的位置
|
||||
// The position of the right mouse button click
|
||||
type: Object as PropType<Axis>,
|
||||
default() {
|
||||
return { x: 0, y: 0 };
|
||||
},
|
||||
},
|
||||
items: {
|
||||
// 最重要的列表,没有的话直接不显示
|
||||
// The most important list, if not, will not be displayed
|
||||
type: Array as PropType<ContextMenuItem[]>,
|
||||
default() {
|
||||
return [];
|
||||
|
@@ -1,2 +1,2 @@
|
||||
// 对vue-count-to进行改造成支持vue3版本
|
||||
// Transform vue-count-to to support vue3 version
|
||||
export { default as CountTo } from './src/index.vue';
|
||||
|
@@ -14,9 +14,8 @@ export default defineComponent({
|
||||
props: descProps,
|
||||
emits: ['register'],
|
||||
setup(props, { attrs, slots, emit }) {
|
||||
// props来自设置
|
||||
const propsRef = ref<Partial<DescOptions> | null>(null);
|
||||
// 自定义title组件:获得title
|
||||
// Custom title component: get title
|
||||
const getMergeProps = computed(() => {
|
||||
return {
|
||||
...props,
|
||||
@@ -34,19 +33,19 @@ export default defineComponent({
|
||||
});
|
||||
|
||||
/**
|
||||
* @description: 是否使用标题
|
||||
* @description: Whether to use title
|
||||
*/
|
||||
const useWrapper = computed(() => {
|
||||
return !!unref(getMergeProps).title;
|
||||
});
|
||||
|
||||
/**
|
||||
* @description: 获取配置Collapse
|
||||
* @description: Get configuration Collapse
|
||||
*/
|
||||
const getCollapseOptions = computed(
|
||||
(): CollapseContainerOptions => {
|
||||
return {
|
||||
// 默认不能展开
|
||||
// Cannot be expanded by default
|
||||
canExpand: false,
|
||||
...unref(getProps).collapseOptions,
|
||||
};
|
||||
@@ -57,7 +56,7 @@ export default defineComponent({
|
||||
* @description:设置desc
|
||||
*/
|
||||
function setDescProps(descProps: Partial<DescOptions>): void {
|
||||
// 保留上一次的setDrawerProps
|
||||
// Keep the last setDrawerProps
|
||||
const mergeProps = deepMerge(unref(propsRef) || {}, descProps);
|
||||
propsRef.value = cloneDeep(mergeProps);
|
||||
}
|
||||
@@ -68,7 +67,7 @@ export default defineComponent({
|
||||
|
||||
emit('register', methods);
|
||||
|
||||
// 防止换行
|
||||
// Prevent line breaks
|
||||
function renderLabel({ label, labelMinWidth, labelStyle }: DescItem) {
|
||||
if (!labelStyle && !labelMinWidth) {
|
||||
return label;
|
||||
@@ -101,7 +100,6 @@ export default defineComponent({
|
||||
|
||||
const width = contentMinWidth;
|
||||
return (
|
||||
// @ts-ignore
|
||||
<Descriptions.Item label={renderLabel(item)} key={field} span={span}>
|
||||
{() =>
|
||||
contentMinWidth ? (
|
||||
@@ -131,7 +129,7 @@ export default defineComponent({
|
||||
|
||||
const renderContainer = () => {
|
||||
const content = props.useCollapse ? renderDesc() : <div>{renderDesc()}</div>;
|
||||
// 减少dom层级
|
||||
// Reduce the dom level
|
||||
return props.useCollapse ? (
|
||||
<CollapseContainer
|
||||
title={unref(getMergeProps).title}
|
||||
|
@@ -2,7 +2,6 @@ import type { VNode } from 'vue';
|
||||
import type { CollapseContainerOptions } from '/@/components/Container/index';
|
||||
|
||||
export interface DescItem {
|
||||
// 最小宽度
|
||||
labelMinWidth?: number;
|
||||
|
||||
contentMinWidth?: number;
|
||||
@@ -11,7 +10,7 @@ export interface DescItem {
|
||||
|
||||
field: string;
|
||||
label: any;
|
||||
// 和并列
|
||||
// Merge column
|
||||
span?: number;
|
||||
show?: (...arg: any) => boolean;
|
||||
// render
|
||||
@@ -19,10 +18,10 @@ export interface DescItem {
|
||||
}
|
||||
|
||||
export interface DescOptions {
|
||||
// 是否包含collapse组件
|
||||
// Whether to include the collapse component
|
||||
useCollapse?: boolean;
|
||||
/**
|
||||
* item配置
|
||||
* item configuration
|
||||
* @type DescItem
|
||||
*/
|
||||
schema: DescItem[];
|
||||
@@ -32,7 +31,7 @@ export interface DescOptions {
|
||||
*/
|
||||
data: any;
|
||||
/**
|
||||
* 内置的CollapseContainer组件配置
|
||||
* Built-in CollapseContainer component configuration
|
||||
* @type CollapseContainerOptions
|
||||
*/
|
||||
collapseOptions?: CollapseContainerOptions;
|
||||
|
@@ -71,7 +71,7 @@ export default defineComponent({
|
||||
}
|
||||
);
|
||||
|
||||
// 底部按钮自定义实现,
|
||||
// Custom implementation of the bottom button,
|
||||
const getFooterHeight = computed(() => {
|
||||
const { footerHeight, showFooter }: DrawerProps = unref(getProps);
|
||||
if (showFooter && footerHeight) {
|
||||
@@ -80,7 +80,7 @@ export default defineComponent({
|
||||
return `0px`;
|
||||
});
|
||||
|
||||
// 取消事件
|
||||
// Cancel event
|
||||
async function onClose(e: any) {
|
||||
const { closeFunc } = unref(getProps);
|
||||
emit('close', e);
|
||||
@@ -93,7 +93,7 @@ export default defineComponent({
|
||||
}
|
||||
|
||||
function setDrawerProps(props: Partial<DrawerProps>): void {
|
||||
// 保留上一次的setDrawerProps
|
||||
// Keep the last setDrawerProps
|
||||
propsRef.value = deepMerge(unref(propsRef) || {}, props);
|
||||
if (Reflect.has(props, 'visible')) {
|
||||
visibleRef.value = !!props.visible;
|
||||
|
@@ -1,9 +1,8 @@
|
||||
import type { PropType } from 'vue';
|
||||
// import {DrawerProps} from './types'
|
||||
export const footerProps = {
|
||||
confirmLoading: Boolean as PropType<boolean>,
|
||||
/**
|
||||
* @description: 显示关闭按钮
|
||||
* @description: Show close button
|
||||
*/
|
||||
showCancelBtn: {
|
||||
type: Boolean as PropType<boolean>,
|
||||
@@ -15,7 +14,7 @@ export const footerProps = {
|
||||
default: '关闭',
|
||||
},
|
||||
/**
|
||||
* @description: 显示确认按钮
|
||||
* @description: Show confirmation button
|
||||
*/
|
||||
showOkBtn: {
|
||||
type: Boolean as PropType<boolean>,
|
||||
|
@@ -73,7 +73,7 @@ export interface DrawerProps extends DrawerFooterProps {
|
||||
showDetailBack?: boolean;
|
||||
visible?: boolean;
|
||||
/**
|
||||
* 内置的ScrollContainer组件配置
|
||||
* Built-in ScrollContainer component configuration
|
||||
* @type ScrollContainerOptions
|
||||
*/
|
||||
scrollOptions?: ScrollContainerOptions;
|
||||
|
@@ -22,7 +22,7 @@ import { isFunction } from '/@/utils/is';
|
||||
|
||||
const dataTransferRef = reactive<any>({});
|
||||
/**
|
||||
* @description: 适用于将drawer独立出去,外面调用
|
||||
* @description: Applicable to separate drawer and call outside
|
||||
*/
|
||||
export function useDrawer(): UseDrawerReturnType {
|
||||
if (!getCurrentInstance()) {
|
||||
|
@@ -1,7 +1,5 @@
|
||||
import type { PropType } from 'vue';
|
||||
/**
|
||||
* @description: 基础表格参数配置
|
||||
*/
|
||||
|
||||
export const dropdownProps = {
|
||||
/**
|
||||
* the trigger mode which executes the drop-down action
|
||||
@@ -14,52 +12,6 @@ export const dropdownProps = {
|
||||
return ['contextmenu'];
|
||||
},
|
||||
},
|
||||
|
||||
// /**
|
||||
// * the dropdown menu
|
||||
// * @type () => Menu
|
||||
// */
|
||||
// overlay: {
|
||||
// type: null,
|
||||
// },
|
||||
|
||||
// /**
|
||||
// * Class name of the dropdown root element
|
||||
// * @type string
|
||||
// */
|
||||
// overlayClassName: String,
|
||||
|
||||
// /**
|
||||
// * Style of the dropdown root element
|
||||
// * @type object
|
||||
// */
|
||||
// overlayStyle: Object,
|
||||
|
||||
// /**
|
||||
// * whether the dropdown menu is visible
|
||||
// * @type boolean
|
||||
// */
|
||||
// visible: Boolean,
|
||||
|
||||
// /**
|
||||
// * whether the dropdown menu is disabled
|
||||
// * @type boolean
|
||||
// */
|
||||
// disabled: Boolean,
|
||||
|
||||
// /**
|
||||
// * to set the ontainer of the dropdown menu. The default is to create a div element in body, you can reset it to the scrolling area and make a relative reposition.
|
||||
// * @default () => document.body
|
||||
// * @type Function
|
||||
// */
|
||||
// getPopupContainer: Function,
|
||||
|
||||
// /**
|
||||
// * placement of pop menu: bottomLeft bottomCenter bottomRight topLeft topCenter topRight
|
||||
// * @default 'bottomLeft'
|
||||
// * @type string
|
||||
// */
|
||||
// placement: String,
|
||||
};
|
||||
export const basicDropdownProps = Object.assign({}, dropdownProps, {
|
||||
dropMenuList: {
|
||||
|
@@ -27,7 +27,7 @@
|
||||
<script lang="ts">
|
||||
import type { FormActionType, FormProps, FormSchema } from './types/form';
|
||||
import type { AdvanceState } from './types/hooks';
|
||||
import type { Ref } from 'vue';
|
||||
import type { Ref, WatchStopHandle } from 'vue';
|
||||
import type { ValidateFields } from 'ant-design-vue/lib/form/interface';
|
||||
|
||||
import { defineComponent, reactive, ref, computed, unref, toRef, onMounted, watch } from 'vue';
|
||||
@@ -66,6 +66,7 @@
|
||||
});
|
||||
|
||||
const defaultValueRef = ref<any>({});
|
||||
const isInitedDefaultRef = ref(false);
|
||||
const propsRef = ref<Partial<FormProps>>({});
|
||||
const schemaRef = ref<Nullable<FormSchema[]>>(null);
|
||||
const formElRef = ref<Nullable<FormActionType>>(null);
|
||||
@@ -164,16 +165,19 @@
|
||||
}
|
||||
);
|
||||
|
||||
watch(
|
||||
const stopWatch: WatchStopHandle = watch(
|
||||
() => getSchema.value,
|
||||
() => {
|
||||
initDefault();
|
||||
(schema) => {
|
||||
if (unref(isInitedDefaultRef)) {
|
||||
return stopWatch();
|
||||
}
|
||||
if (schema && schema.length) {
|
||||
initDefault();
|
||||
isInitedDefaultRef.value = true;
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
/**
|
||||
* @description:设置表单
|
||||
*/
|
||||
function setProps(formProps: Partial<FormProps>): void {
|
||||
const mergeProps = deepMerge(unref(propsRef) || {}, formProps);
|
||||
propsRef.value = mergeProps;
|
||||
|
@@ -1,6 +1,6 @@
|
||||
import { Component } from 'vue';
|
||||
/**
|
||||
* 组件列表,在这里注册才可以在表单使用
|
||||
* Component list, register here to use it in the form
|
||||
*/
|
||||
import {
|
||||
Input,
|
||||
|
@@ -114,7 +114,7 @@ export default function ({
|
||||
) {
|
||||
advanceState.hideAdvanceBtn = false;
|
||||
|
||||
// 大于3行默认收起
|
||||
// More than 3 lines collapsed by default
|
||||
} else if (!advanceState.isLoad) {
|
||||
advanceState.isLoad = true;
|
||||
advanceState.isAdvanced = !advanceState.isAdvanced;
|
||||
@@ -124,7 +124,7 @@ export default function ({
|
||||
if (itemColSum > BASIC_COL_LEN) {
|
||||
return { isAdvanced: advanceState.isAdvanced, itemColSum };
|
||||
} else {
|
||||
// 第一行始终显示
|
||||
// The first line is always displayed
|
||||
return { isAdvanced: true, itemColSum };
|
||||
}
|
||||
}
|
||||
|
@@ -62,7 +62,7 @@ export function useFormAction({
|
||||
Object.keys(values).forEach((key) => {
|
||||
const element = values[key];
|
||||
if (element !== undefined && element !== null && fields.includes(key)) {
|
||||
// 时间
|
||||
// time type
|
||||
if (itemIsDateType(key)) {
|
||||
if (Array.isArray(element)) {
|
||||
const arr: any[] = [];
|
||||
@@ -84,7 +84,7 @@ export function useFormAction({
|
||||
// }
|
||||
}
|
||||
/**
|
||||
* @description: 根据字段名删除
|
||||
* @description: Delete based on field name
|
||||
*/
|
||||
function removeSchemaByFiled(fields: string | string[]): void {
|
||||
const schemaList: FormSchema[] = cloneDeep(unref(getSchema));
|
||||
@@ -102,7 +102,7 @@ export function useFormAction({
|
||||
}
|
||||
|
||||
/**
|
||||
* @description: 根据字段名删除
|
||||
* @description: Delete based on field name
|
||||
*/
|
||||
function _removeSchemaByFiled(field: string, schemaList: FormSchema[]): void {
|
||||
if (isString(field)) {
|
||||
@@ -114,7 +114,7 @@ export function useFormAction({
|
||||
}
|
||||
|
||||
/**
|
||||
* @description: 往某个字段后面插入,如果没有插入最后一个
|
||||
* @description: Insert after a certain field, if not insert the last
|
||||
*/
|
||||
function appendSchemaByField(schema: FormSchema, prefixField?: string) {
|
||||
const schemaList: FormSchema[] = cloneDeep(unref(getSchema));
|
||||
@@ -169,7 +169,7 @@ export function useFormAction({
|
||||
}
|
||||
|
||||
/**
|
||||
* @description: 是否是时间
|
||||
* @description: Is it time
|
||||
*/
|
||||
function itemIsDateType(key: string) {
|
||||
return unref(getSchema).some((item) => {
|
||||
@@ -193,7 +193,7 @@ export function useFormAction({
|
||||
}
|
||||
|
||||
/**
|
||||
* @description: 表单提交
|
||||
* @description: Form submission
|
||||
*/
|
||||
async function handleSubmit(e?: Event): Promise<void> {
|
||||
e && e.preventDefault();
|
||||
|
@@ -18,7 +18,7 @@ export function useFormValues({
|
||||
getSchema,
|
||||
formModel,
|
||||
}: UseFormValuesContext) {
|
||||
// 处理表单值
|
||||
// Processing form values
|
||||
function handleFormValues(values: any) {
|
||||
if (!isObject(values)) {
|
||||
return {};
|
||||
@@ -37,7 +37,7 @@ export function useFormValues({
|
||||
if (isArray(value) && value[0]._isAMomentObject && value[1]._isAMomentObject) {
|
||||
value = value.map((item) => transformDateFunc(item));
|
||||
}
|
||||
// 去除空格
|
||||
// Remove spaces
|
||||
if (isString(value)) {
|
||||
value = value.trim();
|
||||
}
|
||||
@@ -47,7 +47,7 @@ export function useFormValues({
|
||||
}
|
||||
|
||||
/**
|
||||
* @description: 处理时间区间参数
|
||||
* @description: Processing time interval parameters
|
||||
*/
|
||||
function handleRangeTimeValue(values: any) {
|
||||
const fieldMapToTime = unref(fieldMapToTimeRef);
|
||||
|
@@ -31,7 +31,7 @@ export function useItemLabelWidth(schemaItemRef: Ref<FormSchema>, propsRef: Ref<
|
||||
wrapperCol: globWrapperCol,
|
||||
} = unref(propsRef) as any;
|
||||
|
||||
// 如果全局有设置labelWidth, 则所有item使用
|
||||
// If labelWidth is set globally, all items use
|
||||
if ((!globalLabelWidth && !labelWidth && !globalLabelCol) || disabledLabelWidth) {
|
||||
return { labelCol, wrapperCol };
|
||||
}
|
||||
|
@@ -42,57 +42,57 @@ export type UseFormReturnType = [RegisterFn, FormActionType];
|
||||
|
||||
export interface FormProps {
|
||||
// layout?: 'vertical' | 'inline' | 'horizontal';
|
||||
// 表单值
|
||||
// Form value
|
||||
model?: any;
|
||||
// 整个表单所有项宽度
|
||||
// The width of all items in the entire form
|
||||
labelWidth?: number | string;
|
||||
// 重置时提交
|
||||
// Submit form on reset
|
||||
submitOnReset?: boolean;
|
||||
// 整个表单通用Col配置
|
||||
// Col configuration for the entire form
|
||||
labelCol?: Partial<ColEx>;
|
||||
// 整个表单通用Col配置
|
||||
// Col configuration for the entire form
|
||||
wrapperCol?: Partial<ColEx>;
|
||||
|
||||
// 通用col配置
|
||||
// General col configuration
|
||||
baseColProps?: Partial<ColEx>;
|
||||
|
||||
// 表单配置规则
|
||||
// Form configuration rules
|
||||
schemas?: FormSchema[];
|
||||
// 用于合并到动态控制表单项的 函数values
|
||||
// Function values used to merge into dynamic control form items
|
||||
mergeDynamicData?: any;
|
||||
// 紧凑模式,用于搜索表单
|
||||
// Compact mode for search forms
|
||||
compact?: boolean;
|
||||
// 空白行span
|
||||
// Blank line span
|
||||
emptySpan?: number | Partial<ColEx>;
|
||||
// 表单内部组件大小
|
||||
// Internal component size of the form
|
||||
size?: 'default' | 'small' | 'large';
|
||||
// 是否禁用
|
||||
// Whether to disable
|
||||
disabled?: boolean;
|
||||
// 时间区间字段映射成多个
|
||||
// Time interval fields are mapped into multiple
|
||||
fieldMapToTime?: FieldMapToTime;
|
||||
// 自动设置placeholder
|
||||
// Placeholder is set automatically
|
||||
autoSetPlaceHolder?: boolean;
|
||||
// 校验信息是否加入label
|
||||
// Check whether the information is added to the label
|
||||
rulesMessageJoinLabel?: boolean;
|
||||
// 是否显示收起展开按钮
|
||||
// Whether to show collapse and expand buttons
|
||||
showAdvancedButton?: boolean;
|
||||
// 超过指定行数自动收起
|
||||
// Automatically collapse over the specified number of rows
|
||||
autoAdvancedLine?: number;
|
||||
// 是否显示操作按钮
|
||||
// Whether to show the operation button
|
||||
showActionButtonGroup?: boolean;
|
||||
|
||||
// 重置按钮配置
|
||||
// Reset button configuration
|
||||
resetButtonOptions?: Partial<ButtonProps>;
|
||||
|
||||
// 确认按钮配置
|
||||
// Confirm button configuration
|
||||
submitButtonOptions?: Partial<ButtonProps>;
|
||||
|
||||
// 操作列配置
|
||||
// Operation column configuration
|
||||
actionColOptions?: Partial<ColEx>;
|
||||
|
||||
// 显示重置按钮
|
||||
// Show reset button
|
||||
showResetButton?: boolean;
|
||||
// 显示确认按钮
|
||||
// Show confirmation button
|
||||
showSubmitButton?: boolean;
|
||||
|
||||
resetFunc?: () => Promise<void>;
|
||||
@@ -101,27 +101,27 @@ export interface FormProps {
|
||||
colon?: boolean;
|
||||
}
|
||||
export interface FormSchema {
|
||||
// 字段名
|
||||
// Field name
|
||||
field: string;
|
||||
// 内部值更改触发的事件名,默认 change
|
||||
// Event name triggered by internal value change, default change
|
||||
changeEvent?: string;
|
||||
// v-model绑定的变量名 默认 value
|
||||
// Variable name bound to v-model Default value
|
||||
valueField?: string;
|
||||
// 标签名
|
||||
// Label name
|
||||
label: string;
|
||||
// 辅助文本
|
||||
// Auxiliary text
|
||||
subLabel?: string;
|
||||
// 文本右侧帮助文本
|
||||
// Help text on the right side of the text
|
||||
helpMessage?: string | string[];
|
||||
// BaseHelp组件props
|
||||
// BaseHelp component props
|
||||
helpComponentProps?: Partial<HelpComponentProps>;
|
||||
// label宽度,有传的话 itemProps配置的 labelCol 和WrapperCol会失效
|
||||
// Label width, if it is passed, the labelCol and WrapperCol configured by itemProps will be invalid
|
||||
labelWidth?: string | number;
|
||||
// 禁用调有formModel全局设置的labelWidth,自己手动设置 labelCol和wrapperCol
|
||||
// Disable the adjustment of labelWidth with global settings of formModel, and manually set labelCol and wrapperCol by yourself
|
||||
disabledLabelWidth?: boolean;
|
||||
// 组件
|
||||
// render component
|
||||
component: ComponentType;
|
||||
// 组件参数
|
||||
// Component parameters
|
||||
componentProps?:
|
||||
| ((opt: {
|
||||
schema: FormSchema;
|
||||
@@ -130,35 +130,35 @@ export interface FormSchema {
|
||||
formModel: any;
|
||||
}) => any)
|
||||
| object;
|
||||
// 必填
|
||||
// Required
|
||||
required?: boolean;
|
||||
|
||||
// 校验规则
|
||||
// Validation rules
|
||||
rules?: Rule[];
|
||||
// 校验信息是否加入label
|
||||
// Check whether the information is added to the label
|
||||
rulesMessageJoinLabel?: boolean;
|
||||
|
||||
// 参考formModelItem
|
||||
// Reference formModelItem
|
||||
itemProps?: Partial<FormItem>;
|
||||
|
||||
// formModelItem外层的col配置
|
||||
// col configuration outside formModelItem
|
||||
colProps?: Partial<ColEx>;
|
||||
|
||||
// 默认值
|
||||
defaultValue?: any;
|
||||
isAdvanced?: boolean;
|
||||
|
||||
// 配合详情组件
|
||||
// Matching details components
|
||||
span?: number;
|
||||
|
||||
ifShow?: boolean | ((renderCallbackParams: RenderCallbackParams) => boolean);
|
||||
|
||||
show?: boolean | ((renderCallbackParams: RenderCallbackParams) => boolean);
|
||||
|
||||
// 渲染form-item标签内的内容
|
||||
// Render the content in the form-item tag
|
||||
render?: (renderCallbackParams: RenderCallbackParams) => VNode | VNode[] | string;
|
||||
|
||||
// 渲染 col内容,需要外层包裹 form-item
|
||||
// Rendering col content requires outer wrapper form-item
|
||||
renderColContent?: (renderCallbackParams: RenderCallbackParams) => VNode | VNode[] | string;
|
||||
|
||||
renderComponentContent?:
|
||||
@@ -167,10 +167,10 @@ export interface FormSchema {
|
||||
| VNode[]
|
||||
| string;
|
||||
|
||||
// 自定义slot, 在 from-item内
|
||||
// Custom slot, in from-item
|
||||
slot?: string;
|
||||
|
||||
// 自定义slot,类似renderColContent
|
||||
// Custom slot, similar to renderColContent
|
||||
colSlot?: string;
|
||||
|
||||
dynamicDisabled?: boolean | ((renderCallbackParams: RenderCallbackParams) => boolean);
|
||||
@@ -179,16 +179,16 @@ export interface FormSchema {
|
||||
}
|
||||
export interface HelpComponentProps {
|
||||
maxWidth: string;
|
||||
// 是否显示序号
|
||||
// Whether to display the serial number
|
||||
showIndex: boolean;
|
||||
// 文本列表
|
||||
// Text list
|
||||
text: any;
|
||||
// 颜色
|
||||
// colour
|
||||
color: string;
|
||||
// 字体大小
|
||||
// font size
|
||||
fontSize: string;
|
||||
icon: string;
|
||||
absolute: boolean;
|
||||
// 定位
|
||||
// Positioning
|
||||
position: any;
|
||||
}
|
||||
|
@@ -6,7 +6,8 @@ import { Menu } from 'ant-design-vue';
|
||||
import SearchInput from './SearchInput.vue';
|
||||
import MenuContent from './MenuContent';
|
||||
|
||||
import { MenuModeEnum, MenuThemeEnum, MenuTypeEnum } from '/@/enums/menuEnum';
|
||||
import { MenuModeEnum, MenuTypeEnum } from '/@/enums/menuEnum';
|
||||
import { ThemeEnum } from '/@/enums/appEnum';
|
||||
|
||||
import { menuStore } from '/@/store/modules/menu';
|
||||
import { appStore } from '/@/store/modules/app';
|
||||
@@ -254,7 +255,7 @@ export default defineComponent({
|
||||
{getSlot(slots, 'header')}
|
||||
<SearchInput
|
||||
class={!props.search ? 'hidden' : ''}
|
||||
theme={props.theme as MenuThemeEnum}
|
||||
theme={props.theme as ThemeEnum}
|
||||
onChange={handleInputChange}
|
||||
onClick={handleInputClick}
|
||||
collapsed={getCollapsedState}
|
||||
|
@@ -11,7 +11,7 @@
|
||||
<script lang="ts">
|
||||
import type { PropType } from 'vue';
|
||||
import { defineComponent, computed } from 'vue';
|
||||
import { MenuThemeEnum } from '/@/enums/menuEnum';
|
||||
import { ThemeEnum } from '/@/enums/appEnum';
|
||||
|
||||
// hook
|
||||
import { useDebounce } from '/@/hooks/core/useDebounce';
|
||||
@@ -25,7 +25,7 @@
|
||||
default: true,
|
||||
},
|
||||
theme: {
|
||||
type: String as PropType<MenuThemeEnum>,
|
||||
type: String as PropType<ThemeEnum>,
|
||||
},
|
||||
},
|
||||
setup(props, { emit }) {
|
||||
|
@@ -1,7 +1,8 @@
|
||||
import type { Menu } from '/@/router/types';
|
||||
import type { PropType } from 'vue';
|
||||
|
||||
import { MenuModeEnum, MenuTypeEnum, MenuThemeEnum } from '/@/enums/menuEnum';
|
||||
import { MenuModeEnum, MenuTypeEnum } from '/@/enums/menuEnum';
|
||||
import { ThemeEnum } from '/@/enums/appEnum';
|
||||
export const basicProps = {
|
||||
items: {
|
||||
type: Array as PropType<Menu[]>,
|
||||
@@ -40,7 +41,7 @@ export const basicProps = {
|
||||
},
|
||||
theme: {
|
||||
type: String as PropType<string>,
|
||||
default: MenuThemeEnum.DARK,
|
||||
default: ThemeEnum.DARK,
|
||||
},
|
||||
showLogo: {
|
||||
type: Boolean as PropType<boolean>,
|
||||
|
3
src/components/Menu/src/types.d.ts
vendored
3
src/components/Menu/src/types.d.ts
vendored
@@ -1,3 +1,4 @@
|
||||
import { ThemeEnum } from '/@/enums/appEnum';
|
||||
export interface MenuState {
|
||||
// 默认选中的列表
|
||||
defaultSelectedKeys: string[];
|
||||
@@ -6,7 +7,7 @@ export interface MenuState {
|
||||
mode: MenuModeEnum;
|
||||
|
||||
// 主题
|
||||
theme: ComputedRef<MenuThemeEnum> | MenuThemeEnum;
|
||||
theme: ComputedRef<ThemeEnum> | ThemeEnum;
|
||||
|
||||
// 缩进
|
||||
inlineIndent?: number;
|
||||
|
@@ -208,8 +208,8 @@
|
||||
padding: 16px;
|
||||
|
||||
.ant-form {
|
||||
padding: 12px 12px 4px 12px;
|
||||
margin-bottom: 12px;
|
||||
padding: 20px 20px 4px 12px;
|
||||
margin-bottom: 18px;
|
||||
background: #fff;
|
||||
border-radius: 2px;
|
||||
}
|
||||
|
@@ -33,7 +33,7 @@ import {
|
||||
Result,
|
||||
Empty,
|
||||
} from 'ant-design-vue';
|
||||
import { getApp } from '/@/useApp';
|
||||
import { getApp } from '/@/setup/Application';
|
||||
|
||||
const compList = [Icon, Button, AntButton.Group, AppFooter];
|
||||
|
||||
|
Reference in New Issue
Block a user