Commit 5a303517 authored by superman's avatar superman

2016-08-10

parent 613ea9d4
This diff is collapsed.
......@@ -2,6 +2,6 @@
// - https://github.com/dora-js/dora-plugin-proxy#规则定义
module.exports = {
'/api/*': 'http://react.yanky.cn/',
// '/api/*': 'http://192.168.1.126:8080/'
// '/api/*': 'http://react.yanky.cn/',
'/api/*': 'http://192.168.1.126:8080/'
};
......@@ -35,26 +35,29 @@ export default class ContactForm extends Component {
constructor(props, context) {
super(props, context);
this.state = {
staffs: props.product.staffs.map(staffs=> {
staffs.key = UUID();
return staffs;
})
staffs: []
};
}
componentDidMount() {
this.analysisStaffs(this.props);
}
componentWillReceiveProps(nextProps) {
if (nextProps && nextProps.product.staffs && nextProps.product.staffs) {
if (nextProps.product.staffs.length != this.props.product.staffs.length) {
this.setState({
staffs: nextProps.product.staffs.map(staffs=> {
staffs.key = UUID();
return staffs;
})
});
} else {
if (nextProps.isEdit !== this.props.isEdit) {
this.analysisStaffs(nextProps);
}
}
}
analysisStaffs(props) {
if (props.product && props.product.staffs) {
this.setState({
staffs: props.product.staffs.map(staffs=> {
staffs.key = UUID();
return staffs;
})
});
}
}
......
......@@ -52,10 +52,7 @@ export default class DocumentsForm extends Component {
product: PropTypes.object,
};
componentWillMount() {
}
handleSubmit(e) {
e.preventDefault();
......@@ -83,7 +80,7 @@ export default class DocumentsForm extends Component {
const {user, loading, isEdit} = this.props;
return (
<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'}}>
<Col span="24">
<Form.Item>
......@@ -112,10 +109,10 @@ export default class DocumentsForm extends Component {
<li key={file.uid} style={{margin:"10px 0"}}>
<Copy copyText={file.url}>
<Row>
<Col span="4"><Icon type="paper-clip"
<Col span="6"><Icon type="paper-clip"
style={{marginRight:'.3em'}}/>{file.name}
</Col>
<Col span="20">{file.url ? file.url : '正在上传...'}</Col>
<Col span="18">{file.url ? file.url : '正在上传...'}</Col>
</Row>
</Copy>
</li>
......@@ -124,18 +121,39 @@ export default class DocumentsForm extends Component {
</ul>
}
</Form.Item>
<Form.Item style={{marginTop:30, textAlign:'center'}}>
<Button type="primary" htmlType="submit" loading={loading}><Icon
type="save"/>保存</Button>
<Form.Item {...footerFormSubmitLayout} style={{marginTop:30}}>
{
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 &&
<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'}}>
<Icon type="rollback"/>
{isEdit ? '取消' : '返回'}
</Button>
}
</Form.Item>
</Col>
</Row>
</Form>
......
......@@ -47,7 +47,7 @@ export default class ElementForm extends Component {
constructor(props, context) {
super(props, context);
this.state = {
elements: BaseElementTransform(props.product.elements)
elements: []
};
}
......@@ -57,15 +57,23 @@ export default class ElementForm extends Component {
};
componentDidMount() {
this.analysisBaseElement(this.props);
}
componentWillReceiveProps(nextProps) {
if (nextProps && nextProps.product && nextProps.product.elements) {
if (Object.keys(nextProps.product.elements).length != Object.keys(this.props.product.elements).length) {
this.setState({
elements: BaseElementTransform(nextProps.product.elements)
});
}
if (nextProps.isEdit !== this.props.isEdit) {
this.analysisBaseElement(nextProps);
}
}
analysisBaseElement(props) {
if (props.product && props.product.elements) {
const newElements = BaseElementTransform(props.product.elements);
this.setState({
elements: newElements
});
}
console.log(nextProps);
}
/**
......@@ -192,14 +200,14 @@ export default class ElementForm extends Component {
{
isEdit ?
<span>
<Button size="large" onClick={this.handleAddElement.bind(this)}
style={{marginRight:'1em'}}>
<Icon type="plus"/>添加
</Button>
<Button size="large" type="primary" htmlType="submit" loading={loading}>
<Icon type="save"/>保存
</Button>
</span>
<Button size="large" onClick={this.handleAddElement.bind(this)}
style={{marginRight:'1em'}}>
<Icon type="plus"/>添加
</Button>
<Button size="large" type="primary" htmlType="submit" loading={loading}>
<Icon type="save"/>保存
</Button>
</span>
:
<Button type="primary" onClick={e=>{
e.preventDefault();
......
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 {
super(props, context);
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 = {
product: PropTypes.object,
user: PropTypes.object,
dispatch: PropTypes.func
};
componentWillReceiveProps(nextProps) {
if (nextProps && nextProps.product && nextProps.product.commissionAlg) {
if (nextProps.product.commissionAlg.length != this.props.product.commissionAlg.length) {
this.setState({
yongjing: YongjingTransform(nextProps.product.commissionAlg)
});
}
}
}
// componentWillReceiveProps(nextProps) {
// if (nextProps && nextProps.product && nextProps.product.commissionAlg) {
// if (nextProps.product.commissionAlg.length != this.props.product.commissionAlg.length) {
// this.setState({
// yongjing: YongjingTransform(nextProps.product.commissionAlg)
// });
// }
//
// }
// }
/**
* 添加佣金算法
......
......@@ -110,7 +110,7 @@ export default class List extends Component {
onChange={checked=>{
this.props.dispatch({
type:'UPDATE_ANNOUNCEMENT_ITEM',
data:{
item:{
id: record.id,
status: checked ? 1: 0
}
......
......@@ -65,7 +65,6 @@ export default class EditItem extends Component {
componentWillReceiveProps(nextProps) {
if (nextProps.item && nextProps.item.permissions && nextProps.resources) {
this.analysisCheckedKeys(nextProps);
console.log('analysisCheckedKeys');
}
};
......@@ -99,7 +98,8 @@ export default class EditItem extends Component {
if (isNaN(data.status)) {
ENABLE_STATUS_LIST.forEach(item=> {
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 {
render: (status)=>(
<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 {
if (isNaN(data.status)) {
ENABLE_STATUS_LIST.forEach(item=> {
if (item.text === data.status) {
data.status = item.value
data.status = item.value;
return false;
}
})
}
......
This diff is collapsed.
......@@ -47,10 +47,10 @@ const announcement = handleActions({
return {...state, loading: true}
},
['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){
return {...state, err: action.err, loading: false}
return {...state, err: action.err, loading: false, isEdit:false}
},
}, initState);
......
......@@ -62,13 +62,11 @@ const product = handleActions({
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 ret;
return {...state, loading: false, item:{...state.item, ...action.item}, isEdit: false};
},
['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({
return {...state, loading: false, err: action.err};
}
}, {
//cates: [],
items: [],
loading: false,
});
......
......@@ -53,14 +53,20 @@ const user = handleActions({
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){
return {...state, loading:true};
},
['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){
return {...state, loading: false, err: action.err};
return {...state, loading: false, err: action.err, isEdit:false};
},
}, {
......
......@@ -78,13 +78,13 @@ function* watchAdd() {
}
}
function* editItem(data) {
function* editItem(item) {
try{
yield call(updateItem, data);
yield call(updateItem, item);
message.success('修改成功!');
yield put({
type: 'UPDATE_ANNOUNCEMENT_ITEM_SUCCESS',
item: data
item
});
}catch(err){
console.log(err);
......@@ -109,10 +109,18 @@ function* watchEdit() {
if (data && data.item) {
yield fork(editItem, data.item);
}else{
yield put({
type: 'UPDATE_ANNOUNCEMENT_END'
});
}
yield put({
type: 'UPDATE_ANNOUNCEMENT_END'
});
}
}
function* watchSwidth() {
while(true){
const {item} = yield take('UPDATE_ANNOUNCEMENT_ITEM');
yield fork(editItem, item);
}
}
......@@ -121,4 +129,5 @@ export default function*() {
yield fork(watchItem);
yield fork(watchAdd);
yield fork(watchEdit);
yield fork(watchSwidth);
}
......@@ -105,10 +105,11 @@ function* watchEditProductItem() {
if (data && data.item) {
yield fork(editItem, data.item);
}else{
yield put({
type: 'UPDATE_PRODUCT_END'
});
}
yield put({
type: 'UPDATE_PRODUCT_END'
});
}
}
......
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 {message} from 'antd';
......@@ -107,9 +107,23 @@ function* modifyItem(data) {
}
function* watchMidfiyItem(){
while(true){
const {data} = yield take('UPDATE_USER_ITEM');
yield fork(modifyItem, data);
while (true) {
yield take('UPDATE_USER');
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 => {
export const USER_STATUS = {
0: '未激活',
1: '正常'
1: '已激活'
};
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