Commit 2da6334e authored by superman's avatar superman

update

parent 7f0913d4
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/'
};
......@@ -43,6 +43,21 @@ export default class ContactForm extends Component {
}
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 {
}
}
}
static propsType = {
product: PropTypes.object,
};
......@@ -109,13 +124,13 @@ export default class ContactForm extends Component {
<Input.Group>
<Col span="6">
<Input placeholder="姓名"
{...getFieldProps(index + '.name', {
{...getFieldProps(item.key + '.name', {
initialValue: item.name
})} />
</Col>
<Col span="10">
<Input placeholder="电话"
{...getFieldProps(index + '.mobile', {
{...getFieldProps(item.key + '.mobile', {
initialValue: item.mobile
})}/>
</Col>
......
......@@ -49,6 +49,17 @@ export default class ElementForm extends Component {
};
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)
});
}
}
}
/**
* 删除基本要素
* @param index
......@@ -117,14 +128,14 @@ export default class ElementForm extends Component {
<Input.Group>
<Col span="6">
<Input placeholder="标题"
{...getFieldProps(index + '.title', {
{...getFieldProps(item.key + '.title', {
initialValue: item.title
})}
/>
</Col>
<Col span="10">
<Input type="textarea" placeholder="内容" autosize
{...getFieldProps(index + '.content', {
{...getFieldProps(item.key + '.content', {
initialValue: item.content
})}
/>
......
......@@ -53,13 +53,16 @@ export default class ShouyiYongjingForm extends Component {
dispatch: PropTypes.func
};
componentWillReceiveProps(nextProps){
// if(nextProps && nextProps.product && nextProps.product.commissionAlg){
// 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)
});
}
}
}
/**
* 添加佣金算法
......@@ -109,7 +112,7 @@ export default class ShouyiYongjingForm extends Component {
});
data.commissionAlg = JSON.stringify(commissionAlg);
console.log(data);
console.log(formData, data);
this.props.dispatch({
type: 'UPDATE_PRODUCT_ITEM',
......@@ -166,16 +169,16 @@ export default class ShouyiYongjingForm extends Component {
<div key={item.key}>
<Input.Group>
<Col span="5">
<Input {...getFieldProps(index + '.min', {initialValue: item.min})} />
<Input {...getFieldProps(item.key + '.min', {initialValue: item.min})} />
</Col>
<Col span="5">
<Input {...getFieldProps(index + '.max', {initialValue: item.max})}/>
<Input {...getFieldProps(item.key + '.max', {initialValue: item.max})}/>
</Col>
<Col span="5">
<Input {...getFieldProps(index + '.sy', {initialValue: item.result && item.result.sy})}/>
<Input {...getFieldProps(item.key + '.sy', {initialValue: item.result && item.result.sy})}/>
</Col>
<Col span="5">
<Input {...getFieldProps(index + '.yj', {initialValue: item.result && item.result.yj})}/>
<Input {...getFieldProps(item.key + '.yj', {initialValue: item.result && item.result.yj})}/>
</Col>
<Col span="4">
<Icon type="cross"
......
......@@ -41,7 +41,31 @@ const product = handleActions({
return {...state, loading: true};
},
['UPDATE_PRODUCT_ITEM_SUCCESS'](state, action){
return {...state, loading: false, item:{...state.item, ...action.item}};
if(action.item && action.item.commissionAlg && typeof action.item.commissionAlg === 'string'){
try{
action.item.commissionAlg = JSON.parse(action.item.commissionAlg);
}catch(err){
console.log('UPDATE_PRODUCT_ITEM_SUCCESS commissionAlg Error:', action.item.commissionAlg);
}
}
if(action.item && action.item.elements && typeof action.item.elements === 'string'){
try {
action.item.elements = JSON.parse(action.item.elements);
}catch(err){
console.log('UPDATE_PRODUCT_ITEM_SUCCESS elements Error:', action.item.elements);
}
}
if(action.item && action.item.staffs && typeof action.item.staffs === 'string'){
try{
action.item.staffs = JSON.parse(action.item.staffs);
}catch(err){
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;
},
['UPDATE_PRODUCT_ITEM_FAILED'](state, action){
return {...state, loading: false, err: action.err};
......
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