提交 de5bf757 作者: vben

fix(form): formAction slot not work

上级 a1c3c53c
## Wip ## Wip
### ✨ Refactor
独立组件配置到 `/@/settings/componentsSetting`
### ✨ Features ### ✨ Features
- 新增`mixSideTrigger`配置。用于配置左侧混合模式菜单打开方式。可选`hover`,默认`click` - 新增`mixSideTrigger`配置。用于配置左侧混合模式菜单打开方式。可选`hover`,默认`click`
...@@ -16,6 +20,10 @@ ...@@ -16,6 +20,10 @@
- 修复`layout` 收缩展开功能在分割模式下失效 - 修复`layout` 收缩展开功能在分割模式下失效
- 修复 modal 高度计算错误 - 修复 modal 高度计算错误
### 🎫 Chores
- 文档更新
## 2.0.0-rc.15 (2020-12-31) ## 2.0.0-rc.15 (2020-12-31)
### ✨ 表格破坏性更新 ### ✨ 表格破坏性更新
......
{ {
"name": "vben-admin-2.0", "name": "vben-admin",
"version": "2.0.0-rc.15", "version": "2.0.0-rc.15",
"scripts": { "scripts": {
"bootstrap": "yarn install", "bootstrap": "yarn install",
...@@ -35,7 +35,7 @@ ...@@ -35,7 +35,7 @@
"path-to-regexp": "^6.2.0", "path-to-regexp": "^6.2.0",
"qrcode": "^1.4.4", "qrcode": "^1.4.4",
"sortablejs": "^1.12.0", "sortablejs": "^1.12.0",
"vditor": "^3.7.4", "vditor": "^3.7.5",
"vue": "^3.0.5", "vue": "^3.0.5",
"vue-i18n": "9.0.0-beta.14", "vue-i18n": "9.0.0-beta.14",
"vue-router": "^4.0.2", "vue-router": "^4.0.2",
...@@ -48,7 +48,7 @@ ...@@ -48,7 +48,7 @@
"devDependencies": { "devDependencies": {
"@commitlint/cli": "^11.0.0", "@commitlint/cli": "^11.0.0",
"@commitlint/config-conventional": "^11.0.0", "@commitlint/config-conventional": "^11.0.0",
"@iconify/json": "^1.1.278", "@iconify/json": "^1.1.282",
"@ls-lint/ls-lint": "^1.9.2", "@ls-lint/ls-lint": "^1.9.2",
"@purge-icons/generated": "^0.4.1", "@purge-icons/generated": "^0.4.1",
"@types/echarts": "^4.9.3", "@types/echarts": "^4.9.3",
...@@ -63,8 +63,8 @@ ...@@ -63,8 +63,8 @@
"@types/sortablejs": "^1.10.6", "@types/sortablejs": "^1.10.6",
"@types/yargs": "^15.0.12", "@types/yargs": "^15.0.12",
"@types/zxcvbn": "^4.4.0", "@types/zxcvbn": "^4.4.0",
"@typescript-eslint/eslint-plugin": "^4.11.1", "@typescript-eslint/eslint-plugin": "^4.12.0",
"@typescript-eslint/parser": "^4.11.1", "@typescript-eslint/parser": "^4.12.0",
"@vue/compiler-sfc": "^3.0.5", "@vue/compiler-sfc": "^3.0.5",
"@vuedx/typecheck": "^0.4.1", "@vuedx/typecheck": "^0.4.1",
"@vuedx/typescript-plugin-vue": "^0.4.1", "@vuedx/typescript-plugin-vue": "^0.4.1",
...@@ -75,11 +75,11 @@ ...@@ -75,11 +75,11 @@
"cross-env": "^7.0.3", "cross-env": "^7.0.3",
"dot-prop": "^6.0.1", "dot-prop": "^6.0.1",
"dotenv": "^8.2.0", "dotenv": "^8.2.0",
"eslint": "^7.16.0", "eslint": "^7.17.0",
"eslint-config-prettier": "^7.1.0", "eslint-config-prettier": "^7.1.0",
"eslint-plugin-prettier": "^3.3.0", "eslint-plugin-prettier": "^3.3.1",
"eslint-plugin-vue": "^7.4.0", "eslint-plugin-vue": "^7.4.1",
"esno": "^0.3.0", "esno": "^0.4.0",
"fs-extra": "^9.0.1", "fs-extra": "^9.0.1",
"globrex": "^0.1.2", "globrex": "^0.1.2",
"husky": "^4.3.6", "husky": "^4.3.6",
......
...@@ -18,10 +18,14 @@ ...@@ -18,10 +18,14 @@
</FormItem> </FormItem>
</template> </template>
<FormAction <FormAction v-bind="{ ...getProps, ...advanceState }" @toggle-advanced="handleToggleAdvanced">
v-bind="{ ...getProps, ...advanceState }" <template
@toggle-advanced="handleToggleAdvanced" #[item]="data"
/> v-for="item in ['resetBefore', 'submitBefore', 'advanceBefore', 'advanceAfter']"
>
<slot :name="item" v-bind="data" />
</template>
</FormAction>
<slot name="formFooter" /> <slot name="formFooter" />
</Row> </Row>
</Form> </Form>
......
...@@ -88,9 +88,13 @@ export function useForm(props?: Props): UseFormReturnType { ...@@ -88,9 +88,13 @@ export function useForm(props?: Props): UseFormReturnType {
form.setFieldsValue<T>(values); form.setFieldsValue<T>(values);
}, },
appendSchemaByField: async (schema: FormSchema, prefixField?: string | undefined) => { appendSchemaByField: async (
schema: FormSchema,
prefixField: string | undefined,
first: boolean
) => {
const form = await getForm(); const form = await getForm();
form.appendSchemaByField(schema, prefixField); form.appendSchemaByField(schema, prefixField, first);
}, },
submit: async (): Promise<any> => { submit: async (): Promise<any> => {
......
...@@ -33,7 +33,11 @@ export interface FormActionType { ...@@ -33,7 +33,11 @@ export interface FormActionType {
updateSchema: (data: Partial<FormSchema> | Partial<FormSchema>[]) => Promise<void>; updateSchema: (data: Partial<FormSchema> | Partial<FormSchema>[]) => Promise<void>;
setProps: (formProps: Partial<FormProps>) => Promise<void>; setProps: (formProps: Partial<FormProps>) => Promise<void>;
removeSchemaByFiled: (field: string | string[]) => Promise<void>; removeSchemaByFiled: (field: string | string[]) => Promise<void>;
appendSchemaByField: (schema: FormSchema, prefixField?: string) => Promise<void>; appendSchemaByField: (
schema: FormSchema,
prefixField: string | undefined,
first: boolean | undefined
) => Promise<void>;
validateFields: (nameList?: NamePath[]) => Promise<any>; validateFields: (nameList?: NamePath[]) => Promise<any>;
validate: (nameList?: NamePath[]) => Promise<any>; validate: (nameList?: NamePath[]) => Promise<any>;
scrollToField: (name: NamePath, options?: ScrollOptions) => Promise<void>; scrollToField: (name: NamePath, options?: ScrollOptions) => Promise<void>;
......
...@@ -45,7 +45,7 @@ ...@@ -45,7 +45,7 @@
contentStyle: { contentStyle: {
type: Object as PropType<CSSProperties>, type: Object as PropType<CSSProperties>,
}, },
contentBackgrond: propTypes.bool, contentBackground: propTypes.bool,
contentFullHeight: propTypes.bool, contentFullHeight: propTypes.bool,
}, },
setup(props, { slots }) { setup(props, { slots }) {
...@@ -71,8 +71,8 @@ ...@@ -71,8 +71,8 @@
const getContentStyle = computed( const getContentStyle = computed(
(): CSSProperties => { (): CSSProperties => {
const { contentBackgrond, contentFullHeight, contentStyle } = props; const { contentBackground, contentFullHeight, contentStyle } = props;
const bg = contentBackgrond ? { backgroundColor: '#fff' } : {}; const bg = contentBackground ? { backgroundColor: '#fff' } : {};
if (!contentFullHeight) { if (!contentFullHeight) {
return { ...bg, ...contentStyle }; return { ...bg, ...contentStyle };
} }
......
...@@ -87,6 +87,7 @@ ...@@ -87,6 +87,7 @@
'row-mouseleave', 'row-mouseleave',
'edit-end', 'edit-end',
'edit-cancel', 'edit-cancel',
'edit-row-end',
], ],
setup(props, { attrs, emit, slots }) { setup(props, { attrs, emit, slots }) {
const tableElRef = ref<ComponentRef>(null); const tableElRef = ref<ComponentRef>(null);
......
...@@ -210,7 +210,7 @@ ...@@ -210,7 +210,7 @@
return true; return true;
} }
async function handleSubmit() { async function handleSubmit(needEmit = true) {
const isPass = await handleSubmiRule(); const isPass = await handleSubmiRule();
if (!isPass) return false; if (!isPass) return false;
const { column, index } = props; const { column, index } = props;
...@@ -220,7 +220,7 @@ ...@@ -220,7 +220,7 @@
const dataKey = (dataIndex || key) as string; const dataKey = (dataIndex || key) as string;
const record = await table.updateTableData(index, dataKey, unref(getValues)); const record = await table.updateTableData(index, dataKey, unref(getValues));
table.emit?.('edit-end', { record, index, key, value: unref(currentValueRef) }); needEmit && table.emit?.('edit-end', { record, index, key, value: unref(currentValueRef) });
isEdit.value = false; isEdit.value = false;
} }
...@@ -274,7 +274,8 @@ ...@@ -274,7 +274,8 @@
if (!pass) return; if (!pass) return;
const submitFns = props.record?.submitCbs || []; const submitFns = props.record?.submitCbs || [];
submitFns.forEach((fn) => fn()); submitFns.forEach((fn) => fn(false));
table.emit?.('edit-row-end');
return true; return true;
} }
// isArray(props.record?.submitCbs) && props.record?.submitCbs.forEach((fn) => fn()); // isArray(props.record?.submitCbs) && props.record?.submitCbs.forEach((fn) => fn());
......
...@@ -93,11 +93,10 @@ const getCalcContentWidth = computed(() => { ...@@ -93,11 +93,10 @@ const getCalcContentWidth = computed(() => {
unref(getIsTopMenu) || !unref(getShowMenu) || (unref(getSplit) && unref(getMenuHidden)) unref(getIsTopMenu) || !unref(getShowMenu) || (unref(getSplit) && unref(getMenuHidden))
? 0 ? 0
: unref(getIsMixSidebar) : unref(getIsMixSidebar)
? unref(getCollapsed) ? (unref(getCollapsed) ? SIDE_BAR_MINI_WIDTH : SIDE_BAR_SHOW_TIT_MINI_WIDTH) +
? SIDE_BAR_MINI_WIDTH (unref(getMixSideFixed) && unref(mixSideHasChildren) ? unref(getRealWidth) : 0)
: SIDE_BAR_SHOW_TIT_MINI_WIDTH +
(unref(getMixSideFixed) && unref(mixSideHasChildren) ? unref(getRealWidth) : 0)
: unref(getRealWidth); : unref(getRealWidth);
return `calc(100% - ${unref(width)}px)`; return `calc(100% - ${unref(width)}px)`;
}); });
......
...@@ -154,8 +154,8 @@ const transform: AxiosTransform = { ...@@ -154,8 +154,8 @@ const transform: AxiosTransform = {
const { t } = useI18n(); const { t } = useI18n();
errorStore.setupErrorHandle(error); errorStore.setupErrorHandle(error);
const { response, code, message } = error || {}; const { response, code, message } = error || {};
const msg: string = response?.data?.error ? response.data.error.message : ''; const msg: string = response?.data?.error?.message ?? '';
const err: string = error?.toString(); const err: string = error?.toString?.() ?? '';
try { try {
if (code === 'ECONNABORTED' && message.indexOf('timeout') !== -1) { if (code === 'ECONNABORTED' && message.indexOf('timeout') !== -1) {
createMessage.error(t('sys.api.apiTimeoutMessage')); createMessage.error(t('sys.api.apiTimeoutMessage'));
......
<template> <template>
<PageWrapper title="基础详情页" contentBackgrond> <PageWrapper title="基础详情页" contentBackground>
<Description <Description
size="middle" size="middle"
title="退款申请" title="退款申请"
......
<template> <template>
<PageWrapper title="单号:234231029431" contentBackgrond> <PageWrapper title="单号:234231029431" contentBackground>
<template #extra> <template #extra>
<a-button> 操作一 </a-button> <a-button> 操作一 </a-button>
<a-button> 操作二 </a-button> <a-button> 操作二 </a-button>
......
<template> <template>
<PageWrapper <PageWrapper
title="基础表单" title="基础表单"
contentBackgrond contentBackground
content=" 表单页用于向用户收集或验证信息,基础表单常见于数据项较少的表单场景。" content=" 表单页用于向用户收集或验证信息,基础表单常见于数据项较少的表单场景。"
> >
<BasicForm @register="register" /> <BasicForm @register="register" />
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
<PageWrapper <PageWrapper
class="high-form" class="high-form"
title="高级表单" title="高级表单"
contentBackgrond contentBackground
content=" 高级表单常见于一次性输入和提交大批量数据的场景。" content=" 高级表单常见于一次性输入和提交大批量数据的场景。"
> >
<a-card title="仓库管理" :bordered="false"> <a-card title="仓库管理" :bordered="false">
......
<template> <template>
<PageWrapper <PageWrapper
title="分步表单" title="分步表单"
contentBackgrond contentBackground
content=" 将一个冗长或用户不熟悉的表单任务分成多个步骤,指导用户完成。" content=" 将一个冗长或用户不熟悉的表单任务分成多个步骤,指导用户完成。"
> >
<div class="step-form-form"> <div class="step-form-form">
......
<template> <template>
<PageWrapper contentBackgrond title="按钮权限控制" contentClass="p-4"> <PageWrapper contentBackground title="按钮权限控制" contentClass="p-4">
<Alert message="刷新后会还原" show-icon /> <Alert message="刷新后会还原" show-icon />
<CurrentPermissionMode /> <CurrentPermissionMode />
......
<template> <template>
<PageWrapper <PageWrapper
title="后台权限示例" title="后台权限示例"
contentBackgrond contentBackground
contentClass="p-4" contentClass="p-4"
content="目前mock了两组数据, id为1 和 2 具体返回的菜单可以在mock/sys/menu.ts内查看" content="目前mock了两组数据, id为1 和 2 具体返回的菜单可以在mock/sys/menu.ts内查看"
> >
......
<template> <template>
<PageWrapper <PageWrapper
title="前端权限按钮示例" title="前端权限按钮示例"
contentBackgrond contentBackground
contentClass="p-4" contentClass="p-4"
content="由于刷新的时候会请求用户信息接口,会根据接口重置角色信息,所以刷新后界面会恢复原样,如果不需要,可以注释 src/layout/default/index内的获取用户信息接口" content="由于刷新的时候会请求用户信息接口,会根据接口重置角色信息,所以刷新后界面会恢复原样,如果不需要,可以注释 src/layout/default/index内的获取用户信息接口"
> >
......
<template> <template>
<PageWrapper <PageWrapper
title="前端权限示例" title="前端权限示例"
contentBackgrond contentBackground
contentClass="p-4" contentClass="p-4"
content="由于刷新的时候会请求用户信息接口,会根据接口重置角色信息,所以刷新后界面会恢复原样,如果不需要,可以注释 src/layout/default/index内的获取用户信息接口" content="由于刷新的时候会请求用户信息接口,会根据接口重置角色信息,所以刷新后界面会恢复原样,如果不需要,可以注释 src/layout/default/index内的获取用户信息接口"
> >
......
<template> <template>
<PageWrapper title="Tree函数操作示例" contentBackgrond contentClass="p-4"> <PageWrapper title="Tree函数操作示例" contentBackground contentClass="p-4">
<div class="mb-4"> <div class="mb-4">
<a-button @click="handleLevel(2)" class="mr-2">显示到第2级</a-button> <a-button @click="handleLevel(2)" class="mr-2">显示到第2级</a-button>
<a-button @click="handleLevel(1)" class="mr-2">显示到第1级</a-button> <a-button @click="handleLevel(1)" class="mr-2">显示到第1级</a-button>
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论