Commit c4937c4c authored by 陈帅's avatar 陈帅

BasicForm finish

parent 9c3225d1
export default { export default {
plugins: [ plugins: [
['umi-plugin-block-dev', {layout: 'ant-design-pro',}], [
['umi-plugin-react', { 'umi-plugin-block-dev',
{
layout: 'ant-design-pro',
menu: {
name: '主页',
icon: 'home',
},
},
],
[
'umi-plugin-react',
{
dva: true, dva: true,
locale: true, locale: true,
antd: true, antd: true,
}] },
],
], ],
} };
import { queryCurrent } from './service'; import { queryCurrent } from './service';
import { Dispatch } from 'redux';
import { CurrentUser } from './data'; import { CurrentUser } from './data';
export interface ModalState { export interface ModalState {
currentUser: CurrentUser; currentUser: Partial<CurrentUser>;
} }
type callType<T, A extends any[], R> = (thisArg?: T, ...args: A) => R; import { Reducer } from 'redux';
Function.call; import { EffectsCommandMap } from 'dva';
export default { import { AnyAction } from 'redux';
export type Effect = (
action: AnyAction,
effects: EffectsCommandMap & { select: <T>(func: (state: ModalState) => T) => T }
) => void;
export interface ModelType {
namespace: string;
state: ModalState;
effects: {
fetchCurrent: Effect;
};
reducers: {
saveCurrentUser: Reducer<ModalState>;
};
}
const Model: ModelType = {
namespace: 'BLOCK_NAME_CAMEL_CASE', namespace: 'BLOCK_NAME_CAMEL_CASE',
state: { state: {
...@@ -16,16 +33,7 @@ export default { ...@@ -16,16 +33,7 @@ export default {
}, },
effects: { effects: {
*fetchCurrent( *fetchCurrent(_, { call, put }) {
_: ModalState,
{
call,
put,
}: {
call: callType<Function, [], ReturnType<typeof queryCurrent>>;
put: Dispatch;
}
) {
const response = yield call(queryCurrent); const response = yield call(queryCurrent);
yield put({ yield put({
type: 'saveCurrentUser', type: 'saveCurrentUser',
...@@ -35,12 +43,7 @@ export default { ...@@ -35,12 +43,7 @@ export default {
}, },
reducers: { reducers: {
saveCurrentUser( saveCurrentUser(state, action) {
state: ModalState,
action: {
payload: CurrentUser;
}
) {
return { return {
...state, ...state,
currentUser: action.payload || {}, currentUser: action.payload || {},
...@@ -48,3 +51,5 @@ export default { ...@@ -48,3 +51,5 @@ export default {
}, },
}, },
}; };
export default Model;
...@@ -2,15 +2,17 @@ ...@@ -2,15 +2,17 @@
"name": "@umi-block/account-settings", "name": "@umi-block/account-settings",
"version": "0.0.1", "version": "0.0.1",
"description": "AccountSettings", "description": "AccountSettings",
"main": "src/index.js",
"scripts": {
"dev": "umi dev"
},
"repository": { "repository": {
"type": "git", "type": "git",
"url": "https://github.com/umijs/umi-blocks/ant-design-pro/accountsettings" "url": "https://github.com/umijs/umi-blocks/ant-design-pro/accountsettings"
}, },
"license": "ISC",
"main": "src/index.js",
"scripts": {
"dev": "umi dev"
},
"dependencies": { "dependencies": {
"@ant-design/pro-layout": "^4.0.5",
"antd": "^3.10.9", "antd": "^3.10.9",
"dva": "^2.4.0", "dva": "^2.4.0",
"react": "^16.6.3", "react": "^16.6.3",
...@@ -20,6 +22,5 @@ ...@@ -20,6 +22,5 @@
"umi": "^2.6.9", "umi": "^2.6.9",
"umi-plugin-block-dev": "^1.0.0", "umi-plugin-block-dev": "^1.0.0",
"umi-plugin-react": "^1.3.0-beta.1" "umi-plugin-react": "^1.3.0-beta.1"
}, }
"license": "ISC"
} }
\ No newline at end of file
import { query as queryUsers, queryCurrent, queryProvince, queryCity } from './service'; import { query as queryUsers, queryCurrent, queryProvince, queryCity } from './service';
import { Reducer } from 'redux';
import { EffectsCommandMap } from 'dva';
import { AnyAction } from 'redux';
import { CurrentUser, City, Province } from './data';
export default { export interface ModalState {
currentUser?: Partial<CurrentUser>;
province?: Province[];
city?: City[];
isLoading?: boolean;
}
export type Effect = (
action: AnyAction,
effects: EffectsCommandMap & { select: <T>(func: (state: ModalState) => T) => T }
) => void;
export interface ModelType {
namespace: string;
state: ModalState;
effects: {
fetchCurrent: Effect;
fetch: Effect;
fetchProvince: Effect;
fetchCity: Effect;
};
reducers: {
saveCurrentUser: Reducer<ModalState>;
changeNotifyCount: Reducer<ModalState>;
setProvince: Reducer<ModalState>;
setCity: Reducer<ModalState>;
changeLoading: Reducer<ModalState>;
};
}
const Model: ModelType = {
namespace: 'BLOCK_NAME_CAMEL_CASE', namespace: 'BLOCK_NAME_CAMEL_CASE',
state: { state: {
list: [],
currentUser: {}, currentUser: {},
province: [], province: [],
city: [], city: [],
isLoading: false,
}, },
effects: { effects: {
...@@ -46,19 +80,13 @@ export default { ...@@ -46,19 +80,13 @@ export default {
}, },
reducers: { reducers: {
save(state, action) {
return {
...state,
list: action.payload,
};
},
saveCurrentUser(state, action) { saveCurrentUser(state, action) {
return { return {
...state, ...state,
currentUser: action.payload || {}, currentUser: action.payload || {},
}; };
}, },
changeNotifyCount(state, action) { changeNotifyCount(state = {}, action) {
return { return {
...state, ...state,
currentUser: { currentUser: {
...@@ -88,3 +116,5 @@ export default { ...@@ -88,3 +116,5 @@ export default {
}, },
}, },
}; };
export default Model;
...@@ -2,15 +2,17 @@ ...@@ -2,15 +2,17 @@
"name": "@umi-block/advanced-form", "name": "@umi-block/advanced-form",
"version": "0.0.1", "version": "0.0.1",
"description": "AdvancedForm", "description": "AdvancedForm",
"main": "src/index.js",
"scripts": {
"dev": "umi dev"
},
"repository": { "repository": {
"type": "git", "type": "git",
"url": "https://github.com/umijs/umi-blocks/ant-design-pro/advancedform" "url": "https://github.com/umijs/umi-blocks/ant-design-pro/advancedform"
}, },
"license": "ISC",
"main": "src/index.js",
"scripts": {
"dev": "umi dev"
},
"dependencies": { "dependencies": {
"@ant-design/pro-layout": "^4.0.5",
"ant-design-pro": "^2.1.1", "ant-design-pro": "^2.1.1",
"antd": "^3.10.9", "antd": "^3.10.9",
"dva": "^2.4.0", "dva": "^2.4.0",
...@@ -20,8 +22,7 @@ ...@@ -20,8 +22,7 @@
}, },
"devDependencies": { "devDependencies": {
"umi": "^2.6.9", "umi": "^2.6.9",
"umi-plugin-react": "^1.7.2", "umi-plugin-block-dev": "^1.0.0",
"umi-plugin-block-dev": "^1.0.0" "umi-plugin-react": "^1.7.2"
}, }
"license": "ISC"
} }
\ No newline at end of file
import { message } from 'antd'; import { message } from 'antd';
import { fakeSubmitForm } from './service'; import { fakeSubmitForm } from './service';
import { EffectsCommandMap } from 'dva';
import { AnyAction } from 'redux';
export default { export interface ModalState {}
export type Effect = (
action: AnyAction,
effects: EffectsCommandMap & { select: <T>(func: (state: ModalState) => T) => T }
) => void;
export interface ModelType {
namespace: string;
state: ModalState;
effects: {
submitAdvancedForm: Effect;
};
}
const Model: ModelType = {
namespace: 'BLOCK_NAME_CAMEL_CASE', namespace: 'BLOCK_NAME_CAMEL_CASE',
state: {}, state: {},
...@@ -13,3 +30,5 @@ export default { ...@@ -13,3 +30,5 @@ export default {
}, },
}, },
}; };
export default Model;
...@@ -16,7 +16,8 @@ ...@@ -16,7 +16,8 @@
"dva": "^2.4.0", "dva": "^2.4.0",
"lodash-decorators": "^6.0.0", "lodash-decorators": "^6.0.0",
"react": "^16.6.3", "react": "^16.6.3",
"umi-request": "^1.0.0" "umi-request": "^1.0.0",
"@ant-design/pro-layout": "^4.0.5"
}, },
"devDependencies": { "devDependencies": {
"umi": "^2.6.9", "umi": "^2.6.9",
......
export interface AdvancedOperation1 {
key: string;
type: string;
name: string;
status: string;
updatedAt: string;
memo: string;
}
export interface AdvancedOperation2 {
key: string;
type: string;
name: string;
status: string;
updatedAt: string;
memo: string;
}
export interface AdvancedOperation3 {
key: string;
type: string;
name: string;
status: string;
updatedAt: string;
memo: string;
}
export interface AdvancedProfileData {
advancedOperation1: AdvancedOperation1[];
advancedOperation2: AdvancedOperation2[];
advancedOperation3: AdvancedOperation3[];
}
...@@ -24,6 +24,7 @@ import { TabsProps } from 'antd/lib/tabs'; ...@@ -24,6 +24,7 @@ import { TabsProps } from 'antd/lib/tabs';
import classNames from 'classnames'; import classNames from 'classnames';
import DescriptionList from './DescriptionList'; import DescriptionList from './DescriptionList';
import styles from './style.less'; import styles from './style.less';
import { AdvancedProfileData } from './data';
const { Step } = Steps; const { Step } = Steps;
const { Description } = DescriptionList; const { Description } = DescriptionList;
...@@ -230,45 +231,13 @@ const columns = [ ...@@ -230,45 +231,13 @@ const columns = [
key: 'memo', key: 'memo',
}, },
]; ];
export interface AdvancedOperation1 {
key: string;
type: string;
name: string;
status: string;
updatedAt: string;
memo: string;
}
export interface AdvancedOperation2 {
key: string;
type: string;
name: string;
status: string;
updatedAt: string;
memo: string;
}
export interface AdvancedOperation3 {
key: string;
type: string;
name: string;
status: string;
updatedAt: string;
memo: string;
}
export interface RootDataObject {
advancedOperation1: AdvancedOperation1[];
advancedOperation2: AdvancedOperation2[];
advancedOperation3: AdvancedOperation3[];
}
@connect( @connect(
({ ({
BLOCK_NAME_CAMEL_CASE, BLOCK_NAME_CAMEL_CASE,
loading, loading,
}: { }: {
BLOCK_NAME_CAMEL_CASE: RootDataObject; BLOCK_NAME_CAMEL_CASE: AdvancedProfileData;
loading: { loading: {
effects: { [key: string]: boolean }; effects: { [key: string]: boolean };
}; };
...@@ -278,7 +247,7 @@ export interface RootDataObject { ...@@ -278,7 +247,7 @@ export interface RootDataObject {
}) })
) )
class PAGE_NAME_UPPER_CAMEL_CASE extends Component< class PAGE_NAME_UPPER_CAMEL_CASE extends Component<
{ loading: boolean; BLOCK_NAME_CAMEL_CASE: RootDataObject; dispatch: Dispatch }, { loading: boolean; BLOCK_NAME_CAMEL_CASE: AdvancedProfileData; dispatch: Dispatch },
{ {
operationKey: string; operationKey: string;
stepDirection: 'horizontal' | 'vertical'; stepDirection: 'horizontal' | 'vertical';
......
import { queryAdvancedProfile } from './service'; import { queryAdvancedProfile } from './service';
import { Reducer } from 'redux';
import { EffectsCommandMap } from 'dva';
import { AnyAction } from 'redux';
export default { import { AdvancedProfileData } from './data';
export type Effect = (
action: AnyAction,
effects: EffectsCommandMap & { select: <T>(func: (state: AdvancedProfileData) => T) => T }
) => void;
export interface ModelType {
namespace: string;
state: AdvancedProfileData;
effects: {
fetchAdvanced: Effect;
};
reducers: {
show: Reducer<AdvancedProfileData>;
};
}
const Model: ModelType = {
namespace: 'BLOCK_NAME_CAMEL_CASE', namespace: 'BLOCK_NAME_CAMEL_CASE',
state: { state: {
...@@ -28,3 +49,5 @@ export default { ...@@ -28,3 +49,5 @@ export default {
}, },
}, },
}; };
export default Model;
import { fakeChartData } from './service'; import { fakeChartData } from './service';
import { IAnalysisData } from './data';
import { Reducer } from 'redux';
import { EffectsCommandMap } from 'dva';
import { AnyAction } from 'redux';
export default { export type Effect = (
action: AnyAction,
effects: EffectsCommandMap & { select: <T>(func: (state: IAnalysisData) => T) => T }
) => void;
export interface ModelType {
namespace: string;
state: IAnalysisData;
effects: {
fetch: Effect;
fetchSalesData: Effect;
};
reducers: {
save: Reducer<IAnalysisData>;
clear: Reducer<IAnalysisData>;
};
}
const Model: ModelType = {
namespace: 'BLOCK_NAME_CAMEL_CASE', namespace: 'BLOCK_NAME_CAMEL_CASE',
state: { state: {
...@@ -14,7 +36,6 @@ export default { ...@@ -14,7 +36,6 @@ export default {
salesTypeDataOnline: [], salesTypeDataOnline: [],
salesTypeDataOffline: [], salesTypeDataOffline: [],
radarData: [], radarData: [],
loading: false,
}, },
effects: { effects: {
...@@ -59,3 +80,5 @@ export default { ...@@ -59,3 +80,5 @@ export default {
}, },
}, },
}; };
export default Model;
...@@ -15,7 +15,8 @@ ...@@ -15,7 +15,8 @@
"antd": "^3.10.9", "antd": "^3.10.9",
"dva": "^2.4.0", "dva": "^2.4.0",
"react": "^16.6.3", "react": "^16.6.3",
"umi-request": "^1.0.0" "umi-request": "^1.0.0",
"@ant-design/pro-layout": "^4.0.5"
}, },
"devDependencies": { "devDependencies": {
"umi": "^2.6.9", "umi": "^2.6.9",
......
import React from 'react';
import { FormattedMessage } from 'umi-plugin-react/locale';
import Link from 'umi/link';
import { PageHeader } from 'ant-design-pro';
import styles from './index.less';
const PageHeaderWrapper = ({ children, wrapperClassName, ...restProps }) => (
<div style={{ margin: '-24px -24px 0' }} className={wrapperClassName}>
<PageHeader
home={<FormattedMessage id="BLOCK_NAME.menu.home" defaultMessage="Home" />}
key="pageheader"
{...restProps}
linkElement={Link}
itemRender={item => {
if (item.locale) {
return <FormattedMessage id={item.locale} defaultMessage={item.title} />;
}
return item.title;
}}
/>
{children ? <div className={styles.content}>{children}</div> : null}
</div>
);
export default PageHeaderWrapper;
import React from 'react';
import { RouteContext } from '@ant-design/pro-layout';
import { PageHeader } from 'antd';
import styles from './index.less';
interface IPageHeaderWrapperProps {
content: React.ReactNode;
title: React.ReactNode;
}
const PageHeaderWrapper: React.SFC<IPageHeaderWrapperProps> = ({
children,
content,
...restProps
}) => (
<RouteContext.Consumer>
{value => (
<div style={{ margin: '-24px -24px 0' }}>
<PageHeader {...restProps} {...value}>
{content}
</PageHeader>
{children ? <div className={styles.content}>{children}</div> : null}
</div>
)}
</RouteContext.Consumer>
);
export default PageHeaderWrapper;
import React, { PureComponent } from 'react'; import React, { Component } from 'react';
import { connect } from 'dva'; import { connect } from 'dva';
import { formatMessage, FormattedMessage } from 'umi-plugin-react/locale'; import { formatMessage, FormattedMessage } from 'umi-plugin-react/locale';
import { import {
...@@ -15,18 +15,24 @@ import { ...@@ -15,18 +15,24 @@ import {
} from 'antd'; } from 'antd';
import PageHeaderWrapper from './components/PageHeaderWrapper'; import PageHeaderWrapper from './components/PageHeaderWrapper';
import styles from './style.less'; import styles from './style.less';
import { FormComponentProps } from 'antd/lib/form';
import { Dispatch } from 'redux';
const FormItem = Form.Item; const FormItem = Form.Item;
const { Option } = Select; const { Option } = Select;
const { RangePicker } = DatePicker; const { RangePicker } = DatePicker;
const { TextArea } = Input; const { TextArea } = Input;
@connect(({ loading }) => ({ interface PAGE_NAME_UPPER_CAMEL_CASEProps extends FormComponentProps {
submitting: boolean;
dispatch: Dispatch;
}
@connect(({ loading }: { loading: { effects: { [key: string]: boolean } } }) => ({
submitting: loading.effects['BLOCK_NAME_CAMEL_CASE/submitRegularForm'], submitting: loading.effects['BLOCK_NAME_CAMEL_CASE/submitRegularForm'],
})) }))
@Form.create() class PAGE_NAME_UPPER_CAMEL_CASE extends Component<PAGE_NAME_UPPER_CAMEL_CASEProps> {
class PAGE_NAME_UPPER_CAMEL_CASE extends PureComponent { handleSubmit = (e: React.FormEvent) => {
handleSubmit = e => {
const { dispatch, form } = this.props; const { dispatch, form } = this.props;
e.preventDefault(); e.preventDefault();
form.validateFieldsAndScroll((err, values) => { form.validateFieldsAndScroll((err, values) => {
...@@ -247,4 +253,4 @@ class PAGE_NAME_UPPER_CAMEL_CASE extends PureComponent { ...@@ -247,4 +253,4 @@ class PAGE_NAME_UPPER_CAMEL_CASE extends PureComponent {
} }
} }
export default PAGE_NAME_UPPER_CAMEL_CASE; export default Form.create()(PAGE_NAME_UPPER_CAMEL_CASE);
import { message } from 'antd'; import { message } from 'antd';
import { fakeSubmitForm } from './service'; import { fakeSubmitForm } from './service';
import { EffectsCommandMap } from 'dva';
import { AnyAction } from 'redux';
export default { export interface ModalState {}
export type Effect = (
action: AnyAction,
effects: EffectsCommandMap & { select: <T>(func: (state: ModalState) => T) => T }
) => void;
export interface ModelType {
namespace: string;
state: ModalState;
effects: {
submitRegularForm: Effect;
};
}
const Model: ModelType = {
namespace: 'BLOCK_NAME_CAMEL_CASE', namespace: 'BLOCK_NAME_CAMEL_CASE',
state: {}, state: {},
...@@ -13,3 +29,5 @@ export default { ...@@ -13,3 +29,5 @@ export default {
}, },
}, },
}; };
export default Model;
{ {
"private": true, "private": true,
"scripts": { "scripts": {
"dev": "cross-env PAGES_PATH='Analysis/src' umi dev", "dev": "cross-env PAGES_PATH='BasicForm/src' umi dev",
"lint:style": "stylelint \"src/**/*.less\" --syntax less", "lint:style": "stylelint \"src/**/*.less\" --syntax less",
"lint": "eslint --ext .js src mock tests && npm run lint:style", "lint": "eslint --ext .js src mock tests && npm run lint:style",
"lint:fix": "eslint --fix --ext .js src mock tests && npm run lint:style", "lint:fix": "eslint --fix --ext .js src mock tests && npm run lint:style",
...@@ -29,7 +29,7 @@ ...@@ -29,7 +29,7 @@
"stylelint-config-prettier": "^4.0.0", "stylelint-config-prettier": "^4.0.0",
"stylelint-config-standard": "^18.0.0", "stylelint-config-standard": "^18.0.0",
"umi": "^2.3.0-0", "umi": "^2.3.0-0",
"umi-plugin-block-dev": "^2.0.1", "umi-plugin-block-dev": "^2.0.2",
"umi-plugin-react": "^1.3.0-0", "umi-plugin-react": "^1.3.0-0",
"umi-request": "^1.0.0" "umi-request": "^1.0.0"
}, },
...@@ -47,7 +47,6 @@ ...@@ -47,7 +47,6 @@
} }
}, },
"dependencies": { "dependencies": {
"@ant-design/pro-layout": "^4.0.5",
"cross-env": "^5.2.0" "cross-env": "^5.2.0"
} }
} }
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment