Commit a87baa4e authored by superman's avatar superman

update

parent 92d0fce3
This source diff could not be displayed because it is too large. You can view the blob instead.
This diff is collapsed.
...@@ -46,19 +46,14 @@ export default class BaseInfoForm extends Component { ...@@ -46,19 +46,14 @@ export default class BaseInfoForm extends Component {
this.state = { this.state = {
priviewVisible: false, priviewVisible: false,
priviewImage: '', priviewImage: '',
fileList: [] fileList: [],
}; };
} }
componentDidMount() { componentDidMount() {
this.updateStateOfNextProps(this.props); this.updateStateOfNextProps(this.props);
} }
componentWillReceiveProps(nextProps) {
this.updateStateOfNextProps(nextProps);
}
updateStateOfNextProps(props) { updateStateOfNextProps(props) {
const {product:{itemPic}} = props; const {product:{itemPic}} = props;
...@@ -81,6 +76,7 @@ export default class BaseInfoForm extends Component { ...@@ -81,6 +76,7 @@ export default class BaseInfoForm extends Component {
const data = this.props.form.getFieldsValue(); const data = this.props.form.getFieldsValue();
if (Array.isArray(data.categoryId) && data.categoryId.length === 2) { if (Array.isArray(data.categoryId) && data.categoryId.length === 2) {
data.categoryParentId = data.categoryId[0];
data.categoryId = data.categoryId[1]; data.categoryId = data.categoryId[1];
} else { } else {
delete data.categoryId; delete data.categoryId;
...@@ -104,6 +100,8 @@ export default class BaseInfoForm extends Component { ...@@ -104,6 +100,8 @@ export default class BaseInfoForm extends Component {
render() { render() {
const {user, cates, product, loading, form:{getFieldProps}, isEdit} = this.props; const {user, cates, product, loading, form:{getFieldProps}, isEdit} = this.props;
let productCate = []; let productCate = [];
...@@ -236,13 +234,34 @@ export default class BaseInfoForm extends Component { ...@@ -236,13 +234,34 @@ export default class BaseInfoForm extends Component {
</Modal> </Modal>
</Form.Item> </Form.Item>
<Form.Item wrapperCol={{span: 16, offset: 6}} style={{marginTop:30}}> <Form.Item wrapperCol={{span: 16, offset: 6}} style={{marginTop:30}}>
<Button type="primary" htmlType="submit" loading={loading}><Icon {
type="save"/>保存</Button> isEdit ?
<Button 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 ? '取消' : '返回'}
</Button> </Button>
} }
</Form.Item> </Form.Item>
......
...@@ -20,7 +20,14 @@ import { ...@@ -20,7 +20,14 @@ import {
Spin Spin
} from 'antd'; } from 'antd';
import {arrayRemoveIndex, UUID, formItemLayout, smallFormItemLayout, footerFormSubmitLayout} from '../../utils'; import {
arrayRemoveIndex,
UUID,
NULL,
formItemLayout,
smallFormItemLayout,
footerFormSubmitLayout
} from '../../utils';
@Form.create() @Form.create()
...@@ -87,47 +94,108 @@ export default class ContactForm extends Component { ...@@ -87,47 +94,108 @@ export default class ContactForm extends Component {
} }
render() { render() {
const {form:{getFieldProps}, loading} = this.props; const {form:{getFieldProps}, loading, isEdit} = this.props;
return ( return (
<Spin spinning={loading}> <Spin spinning={loading}>
<Form horizontal onSubmit={this.handleSubmit.bind(this)}> <Form horizontal onSubmit={this.handleSubmit.bind(this)}>
<Form.Item> <Row style={{padding:'0 20px'}}>
{ <Col span="24">
this.state.staffs.map((item, index)=> {
<div key={item.key} style={{marginBottom:8}}> isEdit ?
<Input.Group> <Form.Item>
<Col span="6"> {
<Input placeholder="姓名" this.state.staffs.map((item, index)=>
{...getFieldProps(index + '.name', { <div key={item.key} style={{marginBottom:8}}>
initialValue: item.name <Input.Group>
})} /> <Col span="6">
</Col> <Input placeholder="姓名"
<Col span="10"> {...getFieldProps(index + '.name', {
<Input placeholder="电话" initialValue: item.name
{...getFieldProps(index + '.mobile', { })} />
initialValue: item.mobile </Col>
})}/> <Col span="10">
</Col> <Input placeholder="电话"
<Col span="4"> {...getFieldProps(index + '.mobile', {
<Icon type="cross" title="删除" onClick={this.handleRemove.bind(this, index)}/> initialValue: item.mobile
</Col> })}/>
</Input.Group> </Col>
</div> <Col span="4">
) <Icon type="cross" title="删除"
} onClick={this.handleRemove.bind(this, index)}/>
</Form.Item> </Col>
<Form.Item {...footerFormSubmitLayout} style={{marginTop:30}}> </Input.Group>
<Button onClick={this.handleAdd.bind(this)} style={{marginRight:'1em'}}><Icon </div>
type="plus"/>添加</Button> )
<Button type="primary" htmlType="submit" loading={loading}><Icon type="save"/>保存</Button> }
{ </Form.Item>
!this.props.isCreate && :
<Button onClick={e=>{e.preventDefault(); this.props.history.goBack();}}
style={{marginLeft:'1em'}}> this.state.staffs.length ?
<Icon type="rollback" />返回 <table>
</Button> <thead>
} <tr>
</Form.Item> <th>姓名</th>
<th>电话</th>
</tr>
</thead>
<tbody>
{
this.state.staffs.map((item, index)=>
<tr key={index}>
<td>{item.name}</td>
<td>{item.mobile || NULL}</td>
</tr>
)
}
</tbody>
</table>
:
<Form.Item {...footerFormSubmitLayout}>
还没有设置过任何一位服务经理及其联系电话
</Form.Item>
}
<Form.Item {...footerFormSubmitLayout} style={{marginTop:30}}>
{
isEdit ?
<span>
<Button size="large" onClick={this.handleAdd.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();
this.props.dispatch({
type:'UPDATE_PRODUCT'
});
}}>
<Icon type="edit"/>编辑
</Button>
}
{
!this.props.isCreate &&
<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> </Form>
</Spin> </Spin>
); );
......
...@@ -23,11 +23,14 @@ import { ...@@ -23,11 +23,14 @@ import {
import { import {
arrayRemoveIndex, arrayRemoveIndex,
UUID, UUID,
NULL,
formItemLayout, formItemLayout,
smallFormItemLayout, smallFormItemLayout,
footerFormSubmitLayout, footerFormSubmitLayout,
handleUpload handleUpload
} from '../../utils'; } from '../../utils';
import Copy from '../../components/CopyToClipboard/CopyToClipboard';
@Form.create() @Form.create()
export default class DocumentsForm extends Component { export default class DocumentsForm extends Component {
...@@ -49,8 +52,8 @@ export default class DocumentsForm extends Component { ...@@ -49,8 +52,8 @@ export default class DocumentsForm extends Component {
}; };
componentWillMount(){ componentWillMount() {
} }
handleSubmit(e) { handleSubmit(e) {
...@@ -76,35 +79,64 @@ export default class DocumentsForm extends Component { ...@@ -76,35 +79,64 @@ export default class DocumentsForm extends Component {
} }
render() { render() {
const {user, loading} = 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:'800px', margin:'auto'}}>
<Form.Item> <Row style={{padding:'0 20px'}}>
<Upload.Dragger action="/api/fileUpload/upload" <Col span="24">
multiple={true} <Form.Item>
headers={{ {
authorization: user && user.token, isEdit ?
}} <Upload.Dragger action="/api/fileUpload/upload"
onChange={info=>this.setState({fileList: handleUpload(info)})} multiple={true}
fileList={this.state.fileList}> headers={{
<p className="ant-upload-drag-icon"> authorization: user && user.token,
<Icon type="inbox"/> }}
</p> onChange={info=>this.setState({fileList: handleUpload(info)})}
<p className="ant-upload-text">点击或将文件拖拽到此区域上传</p> //showUploadList={false}
<p className="ant-upload-hint">支持单个或批量上传,严禁上传公司内部资料及其他违禁文件</p> onPreview={(e)=>console.log(e)}
</Upload.Dragger> fileList={this.state.fileList}
</Form.Item> >
<Form.Item style={{marginTop:30, textAlign:'center'}}> <p className="ant-upload-drag-icon">
<Button type="primary" htmlType="submit" loading={loading}><Icon type="save"/>保存</Button> <Icon type="inbox"/>
{ </p>
!this.props.isCreate && <p className="ant-upload-text">点击或将文件拖拽到此区域上传</p>
<Button onClick={e=>{e.preventDefault(); this.props.history.goBack();}} <p className="ant-upload-hint">支持单个或批量上传,严禁上传公司内部资料及其他违禁文件</p>
style={{marginLeft:'1em'}}> </Upload.Dragger>
<Icon type="rollback" />返回 :
</Button> <ul style={{paddingTop:30}}>
} {
</Form.Item> this.state.fileList.map(file=>
<li key={file.uid} style={{margin:"10px 0"}}>
<Copy copyText={file.url}>
<Row>
<Col span="4"><Icon type="paper-clip"
style={{marginRight:'.3em'}}/>{file.name}
</Col>
<Col span="20">{file.url ? file.url : '正在上传...'}</Col>
</Row>
</Copy>
</li>
)
}
</ul>
}
</Form.Item>
<Form.Item style={{marginTop:30, textAlign:'center'}}>
<Button type="primary" htmlType="submit" loading={loading}><Icon
type="save"/>保存</Button>
{
!this.props.isCreate &&
<Button onClick={e=>{e.preventDefault(); this.props.history.goBack();}}
style={{marginLeft:'1em'}}>
<Icon type="rollback"/>
{isEdit ? '取消' : '返回'}
</Button>
}
</Form.Item>
</Col>
</Row>
</Form> </Form>
</Spin> </Spin>
); );
......
...@@ -140,30 +140,62 @@ export default class ElementForm extends Component { ...@@ -140,30 +140,62 @@ export default class ElementForm extends Component {
</Form.Item> </Form.Item>
</div> </div>
: :
<table> this.state.elements.length ?
<tbody> <table>
{ <tbody>
this.state.elements.map(item=> {
<tr> this.state.elements.map(item=> {
<th>{item.title}</th> item.title && item.content &&
<td>{item.content || NULL}</td> <tr>
</tr> <th>{item.title}</th>
) <td>{item.content}</td>
} </tr>
</tbody> }
</table> )
}
</tbody>
</table>
:
<Form.Item {...footerFormSubmitLayout}>
还没有设置过任何基本要素
</Form.Item>
} }
<Form.Item {...footerFormSubmitLayout} style={{marginTop:30}}> <Form.Item {...footerFormSubmitLayout} style={{marginTop:30}}>
<Button onClick={this.handleAddElement.bind(this)} style={{marginRight:'1em'}}><Icon {
type="plus"/>添加</Button> isEdit ?
<Button type="primary" htmlType="submit" loading={loading}><Icon <span>
type="save"/>保存</Button> <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();
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 ? '取消' : '返回'}
</Button> </Button>
} }
</Form.Item> </Form.Item>
......
...@@ -108,12 +108,34 @@ export default class HuikuanInfoForm extends Component { ...@@ -108,12 +108,34 @@ export default class HuikuanInfoForm extends Component {
</Form.Item> </Form.Item>
<Form.Item {...footerFormSubmitLayout} style={{marginTop:30}}> <Form.Item {...footerFormSubmitLayout} style={{marginTop:30}}>
<Button type="primary" htmlType="submit" loading={loading}><Icon type="save"/>保存</Button> {
isEdit ?
<Button 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 ? '取消' : '返回'}
</Button> </Button>
} }
</Form.Item> </Form.Item>
......
...@@ -53,6 +53,14 @@ export default class ShouyiYongjingForm extends Component { ...@@ -53,6 +53,14 @@ export default class ShouyiYongjingForm extends Component {
dispatch: PropTypes.func dispatch: PropTypes.func
}; };
componentWillReceiveProps(nextProps){
// if(nextProps && nextProps.product && nextProps.product.commissionAlg){
// this.setState({
// yongjing: YongjingTransform(nextProps.product.commissionAlg)
// });
// }
}
/** /**
* 添加佣金算法 * 添加佣金算法
* @param e * @param e
...@@ -210,15 +218,40 @@ export default class ShouyiYongjingForm extends Component { ...@@ -210,15 +218,40 @@ export default class ShouyiYongjingForm extends Component {
} }
</Form.Item> </Form.Item>
<Form.Item {...footerFormSubmitLayout} style={{marginTop:30}}> <Form.Item {...footerFormSubmitLayout} style={{marginTop:30}}>
<Button style={{marginRight:'1em'}} {
onClick={this.handleAddYongjing.bind(this)}><Icon isEdit ?
type="plus"/>添加</Button> <span>
<Button type="primary" htmlType="submit" loading={loading}><Icon type="save"/>保存</Button> <Button size="large" onClick={this.handleAddYongjing.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();
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 ? '取消' : '返回'}
</Button> </Button>
} }
</Form.Item> </Form.Item>
......
...@@ -67,10 +67,10 @@ export default class BaseUpload extends Component { ...@@ -67,10 +67,10 @@ export default class BaseUpload extends Component {
<p className="ant-upload-text">点击或将图片拖拽到此区域上传</p> <p className="ant-upload-text">点击或将图片拖拽到此区域上传</p>
<p className="ant-upload-hint">支持单个或批量上传,严禁上传公司内部资料及其他违禁文件</p> <p className="ant-upload-hint">支持单个或批量上传,严禁上传公司内部资料及其他违禁文件</p>
</Upload.Dragger> </Upload.Dragger>
<ul className={styles.fileList}> <ul style={{paddingTop:30}}>
{ {
this.state.fileList.map(file=> this.state.fileList.map(file=>
<li key={file.uid}> <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="4"><Icon type="paper-clip"
......
...@@ -69,6 +69,7 @@ class PublishForm extends Component { ...@@ -69,6 +69,7 @@ class PublishForm extends Component {
product: state.product.item, product: state.product.item,
loading: state.product.loading, loading: state.product.loading,
isCreate: true, isCreate: true,
isEdit: state.product.isEdit
})) }))
export default class AddItem extends Component { export default class AddItem extends Component {
...@@ -76,7 +77,7 @@ export default class AddItem extends Component { ...@@ -76,7 +77,7 @@ export default class AddItem extends Component {
constructor(props, content) { constructor(props, content) {
super(props, content); super(props, content);
this.state = { this.state = {
step: parseInt(location.hash.replace('#', ''), 10) || 1 isEdit: true
} }
} }
...@@ -98,6 +99,15 @@ export default class AddItem extends Component { ...@@ -98,6 +99,15 @@ export default class AddItem extends Component {
}; };
componentWillReceiveProps(nextProps) {
this.setState({isEdit: nextProps.isEdit});
if(nextProps.product && nextProps.product.id){
this.props.dispatch({
type: 'UPDATE_PRODUCT'
});
}
}
fetchCates() { fetchCates() {
this.props.dispatch({ this.props.dispatch({
type: 'FETCH_PRODUCT_CATES' type: 'FETCH_PRODUCT_CATES'
...@@ -109,6 +119,8 @@ export default class AddItem extends Component { ...@@ -109,6 +119,8 @@ export default class AddItem extends Component {
const {product} = this.props; const {product} = this.props;
const {isEdit} = this.state;
const styles = require('./Product.less'); const styles = require('./Product.less');
const tabs = [{ const tabs = [{
...@@ -148,7 +160,7 @@ export default class AddItem extends Component { ...@@ -148,7 +160,7 @@ export default class AddItem extends Component {
<Tabs className={styles.tabs} tabPosition="left"> <Tabs className={styles.tabs} tabPosition="left">
{ tabs.map(tp=> { tabs.map(tp=>
<Tabs.TabPane tab={tp.tab} key={tp.key}> <Tabs.TabPane tab={tp.tab} key={tp.key}>
{product && <tp.children {...this.props} isEdit={true} /> } {product && <tp.children {...this.props} isEdit={isEdit} /> }
</Tabs.TabPane> </Tabs.TabPane>
)} )}
</Tabs> </Tabs>
......
...@@ -36,6 +36,7 @@ import Layout from '../../components/Layout/Layout'; ...@@ -36,6 +36,7 @@ import Layout from '../../components/Layout/Layout';
product: state.product.item, product: state.product.item,
loading: state.product.loading, loading: state.product.loading,
user: state.user, user: state.user,
isEdit: state.product.isEdit
})) }))
export default class EditItem extends Component { export default class EditItem extends Component {
...@@ -46,8 +47,8 @@ export default class EditItem extends Component { ...@@ -46,8 +47,8 @@ export default class EditItem extends Component {
product: PropTypes.object product: PropTypes.object
}; };
constructor() { constructor(props, content) {
super(...arguments); super(props, content);
this.state = { this.state = {
isEdit: false isEdit: false
} }
...@@ -61,6 +62,10 @@ export default class EditItem extends Component { ...@@ -61,6 +62,10 @@ export default class EditItem extends Component {
this.fetchItem(this.props.params.id); this.fetchItem(this.props.params.id);
}; };
componentWillReceiveProps(nextProps) {
this.setState({isEdit: nextProps.isEdit});
}
fetchCates() { fetchCates() {
this.props.dispatch({ this.props.dispatch({
type: 'FETCH_PRODUCT_CATES' type: 'FETCH_PRODUCT_CATES'
...@@ -82,13 +87,13 @@ export default class EditItem extends Component { ...@@ -82,13 +87,13 @@ export default class EditItem extends Component {
const styles = require('./Product.less'); const styles = require('./Product.less');
const tabs = [ const tabs = [
{ tab: '基本信息', children: BaseInfoForm }, {tab: '基本信息', children: BaseInfoForm},
{ tab: '收益佣金', children: ShouyiYongjingForm }, {tab: '收益佣金', children: ShouyiYongjingForm},
{ tab: '汇款账号', children: HuikuanInfoForm }, {tab: '汇款账号', children: HuikuanInfoForm},
{ tab: '基本要素', children: ElementForm }, {tab: '基本要素', children: ElementForm},
{ tab: '时间状态', children: DateTimeStatusForm }, {tab: '时间状态', children: DateTimeStatusForm},
{ tab: '相关附件', children: DocumentsForm }, {tab: '相关附件', children: DocumentsForm},
{ tab: '服务经理', children: ContactForm } {tab: '服务经理', children: ContactForm}
].map((tabPane, index)=> { ].map((tabPane, index)=> {
tabPane.key = 'tabs-pane-' + (index + 1); tabPane.key = 'tabs-pane-' + (index + 1);
return tabPane; return tabPane;
...@@ -102,14 +107,23 @@ export default class EditItem extends Component { ...@@ -102,14 +107,23 @@ export default class EditItem extends Component {
{ {
product && product &&
<Button type="ghost" <Button type="ghost"
onClick={e=>{e.preventDefault(); this.setState({isEdit: !this.state.isEdit})}}> onClick={
e=>{
e.preventDefault();
this.props.dispatch({
type: isEdit ? 'CANCEL_UPDATE_PRODUCT' : 'UPDATE_PRODUCT'
});
}
}>
<Icon type="edit"/> <Icon type="edit"/>
</Button> </Button>
} }
<Button type="ghost" onClick={e=>{ <Button type="ghost" onClick={e=>{
e.preventDefault(); e.preventDefault();
isEdit ? isEdit ?
this.setState({isEdit: !this.state.isEdit}) : this.props.dispatch({
type: 'CANCEL_UPDATE_PRODUCT'
}) :
this.props.history.goBack(); this.props.history.goBack();
}}> }}>
<Icon type="rollback"/> <Icon type="rollback"/>
...@@ -118,7 +132,7 @@ export default class EditItem extends Component { ...@@ -118,7 +132,7 @@ export default class EditItem extends Component {
</div> </div>
); );
const title = (product && product.itemShortTitle ? product.itemShortTitle + ' - ' : '') + '产品详情' + (isEdit?' - 编辑中': ''); const title = (product && product.itemShortTitle ? product.itemShortTitle + ' - ' : '') + '产品详情' + (isEdit ? ' - 编辑中' : '');
const header = (<MainHeader breadcrumb={['产品管理', '产品详情']} title={title} operation={operation}/>); const header = (<MainHeader breadcrumb={['产品管理', '产品详情']} title={title} operation={operation}/>);
...@@ -127,7 +141,7 @@ export default class EditItem extends Component { ...@@ -127,7 +141,7 @@ export default class EditItem extends Component {
<Tabs className={styles.tabs} tabPosition="left"> <Tabs className={styles.tabs} tabPosition="left">
{ tabs.map(tp=> { tabs.map(tp=>
<Tabs.TabPane tab={tp.tab} key={tp.key}> <Tabs.TabPane tab={tp.tab} key={tp.key}>
{product && <tp.children {...this.props} isEdit={isEdit} /> } {product && <tp.children {...this.props} isEdit={isEdit}/> }
</Tabs.TabPane> </Tabs.TabPane>
)} )}
</Tabs> </Tabs>
......
...@@ -38,7 +38,7 @@ import MainHeader from '../../components/MainHeader/MainHeader'; ...@@ -38,7 +38,7 @@ import MainHeader from '../../components/MainHeader/MainHeader';
@Form.create() @Form.create()
export default class Commission extends Component { export default class Commission extends Component {
componentWillMount() { componentDidMount() {
const {dispatch, params:{id}} = this.props; const {dispatch, params:{id}} = this.props;
dispatch({ dispatch({
type: 'FETCH_TRADE_ITEM', type: 'FETCH_TRADE_ITEM',
...@@ -70,7 +70,7 @@ export default class Commission extends Component { ...@@ -70,7 +70,7 @@ export default class Commission extends Component {
<Form.Item label="产品" {...smallFormItemLayout}> <Form.Item label="产品" {...smallFormItemLayout}>
<p>{item && item.title}</p> <p>{item && item.title}</p>
</Form.Item> </Form.Item>
<Form.Item label="确认打款金额" {...smallFormItemLayout}> <Form.Item label="确认打款金额" {...smallFormItemLayout}>
<Input placeholder="确认打款金额" <Input placeholder="确认打款金额"
readOnly readOnly
......
...@@ -29,15 +29,25 @@ const product = handleActions({ ...@@ -29,15 +29,25 @@ const product = handleActions({
['FETCH_PRODUCT_ITEM_FAILED'](state, action){ ['FETCH_PRODUCT_ITEM_FAILED'](state, action){
return {...state, err: action.err, loading: false} return {...state, err: action.err, loading: false}
}, },
['UPDATE_PRODUCT_START'](state){
return {...state, isEdit: true}
},
['UPDATE_PRODUCT_END'](state){
return {...state, isEdit: false}
},
['UPDATE_PRODUCT_ITEM'](state){ ['UPDATE_PRODUCT_ITEM'](state){
return {...state, loading: true}; return {...state, loading: true};
}, },
['UPDATE_PRODUCT_ITEM_SUCCESS'](state){ ['UPDATE_PRODUCT_ITEM_SUCCESS'](state, action){
return {...state, loading: false}; return {...state, loading: false, item:{...state.item, ...action.item}};
}, },
['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};
}, },
['CREATE_PRODUCT_ITEM'](state){ ['CREATE_PRODUCT_ITEM'](state){
return {...state, loading: true}; return {...state, loading: true};
}, },
......
import {takeLatest} from 'redux-saga'; import {takeLatest} from 'redux-saga';
import {take, call, put, fork, cancel, select} from 'redux-saga/effects'; import {take, call, put, fork, cancel, select, race} from 'redux-saga/effects';
import {fetchList, fetchCates, fetchItem, updateItem, createItem} from '../services/product'; import {fetchList, fetchCates, fetchItem, updateItem, createItem} from '../services/product';
import {message} from 'antd'; import {message} from 'antd';
...@@ -75,41 +75,55 @@ function* watchProductItem() { ...@@ -75,41 +75,55 @@ function* watchProductItem() {
} }
function* editItem(item) { function* editItem(item) {
try{ try {
yield call(updateItem, item); yield call(updateItem, item);
message.success('保存成功!'); message.success('保存成功!');
yield put({ yield put({
type: 'UPDATE_PRODUCT_ITEM_SUCCESS', type: 'UPDATE_PRODUCT_ITEM_SUCCESS',
item
}); });
}catch(err){ } catch (err) {
console.log(err); console.log(err);
message.error(err); message.error(err);
yield put({ yield put({
type:'UPDATE_PRODUCT_ITEM_FAILED', type: 'UPDATE_PRODUCT_ITEM_FAILED',
err err
}); });
} }
} }
function* watchEditProductItem(){ function* watchEditProductItem() {
while(true){ while (true) {
const {item} = yield take('UPDATE_PRODUCT_ITEM'); yield take('UPDATE_PRODUCT');
yield fork(editItem, item); yield put({
type: 'UPDATE_PRODUCT_START'
});
const {data} = yield race({
data: take('UPDATE_PRODUCT_ITEM'),
canceled: take('CANCEL_UPDATE_PRODUCT')
});
if (data && data.item) {
yield fork(editItem, data.item);
}
yield put({
type: 'UPDATE_PRODUCT_END'
});
} }
} }
function* addItem() { function* addItem() {
try{ try {
const item = yield call(createItem); const item = yield call(createItem);
yield put({ yield put({
type: 'CREATE_PRODUCT_ITEM_SUCCESS', type: 'CREATE_PRODUCT_ITEM_SUCCESS',
item item
}); });
}catch(err){ } catch (err) {
console.log(err); console.log(err);
message.error(err); message.error(err);
yield put({ yield put({
type:'CREATE_PRODUCT_ITEM_FAILED', type: 'CREATE_PRODUCT_ITEM_FAILED',
err err
}); });
} }
......
...@@ -102,9 +102,9 @@ export const tradeStatusToString = status => { ...@@ -102,9 +102,9 @@ export const tradeStatusToString = status => {
export const tradeCreateTypeToString = type => { export const tradeCreateTypeToString = type => {
switch (type) { switch (type) {
case 1: case 1:
return '后台创建';
case 5:
return 'APP创建'; return 'APP创建';
case 5:
return '后台创建';
default: default:
return '未知创建者'; return '未知创建者';
} }
......
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