提交 344623e0 authored 作者: YunaiV's avatar YunaiV

前端:商品添加。提交部分,让小范帮忙看看~

上级 92b5f6ba
...@@ -119,10 +119,23 @@ export default { ...@@ -119,10 +119,23 @@ export default {
if (callback) { if (callback) {
callback(response); callback(response);
} }
yield put({ // yield put({
type: 'tree', // type: 'tree',
payload: {}, // payload: {},
}); // });
alert('添加成功!后续改成跳转到手机站的详情');
},
*update({ payload }, { call, put }) {
const { callback, body } = payload;
const response = yield call(productSpuAdd, body);
if (callback) {
callback(response);
}
// yield put({
// type: 'tree',
// payload: {},
// });
alert('修改成功!后续改成跳转到手机站的详情');
}, },
}, },
......
import { message } from 'antd'; import { message } from 'antd';
import { productSpuPage, productCategoryAdd, productCategoryUpdate, productCategoryUpdateStatus, productCategoryDelete } from '../../services/product'; import { productSpuPage, productCategoryAdd, productCategoryUpdate, productCategoryUpdateStatus, productCategoryDelete } from '../../services/product';
import {routerRedux} from "dva/router";
export default { export default {
namespace: 'productSpuList', namespace: 'productSpuList',
...@@ -9,46 +10,50 @@ export default { ...@@ -9,46 +10,50 @@ export default {
}, },
effects: { effects: {
*add({ payload }, { call, put }) { // *add({ payload }, { call, put }) {
const { callback, body } = payload; // const { callback, body } = payload;
const response = yield call(productCategoryAdd, body); // const response = yield call(productCategoryAdd, body);
if (callback) { // if (callback) {
callback(response); // callback(response);
} // }
yield put({ // yield put({
type: 'tree', // type: 'tree',
payload: {}, // payload: {},
}); // });
}, // },
*update({ payload }, { call, put }) { // *update({ payload }, { call, put }) {
const { callback, body } = payload; // const { callback, body } = payload;
const response = yield call(productCategoryUpdate, body); // const response = yield call(productCategoryUpdate, body);
if (callback) { // if (callback) {
callback(response); // callback(response);
} // }
yield put({ // yield put({
type: 'tree', // type: 'tree',
payload: {}, // payload: {},
}); // });
}, // },
*updateStatus({ payload }, { call, put }) { // *updateStatus({ payload }, { call, put }) {
const { callback, body } = payload; // const { callback, body } = payload;
const response = yield call(productCategoryUpdateStatus, body); // const response = yield call(productCategoryUpdateStatus, body);
if (callback) { // if (callback) {
callback(response); // callback(response);
} // }
yield put({ // yield put({
type: 'tree', // type: 'tree',
payload: {}, // payload: {},
}); // });
}, // },
*delete({ payload }, { call, put }) { // *delete({ payload }, { call, put }) {
const response = yield call(productCategoryDelete, payload); // const response = yield call(productCategoryDelete, payload);
message.info('删除成功!'); // message.info('删除成功!');
yield put({ // yield put({
type: 'tree', // type: 'tree',
payload: {}, // payload: {},
}); // });
// },
*redirectToAdd({ payload }, { call, put }) {
// const { callback, body } = payload;
yield put(routerRedux.replace('/product/product-spu-add'));
}, },
*page({ payload }, { call, put }) { *page({ payload }, { call, put }) {
const { queryParams } = payload; const { queryParams } = payload;
......
...@@ -77,50 +77,11 @@ class ProductSpuList extends PureComponent { ...@@ -77,50 +77,11 @@ class ProductSpuList extends PureComponent {
}); });
} }
handleModalVisible = (flag, modalType, initValues) => { redirectToAdd = () => {
this.setState({ const { dispatch } = this.props;
modalVisible: !!flag,
initValues: initValues || {},
modalType: modalType || 'add',
});
};
handleAdd = ({ fields, modalType, initValues }) => {
const { dispatch, data } = this.props;
const queryParams = {
pageNo: data.pageNo,
pageSize: data.pageSize,
};
if (modalType === 'add') {
dispatch({
type: 'roleList/add',
payload: {
body: {
...fields,
},
queryParams,
callback: () => {
message.success('添加成功');
this.handleModalVisible();
},
},
});
} else {
dispatch({ dispatch({
type: 'roleList/update', type: 'productSpuList/redirectToAdd',
payload: {
body: {
...initValues,
...fields,
},
queryParams,
callback: () => {
message.success('更新成功');
this.handleModalVisible();
},
},
}); });
}
}; };
render() { render() {
...@@ -199,7 +160,7 @@ class ProductSpuList extends PureComponent { ...@@ -199,7 +160,7 @@ class ProductSpuList extends PureComponent {
<Button <Button
icon="plus" icon="plus"
type="primary" type="primary"
onClick={() => this.handleModalVisible(true, 'add', {})} onClick={this.redirectToAdd}
> >
发布商品 发布商品
</Button> </Button>
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论