Skip to content

Commit

Permalink
fix: some error
Browse files Browse the repository at this point in the history
  • Loading branch information
anncwb committed Oct 30, 2020
1 parent 9abf176 commit 2407b33
Show file tree
Hide file tree
Showing 28 changed files with 359 additions and 101 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.zh_CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,14 @@
- 添加部分注释
- pwa 图标补充
- types 类型调整
- 升级`ant-design-vue``beta.11`,并修改带来的已知问题

### 🐛 Bug Fixes

- 修复本地代理 post 接口到 https 地址超时错误
- 修复 modal 在不显示 footer 的时候全屏高度计算问题
- 修复表单重置未删除校验信息错误
- 修复顶部菜单分割模式样式问题

## 2.0.0-rc.6 (2020-10-28)

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
},
"dependencies": {
"@iconify/iconify": "^2.0.0-rc.1",
"ant-design-vue": "^2.0.0-beta.10",
"ant-design-vue": "^2.0.0-beta.11",
"apexcharts": "^3.22.0",
"axios": "^0.21.0",
"echarts": "^4.9.0",
Expand Down
49 changes: 20 additions & 29 deletions src/components/Drawer/src/BasicDrawer.tsx
Original file line number Diff line number Diff line change
@@ -1,17 +1,6 @@
import { Drawer, Row, Col, Button } from 'ant-design-vue';
import {
defineComponent,
ref,
computed,
watchEffect,
watch,
unref,
// getCurrentInstance,
nextTick,
toRaw,
} from 'vue';
import { defineComponent, ref, computed, watchEffect, watch, unref, nextTick, toRaw } from 'vue';
import { BasicTitle } from '/@/components/Basic';
// import { ScrollContainer, ScrollContainerOptions } from '/@/components/Container/index';
import { FullLoading } from '/@/components/Loading/index';

import { getSlot } from '/@/utils/helper/tsxHelper';
Expand All @@ -21,8 +10,6 @@ import { DrawerInstance, DrawerProps } from './types';
import { basicProps } from './props';
import { isFunction, isNumber } from '/@/utils/is';
import { LeftOutlined } from '@ant-design/icons-vue';
// import { appStore } from '/@/store/modules/app';
// import { useRouter } from 'vue-router';
import { buildUUID } from '/@/utils/uuid';
import { deepMerge } from '/@/utils';
import './index.less';
Expand All @@ -38,7 +25,6 @@ export default defineComponent({
const visibleRef = ref(false);
const propsRef = ref<Partial<DrawerProps> | null>(null);

// 自定义title组件:获得title
const getMergeProps = computed((): any => {
return deepMerge(toRaw(props), unref(propsRef));
});
Expand Down Expand Up @@ -68,9 +54,11 @@ export default defineComponent({
}
return opt;
});

watchEffect(() => {
visibleRef.value = props.visible;
});

watch(
() => visibleRef.value,
(visible) => {
Expand All @@ -83,6 +71,15 @@ export default defineComponent({
}
);

// 底部按钮自定义实现,
const getFooterHeight = computed(() => {
const { footerHeight, showFooter }: DrawerProps = unref(getProps);
if (showFooter && footerHeight) {
return isNumber(footerHeight) ? `${footerHeight}px` : `${footerHeight.replace('px', '')}px`;
}
return `0px`;
});

// 取消事件
async function onClose(e: any) {
const { closeFunc } = unref(getProps);
Expand All @@ -103,14 +100,6 @@ export default defineComponent({
}
}

// 底部按钮自定义实现,
const getFooterHeight = computed(() => {
const { footerHeight, showFooter }: DrawerProps = unref(getProps);
if (showFooter && footerHeight) {
return isNumber(footerHeight) ? `${footerHeight}px` : `${footerHeight.replace('px', '')}px`;
}
return `0px`;
});
function renderFooter() {
const {
showCancelBtn,
Expand Down Expand Up @@ -171,11 +160,13 @@ export default defineComponent({
)}
</Col>
)}

{title && (
<Col style="flex:1" class={[`${prefixCls}__detail-title`, 'ellipsis', 'px-2']}>
{() => title}
</Col>
)}

{getSlot(slots, 'titleToolbar')}
</>
)}
Expand Down Expand Up @@ -208,22 +199,22 @@ export default defineComponent({
title: () => renderHeader(),
default: () => (
<>
<FullLoading
absolute
class={[!unref(getProps).loading ? 'hidden' : '']}
tip="加载中..."
/>
<div
ref={scrollRef}
{...attrs}
data-id="123"
style={{
position: 'relative',
height: `calc(100% - ${footerHeight})`,
overflow: 'auto',
padding: '16px',
paddingBottom: '30px',
}}
>
<FullLoading
absolute
tip="加载中..."
class={[!unref(getProps).loading ? 'hidden' : '']}
/>
{getSlot(slots, 'default')}
</div>
{renderFooter()}
Expand Down
6 changes: 3 additions & 3 deletions src/components/Drawer/src/types.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { Button } from 'ant-design-vue/types/button/button';
import type { ButtonProps } from 'ant-design-vue/lib/button/buttonTypes';
import type { CSSProperties, VNodeChild } from 'vue';
import type { ScrollContainerOptions } from '/@/components/Container/index';

Expand Down Expand Up @@ -47,13 +47,13 @@ export interface DrawerFooterProps {
* The ok button props, follow jsx rules
* @type object
*/
okButtonProps: { props: Button; on: {} };
okButtonProps: { props: ButtonProps; on: {} };

/**
* The cancel button props, follow jsx rules
* @type object
*/
cancelButtonProps: { props: Button; on: {} };
cancelButtonProps: { props: ButtonProps; on: {} };
/**
* Whether to apply loading visual effect for OK button or not
* @default false
Expand Down
5 changes: 3 additions & 2 deletions src/components/Form/src/hooks/useForm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@ import { isInSetup } from '/@/utils/helper/vueHelper';
import { isProdMode } from '/@/utils/env';

import type { FormProps, FormActionType, UseFormReturnType, FormSchema } from '../types/form';
import type { NamePath } from 'ant-design-vue/types/form/form-item';
import type { ValidateFields } from 'ant-design-vue/types/form/form';
import type { NamePath } from 'ant-design-vue/lib/form/interface';

export declare type ValidateFields = (nameList?: NamePath[]) => Promise<any>;

export function useForm(props?: Partial<FormProps>): UseFormReturnType {
isInSetup();
Expand Down
7 changes: 3 additions & 4 deletions src/components/Form/src/hooks/useFormAction.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import type { ComputedRef, Ref } from 'vue';
import type { FormProps, FormSchema } from '../types/form';
import type { Form as FormType } from 'ant-design-vue/types/form/form';
import type { NamePath } from 'ant-design-vue/types/form/form-item';
import type { FormProps, FormSchema, FormActionType } from '../types/form';
import type { NamePath } from 'ant-design-vue/lib/form/interface';

import { unref, toRaw } from 'vue';

Expand All @@ -17,7 +16,7 @@ interface UseFormActionContext {
getSchema: ComputedRef<FormSchema[]>;
formModel: any;
defaultValueRef: Ref<any>;
formElRef: Ref<FormType>;
formElRef: Ref<FormActionType>;
schemaRef: Ref<FormSchema[]>;
handleFormValues: Fn;
actionState: {
Expand Down
9 changes: 5 additions & 4 deletions src/components/Form/src/types/form.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { Form, NamePath, ValidationRule } from 'ant-design-vue/types/form/form';
import type { NamePath, RuleObject } from 'ant-design-vue/lib/form/interface';
import type { VNode } from 'vue';
import type { BasicButtonProps } from '/@/components/Button/types';
import type { FormItem } from './formItem';
Expand All @@ -17,7 +17,7 @@ export interface ButtonProps extends BasicButtonProps {
text?: string;
}

export interface FormActionType extends Form {
export interface FormActionType {
submit: () => Promise<void>;
setFieldsValue: <T>(values: T) => void;
resetFields: () => Promise<any>;
Expand All @@ -29,6 +29,7 @@ export interface FormActionType extends Form {
appendSchemaByField: (schema: FormSchema, prefixField?: string) => void;
validateFields: (nameList?: NamePath[]) => Promise<any>;
validate: (nameList?: NamePath[]) => Promise<any>;
scrollToField: (name: NamePath, options?: ScrollOptions) => void;
}
export type RegisterFn = (formInstance: FormActionType) => void;

Expand Down Expand Up @@ -113,7 +114,7 @@ export interface FormSchema {
componentProps?: any;

// 校验规则
rules?: ValidationRule[];
rules?: RuleObject[];
// 校验信息是否加入label
rulesMessageJoinLabel?: boolean;

Expand Down Expand Up @@ -150,7 +151,7 @@ export interface FormSchema {

dynamicDisabled?: boolean | ((renderCallbackParams: RenderCallbackParams) => boolean);

dynamicRules?: (renderCallbackParams: RenderCallbackParams) => ValidationRule[];
dynamicRules?: (renderCallbackParams: RenderCallbackParams) => RuleObject[];
}
export interface HelpComponentProps {
maxWidth: string;
Expand Down
8 changes: 4 additions & 4 deletions src/components/Form/src/types/formItem.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { NamePath } from 'ant-design-vue/types/form/form-item';
import type { Col } from 'ant-design-vue/types/grid/col';
import type { NamePath } from 'ant-design-vue/lib/form/interface';
import type { ColProps } from 'ant-design-vue/lib/grid/Col';
import type { VNodeChild } from 'vue';

export interface FormItem {
Expand Down Expand Up @@ -39,7 +39,7 @@ export interface FormItem {
* The layout of label. You can set span offset to something like {span: 3, offset: 12} or sm: {span: 3, offset: 12} same as with <Col>
* @type Col
*/
labelCol?: Col;
labelCol?: ColProps;

/**
* Whether provided or not, it will be generated by the validation rule.
Expand All @@ -58,7 +58,7 @@ export interface FormItem {
* The layout for input controls, same as labelCol
* @type Col
*/
wrapperCol?: Col;
wrapperCol?: ColProps;
/**
* Set sub label htmlFor.
*/
Expand Down
3 changes: 1 addition & 2 deletions src/components/Form/src/types/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { ColSpanType } from 'ant-design-vue/types/grid/col';

type ColSpanType = number | string;
export interface ColEx {
style?: any;
/**
Expand Down
4 changes: 2 additions & 2 deletions src/components/Menu/src/SearchInput.vue
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,7 @@
margin: 12px 9px;
&__search--dark {
// .setPlaceholder('.ant-input',#fff);
.ant-input-affix-wrapper,
.ant-input {
.set-bg();
Expand All @@ -91,6 +90,7 @@
}
&__search--light {
.ant-input-affix-wrapper,
.ant-input {
color: @text-color-base;
background: #fff;
Expand Down
4 changes: 2 additions & 2 deletions src/components/Menu/src/index.less
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,8 @@
&.ant-menu-light {
.ant-menu-item {
&.basic-menu-item__level1 {
height: 46px;
line-height: 46px;
height: 38px;
line-height: 38px;
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/components/Modal/src/provideModal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@ export function provideModal(redoHeight: Fn) {
}

export function injectModal(): Fn {
return inject(key) as Fn;
return inject(key, () => {}) as Fn;
}
6 changes: 3 additions & 3 deletions src/components/Table/src/components/renderFooter.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { Table } from 'ant-design-vue';
import { TableRowSelection } from 'ant-design-vue/types/table/table';
import { cloneDeep } from 'lodash-es';
import { unref, ComputedRef } from 'vue';
import { BasicColumn } from '../types/table';
import { isFunction } from '/@/utils/is';
import type { BasicColumn, TableRowSelection } from '../types/table';

export default ({
scroll = {},
columnsRef,
Expand All @@ -17,7 +17,7 @@ export default ({
summaryFunc: any;
rowKey?: string;
dataSourceRef: ComputedRef<any[]>;
rowSelectionRef: ComputedRef<TableRowSelection<any> | null>;
rowSelectionRef: ComputedRef<TableRowSelection | null>;
}) => {
if (!summaryFunc) {
return;
Expand Down
2 changes: 1 addition & 1 deletion src/components/Table/src/const.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { SorterResult } from 'ant-design-vue/types/table/table';
import type { SorterResult } from './types/table';

export const ROW_KEY = 'key';

Expand Down
5 changes: 2 additions & 3 deletions src/components/Table/src/hooks/useRowSelection.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { computed, ref, unref, ComputedRef } from 'vue';
import { BasicTableProps } from '../types/table';
import { TableRowSelection } from 'ant-design-vue/types/table/table';
import type { BasicTableProps, TableRowSelection } from '../types/table';
import { useProps } from './useProps';

/* eslint-disable */
Expand All @@ -10,7 +9,7 @@ export function useRowSelection(refProps: ComputedRef<BasicTableProps>, emit: Em
const selectedRowKeysRef = ref<string[]>([]);
const selectedRowRef = ref<any[]>([]);

const getRowSelectionRef = computed((): TableRowSelection<any> | null => {
const getRowSelectionRef = computed((): TableRowSelection | null => {
const rowSelection = unref(propsRef).rowSelection;
if (!rowSelection) {
return null;
Expand Down
8 changes: 5 additions & 3 deletions src/components/Table/src/props.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
import type { PropType } from 'vue';
import type { PaginationProps } from './types/pagination';
import type { BasicColumn, FetchSetting, TableSetting } from './types/table';
import type {
BasicColumn,
FetchSetting,
TableSetting,
SorterResult,
TableCustomRecord,
TableRowSelection,
} from 'ant-design-vue/types/table/table';
} from './types/table';
import type { FormProps } from '/@/components/Form/index';
import { DEFAULT_SORT_FN, FETCH_SETTING } from './const';

Expand Down Expand Up @@ -127,7 +129,7 @@ export const basicProps = {
default: 0,
},
rowSelection: {
type: Object as PropType<TableRowSelection<any> | null>,
type: Object as PropType<TableRowSelection | null>,
default: null,
},
title: {
Expand Down
Loading

0 comments on commit 2407b33

Please sign in to comment.