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

pull/1/head
YunaiV 2019-03-18 20:17:10 +08:00
parent 92b5f6baff
commit 344623e0c9
3 changed files with 67 additions and 88 deletions

View File

@ -119,10 +119,23 @@ export default {
if (callback) {
callback(response);
}
yield put({
type: 'tree',
payload: {},
});
// yield put({
// type: 'tree',
// 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('修改成功!后续改成跳转到手机站的详情');
},
},

View File

@ -1,5 +1,6 @@
import { message } from 'antd';
import { productSpuPage, productCategoryAdd, productCategoryUpdate, productCategoryUpdateStatus, productCategoryDelete } from '../../services/product';
import {routerRedux} from "dva/router";
export default {
namespace: 'productSpuList',
@ -9,46 +10,50 @@ export default {
},
effects: {
*add({ payload }, { call, put }) {
const { callback, body } = payload;
const response = yield call(productCategoryAdd, body);
if (callback) {
callback(response);
}
yield put({
type: 'tree',
payload: {},
});
},
*update({ payload }, { call, put }) {
const { callback, body } = payload;
const response = yield call(productCategoryUpdate, body);
if (callback) {
callback(response);
}
yield put({
type: 'tree',
payload: {},
});
},
*updateStatus({ payload }, { call, put }) {
const { callback, body } = payload;
const response = yield call(productCategoryUpdateStatus, body);
if (callback) {
callback(response);
}
yield put({
type: 'tree',
payload: {},
});
},
*delete({ payload }, { call, put }) {
const response = yield call(productCategoryDelete, payload);
message.info('删除成功!');
yield put({
type: 'tree',
payload: {},
});
// *add({ payload }, { call, put }) {
// const { callback, body } = payload;
// const response = yield call(productCategoryAdd, body);
// if (callback) {
// callback(response);
// }
// yield put({
// type: 'tree',
// payload: {},
// });
// },
// *update({ payload }, { call, put }) {
// const { callback, body } = payload;
// const response = yield call(productCategoryUpdate, body);
// if (callback) {
// callback(response);
// }
// yield put({
// type: 'tree',
// payload: {},
// });
// },
// *updateStatus({ payload }, { call, put }) {
// const { callback, body } = payload;
// const response = yield call(productCategoryUpdateStatus, body);
// if (callback) {
// callback(response);
// }
// yield put({
// type: 'tree',
// payload: {},
// });
// },
// *delete({ payload }, { call, put }) {
// const response = yield call(productCategoryDelete, payload);
// message.info('删除成功!');
// yield put({
// type: 'tree',
// payload: {},
// });
// },
*redirectToAdd({ payload }, { call, put }) {
// const { callback, body } = payload;
yield put(routerRedux.replace('/product/product-spu-add'));
},
*page({ payload }, { call, put }) {
const { queryParams } = payload;

View File

@ -77,50 +77,11 @@ class ProductSpuList extends PureComponent {
});
}
handleModalVisible = (flag, modalType, initValues) => {
this.setState({
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') {
redirectToAdd = () => {
const { dispatch } = this.props;
dispatch({
type: 'roleList/add',
payload: {
body: {
...fields,
},
queryParams,
callback: () => {
message.success('添加成功');
this.handleModalVisible();
},
},
type: 'productSpuList/redirectToAdd',
});
} else {
dispatch({
type: 'roleList/update',
payload: {
body: {
...initValues,
...fields,
},
queryParams,
callback: () => {
message.success('更新成功');
this.handleModalVisible();
},
},
});
}
};
render() {
@ -199,7 +160,7 @@ class ProductSpuList extends PureComponent {
<Button
icon="plus"
type="primary"
onClick={() => this.handleModalVisible(true, 'add', {})}
onClick={this.redirectToAdd}
>
发布商品
</Button>