Skip to content

Commit

Permalink
fix(form): formAction slot not work
Browse files Browse the repository at this point in the history
  • Loading branch information
anncwb committed Jan 7, 2021
1 parent a1c3c53 commit de5bf75
Show file tree
Hide file tree
Showing 21 changed files with 136 additions and 116 deletions.
8 changes: 8 additions & 0 deletions CHANGELOG.zh_CN.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
## Wip

### ✨ Refactor

独立组件配置到 `/@/settings/componentsSetting`

### ✨ Features

- 新增`mixSideTrigger`配置。用于配置左侧混合模式菜单打开方式。可选`hover`,默认`click`
Expand All @@ -16,6 +20,10 @@
- 修复`layout` 收缩展开功能在分割模式下失效
- 修复 modal 高度计算错误

### 🎫 Chores

- 文档更新

## 2.0.0-rc.15 (2020-12-31)

### ✨ 表格破坏性更新
Expand Down
18 changes: 9 additions & 9 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "vben-admin-2.0",
"name": "vben-admin",
"version": "2.0.0-rc.15",
"scripts": {
"bootstrap": "yarn install",
Expand Down Expand Up @@ -35,7 +35,7 @@
"path-to-regexp": "^6.2.0",
"qrcode": "^1.4.4",
"sortablejs": "^1.12.0",
"vditor": "^3.7.4",
"vditor": "^3.7.5",
"vue": "^3.0.5",
"vue-i18n": "9.0.0-beta.14",
"vue-router": "^4.0.2",
Expand All @@ -48,7 +48,7 @@
"devDependencies": {
"@commitlint/cli": "^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",
"@purge-icons/generated": "^0.4.1",
"@types/echarts": "^4.9.3",
Expand All @@ -63,8 +63,8 @@
"@types/sortablejs": "^1.10.6",
"@types/yargs": "^15.0.12",
"@types/zxcvbn": "^4.4.0",
"@typescript-eslint/eslint-plugin": "^4.11.1",
"@typescript-eslint/parser": "^4.11.1",
"@typescript-eslint/eslint-plugin": "^4.12.0",
"@typescript-eslint/parser": "^4.12.0",
"@vue/compiler-sfc": "^3.0.5",
"@vuedx/typecheck": "^0.4.1",
"@vuedx/typescript-plugin-vue": "^0.4.1",
Expand All @@ -75,11 +75,11 @@
"cross-env": "^7.0.3",
"dot-prop": "^6.0.1",
"dotenv": "^8.2.0",
"eslint": "^7.16.0",
"eslint": "^7.17.0",
"eslint-config-prettier": "^7.1.0",
"eslint-plugin-prettier": "^3.3.0",
"eslint-plugin-vue": "^7.4.0",
"esno": "^0.3.0",
"eslint-plugin-prettier": "^3.3.1",
"eslint-plugin-vue": "^7.4.1",
"esno": "^0.4.0",
"fs-extra": "^9.0.1",
"globrex": "^0.1.2",
"husky": "^4.3.6",
Expand Down
12 changes: 8 additions & 4 deletions src/components/Form/src/BasicForm.vue
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,14 @@
</FormItem>
</template>

<FormAction
v-bind="{ ...getProps, ...advanceState }"
@toggle-advanced="handleToggleAdvanced"
/>
<FormAction v-bind="{ ...getProps, ...advanceState }" @toggle-advanced="handleToggleAdvanced">
<template
#[item]="data"
v-for="item in ['resetBefore', 'submitBefore', 'advanceBefore', 'advanceAfter']"
>
<slot :name="item" v-bind="data" />
</template>
</FormAction>
<slot name="formFooter" />
</Row>
</Form>
Expand Down
8 changes: 6 additions & 2 deletions src/components/Form/src/hooks/useForm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,9 +88,13 @@ export function useForm(props?: Props): UseFormReturnType {
form.setFieldsValue<T>(values);
},

appendSchemaByField: async (schema: FormSchema, prefixField?: string | undefined) => {
appendSchemaByField: async (
schema: FormSchema,
prefixField: string | undefined,
first: boolean
) => {
const form = await getForm();
form.appendSchemaByField(schema, prefixField);
form.appendSchemaByField(schema, prefixField, first);
},

submit: async (): Promise<any> => {
Expand Down
6 changes: 5 additions & 1 deletion src/components/Form/src/types/form.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,11 @@ export interface FormActionType {
updateSchema: (data: Partial<FormSchema> | Partial<FormSchema>[]) => Promise<void>;
setProps: (formProps: Partial<FormProps>) => 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>;
validate: (nameList?: NamePath[]) => Promise<any>;
scrollToField: (name: NamePath, options?: ScrollOptions) => Promise<void>;
Expand Down
6 changes: 3 additions & 3 deletions src/components/Page/src/PageWrapper.vue
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
contentStyle: {
type: Object as PropType<CSSProperties>,
},
contentBackgrond: propTypes.bool,
contentBackground: propTypes.bool,
contentFullHeight: propTypes.bool,
},
setup(props, { slots }) {
Expand All @@ -71,8 +71,8 @@
const getContentStyle = computed(
(): CSSProperties => {
const { contentBackgrond, contentFullHeight, contentStyle } = props;
const bg = contentBackgrond ? { backgroundColor: '#fff' } : {};
const { contentBackground, contentFullHeight, contentStyle } = props;
const bg = contentBackground ? { backgroundColor: '#fff' } : {};
if (!contentFullHeight) {
return { ...bg, ...contentStyle };
}
Expand Down
1 change: 1 addition & 0 deletions src/components/Table/src/BasicTable.vue
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@
'row-mouseleave',
'edit-end',
'edit-cancel',
'edit-row-end',
],
setup(props, { attrs, emit, slots }) {
const tableElRef = ref<ComponentRef>(null);
Expand Down
7 changes: 4 additions & 3 deletions src/components/Table/src/components/editable/EditableCell.vue
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@
return true;
}
async function handleSubmit() {
async function handleSubmit(needEmit = true) {
const isPass = await handleSubmiRule();
if (!isPass) return false;
const { column, index } = props;
Expand All @@ -220,7 +220,7 @@
const dataKey = (dataIndex || key) as string;
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;
}
Expand Down Expand Up @@ -274,7 +274,8 @@
if (!pass) return;
const submitFns = props.record?.submitCbs || [];
submitFns.forEach((fn) => fn());
submitFns.forEach((fn) => fn(false));
table.emit?.('edit-row-end');
return true;
}
// isArray(props.record?.submitCbs) && props.record?.submitCbs.forEach((fn) => fn());
Expand Down
7 changes: 3 additions & 4 deletions src/hooks/setting/useMenuSetting.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,11 +93,10 @@ const getCalcContentWidth = computed(() => {
unref(getIsTopMenu) || !unref(getShowMenu) || (unref(getSplit) && unref(getMenuHidden))
? 0
: unref(getIsMixSidebar)
? unref(getCollapsed)
? SIDE_BAR_MINI_WIDTH
: SIDE_BAR_SHOW_TIT_MINI_WIDTH +
(unref(getMixSideFixed) && unref(mixSideHasChildren) ? unref(getRealWidth) : 0)
? (unref(getCollapsed) ? SIDE_BAR_MINI_WIDTH : SIDE_BAR_SHOW_TIT_MINI_WIDTH) +
(unref(getMixSideFixed) && unref(mixSideHasChildren) ? unref(getRealWidth) : 0)
: unref(getRealWidth);

return `calc(100% - ${unref(width)}px)`;
});

Expand Down
4 changes: 2 additions & 2 deletions src/utils/http/axios/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -154,8 +154,8 @@ const transform: AxiosTransform = {
const { t } = useI18n();
errorStore.setupErrorHandle(error);
const { response, code, message } = error || {};
const msg: string = response?.data?.error ? response.data.error.message : '';
const err: string = error?.toString();
const msg: string = response?.data?.error?.message ?? '';
const err: string = error?.toString?.() ?? '';
try {
if (code === 'ECONNABORTED' && message.indexOf('timeout') !== -1) {
createMessage.error(t('sys.api.apiTimeoutMessage'));
Expand Down
2 changes: 1 addition & 1 deletion src/views/demo/page/desc/basic/index.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<template>
<PageWrapper title="基础详情页" contentBackgrond>
<PageWrapper title="基础详情页" contentBackground>
<Description
size="middle"
title="退款申请"
Expand Down
2 changes: 1 addition & 1 deletion src/views/demo/page/desc/high/index.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<template>
<PageWrapper title="单号:234231029431" contentBackgrond>
<PageWrapper title="单号:234231029431" contentBackground>
<template #extra>
<a-button> 操作一 </a-button>
<a-button> 操作二 </a-button>
Expand Down
2 changes: 1 addition & 1 deletion src/views/demo/page/form/basic/index.vue
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<template>
<PageWrapper
title="基础表单"
contentBackgrond
contentBackground
content=" 表单页用于向用户收集或验证信息,基础表单常见于数据项较少的表单场景。"
>
<BasicForm @register="register" />
Expand Down
2 changes: 1 addition & 1 deletion src/views/demo/page/form/high/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<PageWrapper
class="high-form"
title="高级表单"
contentBackgrond
contentBackground
content=" 高级表单常见于一次性输入和提交大批量数据的场景。"
>
<a-card title="仓库管理" :bordered="false">
Expand Down
2 changes: 1 addition & 1 deletion src/views/demo/page/form/step/index.vue
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<template>
<PageWrapper
title="分步表单"
contentBackgrond
contentBackground
content=" 将一个冗长或用户不熟悉的表单任务分成多个步骤,指导用户完成。"
>
<div class="step-form-form">
Expand Down
2 changes: 1 addition & 1 deletion src/views/demo/permission/back/Btn.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<template>
<PageWrapper contentBackgrond title="按钮权限控制" contentClass="p-4">
<PageWrapper contentBackground title="按钮权限控制" contentClass="p-4">
<Alert message="刷新后会还原" show-icon />

<CurrentPermissionMode />
Expand Down
2 changes: 1 addition & 1 deletion src/views/demo/permission/back/index.vue
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<template>
<PageWrapper
title="后台权限示例"
contentBackgrond
contentBackground
contentClass="p-4"
content="目前mock了两组数据, id为1 和 2 具体返回的菜单可以在mock/sys/menu.ts内查看"
>
Expand Down
2 changes: 1 addition & 1 deletion src/views/demo/permission/front/Btn.vue
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<template>
<PageWrapper
title="前端权限按钮示例"
contentBackgrond
contentBackground
contentClass="p-4"
content="由于刷新的时候会请求用户信息接口,会根据接口重置角色信息,所以刷新后界面会恢复原样,如果不需要,可以注释 src/layout/default/index内的获取用户信息接口"
>
Expand Down
2 changes: 1 addition & 1 deletion src/views/demo/permission/front/index.vue
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<template>
<PageWrapper
title="前端权限示例"
contentBackgrond
contentBackground
contentClass="p-4"
content="由于刷新的时候会请求用户信息接口,会根据接口重置角色信息,所以刷新后界面会恢复原样,如果不需要,可以注释 src/layout/default/index内的获取用户信息接口"
>
Expand Down
2 changes: 1 addition & 1 deletion src/views/demo/tree/ActionTree.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<template>
<PageWrapper title="Tree函数操作示例" contentBackgrond contentClass="p-4">
<PageWrapper title="Tree函数操作示例" contentBackground contentClass="p-4">
<div class="mb-4">
<a-button @click="handleLevel(2)" class="mr-2">显示到第2级</a-button>
<a-button @click="handleLevel(1)" class="mr-2">显示到第1级</a-button>
Expand Down
Loading

0 comments on commit de5bf75

Please sign in to comment.