Commit c4937c4c authored by 陈帅's avatar 陈帅

BasicForm finish

parent 9c3225d1
export default {
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,
locale: true,
antd: true,
}]
},
],
],
}
};
import { queryCurrent } from './service';
import { Dispatch } from 'redux';
import { CurrentUser } from './data';
export interface ModalState {
currentUser: CurrentUser;
currentUser: Partial<CurrentUser>;
}
type callType<T, A extends any[], R> = (thisArg?: T, ...args: A) => R;
Function.call;
export default {
import { Reducer } from 'redux';
import { EffectsCommandMap } from 'dva';
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',
state: {
......@@ -16,16 +33,7 @@ export default {
},
effects: {
*fetchCurrent(
_: ModalState,
{
call,
put,
}: {
call: callType<Function, [], ReturnType<typeof queryCurrent>>;
put: Dispatch;
}
) {
*fetchCurrent(_, { call, put }) {
const response = yield call(queryCurrent);
yield put({
type: 'saveCurrentUser',
......@@ -35,12 +43,7 @@ export default {
},
reducers: {
saveCurrentUser(
state: ModalState,
action: {
payload: CurrentUser;
}
) {
saveCurrentUser(state, action) {
return {
...state,
currentUser: action.payload || {},
......@@ -48,3 +51,5 @@ export default {
},
},
};
export default Model;
......@@ -2,15 +2,17 @@
"name": "@umi-block/account-settings",
"version": "0.0.1",
"description": "AccountSettings",
"main": "src/index.js",
"scripts": {
"dev": "umi dev"
},
"repository": {
"type": "git",
"url": "https://github.com/umijs/umi-blocks/ant-design-pro/accountsettings"
},
"license": "ISC",
"main": "src/index.js",
"scripts": {
"dev": "umi dev"
},
"dependencies": {
"@ant-design/pro-layout": "^4.0.5",
"antd": "^3.10.9",
"dva": "^2.4.0",
"react": "^16.6.3",
......@@ -20,6 +22,5 @@
"umi": "^2.6.9",
"umi-plugin-block-dev": "^1.0.0",
"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 { 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',
state: {
list: [],
currentUser: {},
province: [],
city: [],
isLoading: false,
},
effects: {
......@@ -46,19 +80,13 @@ export default {
},
reducers: {
save(state, action) {
return {
...state,
list: action.payload,
};
},
saveCurrentUser(state, action) {
return {
...state,
currentUser: action.payload || {},
};
},
changeNotifyCount(state, action) {
changeNotifyCount(state = {}, action) {
return {
...state,
currentUser: {
......@@ -88,3 +116,5 @@ export default {
},
},
};
export default Model;
......@@ -2,15 +2,17 @@
"name": "@umi-block/advanced-form",
"version": "0.0.1",
"description": "AdvancedForm",
"main": "src/index.js",
"scripts": {
"dev": "umi dev"
},
"repository": {
"type": "git",
"url": "https://github.com/umijs/umi-blocks/ant-design-pro/advancedform"
},
"license": "ISC",
"main": "src/index.js",
"scripts": {
"dev": "umi dev"
},
"dependencies": {
"@ant-design/pro-layout": "^4.0.5",
"ant-design-pro": "^2.1.1",
"antd": "^3.10.9",
"dva": "^2.4.0",
......@@ -20,8 +22,7 @@
},
"devDependencies": {
"umi": "^2.6.9",
"umi-plugin-react": "^1.7.2",
"umi-plugin-block-dev": "^1.0.0"
},
"license": "ISC"
"umi-plugin-block-dev": "^1.0.0",
"umi-plugin-react": "^1.7.2"
}
}
\ No newline at end of file
import { message } from 'antd';
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',
state: {},
......@@ -13,3 +30,5 @@ export default {
},
},
};
export default Model;
......@@ -16,7 +16,8 @@
"dva": "^2.4.0",
"lodash-decorators": "^6.0.0",
"react": "^16.6.3",
"umi-request": "^1.0.0"
"umi-request": "^1.0.0",
"@ant-design/pro-layout": "^4.0.5"
},
"devDependencies": {
"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';
import classNames from 'classnames';
import DescriptionList from './DescriptionList';
import styles from './style.less';
import { AdvancedProfileData } from './data';
const { Step } = Steps;
const { Description } = DescriptionList;
......@@ -230,45 +231,13 @@ const columns = [
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(
({
BLOCK_NAME_CAMEL_CASE,
loading,
}: {
BLOCK_NAME_CAMEL_CASE: RootDataObject;
BLOCK_NAME_CAMEL_CASE: AdvancedProfileData;
loading: {
effects: { [key: string]: boolean };
};
......@@ -278,7 +247,7 @@ export interface RootDataObject {
})
)
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;
stepDirection: 'horizontal' | 'vertical';
......
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',
state: {
......@@ -28,3 +49,5 @@ export default {
},
},
};
export default Model;
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',
state: {
......@@ -14,7 +36,6 @@ export default {
salesTypeDataOnline: [],
salesTypeDataOffline: [],
radarData: [],
loading: false,
},
effects: {
......@@ -59,3 +80,5 @@ export default {
},
},
};
export default Model;
......@@ -15,7 +15,8 @@
"antd": "^3.10.9",
"dva": "^2.4.0",
"react": "^16.6.3",
"umi-request": "^1.0.0"
"umi-request": "^1.0.0",
"@ant-design/pro-layout": "^4.0.5"
},
"devDependencies": {
"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 { formatMessage, FormattedMessage } from 'umi-plugin-react/locale';
import {
......@@ -15,18 +15,24 @@ import {
} from 'antd';
import PageHeaderWrapper from './components/PageHeaderWrapper';
import styles from './style.less';
import { FormComponentProps } from 'antd/lib/form';
import { Dispatch } from 'redux';
const FormItem = Form.Item;
const { Option } = Select;
const { RangePicker } = DatePicker;
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'],
}))
@Form.create()
class PAGE_NAME_UPPER_CAMEL_CASE extends PureComponent {
handleSubmit = e => {
class PAGE_NAME_UPPER_CAMEL_CASE extends Component<PAGE_NAME_UPPER_CAMEL_CASEProps> {
handleSubmit = (e: React.FormEvent) => {
const { dispatch, form } = this.props;
e.preventDefault();
form.validateFieldsAndScroll((err, values) => {
......@@ -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 { 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',
state: {},
......@@ -13,3 +29,5 @@ export default {
},
},
};
export default Model;
{
"private": true,
"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": "eslint --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 @@
"stylelint-config-prettier": "^4.0.0",
"stylelint-config-standard": "^18.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-request": "^1.0.0"
},
......@@ -47,7 +47,6 @@
}
},
"dependencies": {
"@ant-design/pro-layout": "^4.0.5",
"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