Commit 5a303517 authored by superman's avatar superman

2016-08-10

parent 613ea9d4
This source diff could not be displayed because it is too large. You can view the blob instead.
...@@ -2,6 +2,6 @@ ...@@ -2,6 +2,6 @@
// - https://github.com/dora-js/dora-plugin-proxy#规则定义 // - https://github.com/dora-js/dora-plugin-proxy#规则定义
module.exports = { module.exports = {
'/api/*': 'http://react.yanky.cn/', // '/api/*': 'http://react.yanky.cn/',
// '/api/*': 'http://192.168.1.126:8080/' '/api/*': 'http://192.168.1.126:8080/'
}; };
...@@ -35,26 +35,29 @@ export default class ContactForm extends Component { ...@@ -35,26 +35,29 @@ export default class ContactForm extends Component {
constructor(props, context) { constructor(props, context) {
super(props, context); super(props, context);
this.state = { this.state = {
staffs: props.product.staffs.map(staffs=> { staffs: []
staffs.key = UUID();
return staffs;
})
}; };
} }
componentDidMount() {
this.analysisStaffs(this.props);
}
componentWillReceiveProps(nextProps) { componentWillReceiveProps(nextProps) {
if (nextProps && nextProps.product.staffs && nextProps.product.staffs) { if (nextProps.isEdit !== this.props.isEdit) {
if (nextProps.product.staffs.length != this.props.product.staffs.length) { this.analysisStaffs(nextProps);
}
}
analysisStaffs(props) {
if (props.product && props.product.staffs) {
this.setState({ this.setState({
staffs: nextProps.product.staffs.map(staffs=> { staffs: props.product.staffs.map(staffs=> {
staffs.key = UUID(); staffs.key = UUID();
return staffs; return staffs;
}) })
}); });
} else {
}
} }
} }
......
...@@ -53,9 +53,6 @@ export default class DocumentsForm extends Component { ...@@ -53,9 +53,6 @@ export default class DocumentsForm extends Component {
}; };
componentWillMount() {
}
handleSubmit(e) { handleSubmit(e) {
e.preventDefault(); e.preventDefault();
...@@ -83,7 +80,7 @@ export default class DocumentsForm extends Component { ...@@ -83,7 +80,7 @@ export default class DocumentsForm extends Component {
const {user, loading, isEdit} = this.props; const {user, loading, isEdit} = this.props;
return ( return (
<Spin spinning={loading}> <Spin spinning={loading}>
<Form horizontal onSubmit={this.handleSubmit.bind(this)} style={{maxWidth:'800px', margin:'auto'}}> <Form horizontal onSubmit={this.handleSubmit.bind(this)} style={{maxWidth:'1000px', margin:'auto'}}>
<Row style={{padding:'0 20px'}}> <Row style={{padding:'0 20px'}}>
<Col span="24"> <Col span="24">
<Form.Item> <Form.Item>
...@@ -112,10 +109,10 @@ export default class DocumentsForm extends Component { ...@@ -112,10 +109,10 @@ export default class DocumentsForm extends Component {
<li key={file.uid} style={{margin:"10px 0"}}> <li key={file.uid} style={{margin:"10px 0"}}>
<Copy copyText={file.url}> <Copy copyText={file.url}>
<Row> <Row>
<Col span="4"><Icon type="paper-clip" <Col span="6"><Icon type="paper-clip"
style={{marginRight:'.3em'}}/>{file.name} style={{marginRight:'.3em'}}/>{file.name}
</Col> </Col>
<Col span="20">{file.url ? file.url : '正在上传...'}</Col> <Col span="18">{file.url ? file.url : '正在上传...'}</Col>
</Row> </Row>
</Copy> </Copy>
</li> </li>
...@@ -124,18 +121,39 @@ export default class DocumentsForm extends Component { ...@@ -124,18 +121,39 @@ export default class DocumentsForm extends Component {
</ul> </ul>
} }
</Form.Item> </Form.Item>
<Form.Item style={{marginTop:30, textAlign:'center'}}> <Form.Item {...footerFormSubmitLayout} style={{marginTop:30}}>
<Button type="primary" htmlType="submit" loading={loading}><Icon {
type="save"/>保存</Button> isEdit ?
<Button size="large" type="primary" htmlType="submit" loading={loading}>
<Icon type="save"/>保存
</Button>
:
<Button type="primary" onClick={e=>{
e.preventDefault();
this.props.dispatch({
type:'UPDATE_PRODUCT'
});
}}>
<Icon type="edit"/>上传
</Button>
}
{ {
!this.props.isCreate && !this.props.isCreate &&
<Button onClick={e=>{e.preventDefault(); this.props.history.goBack();}} <Button onClick={e=>{
e.preventDefault();
isEdit ?
this.props.dispatch({
type: 'CANCEL_UPDATE_PRODUCT'
}) :
this.props.history.goBack();
}}
style={{marginLeft:'1em'}}> style={{marginLeft:'1em'}}>
<Icon type="rollback"/> <Icon type="rollback"/>
{isEdit ? '取消' : '返回'} {isEdit ? '取消' : '返回'}
</Button> </Button>
} }
</Form.Item> </Form.Item>
</Col> </Col>
</Row> </Row>
</Form> </Form>
......
...@@ -47,7 +47,7 @@ export default class ElementForm extends Component { ...@@ -47,7 +47,7 @@ export default class ElementForm extends Component {
constructor(props, context) { constructor(props, context) {
super(props, context); super(props, context);
this.state = { this.state = {
elements: BaseElementTransform(props.product.elements) elements: []
}; };
} }
...@@ -57,16 +57,24 @@ export default class ElementForm extends Component { ...@@ -57,16 +57,24 @@ export default class ElementForm extends Component {
}; };
componentDidMount() {
this.analysisBaseElement(this.props);
}
componentWillReceiveProps(nextProps) { componentWillReceiveProps(nextProps) {
if (nextProps && nextProps.product && nextProps.product.elements) { if (nextProps.isEdit !== this.props.isEdit) {
if (Object.keys(nextProps.product.elements).length != Object.keys(this.props.product.elements).length) { this.analysisBaseElement(nextProps);
}
}
analysisBaseElement(props) {
if (props.product && props.product.elements) {
const newElements = BaseElementTransform(props.product.elements);
this.setState({ this.setState({
elements: BaseElementTransform(nextProps.product.elements) elements: newElements
}); });
} }
} }
console.log(nextProps);
}
/** /**
* 删除基本要素 * 删除基本要素
......
import React, {Component, PropTypes} from 'react';
import {
Row,
Col,
Form,
Input,
Button,
Checkbox,
Select,
message,
Tabs,
Cascader,
Radio,
Upload,
Icon,
Modal,
DatePicker,
Table,
Spin
} from 'antd';
export default class KeyValue extends Component {
render(){
const {label, content, operation} = this.props;
return (
<Row>
<Col span={label.layout}>
<Input {...label.input}/>
</Col>
<Col span={content.layout}>
<Input {...content.input}/>
</Col>
<Col span={operation.layout}>
{operation.input}
</Col>
</Row>
);
}
}
...@@ -43,26 +43,44 @@ export default class ShouyiYongjingForm extends Component { ...@@ -43,26 +43,44 @@ export default class ShouyiYongjingForm extends Component {
super(props, context); super(props, context);
this.state = { this.state = {
yongjing: YongjingTransform(props.product.commissionAlg) yongjing: []
}; };
} }
componentDidMount() {
this.analysisYongjing(this.props);
}
componentWillReceiveProps(nextProps) {
if (nextProps.isEdit !== this.props.isEdit) {
this.analysisYongjing(nextProps);
}
}
analysisYongjing(props) {
if (props.product && props.product.commissionAlg) {
this.setState({
yongjing: YongjingTransform(props.product.commissionAlg)
});
}
}
static propsType = { static propsType = {
product: PropTypes.object, product: PropTypes.object,
user: PropTypes.object, user: PropTypes.object,
dispatch: PropTypes.func dispatch: PropTypes.func
}; };
componentWillReceiveProps(nextProps) { // componentWillReceiveProps(nextProps) {
if (nextProps && nextProps.product && nextProps.product.commissionAlg) { // if (nextProps && nextProps.product && nextProps.product.commissionAlg) {
if (nextProps.product.commissionAlg.length != this.props.product.commissionAlg.length) { // if (nextProps.product.commissionAlg.length != this.props.product.commissionAlg.length) {
this.setState({ // this.setState({
yongjing: YongjingTransform(nextProps.product.commissionAlg) // yongjing: YongjingTransform(nextProps.product.commissionAlg)
}); // });
} // }
//
} // }
} // }
/** /**
* 添加佣金算法 * 添加佣金算法
......
...@@ -110,7 +110,7 @@ export default class List extends Component { ...@@ -110,7 +110,7 @@ export default class List extends Component {
onChange={checked=>{ onChange={checked=>{
this.props.dispatch({ this.props.dispatch({
type:'UPDATE_ANNOUNCEMENT_ITEM', type:'UPDATE_ANNOUNCEMENT_ITEM',
data:{ item:{
id: record.id, id: record.id,
status: checked ? 1: 0 status: checked ? 1: 0
} }
......
...@@ -65,7 +65,6 @@ export default class EditItem extends Component { ...@@ -65,7 +65,6 @@ export default class EditItem extends Component {
componentWillReceiveProps(nextProps) { componentWillReceiveProps(nextProps) {
if (nextProps.item && nextProps.item.permissions && nextProps.resources) { if (nextProps.item && nextProps.item.permissions && nextProps.resources) {
this.analysisCheckedKeys(nextProps); this.analysisCheckedKeys(nextProps);
console.log('analysisCheckedKeys');
} }
}; };
...@@ -99,7 +98,8 @@ export default class EditItem extends Component { ...@@ -99,7 +98,8 @@ export default class EditItem extends Component {
if (isNaN(data.status)) { if (isNaN(data.status)) {
ENABLE_STATUS_LIST.forEach(item=> { ENABLE_STATUS_LIST.forEach(item=> {
if (item.text === data.status) { if (item.text === data.status) {
data.status = item.value data.status = item.value;
return false;
} }
}) })
} }
......
...@@ -122,16 +122,6 @@ export default class List extends Component { ...@@ -122,16 +122,6 @@ export default class List extends Component {
render: (status)=>( render: (status)=>(
<span>{enableStatusToString(status)}</span> <span>{enableStatusToString(status)}</span>
) )
}, {
title: '操作',
key: 'operation',
width: 120,
className: 'tac',
render: (text, item)=>(
<span onClick={e=>{e.stopPropagation(); e.preventDefault();}}>
</span>
)
} }
]; ];
......
...@@ -73,7 +73,8 @@ export default class EditItem extends Component { ...@@ -73,7 +73,8 @@ export default class EditItem extends Component {
if (isNaN(data.status)) { if (isNaN(data.status)) {
ENABLE_STATUS_LIST.forEach(item=> { ENABLE_STATUS_LIST.forEach(item=> {
if (item.text === data.status) { if (item.text === data.status) {
data.status = item.value data.status = item.value;
return false;
} }
}) })
} }
......
...@@ -29,27 +29,49 @@ import { ...@@ -29,27 +29,49 @@ import {
footerFormSubmitLayout, footerFormSubmitLayout,
userStatusToString, userStatusToString,
formatDateTime, formatDateTime,
NULL NULL,
USER_STATUS
} from '../../utils'; } from '../../utils';
@connect(state=>({ @connect(state=>({
loading: state.user.loading, loading: state.user.loading || state.authority.loading,
item: state.user.item, item: state.user.item,
isEdit: state.user.isEdit,
authorities: state.authority.items,
})) }))
@Form.create() @Form.create()
export default class EditItem extends Component { export default class EditItem extends Component {
constructor() { constructor() {
super(...arguments); super(...arguments);
this.state = {
isEdit: false
} }
}
componentDidMount() { componentDidMount() {
this.fetchItem(this.props.params.id); this.fetchItem(this.props.params.id);
this.fetchAuthorityList();
}; };
// componentWillReceiveProps(nextProps) {
// if (nextProps.item && nextProps.authorities) {
// this.analysisCheckedKeys(nextProps);
// }
// };
//
// analysisCheckedKeys(props) {
// const {item, authorities, isEdit} = props;
// //对权限资源分组
// const authoritiesMap = {};
// const checkedKeys = [];
// authorities && authorities.forEach(authority=> {
// authoritiesMap[authority.name] = authority;
//
// });
//
// this.setState({
// authoritiesMap,
// checkedKeys
// });
// }
fetchItem(id) { fetchItem(id) {
this.props.dispatch({ this.props.dispatch({
type: 'FETCH_USER_ITEM', type: 'FETCH_USER_ITEM',
...@@ -57,15 +79,25 @@ export default class EditItem extends Component { ...@@ -57,15 +79,25 @@ export default class EditItem extends Component {
}); });
}; };
handleSubmit(status, e) { fetchAuthorityList() {
this.props.dispatch({
type: 'FETCH_AUTHORITY_LIST',
query: {s: 100}
});
};
handleSubmit(e) {
e.preventDefault(); e.preventDefault();
let data = {}; const data = this.props.form.getFieldsValue();
if (status == 1 || status == 0) {
data.status = status;
} else {
data = this.props.form.getFieldsValue();
}
data.id = this.props.params.id; data.id = this.props.params.id;
if (isNaN(data.status)) {
Object.keys(USER_STATUS).forEach(key=> {
if (USER_STATUS[key] === data.status) {
data.status = key;
return false;
}
})
}
console.log(data); console.log(data);
this.props.dispatch({ this.props.dispatch({
type: 'UPDATE_USER_ITEM', type: 'UPDATE_USER_ITEM',
...@@ -74,15 +106,30 @@ export default class EditItem extends Component { ...@@ -74,15 +106,30 @@ export default class EditItem extends Component {
} }
render() { render() {
const {item, loading, form:{getFieldProps}, location:{query}} = this.props; const {item, loading, form:{getFieldProps}, location:{query}, isEdit, authorities} = this.props;
const {isEdit} = this.state;
const operation = ( const operation = (
<div style={{textAlign:'right'}}> <div style={{textAlign:'right'}}>
<Button.Group> <Button.Group>
<Button type="ghost"
<Button type="ghost" onClick={e=>{e.preventDefault(); this.props.history.goBack();}}> onClick={
e=>{
e.preventDefault();
this.props.dispatch({
type: isEdit ? 'CANCEL_UPDATE_USER' : 'UPDATE_USER'
});
}
}>
<Icon type="edit"/>
</Button>
<Button type="ghost" onClick={e=>{
e.preventDefault();
isEdit ?
this.props.dispatch({
type: 'CANCEL_UPDATE_USER'
}) :
this.props.history.goBack();
}}>
<Icon type="rollback"/> <Icon type="rollback"/>
</Button> </Button>
</Button.Group> </Button.Group>
...@@ -91,22 +138,53 @@ export default class EditItem extends Component { ...@@ -91,22 +138,53 @@ export default class EditItem extends Component {
const header = ( const header = (
<MainHeader breadcrumb={['用户管理', '用户详情']} <MainHeader breadcrumb={['用户管理', '用户详情']}
title={(query && query.title ? query.title + ' - ' : '') + '用户详情'} title={'用户详情' + (isEdit ? ' - 编辑' : '')}
operation={operation} operation={operation}
/> />
); );
const authoritiesMap = authorities ? authorities.reduce((map, authority)=> {
map[authority.name] = authority;
return map;
}, {}) : {};
if (item) {
item.authorities = item.authorities.split(',');
item.authoritiesDescList = [];
// item.authoritiesMap = item.authorities.reduce((map, name)=> {
// const authority = authoritiesMap[name];
// map[name] = authority;
// item.authoritiesDescList.push(authority.description);
// }, {});
}
return ( return (
<Layout header={header}> <Layout header={header}>
<Spin spinning={loading}> <Spin spinning={loading}>
{ {
item && item &&
<Form className="main-form" horizontal> <Form className="main-form" horizontal>
<Row>
<Col span="12">
<Form.Item label="用户名" {...smallFormItemLayout}> <Form.Item label="用户名" {...smallFormItemLayout}>
{ item.username } { item.username }
</Form.Item> </Form.Item>
<Form.Item label="状态" {...smallFormItemLayout}> <Form.Item label="状态" {...smallFormItemLayout}>
{userStatusToString(item.status)} {
isEdit ?
<Select
placeholder="请选择状态" {...getFieldProps('status', {initialValue: userStatusToString(item.status)})} >
<Select.Option value="0">未激活</Select.Option>
<Select.Option value="1">已激活</Select.Option>
</Select>
:
(typeof item.status !== 'undefined' ? userStatusToString(item.status) : NULL)
}
</Form.Item>
<Form.Item label="角色" {...smallFormItemLayout}>
{item.authoritiesDescList.join()}
</Form.Item> </Form.Item>
<Form.Item label="昵称" {...smallFormItemLayout}> <Form.Item label="昵称" {...smallFormItemLayout}>
{ {
...@@ -138,27 +216,39 @@ export default class EditItem extends Component { ...@@ -138,27 +216,39 @@ export default class EditItem extends Component {
<Form.Item {...footerFormSubmitLayout} style={{marginTop:30}}> <Form.Item {...footerFormSubmitLayout} style={{marginTop:30}}>
{ {
isEdit ? isEdit ?
<Button type="primary" onClick={this.handleSubmit.bind(this, -1)} <Button type="primary" onClick={this.handleSubmit.bind(this)}
loading={loading}> loading={loading}>
<Icon type="save"/>修改 <Icon type="save"/>保存
</Button> </Button>
: :
item.status ? <Button type="primary" onClick={e=>{
<Button type="primary" onClick={this.handleSubmit.bind(this, 0)} e.preventDefault();
loading={loading}> this.props.dispatch({
<Icon type="save"/>禁用 type:'UPDATE_USER'
</Button> });
: }}>
<Button type="primary" onClick={this.handleSubmit.bind(this, 1)} <Icon type="edit"/>编辑
loading={loading}>
<Icon type="save"/>激活
</Button> </Button>
} }
<Button onClick={e=>{e.preventDefault(); this.props.history.goBack();}} <Button onClick={e=>{
e.preventDefault();
isEdit ?
this.props.dispatch({
type: 'CANCEL_UPDATE_USER'
}) :
this.props.history.goBack();
}}
style={{marginLeft:'1em'}}> style={{marginLeft:'1em'}}>
<Icon type="rollback"/>返回 <Icon type="rollback"/>
{isEdit ? '取消' : '返回'}
</Button> </Button>
</Form.Item> </Form.Item>
</Col>
<Col span="12">
</Col>
</Row>
</Form> </Form>
} }
</Spin> </Spin>
...@@ -170,3 +260,28 @@ export default class EditItem extends Component { ...@@ -170,3 +260,28 @@ export default class EditItem extends Component {
// <Button type="ghost" onClick={e=>{e.preventDefault(); this.setState({isEdit: !this.state.isEdit})}}> // <Button type="ghost" onClick={e=>{e.preventDefault(); this.setState({isEdit: !this.state.isEdit})}}>
// <Icon type="edit"/> // <Icon type="edit"/>
// </Button> // </Button>
// <Form.Item {...footerFormSubmitLayout} style={{marginTop:30}}>
// {
// isEdit ?
// <Button type="primary" onClick={this.handleSubmit.bind(this, -1)}
// loading={loading}>
// <Icon type="save"/>修改
// </Button>
// :
// item.status ?
// <Button type="primary" onClick={this.handleSubmit.bind(this, 0)}
// loading={loading}>
// <Icon type="save"/>禁用
// </Button>
// :
// <Button type="primary" onClick={this.handleSubmit.bind(this, 1)}
// loading={loading}>
// <Icon type="save"/>激活
// </Button>
// }
// <Button onClick={e=>{e.preventDefault(); this.props.history.goBack();}}
// style={{marginLeft:'1em'}}>
// <Icon type="rollback"/>返回
// </Button>
// </Form.Item>
...@@ -47,10 +47,10 @@ const announcement = handleActions({ ...@@ -47,10 +47,10 @@ const announcement = handleActions({
return {...state, loading: true} return {...state, loading: true}
}, },
['UPDATE_ANNOUNCEMENT_ITEM_SUCCESS'](state, action){ ['UPDATE_ANNOUNCEMENT_ITEM_SUCCESS'](state, action){
return {...state, loading: false, item: {...state.item, ...action.item}} return {...state, loading: false, isEdit:false, item: {...state.item, ...action.item}}
}, },
['UPDATE_ANNOUNCEMENT_ITEM_FAILED'](state, action){ ['UPDATE_ANNOUNCEMENT_ITEM_FAILED'](state, action){
return {...state, err: action.err, loading: false} return {...state, err: action.err, loading: false, isEdit:false}
}, },
}, initState); }, initState);
......
...@@ -62,13 +62,11 @@ const product = handleActions({ ...@@ -62,13 +62,11 @@ const product = handleActions({
console.log('UPDATE_PRODUCT_ITEM_SUCCESS staffs Error:', action.item.staffs); console.log('UPDATE_PRODUCT_ITEM_SUCCESS staffs Error:', action.item.staffs);
} }
} }
const ret = {...state, loading: false, item:{...state.item, ...action.item}};
console.log(ret, state); return {...state, loading: false, item:{...state.item, ...action.item}, isEdit: false};
return ret;
}, },
['UPDATE_PRODUCT_ITEM_FAILED'](state, action){ ['UPDATE_PRODUCT_ITEM_FAILED'](state, action){
return {...state, loading: false, err: action.err}; return {...state, loading: false, err: action.err, isEdit: false};
}, },
...@@ -82,7 +80,6 @@ const product = handleActions({ ...@@ -82,7 +80,6 @@ const product = handleActions({
return {...state, loading: false, err: action.err}; return {...state, loading: false, err: action.err};
} }
}, { }, {
//cates: [],
items: [], items: [],
loading: false, loading: false,
}); });
......
...@@ -53,14 +53,20 @@ const user = handleActions({ ...@@ -53,14 +53,20 @@ const user = handleActions({
return {...state, loading: false, err: action.err}; return {...state, loading: false, err: action.err};
}, },
['UPDATE_USER_START'](state){
return {...state, isEdit: true}
},
['UPDATE_USER_END'](state){
return {...state, isEdit: false}
},
['UPDATE_USER_ITEM'](state){ ['UPDATE_USER_ITEM'](state){
return {...state, loading:true}; return {...state, loading:true};
}, },
['UPDATE_USER_ITEM_SUCCESS'](state, action){ ['UPDATE_USER_ITEM_SUCCESS'](state, action){
return {...state, loading: false, item: {...state.item, ...action.item}}; return {...state, loading: false, item: {...state.item, ...action.item}, isEdit: false};
}, },
['UPDATE_USER_ITEM_FAILED'](state, action){ ['UPDATE_USER_ITEM_FAILED'](state, action){
return {...state, loading: false, err: action.err}; return {...state, loading: false, err: action.err, isEdit:false};
}, },
}, { }, {
......
...@@ -78,13 +78,13 @@ function* watchAdd() { ...@@ -78,13 +78,13 @@ function* watchAdd() {
} }
} }
function* editItem(data) { function* editItem(item) {
try{ try{
yield call(updateItem, data); yield call(updateItem, item);
message.success('修改成功!'); message.success('修改成功!');
yield put({ yield put({
type: 'UPDATE_ANNOUNCEMENT_ITEM_SUCCESS', type: 'UPDATE_ANNOUNCEMENT_ITEM_SUCCESS',
item: data item
}); });
}catch(err){ }catch(err){
console.log(err); console.log(err);
...@@ -109,11 +109,19 @@ function* watchEdit() { ...@@ -109,11 +109,19 @@ function* watchEdit() {
if (data && data.item) { if (data && data.item) {
yield fork(editItem, data.item); yield fork(editItem, data.item);
} }else{
yield put({ yield put({
type: 'UPDATE_ANNOUNCEMENT_END' type: 'UPDATE_ANNOUNCEMENT_END'
}); });
} }
}
}
function* watchSwidth() {
while(true){
const {item} = yield take('UPDATE_ANNOUNCEMENT_ITEM');
yield fork(editItem, item);
}
} }
export default function*() { export default function*() {
...@@ -121,4 +129,5 @@ export default function*() { ...@@ -121,4 +129,5 @@ export default function*() {
yield fork(watchItem); yield fork(watchItem);
yield fork(watchAdd); yield fork(watchAdd);
yield fork(watchEdit); yield fork(watchEdit);
yield fork(watchSwidth);
} }
...@@ -105,11 +105,12 @@ function* watchEditProductItem() { ...@@ -105,11 +105,12 @@ function* watchEditProductItem() {
if (data && data.item) { if (data && data.item) {
yield fork(editItem, data.item); yield fork(editItem, data.item);
} }else{
yield put({ yield put({
type: 'UPDATE_PRODUCT_END' type: 'UPDATE_PRODUCT_END'
}); });
} }
}
} }
function* addItem() { function* addItem() {
......
import {takeLatest} from 'redux-saga'; import {takeLatest} from 'redux-saga';
import {take, call, put, fork, cancel} from 'redux-saga/effects'; import {take, call, put, fork, cancel, race } from 'redux-saga/effects';
import {fetch, clear, save, create, fetchList, fetchItem, updateItem} from '../services/user'; import {fetch, clear, save, create, fetchList, fetchItem, updateItem} from '../services/user';
import {message} from 'antd'; import {message} from 'antd';
...@@ -107,9 +107,23 @@ function* modifyItem(data) { ...@@ -107,9 +107,23 @@ function* modifyItem(data) {
} }
function* watchMidfiyItem(){ function* watchMidfiyItem(){
while(true){ while (true) {
const {data} = yield take('UPDATE_USER_ITEM'); yield take('UPDATE_USER');
yield fork(modifyItem, data); yield put({
type: 'UPDATE_USER_START'
});
const {data} = yield race({
data: take('UPDATE_USER_ITEM'),
canceled: take('CANCEL_UPDATE_USER')
});
if (data && data.item) {
yield fork(modifyItem, data.item);
}else{
yield put({
type: 'UPDATE_USER_END'
});
}
} }
} }
......
...@@ -69,7 +69,7 @@ export const productEnableCreateTrade = status => { ...@@ -69,7 +69,7 @@ export const productEnableCreateTrade = status => {
export const USER_STATUS = { export const USER_STATUS = {
0: '未激活', 0: '未激活',
1: '正常' 1: '已激活'
}; };
export const userStatusToString = status => { export const userStatusToString = status => {
......
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