- 前端:完善商品列表
- 后端:将商品模块的 Service 改成有业务异常时,抛出异常,而不是返回 CommonResult - 后端:将搜索模块的 Service 改成有业务异常时,抛出异常,而不是返回 CommonResult
This commit is contained in:
@@ -62,6 +62,9 @@ export default {
|
||||
const response = yield call(productSpuInfo, {
|
||||
id: payload,
|
||||
});
|
||||
if (response.code !== 0) {
|
||||
return;
|
||||
}
|
||||
// 响应
|
||||
let skus = [];
|
||||
let attrTree = [];
|
||||
@@ -193,6 +196,9 @@ export default {
|
||||
*add({ payload }, { call, put }) {
|
||||
const { callback, body } = payload;
|
||||
const response = yield call(productSpuAdd, body);
|
||||
if (response.code !== 0) {
|
||||
return;
|
||||
}
|
||||
if (callback) {
|
||||
callback(response);
|
||||
}
|
||||
@@ -205,6 +211,9 @@ export default {
|
||||
*update({ payload }, { call, put }) {
|
||||
const { callback, body } = payload;
|
||||
const response = yield call(productSpuUpdate, body);
|
||||
if (response.code !== 0) {
|
||||
return;
|
||||
}
|
||||
if (callback) {
|
||||
callback(response);
|
||||
}
|
||||
|
||||
@@ -1,12 +1,33 @@
|
||||
import { message } from 'antd';
|
||||
import { productSpuPage, productCategoryAdd, productCategoryUpdate, productCategoryUpdateStatus, productCategoryDelete } from '../../services/product';
|
||||
import { productSpuPage, productSpuUpdateSort } from '../../services/product';
|
||||
import {routerRedux} from "dva/router";
|
||||
import PaginationHelper from '../../../helpers/PaginationHelper';
|
||||
|
||||
const SEARCH_PARAMS_DEFAULT = {
|
||||
name: '',
|
||||
status: 1,
|
||||
cid: undefined,
|
||||
};
|
||||
|
||||
export default {
|
||||
namespace: 'productSpuList',
|
||||
|
||||
state: {
|
||||
// 分页列表相关
|
||||
list: [],
|
||||
listLoading: false,
|
||||
pagination: PaginationHelper.defaultPaginationConfig,
|
||||
searchParams: SEARCH_PARAMS_DEFAULT,
|
||||
|
||||
// 添加 or 修改表单相关
|
||||
// modalVisible: false,
|
||||
// modalType: undefined, // 'add' or 'update' 表单
|
||||
formVals: {}, // 当前表单值
|
||||
// modalLoading: false,
|
||||
|
||||
|
||||
sortModalVisible: false, // 修改排序弹窗
|
||||
sortModalLoading: false, // 修改排序的加载
|
||||
},
|
||||
|
||||
effects: {
|
||||
@@ -35,19 +56,76 @@ export default {
|
||||
},
|
||||
*redirectToUpdate({ payload }, { call, put }) {
|
||||
// const { callback, body } = payload;
|
||||
debugger;
|
||||
yield put(routerRedux.replace('/product/product-spu-update?id=' + payload));
|
||||
},
|
||||
*page({ payload }, { call, put }) {
|
||||
// const { queryParams } = payload;
|
||||
const response = yield call(productSpuPage, payload);
|
||||
message.info('查询成功!');
|
||||
// const response = yield call(productSpuPage, payload);
|
||||
// message.info('查询成功!');
|
||||
// yield put({
|
||||
// type: 'treeSuccess',
|
||||
// payload: {
|
||||
// list: response.data,
|
||||
// },
|
||||
// });
|
||||
|
||||
// 显示加载中
|
||||
yield put({
|
||||
type: 'treeSuccess',
|
||||
type: 'changeListLoading',
|
||||
payload: true,
|
||||
});
|
||||
|
||||
// 请求
|
||||
const response = yield call(productSpuPage, payload);
|
||||
// 响应
|
||||
yield put({
|
||||
type: 'setAll',
|
||||
payload: {
|
||||
list: response.data,
|
||||
list: response.data.list,
|
||||
pagination: PaginationHelper.formatPagination(response.data, payload),
|
||||
searchParams: {
|
||||
name: payload.name,
|
||||
status: payload.status,
|
||||
cid: payload.cid,
|
||||
}
|
||||
},
|
||||
});
|
||||
|
||||
// 隐藏加载中
|
||||
yield put({
|
||||
type: 'changeListLoading',
|
||||
payload: false,
|
||||
});
|
||||
},
|
||||
*updateSort({ payload }, { call, put }) {
|
||||
// 显示加载中
|
||||
yield put({
|
||||
type: 'changeSortModalLoading',
|
||||
payload: true,
|
||||
});
|
||||
|
||||
// 请求
|
||||
const { callback, body } = payload;
|
||||
// 响应
|
||||
const response = yield call(productSpuUpdateSort, body);
|
||||
if(response.code === 0) {
|
||||
if (callback) {
|
||||
callback(response);
|
||||
}
|
||||
yield put({
|
||||
type: 'page',
|
||||
payload: {
|
||||
...this.state.pagination,
|
||||
...this.state.searchParams,
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
// 隐藏加载中
|
||||
yield put({
|
||||
type: 'changeSortModalLoading',
|
||||
payload: false,
|
||||
});
|
||||
},
|
||||
},
|
||||
|
||||
@@ -58,5 +136,25 @@ export default {
|
||||
...payload,
|
||||
};
|
||||
},
|
||||
// 修改加载中的状态
|
||||
changeSortModalLoading(state, { payload }) {
|
||||
return {
|
||||
...state,
|
||||
sortModalLoading: payload,
|
||||
};
|
||||
},
|
||||
changeListLoading(state, { payload }) {
|
||||
return {
|
||||
...state,
|
||||
listLoading: payload,
|
||||
};
|
||||
},
|
||||
// 设置所有属性
|
||||
setAll(state, { payload }) {
|
||||
return {
|
||||
...state,
|
||||
...payload,
|
||||
};
|
||||
}
|
||||
},
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user