Compare commits
17 Commits
Author | SHA1 | Date | |
---|---|---|---|
![]() |
4baa0aed8b | ||
![]() |
b2d3cf10aa | ||
![]() |
63d2b38fd1 | ||
![]() |
78cd6677c3 | ||
![]() |
c0962fec18 | ||
![]() |
d38093ca7d | ||
![]() |
687c33ec29 | ||
![]() |
8ba7bdf2bd | ||
![]() |
b015fbc9fc | ||
![]() |
b69320c070 | ||
![]() |
dcccc213ce | ||
![]() |
c0e601c020 | ||
![]() |
017ed1a9e1 | ||
![]() |
598f371568 | ||
![]() |
ca2aadaf4a | ||
![]() |
616db1c127 | ||
![]() |
08de1a6f19 |
@@ -1,5 +1,9 @@
|
|||||||
# 1.4.1
|
# 1.4.1
|
||||||
|
|
||||||
|
**FEATURES**
|
||||||
|
|
||||||
|
- Tinymce添加在antd原生表单/useVbenForm下的校验样式
|
||||||
|
|
||||||
**BUG FIX**
|
**BUG FIX**
|
||||||
|
|
||||||
- 菜单管理 路由地址的必填项不生效
|
- 菜单管理 路由地址的必填项不生效
|
||||||
@@ -7,13 +11,14 @@
|
|||||||
**REFACTOR**
|
**REFACTOR**
|
||||||
|
|
||||||
- 字典接口抛出异常(为什么会抛出异常?)无限调用接口 兼容处理
|
- 字典接口抛出异常(为什么会抛出异常?)无限调用接口 兼容处理
|
||||||
|
- 代码生成 字典下拉加载 改为每次进入编辑页面都加载
|
||||||
|
|
||||||
# 1.4.0
|
# 1.4.0
|
||||||
|
|
||||||
**FEATURES**
|
**FEATURES**
|
||||||
|
|
||||||
- 菜单管理(通用方法) 保存表格滚动/展开状态并执行回调 用于树表在执行 新增/编辑/删除等操作后 依然在当前位置(体验优化)
|
- 菜单管理(通用方法) 保存表格滚动/展开状态并执行回调 用于树表在执行 新增/编辑/删除等操作后 依然在当前位置(体验优化)
|
||||||
|
-
|
||||||
- 菜单管理 级联删除 删除菜单和children
|
- 菜单管理 级联删除 删除菜单和children
|
||||||
|
|
||||||
**REFACTOR**
|
**REFACTOR**
|
||||||
|
@@ -202,6 +202,9 @@ const events = computed(() => {
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<style lang="scss">
|
<style lang="scss">
|
||||||
|
// 展开层元素z-index
|
||||||
|
$dropdown-index: 2025;
|
||||||
|
|
||||||
@mixin tinymce-valid-fail($color) {
|
@mixin tinymce-valid-fail($color) {
|
||||||
.app-tinymce {
|
.app-tinymce {
|
||||||
// 最外层的tinymce容器
|
// 最外层的tinymce容器
|
||||||
@@ -219,7 +222,11 @@ const events = computed(() => {
|
|||||||
|
|
||||||
.tox.tox-silver-sink.tox-tinymce-aux {
|
.tox.tox-silver-sink.tox-tinymce-aux {
|
||||||
/** 该样式默认为1300的zIndex */
|
/** 该样式默认为1300的zIndex */
|
||||||
z-index: 2025;
|
z-index: $dropdown-index;
|
||||||
|
}
|
||||||
|
|
||||||
|
.tox-fullscreen .tox.tox-tinymce-aux {
|
||||||
|
z-index: $dropdown-index !important;
|
||||||
}
|
}
|
||||||
|
|
||||||
.app-tinymce {
|
.app-tinymce {
|
||||||
@@ -249,4 +256,9 @@ const events = computed(() => {
|
|||||||
|
|
||||||
@include tinymce-valid-fail($error-color);
|
@include tinymce-valid-fail($error-color);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 全屏下样式处理 不去掉transform位置会异常
|
||||||
|
div[role='dialog']:has(.tox.tox-tinymce.tox-fullscreen) {
|
||||||
|
transform: none !important;
|
||||||
|
}
|
||||||
</style>
|
</style>
|
||||||
|
@@ -138,8 +138,8 @@ watch(
|
|||||||
:avatar
|
:avatar
|
||||||
:menus
|
:menus
|
||||||
:text="userStore.userInfo?.realName"
|
:text="userStore.userInfo?.realName"
|
||||||
description="ann.vben@gmail.com"
|
:description="userStore.userInfo?.email"
|
||||||
tag-text="Pro"
|
:tag-text="userStore.userInfo?.username"
|
||||||
@logout="handleLogout"
|
@logout="handleLogout"
|
||||||
/>
|
/>
|
||||||
</template>
|
</template>
|
||||||
|
@@ -118,6 +118,7 @@ export const useAuthStore = defineStore('auth', () => {
|
|||||||
roles,
|
roles,
|
||||||
userId: user.userId,
|
userId: user.userId,
|
||||||
username: user.userName,
|
username: user.userName,
|
||||||
|
email: user.email ?? '',
|
||||||
};
|
};
|
||||||
userStore.setUserInfo(userInfo);
|
userStore.setUserInfo(userInfo);
|
||||||
/**
|
/**
|
||||||
|
@@ -10,7 +10,7 @@ import { cloneDeep, eachTree } from '@vben/utils';
|
|||||||
import { omit } from 'lodash-es';
|
import { omit } from 'lodash-es';
|
||||||
|
|
||||||
import { useVbenForm } from '#/adapter/form';
|
import { useVbenForm } from '#/adapter/form';
|
||||||
import { menuTreeSelect, tenantPackageMenuTreeSelect } from '#/api/system/menu';
|
import { tenantPackageMenuTreeSelect } from '#/api/system/menu';
|
||||||
import {
|
import {
|
||||||
packageAdd,
|
packageAdd,
|
||||||
packageInfo,
|
packageInfo,
|
||||||
@@ -40,30 +40,18 @@ const [BasicForm, formApi] = useVbenForm({
|
|||||||
|
|
||||||
const menuTree = ref<MenuOption[]>([]);
|
const menuTree = ref<MenuOption[]>([]);
|
||||||
async function setupMenuTree(id?: number | string) {
|
async function setupMenuTree(id?: number | string) {
|
||||||
if (id) {
|
// 0为新增使用 获取除了`租户管理`的所有菜单
|
||||||
const resp = await tenantPackageMenuTreeSelect(id);
|
const resp = await tenantPackageMenuTreeSelect(id ?? 0);
|
||||||
const menus = resp.menus;
|
const menus = resp.menus;
|
||||||
// i18n处理
|
// i18n处理
|
||||||
eachTree(menus, (node) => {
|
eachTree(menus, (node) => {
|
||||||
node.label = $t(node.label);
|
node.label = $t(node.label);
|
||||||
});
|
});
|
||||||
// 设置菜单信息
|
// 设置菜单信息
|
||||||
menuTree.value = resp.menus;
|
menuTree.value = menus;
|
||||||
// keys依赖于menu 需要先加载menu
|
// keys依赖于menu 需要先加载menu
|
||||||
await nextTick();
|
await nextTick();
|
||||||
await formApi.setFieldValue('menuIds', resp.checkedKeys);
|
await formApi.setFieldValue('menuIds', resp.checkedKeys);
|
||||||
} else {
|
|
||||||
const resp = await menuTreeSelect();
|
|
||||||
// i18n处理
|
|
||||||
eachTree(resp, (node) => {
|
|
||||||
node.label = $t(node.label);
|
|
||||||
});
|
|
||||||
// 设置菜单信息
|
|
||||||
menuTree.value = resp;
|
|
||||||
// keys依赖于menu 需要先加载menu
|
|
||||||
await nextTick();
|
|
||||||
await formApi.setFieldValue('menuIds', []);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async function customFormValueGetter() {
|
async function customFormValueGetter() {
|
||||||
|
@@ -4,9 +4,10 @@ import type { Ref } from 'vue';
|
|||||||
import type { VxeGridProps } from '#/adapter/vxe-table';
|
import type { VxeGridProps } from '#/adapter/vxe-table';
|
||||||
import type { GenInfo } from '#/api/tool/gen/model';
|
import type { GenInfo } from '#/api/tool/gen/model';
|
||||||
|
|
||||||
import { inject } from 'vue';
|
import { inject, onMounted, reactive } from 'vue';
|
||||||
|
|
||||||
import { useVbenVxeGrid } from '#/adapter/vxe-table';
|
import { useVbenVxeGrid } from '#/adapter/vxe-table';
|
||||||
|
import { dictOptionSelectList } from '#/api/system/dict/dict-type';
|
||||||
|
|
||||||
import { validRules, vxeTableColumns } from './gen-data';
|
import { validRules, vxeTableColumns } from './gen-data';
|
||||||
|
|
||||||
@@ -15,8 +16,26 @@ import { validRules, vxeTableColumns } from './gen-data';
|
|||||||
*/
|
*/
|
||||||
const genInfoData = inject('genInfoData') as Ref<GenInfo['info']>;
|
const genInfoData = inject('genInfoData') as Ref<GenInfo['info']>;
|
||||||
|
|
||||||
|
const dictOptions = reactive<{ label: string; value: string }[]>([
|
||||||
|
{ label: '未设置', value: '' },
|
||||||
|
]);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 加载字典下拉数据
|
||||||
|
*/
|
||||||
|
onMounted(async () => {
|
||||||
|
const resp = await dictOptionSelectList();
|
||||||
|
|
||||||
|
const options = resp.map((dict) => ({
|
||||||
|
label: `${dict.dictName} | ${dict.dictType}`,
|
||||||
|
value: dict.dictType,
|
||||||
|
}));
|
||||||
|
|
||||||
|
dictOptions.push(...options);
|
||||||
|
});
|
||||||
|
|
||||||
const gridOptions: VxeGridProps = {
|
const gridOptions: VxeGridProps = {
|
||||||
columns: vxeTableColumns,
|
columns: vxeTableColumns(dictOptions),
|
||||||
keepSource: true,
|
keepSource: true,
|
||||||
editConfig: { trigger: 'click', mode: 'cell', showStatus: true },
|
editConfig: { trigger: 'click', mode: 'cell', showStatus: true },
|
||||||
editRules: validRules,
|
editRules: validRules,
|
||||||
|
@@ -2,14 +2,10 @@ import type { Recordable } from '@vben/types';
|
|||||||
|
|
||||||
import type { VxeGridProps } from '#/adapter/vxe-table';
|
import type { VxeGridProps } from '#/adapter/vxe-table';
|
||||||
|
|
||||||
import { reactive } from 'vue';
|
|
||||||
|
|
||||||
import { getPopupContainer } from '@vben/utils';
|
import { getPopupContainer } from '@vben/utils';
|
||||||
|
|
||||||
import { Checkbox, Input, Select } from 'ant-design-vue';
|
import { Checkbox, Input, Select } from 'ant-design-vue';
|
||||||
|
|
||||||
import { dictOptionSelectList } from '#/api/system/dict/dict-type';
|
|
||||||
|
|
||||||
const JavaTypes: string[] = [
|
const JavaTypes: string[] = [
|
||||||
'Long',
|
'Long',
|
||||||
'String',
|
'String',
|
||||||
@@ -45,24 +41,6 @@ const componentsOptions = [
|
|||||||
{ label: '富文本', value: 'editor' },
|
{ label: '富文本', value: 'editor' },
|
||||||
];
|
];
|
||||||
|
|
||||||
const dictOptions = reactive<{ label: string; value: string }[]>([
|
|
||||||
{ label: '未设置', value: '' },
|
|
||||||
]);
|
|
||||||
/**
|
|
||||||
* 在这里初始化字典下拉框
|
|
||||||
*/
|
|
||||||
(async function init() {
|
|
||||||
const ret = await dictOptionSelectList();
|
|
||||||
|
|
||||||
ret.forEach((dict) => {
|
|
||||||
const option = {
|
|
||||||
label: `${dict.dictName} | ${dict.dictType}`,
|
|
||||||
value: dict.dictType,
|
|
||||||
};
|
|
||||||
dictOptions.push(option);
|
|
||||||
});
|
|
||||||
})();
|
|
||||||
|
|
||||||
function renderBooleanTag(row: Recordable<any>, field: string) {
|
function renderBooleanTag(row: Recordable<any>, field: string) {
|
||||||
const value = row[field] ? '是' : '否';
|
const value = row[field] ? '是' : '否';
|
||||||
const className = row[field] ? 'text-green-500' : 'text-red-500';
|
const className = row[field] ? 'text-green-500' : 'text-red-500';
|
||||||
@@ -78,7 +56,10 @@ export const validRules: VxeGridProps['editRules'] = {
|
|||||||
javaField: [{ required: true, message: '请输入' }],
|
javaField: [{ required: true, message: '请输入' }],
|
||||||
};
|
};
|
||||||
|
|
||||||
export const vxeTableColumns: VxeGridProps['columns'] = [
|
// 内部依赖的字典从外部通过函数传入
|
||||||
|
export const vxeTableColumns: (
|
||||||
|
dictOptions: { label: string; value: string }[],
|
||||||
|
) => VxeGridProps['columns'] = (dictOptions) => [
|
||||||
{
|
{
|
||||||
title: '序号',
|
title: '序号',
|
||||||
type: 'seq',
|
type: 'seq',
|
||||||
|
@@ -91,6 +91,7 @@ const gridOptions: VxeGridProps = {
|
|||||||
toolbarConfig: {
|
toolbarConfig: {
|
||||||
enabled: false,
|
enabled: false,
|
||||||
},
|
},
|
||||||
|
cellClassName: 'cursor-pointer',
|
||||||
};
|
};
|
||||||
|
|
||||||
const [BasicTable, tableApi] = useVbenVxeGrid({ formOptions, gridOptions });
|
const [BasicTable, tableApi] = useVbenVxeGrid({ formOptions, gridOptions });
|
||||||
|
@@ -6,6 +6,7 @@ import { stringify } from '@vben/request';
|
|||||||
import { useAccessStore } from '@vben/stores';
|
import { useAccessStore } from '@vben/stores';
|
||||||
|
|
||||||
import { useEventListener } from '@vueuse/core';
|
import { useEventListener } from '@vueuse/core';
|
||||||
|
import { Alert } from 'ant-design-vue';
|
||||||
|
|
||||||
defineOptions({ name: 'FlowDesigner' });
|
defineOptions({ name: 'FlowDesigner' });
|
||||||
|
|
||||||
@@ -48,5 +49,13 @@ useEventListener('message', messageHandler);
|
|||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<iframe :src="url" class="size-full"></iframe>
|
<div class="size-full">
|
||||||
|
<Alert
|
||||||
|
class="mx-4 my-2"
|
||||||
|
type="warning"
|
||||||
|
:show-icon="true"
|
||||||
|
message="这是iframe页面! iframe页面! iframe页面! 不是我写的真服了"
|
||||||
|
/>
|
||||||
|
<iframe :src="url" class="size-full"></iframe>
|
||||||
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
4
packages/@core/base/typings/src/basic.d.ts
vendored
4
packages/@core/base/typings/src/basic.d.ts
vendored
@@ -12,6 +12,10 @@ interface BasicUserInfo {
|
|||||||
* 头像
|
* 头像
|
||||||
*/
|
*/
|
||||||
avatar: string;
|
avatar: string;
|
||||||
|
/**
|
||||||
|
* 邮箱
|
||||||
|
*/
|
||||||
|
email: string;
|
||||||
/**
|
/**
|
||||||
* 用户权限
|
* 用户权限
|
||||||
*/
|
*/
|
||||||
|
@@ -1,7 +1,15 @@
|
|||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import type { DrawerProps, ExtendedDrawerApi } from './drawer';
|
import type { DrawerProps, ExtendedDrawerApi } from './drawer';
|
||||||
|
|
||||||
import { computed, provide, ref, unref, useId, watch } from 'vue';
|
import {
|
||||||
|
computed,
|
||||||
|
onDeactivated,
|
||||||
|
provide,
|
||||||
|
ref,
|
||||||
|
unref,
|
||||||
|
useId,
|
||||||
|
watch,
|
||||||
|
} from 'vue';
|
||||||
|
|
||||||
import {
|
import {
|
||||||
useIsMobile,
|
useIsMobile,
|
||||||
@@ -94,6 +102,16 @@ const {
|
|||||||
// },
|
// },
|
||||||
// );
|
// );
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 在开启keepAlive情况下 直接通过浏览器按钮/手势等返回 不会关闭弹窗
|
||||||
|
*/
|
||||||
|
onDeactivated(() => {
|
||||||
|
// 如果弹窗没有被挂载到内容区域,则关闭弹窗
|
||||||
|
if (!appendToMain.value) {
|
||||||
|
props.drawerApi?.close();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
function interactOutside(e: Event) {
|
function interactOutside(e: Event) {
|
||||||
if (!closeOnClickModal.value || submitting.value) {
|
if (!closeOnClickModal.value || submitting.value) {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
|
@@ -9,7 +9,6 @@ import {
|
|||||||
h,
|
h,
|
||||||
inject,
|
inject,
|
||||||
nextTick,
|
nextTick,
|
||||||
onDeactivated,
|
|
||||||
provide,
|
provide,
|
||||||
reactive,
|
reactive,
|
||||||
ref,
|
ref,
|
||||||
@@ -72,13 +71,6 @@ export function useVbenDrawer<
|
|||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
/**
|
|
||||||
* 在开启keepAlive情况下 直接通过浏览器按钮/手势等返回 不会关闭弹窗
|
|
||||||
*/
|
|
||||||
onDeactivated(() => {
|
|
||||||
(extendedApi as ExtendedDrawerApi)?.close?.();
|
|
||||||
});
|
|
||||||
|
|
||||||
return [Drawer, extendedApi as ExtendedDrawerApi] as const;
|
return [Drawer, extendedApi as ExtendedDrawerApi] as const;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -1,7 +1,16 @@
|
|||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import type { ExtendedModalApi, ModalProps } from './modal';
|
import type { ExtendedModalApi, ModalProps } from './modal';
|
||||||
|
|
||||||
import { computed, nextTick, provide, ref, unref, useId, watch } from 'vue';
|
import {
|
||||||
|
computed,
|
||||||
|
nextTick,
|
||||||
|
onDeactivated,
|
||||||
|
provide,
|
||||||
|
ref,
|
||||||
|
unref,
|
||||||
|
useId,
|
||||||
|
watch,
|
||||||
|
} from 'vue';
|
||||||
|
|
||||||
import {
|
import {
|
||||||
useIsMobile,
|
useIsMobile,
|
||||||
@@ -135,6 +144,16 @@ watch(
|
|||||||
// },
|
// },
|
||||||
// );
|
// );
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 在开启keepAlive情况下 直接通过浏览器按钮/手势等返回 不会关闭弹窗
|
||||||
|
*/
|
||||||
|
onDeactivated(() => {
|
||||||
|
// 如果弹窗没有被挂载到内容区域,则关闭弹窗
|
||||||
|
if (!appendToMain.value) {
|
||||||
|
props.modalApi?.close();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
function handleFullscreen() {
|
function handleFullscreen() {
|
||||||
props.modalApi?.setState((prev) => {
|
props.modalApi?.setState((prev) => {
|
||||||
// if (prev.fullscreen) {
|
// if (prev.fullscreen) {
|
||||||
|
@@ -5,7 +5,6 @@ import {
|
|||||||
h,
|
h,
|
||||||
inject,
|
inject,
|
||||||
nextTick,
|
nextTick,
|
||||||
onDeactivated,
|
|
||||||
provide,
|
provide,
|
||||||
reactive,
|
reactive,
|
||||||
ref,
|
ref,
|
||||||
@@ -71,13 +70,6 @@ export function useVbenModal<TParentModalProps extends ModalProps = ModalProps>(
|
|||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
/**
|
|
||||||
* 在开启keepAlive情况下 直接通过浏览器按钮/手势等返回 不会关闭弹窗
|
|
||||||
*/
|
|
||||||
onDeactivated(() => {
|
|
||||||
(extendedApi as ExtendedModalApi)?.close?.();
|
|
||||||
});
|
|
||||||
|
|
||||||
return [Modal, extendedApi as ExtendedModalApi] as const;
|
return [Modal, extendedApi as ExtendedModalApi] as const;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -130,6 +122,7 @@ export function useVbenModal<TParentModalProps extends ModalProps = ModalProps>(
|
|||||||
},
|
},
|
||||||
);
|
);
|
||||||
injectData.extendApi?.(extendedApi);
|
injectData.extendApi?.(extendedApi);
|
||||||
|
|
||||||
return [Modal, extendedApi] as const;
|
return [Modal, extendedApi] as const;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -122,6 +122,7 @@ async function onBtnClick(value: ValueType) {
|
|||||||
v-bind="btnDefaultProps"
|
v-bind="btnDefaultProps"
|
||||||
:variant="innerValue.includes(btn.value) ? 'default' : 'outline'"
|
:variant="innerValue.includes(btn.value) ? 'default' : 'outline'"
|
||||||
@click="onBtnClick(btn.value)"
|
@click="onBtnClick(btn.value)"
|
||||||
|
type="button"
|
||||||
>
|
>
|
||||||
<div class="icon-wrapper" v-if="props.showIcon">
|
<div class="icon-wrapper" v-if="props.showIcon">
|
||||||
<slot
|
<slot
|
||||||
|
@@ -8,19 +8,40 @@ import { isFunction } from '@vben/utils';
|
|||||||
|
|
||||||
import { useElementHover } from '@vueuse/core';
|
import { useElementHover } from '@vueuse/core';
|
||||||
|
|
||||||
|
interface HoverDelayOptions {
|
||||||
|
/** 鼠标进入延迟时间 */
|
||||||
|
enterDelay?: (() => number) | number;
|
||||||
|
/** 鼠标离开延迟时间 */
|
||||||
|
leaveDelay?: (() => number) | number;
|
||||||
|
}
|
||||||
|
|
||||||
|
const DEFAULT_LEAVE_DELAY = 500; // 鼠标离开延迟时间,默认为 500ms
|
||||||
|
const DEFAULT_ENTER_DELAY = 0; // 鼠标进入延迟时间,默认为 0(立即响应)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 监测鼠标是否在元素内部,如果在元素内部则返回 true,否则返回 false
|
* 监测鼠标是否在元素内部,如果在元素内部则返回 true,否则返回 false
|
||||||
* @param refElement 所有需要检测的元素。如果提供了一个数组,那么鼠标在任何一个元素内部都会返回 true
|
* @param refElement 所有需要检测的元素。如果提供了一个数组,那么鼠标在任何一个元素内部都会返回 true
|
||||||
* @param delay 延迟更新状态的时间
|
* @param delay 延迟更新状态的时间,可以是数字或包含进入/离开延迟的配置对象
|
||||||
* @returns 返回一个数组,第一个元素是一个 ref,表示鼠标是否在元素内部,第二个元素是一个控制器,可以通过 enable 和 disable 方法来控制监听器的启用和禁用
|
* @returns 返回一个数组,第一个元素是一个 ref,表示鼠标是否在元素内部,第二个元素是一个控制器,可以通过 enable 和 disable 方法来控制监听器的启用和禁用
|
||||||
*/
|
*/
|
||||||
export function useHoverToggle(
|
export function useHoverToggle(
|
||||||
refElement: Arrayable<MaybeElementRef>,
|
refElement: Arrayable<MaybeElementRef>,
|
||||||
delay: (() => number) | number = 500,
|
delay: (() => number) | HoverDelayOptions | number = DEFAULT_LEAVE_DELAY,
|
||||||
) {
|
) {
|
||||||
|
// 兼容旧版本API
|
||||||
|
const normalizedOptions: HoverDelayOptions =
|
||||||
|
typeof delay === 'number' || isFunction(delay)
|
||||||
|
? { enterDelay: DEFAULT_ENTER_DELAY, leaveDelay: delay }
|
||||||
|
: {
|
||||||
|
enterDelay: DEFAULT_ENTER_DELAY,
|
||||||
|
leaveDelay: DEFAULT_LEAVE_DELAY,
|
||||||
|
...delay,
|
||||||
|
};
|
||||||
|
|
||||||
const isHovers: Array<Ref<boolean>> = [];
|
const isHovers: Array<Ref<boolean>> = [];
|
||||||
const value = ref(false);
|
const value = ref(false);
|
||||||
const timer = ref<ReturnType<typeof setTimeout> | undefined>();
|
const enterTimer = ref<ReturnType<typeof setTimeout> | undefined>();
|
||||||
|
const leaveTimer = ref<ReturnType<typeof setTimeout> | undefined>();
|
||||||
const refs = Array.isArray(refElement) ? refElement : [refElement];
|
const refs = Array.isArray(refElement) ? refElement : [refElement];
|
||||||
refs.forEach((refEle) => {
|
refs.forEach((refEle) => {
|
||||||
const eleRef = computed(() => {
|
const eleRef = computed(() => {
|
||||||
@@ -32,15 +53,47 @@ export function useHoverToggle(
|
|||||||
});
|
});
|
||||||
const isOutsideAll = computed(() => isHovers.every((v) => !v.value));
|
const isOutsideAll = computed(() => isHovers.every((v) => !v.value));
|
||||||
|
|
||||||
|
function clearTimers() {
|
||||||
|
if (enterTimer.value) {
|
||||||
|
clearTimeout(enterTimer.value);
|
||||||
|
enterTimer.value = undefined;
|
||||||
|
}
|
||||||
|
if (leaveTimer.value) {
|
||||||
|
clearTimeout(leaveTimer.value);
|
||||||
|
leaveTimer.value = undefined;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function setValueDelay(val: boolean) {
|
function setValueDelay(val: boolean) {
|
||||||
timer.value && clearTimeout(timer.value);
|
clearTimers();
|
||||||
timer.value = setTimeout(
|
|
||||||
() => {
|
if (val) {
|
||||||
value.value = val;
|
// 鼠标进入
|
||||||
timer.value = undefined;
|
const enterDelay = normalizedOptions.enterDelay ?? DEFAULT_ENTER_DELAY;
|
||||||
},
|
const delayTime = isFunction(enterDelay) ? enterDelay() : enterDelay;
|
||||||
isFunction(delay) ? delay() : delay,
|
|
||||||
);
|
if (delayTime <= 0) {
|
||||||
|
value.value = true;
|
||||||
|
} else {
|
||||||
|
enterTimer.value = setTimeout(() => {
|
||||||
|
value.value = true;
|
||||||
|
enterTimer.value = undefined;
|
||||||
|
}, delayTime);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// 鼠标离开
|
||||||
|
const leaveDelay = normalizedOptions.leaveDelay ?? DEFAULT_LEAVE_DELAY;
|
||||||
|
const delayTime = isFunction(leaveDelay) ? leaveDelay() : leaveDelay;
|
||||||
|
|
||||||
|
if (delayTime <= 0) {
|
||||||
|
value.value = false;
|
||||||
|
} else {
|
||||||
|
leaveTimer.value = setTimeout(() => {
|
||||||
|
value.value = false;
|
||||||
|
leaveTimer.value = undefined;
|
||||||
|
}, delayTime);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const watcher = watch(
|
const watcher = watch(
|
||||||
@@ -61,7 +114,7 @@ export function useHoverToggle(
|
|||||||
};
|
};
|
||||||
|
|
||||||
onUnmounted(() => {
|
onUnmounted(() => {
|
||||||
timer.value && clearTimeout(timer.value);
|
clearTimers();
|
||||||
});
|
});
|
||||||
|
|
||||||
return [value, controller] as [typeof value, typeof controller];
|
return [value, controller] as [typeof value, typeof controller];
|
||||||
|
@@ -1,8 +1,11 @@
|
|||||||
import type { ExtendedFormApi } from '@vben-core/form-ui';
|
|
||||||
import type { VxeGridInstance } from 'vxe-table';
|
import type { VxeGridInstance } from 'vxe-table';
|
||||||
|
|
||||||
|
import type { ExtendedFormApi } from '@vben-core/form-ui';
|
||||||
|
|
||||||
import type { VxeGridProps } from './types';
|
import type { VxeGridProps } from './types';
|
||||||
|
|
||||||
|
import { toRaw } from 'vue';
|
||||||
|
|
||||||
import { Store } from '@vben-core/shared/store';
|
import { Store } from '@vben-core/shared/store';
|
||||||
import {
|
import {
|
||||||
bindMethods,
|
bindMethods,
|
||||||
@@ -11,7 +14,6 @@ import {
|
|||||||
mergeWithArrayOverride,
|
mergeWithArrayOverride,
|
||||||
StateHandler,
|
StateHandler,
|
||||||
} from '@vben-core/shared/utils';
|
} from '@vben-core/shared/utils';
|
||||||
import { toRaw } from 'vue';
|
|
||||||
|
|
||||||
function getDefaultState(): VxeGridProps {
|
function getDefaultState(): VxeGridProps {
|
||||||
return {
|
return {
|
||||||
@@ -24,18 +26,18 @@ function getDefaultState(): VxeGridProps {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
export class VxeGridApi {
|
export class VxeGridApi<T extends Record<string, any> = any> {
|
||||||
private isMounted = false;
|
|
||||||
|
|
||||||
private stateHandler: StateHandler;
|
|
||||||
public formApi = {} as ExtendedFormApi;
|
public formApi = {} as ExtendedFormApi;
|
||||||
|
|
||||||
// private prevState: null | VxeGridProps = null;
|
// private prevState: null | VxeGridProps = null;
|
||||||
public grid = {} as VxeGridInstance;
|
public grid = {} as VxeGridInstance<T>;
|
||||||
|
public state: null | VxeGridProps<T> = null;
|
||||||
|
|
||||||
public state: null | VxeGridProps = null;
|
public store: Store<VxeGridProps<T>>;
|
||||||
|
|
||||||
public store: Store<VxeGridProps>;
|
private isMounted = false;
|
||||||
|
|
||||||
|
private stateHandler: StateHandler;
|
||||||
|
|
||||||
constructor(options: VxeGridProps = {}) {
|
constructor(options: VxeGridProps = {}) {
|
||||||
const storeState = { ...options };
|
const storeState = { ...options };
|
||||||
@@ -97,8 +99,8 @@ export class VxeGridApi {
|
|||||||
|
|
||||||
setState(
|
setState(
|
||||||
stateOrFn:
|
stateOrFn:
|
||||||
| ((prev: VxeGridProps) => Partial<VxeGridProps>)
|
| ((prev: VxeGridProps<T>) => Partial<VxeGridProps<T>>)
|
||||||
| Partial<VxeGridProps>,
|
| Partial<VxeGridProps<T>>,
|
||||||
) {
|
) {
|
||||||
if (isFunction(stateOrFn)) {
|
if (isFunction(stateOrFn)) {
|
||||||
this.store.setState((prev) => {
|
this.store.setState((prev) => {
|
||||||
|
@@ -9,7 +9,7 @@ import type { Ref } from 'vue';
|
|||||||
|
|
||||||
import type { ClassType, DeepPartial } from '@vben/types';
|
import type { ClassType, DeepPartial } from '@vben/types';
|
||||||
|
|
||||||
import type { VbenFormProps } from '@vben-core/form-ui';
|
import type { BaseFormComponentType, VbenFormProps } from '@vben-core/form-ui';
|
||||||
|
|
||||||
import type { VxeGridApi } from './api';
|
import type { VxeGridApi } from './api';
|
||||||
|
|
||||||
@@ -35,7 +35,11 @@ export interface SeparatorOptions {
|
|||||||
show?: boolean;
|
show?: boolean;
|
||||||
backgroundColor?: string;
|
backgroundColor?: string;
|
||||||
}
|
}
|
||||||
export interface VxeGridProps {
|
|
||||||
|
export interface VxeGridProps<
|
||||||
|
T extends Record<string, any> = any,
|
||||||
|
D extends BaseFormComponentType = BaseFormComponentType,
|
||||||
|
> {
|
||||||
/**
|
/**
|
||||||
* 标题
|
* 标题
|
||||||
*/
|
*/
|
||||||
@@ -55,15 +59,15 @@ export interface VxeGridProps {
|
|||||||
/**
|
/**
|
||||||
* vxe-grid 配置
|
* vxe-grid 配置
|
||||||
*/
|
*/
|
||||||
gridOptions?: DeepPartial<VxeTableGridOptions>;
|
gridOptions?: DeepPartial<VxeTableGridOptions<T>>;
|
||||||
/**
|
/**
|
||||||
* vxe-grid 事件
|
* vxe-grid 事件
|
||||||
*/
|
*/
|
||||||
gridEvents?: Partial<VxeGridListeners>;
|
gridEvents?: Partial<VxeGridListeners<T>>;
|
||||||
/**
|
/**
|
||||||
* 表单配置
|
* 表单配置
|
||||||
*/
|
*/
|
||||||
formOptions?: VbenFormProps;
|
formOptions?: VbenFormProps<D>;
|
||||||
/**
|
/**
|
||||||
* 显示搜索表单
|
* 显示搜索表单
|
||||||
*/
|
*/
|
||||||
@@ -74,9 +78,12 @@ export interface VxeGridProps {
|
|||||||
separator?: boolean | SeparatorOptions;
|
separator?: boolean | SeparatorOptions;
|
||||||
}
|
}
|
||||||
|
|
||||||
export type ExtendedVxeGridApi = VxeGridApi & {
|
export type ExtendedVxeGridApi<
|
||||||
useStore: <T = NoInfer<VxeGridProps>>(
|
D extends Record<string, any> = any,
|
||||||
selector?: (state: NoInfer<VxeGridProps>) => T,
|
F extends BaseFormComponentType = BaseFormComponentType,
|
||||||
|
> = VxeGridApi<D> & {
|
||||||
|
useStore: <T = NoInfer<VxeGridProps<D, F>>>(
|
||||||
|
selector?: (state: NoInfer<VxeGridProps<any, any>>) => T,
|
||||||
) => Readonly<Ref<T>>;
|
) => Readonly<Ref<T>>;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@@ -1,3 +1,5 @@
|
|||||||
|
import type { BaseFormComponentType } from '@vben-core/form-ui';
|
||||||
|
|
||||||
import type { ExtendedVxeGridApi, VxeGridProps } from './types';
|
import type { ExtendedVxeGridApi, VxeGridProps } from './types';
|
||||||
|
|
||||||
import { defineComponent, h, onBeforeUnmount } from 'vue';
|
import { defineComponent, h, onBeforeUnmount } from 'vue';
|
||||||
@@ -7,16 +9,19 @@ import { useStore } from '@vben-core/shared/store';
|
|||||||
import { VxeGridApi } from './api';
|
import { VxeGridApi } from './api';
|
||||||
import VxeGrid from './use-vxe-grid.vue';
|
import VxeGrid from './use-vxe-grid.vue';
|
||||||
|
|
||||||
export function useVbenVxeGrid(options: VxeGridProps) {
|
export function useVbenVxeGrid<
|
||||||
|
T extends Record<string, any> = any,
|
||||||
|
D extends BaseFormComponentType = BaseFormComponentType,
|
||||||
|
>(options: VxeGridProps<T, D>) {
|
||||||
// const IS_REACTIVE = isReactive(options);
|
// const IS_REACTIVE = isReactive(options);
|
||||||
const api = new VxeGridApi(options);
|
const api = new VxeGridApi(options);
|
||||||
const extendedApi: ExtendedVxeGridApi = api as ExtendedVxeGridApi;
|
const extendedApi: ExtendedVxeGridApi<T, D> = api as ExtendedVxeGridApi<T, D>;
|
||||||
extendedApi.useStore = (selector) => {
|
extendedApi.useStore = (selector) => {
|
||||||
return useStore(api.store, selector);
|
return useStore(api.store, selector);
|
||||||
};
|
};
|
||||||
|
|
||||||
const Grid = defineComponent(
|
const Grid = defineComponent(
|
||||||
(props: VxeGridProps, { attrs, slots }) => {
|
(props: VxeGridProps<T>, { attrs, slots }) => {
|
||||||
onBeforeUnmount(() => {
|
onBeforeUnmount(() => {
|
||||||
api.unmount();
|
api.unmount();
|
||||||
});
|
});
|
||||||
|
@@ -1,6 +1,8 @@
|
|||||||
import type { RequestClient } from '../request-client';
|
import type { RequestClient } from '../request-client';
|
||||||
import type { RequestClientConfig } from '../types';
|
import type { RequestClientConfig } from '../types';
|
||||||
|
|
||||||
|
import { isUndefined } from '@vben/utils';
|
||||||
|
|
||||||
class FileUploader {
|
class FileUploader {
|
||||||
private client: RequestClient;
|
private client: RequestClient;
|
||||||
|
|
||||||
@@ -18,10 +20,10 @@ class FileUploader {
|
|||||||
Object.entries(data).forEach(([key, value]) => {
|
Object.entries(data).forEach(([key, value]) => {
|
||||||
if (Array.isArray(value)) {
|
if (Array.isArray(value)) {
|
||||||
value.forEach((item, index) => {
|
value.forEach((item, index) => {
|
||||||
formData.append(`${key}[${index}]`, item);
|
!isUndefined(item) && formData.append(`${key}[${index}]`, item);
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
formData.append(key, value);
|
!isUndefined(value) && formData.append(key, value);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@@ -6,6 +6,10 @@ interface BasicUserInfo {
|
|||||||
* 头像
|
* 头像
|
||||||
*/
|
*/
|
||||||
avatar: string;
|
avatar: string;
|
||||||
|
/**
|
||||||
|
* 邮箱
|
||||||
|
*/
|
||||||
|
email: string;
|
||||||
/**
|
/**
|
||||||
* 用户权限
|
* 用户权限
|
||||||
*/
|
*/
|
||||||
|
@@ -1,10 +1,16 @@
|
|||||||
|
import type { VxeTableGridOptions } from '@vben/plugins/vxe-table';
|
||||||
import type { Recordable } from '@vben/types';
|
import type { Recordable } from '@vben/types';
|
||||||
|
|
||||||
|
import type { ComponentType } from './component';
|
||||||
|
|
||||||
import { h } from 'vue';
|
import { h } from 'vue';
|
||||||
|
|
||||||
import { IconifyIcon } from '@vben/icons';
|
import { IconifyIcon } from '@vben/icons';
|
||||||
import { $te } from '@vben/locales';
|
import { $te } from '@vben/locales';
|
||||||
import { setupVbenVxeTable, useVbenVxeGrid } from '@vben/plugins/vxe-table';
|
import {
|
||||||
|
setupVbenVxeTable,
|
||||||
|
useVbenVxeGrid as useGrid,
|
||||||
|
} from '@vben/plugins/vxe-table';
|
||||||
import { get, isFunction, isString } from '@vben/utils';
|
import { get, isFunction, isString } from '@vben/utils';
|
||||||
|
|
||||||
import { objectOmit } from '@vueuse/core';
|
import { objectOmit } from '@vueuse/core';
|
||||||
@@ -42,7 +48,7 @@ setupVbenVxeTable({
|
|||||||
round: true,
|
round: true,
|
||||||
showOverflow: true,
|
showOverflow: true,
|
||||||
size: 'small',
|
size: 'small',
|
||||||
},
|
} as VxeTableGridOptions,
|
||||||
});
|
});
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -277,7 +283,10 @@ setupVbenVxeTable({
|
|||||||
useVbenForm,
|
useVbenForm,
|
||||||
});
|
});
|
||||||
|
|
||||||
export { useVbenVxeGrid };
|
export const useVbenVxeGrid = <T extends Record<string, any>>(
|
||||||
|
...rest: Parameters<typeof useGrid<T, ComponentType>>
|
||||||
|
) => useGrid<T, ComponentType>(...rest);
|
||||||
|
|
||||||
export type OnActionClickParams<T = Recordable<any>> = {
|
export type OnActionClickParams<T = Recordable<any>> = {
|
||||||
code: string;
|
code: string;
|
||||||
row: T;
|
row: T;
|
||||||
|
@@ -43,7 +43,22 @@ const gridEvents: VxeGridListeners<RowType> = {
|
|||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
const [Grid, gridApi] = useVbenVxeGrid({ gridEvents, gridOptions });
|
const [Grid, gridApi] = useVbenVxeGrid<RowType>({
|
||||||
|
// 放开注释查看表单组件的类型
|
||||||
|
// formOptions: {
|
||||||
|
// schema: [
|
||||||
|
// {
|
||||||
|
// component: 'Switch',
|
||||||
|
// fieldName: 'name',
|
||||||
|
// },
|
||||||
|
// ],
|
||||||
|
// },
|
||||||
|
gridEvents,
|
||||||
|
gridOptions,
|
||||||
|
});
|
||||||
|
|
||||||
|
// 放开注释查看当前表格实例的类型
|
||||||
|
// gridApi.grid
|
||||||
|
|
||||||
const showBorder = gridApi.useStore((state) => state.gridOptions?.border);
|
const showBorder = gridApi.useStore((state) => state.gridOptions?.border);
|
||||||
const showStripe = gridApi.useStore((state) => state.gridOptions?.stripe);
|
const showStripe = gridApi.useStore((state) => state.gridOptions?.stripe);
|
||||||
|
@@ -241,10 +241,10 @@ const schema: VbenFormSchema[] = [
|
|||||||
component: 'Input',
|
component: 'Input',
|
||||||
dependencies: {
|
dependencies: {
|
||||||
rules: (values) => {
|
rules: (values) => {
|
||||||
return values.type === 'action' ? 'required' : null;
|
return values.type === 'button' ? 'required' : null;
|
||||||
},
|
},
|
||||||
show: (values) => {
|
show: (values) => {
|
||||||
return ['action', 'catalog', 'embedded', 'menu'].includes(values.type);
|
return ['button', 'catalog', 'embedded', 'menu'].includes(values.type);
|
||||||
},
|
},
|
||||||
triggerFields: ['type'],
|
triggerFields: ['type'],
|
||||||
},
|
},
|
||||||
@@ -277,7 +277,7 @@ const schema: VbenFormSchema[] = [
|
|||||||
},
|
},
|
||||||
dependencies: {
|
dependencies: {
|
||||||
show: (values) => {
|
show: (values) => {
|
||||||
return values.type !== 'action';
|
return values.type !== 'button';
|
||||||
},
|
},
|
||||||
triggerFields: ['type'],
|
triggerFields: ['type'],
|
||||||
},
|
},
|
||||||
@@ -295,7 +295,7 @@ const schema: VbenFormSchema[] = [
|
|||||||
},
|
},
|
||||||
dependencies: {
|
dependencies: {
|
||||||
show: (values) => {
|
show: (values) => {
|
||||||
return values.type !== 'action';
|
return values.type !== 'button';
|
||||||
},
|
},
|
||||||
triggerFields: ['type'],
|
triggerFields: ['type'],
|
||||||
},
|
},
|
||||||
@@ -314,7 +314,7 @@ const schema: VbenFormSchema[] = [
|
|||||||
},
|
},
|
||||||
dependencies: {
|
dependencies: {
|
||||||
show: (values) => {
|
show: (values) => {
|
||||||
return values.type !== 'action';
|
return values.type !== 'button';
|
||||||
},
|
},
|
||||||
triggerFields: ['type'],
|
triggerFields: ['type'],
|
||||||
},
|
},
|
||||||
@@ -325,7 +325,7 @@ const schema: VbenFormSchema[] = [
|
|||||||
component: 'Divider',
|
component: 'Divider',
|
||||||
dependencies: {
|
dependencies: {
|
||||||
show: (values) => {
|
show: (values) => {
|
||||||
return !['action', 'link'].includes(values.type);
|
return !['button', 'link'].includes(values.type);
|
||||||
},
|
},
|
||||||
triggerFields: ['type'],
|
triggerFields: ['type'],
|
||||||
},
|
},
|
||||||
@@ -372,7 +372,7 @@ const schema: VbenFormSchema[] = [
|
|||||||
component: 'Checkbox',
|
component: 'Checkbox',
|
||||||
dependencies: {
|
dependencies: {
|
||||||
show: (values) => {
|
show: (values) => {
|
||||||
return !['action'].includes(values.type);
|
return !['button'].includes(values.type);
|
||||||
},
|
},
|
||||||
triggerFields: ['type'],
|
triggerFields: ['type'],
|
||||||
},
|
},
|
||||||
@@ -402,7 +402,7 @@ const schema: VbenFormSchema[] = [
|
|||||||
component: 'Checkbox',
|
component: 'Checkbox',
|
||||||
dependencies: {
|
dependencies: {
|
||||||
show: (values) => {
|
show: (values) => {
|
||||||
return !['action', 'link'].includes(values.type);
|
return !['button', 'link'].includes(values.type);
|
||||||
},
|
},
|
||||||
triggerFields: ['type'],
|
triggerFields: ['type'],
|
||||||
},
|
},
|
||||||
@@ -417,7 +417,7 @@ const schema: VbenFormSchema[] = [
|
|||||||
component: 'Checkbox',
|
component: 'Checkbox',
|
||||||
dependencies: {
|
dependencies: {
|
||||||
show: (values) => {
|
show: (values) => {
|
||||||
return !['action', 'link'].includes(values.type);
|
return !['button', 'link'].includes(values.type);
|
||||||
},
|
},
|
||||||
triggerFields: ['type'],
|
triggerFields: ['type'],
|
||||||
},
|
},
|
||||||
|
Reference in New Issue
Block a user