提交 dcc58fbb authored 作者: YunaiV's avatar YunaiV

文档:增加功能列表

后端 + 前端:完善展示分类功能
上级 83a36890
...@@ -27,6 +27,12 @@ class PicturesWall extends React.Component { ...@@ -27,6 +27,12 @@ class PicturesWall extends React.Component {
], ],
}; };
componentDidMount() {
if (this.props.urls) {
this.setUrls(this.props.urls);
}
}
handleCancel = () => this.setState({ previewVisible: false }) handleCancel = () => this.setState({ previewVisible: false })
handlePreview = (file) => { handlePreview = (file) => {
...@@ -137,6 +143,14 @@ class PicturesWall extends React.Component { ...@@ -137,6 +143,14 @@ class PicturesWall extends React.Component {
return urls; return urls;
}; };
getUrl = () => {
let urls = this.getUrls();
if (urls && urls.length > 0) {
return urls[0];
}
return undefined;
};
setUrls = (urls) => { setUrls = (urls) => {
// let urls = this.props.urls; // let urls = this.props.urls;
if (urls) { if (urls) {
...@@ -188,7 +202,7 @@ class PicturesWall extends React.Component { ...@@ -188,7 +202,7 @@ class PicturesWall extends React.Component {
PicturesWall.propTypes = { PicturesWall.propTypes = {
maxLength: Number, // 最大照片墙图片数量 maxLength: Number, // 最大照片墙图片数量
// urls: String[], // 初始图片列表 urls: Array, // 初始图片列表
}; };
export default PicturesWall; export default PicturesWall;
...@@ -69,7 +69,6 @@ export default { ...@@ -69,7 +69,6 @@ export default {
}); });
}, },
* add({ payload }, { call, put }) { * add({ payload }, { call, put }) {
const { callback, body } = payload;
// 显示加载中 // 显示加载中
yield put({ yield put({
type: 'changeModalLoading', type: 'changeModalLoading',
...@@ -77,6 +76,7 @@ export default { ...@@ -77,6 +76,7 @@ export default {
}); });
// 请求 // 请求
const { callback, body } = payload;
const response = yield call(addAdmin, body); const response = yield call(addAdmin, body);
// 响应 // 响应
if (response.code === 0) { if (response.code === 0) {
......
...@@ -5,61 +5,129 @@ export default { ...@@ -5,61 +5,129 @@ export default {
namespace: 'productCategoryList', namespace: 'productCategoryList',
state: { state: {
// 分页列表相关
list: [], list: [],
listLoading: false,
// 添加 or 修改表单相关
modalVisible: false,
modalType: undefined, // 'add' or 'update' 表单
formVals: {}, // 当前表单值
modalLoading: false,
}, },
effects: { effects: {
// 查询列表
*tree({ payload }, { call, put }) {
// 显示加载中
yield put({
type: 'changeListLoading',
payload: true,
});
// 请求
const { queryParams } = payload;
// 响应
const response = yield call(productCategoryTree, queryParams);
yield put({
type: 'treeSuccess',
payload: {
list: response.data,
},
});
// 隐藏加载中
yield put({
type: 'changeListLoading',
payload: false,
});
},
*add({ payload }, { call, put }) { *add({ payload }, { call, put }) {
// 显示加载中
yield put({
type: 'changeModalLoading',
payload: true,
});
// 请求
const { callback, body } = payload; const { callback, body } = payload;
const response = yield call(productCategoryAdd, body); const response = yield call(productCategoryAdd, body);
if (callback) { // 响应
callback(response); if (response.code === 0) {
if (callback) {
callback(response);
}
// 刷新列表
yield put({
type: 'tree',
payload: {},
});
} }
// 隐藏加载中
yield put({ yield put({
type: 'tree', type: 'changeModalLoading',
payload: {}, payload: false,
}); });
}, },
*update({ payload }, { call, put }) { *update({ payload }, { call, put }) {
// 显示加载中
yield put({
type: 'changeModalLoading',
payload: true,
});
// 请求
const { callback, body } = payload; const { callback, body } = payload;
const response = yield call(productCategoryUpdate, body); const response = yield call(productCategoryUpdate, body);
if (callback) { // 响应
callback(response); if (response.code === 0) {
if (callback) {
callback(response);
}
// 刷新列表
yield put({
type: 'tree',
payload: {},
});
} }
// 隐藏加载中
yield put({ yield put({
type: 'tree', type: 'changeModalLoading',
payload: {}, payload: false,
}); });
}, },
*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(response.code === 0) {
callback(response); message.info('更新状态成功!');
if (callback) {
callback(response);
}
yield put({
type: 'tree',
payload: {},
});
} }
yield put({
type: 'tree',
payload: {},
});
}, },
*delete({ payload }, { call, put }) { *delete({ payload }, { call, put }) {
// 响应
const response = yield call(productCategoryDelete, payload); const response = yield call(productCategoryDelete, payload);
message.info('删除成功!'); if(response.code === 0) {
yield put({ message.info('删除成功!');
type: 'tree', if (callback) {
payload: {}, callback(response);
}); }
}, yield put({
*tree({ payload }, { call, put }) { type: 'tree',
const { queryParams } = payload; payload: {},
const response = yield call(productCategoryTree, queryParams); });
message.info('查询成功!'); }
yield put({
type: 'treeSuccess',
payload: {
list: response.data,
},
});
}, },
}, },
...@@ -70,5 +138,25 @@ export default { ...@@ -70,5 +138,25 @@ export default {
...payload, ...payload,
}; };
}, },
// 修改加载中的状态
changeModalLoading(state, { payload }) {
return {
...state,
modalLoading: payload,
};
},
changeListLoading(state, { payload }) {
return {
...state,
listLoading: payload,
};
},
// 设置所有属性
setAll(state, { payload }) {
return {
...state,
...payload,
};
}
}, },
}; };
...@@ -213,7 +213,7 @@ const AddOrUpdateForm = Form.create()(props => { ...@@ -213,7 +213,7 @@ const AddOrUpdateForm = Form.create()(props => {
// 清空表单 // 清空表单
form.resetFields(); form.resetFields();
// 提示 // 提示
message.success('添加成功'); message.success('新建成功');
// 关闭弹窗 // 关闭弹窗
handleModalVisible(); handleModalVisible();
}, },
...@@ -232,7 +232,7 @@ const AddOrUpdateForm = Form.create()(props => { ...@@ -232,7 +232,7 @@ const AddOrUpdateForm = Form.create()(props => {
// 清空表单 // 清空表单
form.resetFields(); form.resetFields();
// 提示 // 提示
message.success('更新成功'); message.success('编辑成功');
// 关闭弹窗 // 关闭弹窗
handleModalVisible(); handleModalVisible();
}, },
...@@ -242,7 +242,7 @@ const AddOrUpdateForm = Form.create()(props => { ...@@ -242,7 +242,7 @@ const AddOrUpdateForm = Form.create()(props => {
}); });
}; };
const title = modalType === 'add' ? '新建管理员' : '更新管理员'; const title = modalType === 'add' ? '新建员工' : '更新员工';
return ( return (
<Modal <Modal
destroyOnClose destroyOnClose
...@@ -389,11 +389,6 @@ const RoleAssignModal = Form.create()(props => { ...@@ -389,11 +389,6 @@ const RoleAssignModal = Form.create()(props => {
// 主界面 // 主界面
@Form.create() @Form.create()
class AdminList extends PureComponent { class AdminList extends PureComponent {
state = {
// 分配角色弹窗
modalRoleVisible: false,
modalRoleRow: {},
};
componentDidMount() { componentDidMount() {
const { dispatch } = this.props; const { dispatch } = this.props;
...@@ -461,6 +456,7 @@ class AdminList extends PureComponent { ...@@ -461,6 +456,7 @@ class AdminList extends PureComponent {
dispatch, dispatch,
handleModalVisible: this.handleModalVisible, // Function handleModalVisible: this.handleModalVisible, // Function
}; };
// 分配角色 Modal 属性 // 分配角色 Modal 属性
const roleAssignModal = { const roleAssignModal = {
loading: roleAssignLoading, loading: roleAssignLoading,
...@@ -485,7 +481,7 @@ class AdminList extends PureComponent { ...@@ -485,7 +481,7 @@ class AdminList extends PureComponent {
type="primary" type="primary"
onClick={() => this.handleModalVisible(true, 'add', {})} onClick={() => this.handleModalVisible(true, 'add', {})}
> >
新建管理员 新建员工
</Button> </Button>
</div> </div>
</div> </div>
...@@ -500,4 +496,4 @@ class AdminList extends PureComponent { ...@@ -500,4 +496,4 @@ class AdminList extends PureComponent {
} }
} }
export default AdminList; export default AdminList;
\ No newline at end of file
如下是 onemall 的功能列表。
* 当功能被完成时,会标记已完成。
* 未完成的功能,欢迎一起来开发。
- [ ] 首页
- 商品相关
- [ ] 分类列表
- [ ] 商品搜索
- [ ] 商品列表(基于分类)
- [ ] 商品列表(基于促销活动)
- [ ] 商品详情
- [ ] 商品收藏
- 订单相关
- [ ] 下单(直接购买)
- [ ] 下单(购物车购买)
- [ ] 下单(拼团)
- [ ] 订单列表
- [ ] 订单详情
- [ ] 支付
- [ ] 退款
- [ ] 购物车
- [ ] 收获地址
- 营销相关
- [ ] 优惠劵
- [ ] 优惠码
- 用户相关
- [ ] 登陆
- [ ] 注册
- [ ] 个人信息
如下是 onemall 的功能列表。
* 当功能被完成时,会标记已完成。
* 未完成的功能,欢迎一起来开发。
- [ ] 概述 TODO - [ ] 概述 TODO
- [ ] 数据分析 - [ ] 数据分析
- [ ] TODO 未开始 - [ ] TODO 未开始
- [ ] 店铺资产 - [ ] 店铺资产
- [ ] TODO 未开始 - [ ] TODO 未开始
...@@ -14,9 +19,9 @@ ...@@ -14,9 +19,9 @@
- [ ] 订单评价 - [ ] 订单评价
- [ ] 会员管理 - [ ] 会员管理
- [ ] 会员资料 - [ ] 会员资料
- TODO 需要补充 - TODO 需要补充
- [ ] 营销管理 - [ ] 营销管理
- [ ] 广告管理 - [ ] 广告管理
- [ ] 优惠劵 - [ ] 优惠劵
- [ ] 优惠码 - [ ] 优惠码
- [ ] 商品推荐 - [ ] 商品推荐
...@@ -29,5 +34,5 @@ ...@@ -29,5 +34,5 @@
- [ ] 权限管理 - [ ] 权限管理
- [ ] 短信管理 - [ ] 短信管理
- [ ] 短信模板 - [ ] 短信模板
- [ ] 发送日志 - [ ] 发送日志
- [ ] 操作日志 - [ ] 操作日志
\ No newline at end of file
...@@ -14,6 +14,7 @@ public enum ProductErrorCodeEnum { ...@@ -14,6 +14,7 @@ public enum ProductErrorCodeEnum {
PRODUCT_CATEGORY_STATUS_EQUALS(1002001003, "商品分类已经是该状态"), PRODUCT_CATEGORY_STATUS_EQUALS(1002001003, "商品分类已经是该状态"),
PRODUCT_CATEGORY_DELETE_ONLY_DISABLE(1002001004, "只有关闭的商品分类才可以删除"), PRODUCT_CATEGORY_DELETE_ONLY_DISABLE(1002001004, "只有关闭的商品分类才可以删除"),
PRODUCT_CATEGORY_MUST_ENABLE(1002001005, "只有开启的商品分类,才可以使用"), PRODUCT_CATEGORY_MUST_ENABLE(1002001005, "只有开启的商品分类,才可以使用"),
PRODUCT_CATEGORY_PARENT_CAN_NOT_BE_LEVEL2(1002001005, "父分类必须是一级分类"),
// ========== PRODUCT SPU + SKU 模块 ========== // ========== PRODUCT SPU + SKU 模块 ==========
PRODUCT_SKU_ATTR_CANT_NOT_DUPLICATE(1003002000, "一个 Sku 下,不能有重复的规格"), PRODUCT_SKU_ATTR_CANT_NOT_DUPLICATE(1003002000, "一个 Sku 下,不能有重复的规格"),
...@@ -46,4 +47,4 @@ public enum ProductErrorCodeEnum { ...@@ -46,4 +47,4 @@ public enum ProductErrorCodeEnum {
return message; return message;
} }
} }
\ No newline at end of file
...@@ -47,11 +47,8 @@ public class ProductCategoryServiceImpl implements ProductCategoryService { ...@@ -47,11 +47,8 @@ public class ProductCategoryServiceImpl implements ProductCategoryService {
@Override @Override
public CommonResult<ProductCategoryBO> addProductCategory(Integer adminId, ProductCategoryAddDTO productCategoryAddDTO) { public CommonResult<ProductCategoryBO> addProductCategory(Integer adminId, ProductCategoryAddDTO productCategoryAddDTO) {
// 校验父分类是否存在 // 校验父分类
if (!ProductCategoryConstants.PID_ROOT.equals(productCategoryAddDTO.getPid()) validParent(productCategoryAddDTO.getPid());
&& productCategoryMapper.selectById(productCategoryAddDTO.getPid()) == null) {
return ServiceExceptionUtil.error(ProductErrorCodeEnum.PRODUCT_CATEGORY_PARENT_NOT_EXISTS.getCode());
}
// 保存到数据库 // 保存到数据库
ProductCategoryDO productCategory = ProductCategoryConvert.INSTANCE.convert(productCategoryAddDTO) ProductCategoryDO productCategory = ProductCategoryConvert.INSTANCE.convert(productCategoryAddDTO)
.setStatus(ProductCategoryConstants.STATUS_ENABLE); .setStatus(ProductCategoryConstants.STATUS_ENABLE);
...@@ -65,10 +62,8 @@ public class ProductCategoryServiceImpl implements ProductCategoryService { ...@@ -65,10 +62,8 @@ public class ProductCategoryServiceImpl implements ProductCategoryService {
@Override @Override
public CommonResult<Boolean> updateProductCategory(Integer adminId, ProductCategoryUpdateDTO productCategoryUpdateDTO) { public CommonResult<Boolean> updateProductCategory(Integer adminId, ProductCategoryUpdateDTO productCategoryUpdateDTO) {
// 校验分类是否存在 // 校验父分类
if (productCategoryMapper.selectById(productCategoryUpdateDTO.getId()) == null) { validParent(productCategoryUpdateDTO.getPid());
return ServiceExceptionUtil.error(ProductErrorCodeEnum.PRODUCT_CATEGORY_NOT_EXISTS.getCode());
}
// 校验不能设置自己为父分类 // 校验不能设置自己为父分类
if (productCategoryUpdateDTO.getId().equals(productCategoryUpdateDTO.getPid())) { if (productCategoryUpdateDTO.getId().equals(productCategoryUpdateDTO.getPid())) {
return ServiceExceptionUtil.error(ProductErrorCodeEnum.PRODUCT_CATEGORY_PARENT_NOT_SELF.getCode()); return ServiceExceptionUtil.error(ProductErrorCodeEnum.PRODUCT_CATEGORY_PARENT_NOT_SELF.getCode());
...@@ -153,4 +148,18 @@ public class ProductCategoryServiceImpl implements ProductCategoryService { ...@@ -153,4 +148,18 @@ public class ProductCategoryServiceImpl implements ProductCategoryService {
|| ProductCategoryConstants.STATUS_DISABLE.equals(status); || ProductCategoryConstants.STATUS_DISABLE.equals(status);
} }
private void validParent(Integer pid) {
if (!ProductCategoryConstants.PID_ROOT.equals(pid)) {
ProductCategoryDO parentCategory = productCategoryMapper.selectById(pid);
// 校验父分类是否存在
if (parentCategory == null) {
throw ServiceExceptionUtil.exception(ProductErrorCodeEnum.PRODUCT_CATEGORY_PARENT_NOT_EXISTS.getCode());
}
// 父分类必须是一级分类
if (!ProductCategoryConstants.PID_ROOT.equals(parentCategory.getPid())) {
throw ServiceExceptionUtil.exception((ProductErrorCodeEnum.PRODUCT_CATEGORY_PARENT_CAN_NOT_BE_LEVEL2.getCode()));
}
}
}
} }
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论