From fd1d1d3074273647e906f2d3bb5c7b89c5d997d2 Mon Sep 17 00:00:00 2001
From: YunaiV <>
Date: Fri, 15 Mar 2019 22:09:26 +0800
Subject: [PATCH] =?UTF-8?q?=E5=89=8D=E7=AB=AF=EF=BC=9A=E5=95=86=E5=93=81?=
=?UTF-8?q?=E5=88=86=E7=B1=BB=E6=A8=A1=E5=9D=97=E5=AE=8C=E6=88=90?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../src/models/product/productCategoryList.js | 26 ++++---
.../src/pages/Product/ProductCategoryList.js | 73 +++++++++++--------
admin-web/src/services/product.js | 19 +++--
.../service/ProductCategoryServiceImpl.java | 6 +-
4 files changed, 76 insertions(+), 48 deletions(-)
diff --git a/admin-web/src/models/product/productCategoryList.js b/admin-web/src/models/product/productCategoryList.js
index a6850bf86..67a264bc8 100644
--- a/admin-web/src/models/product/productCategoryList.js
+++ b/admin-web/src/models/product/productCategoryList.js
@@ -1,6 +1,5 @@
import { message } from 'antd';
-import { addResource, updateResource, deleteResource, resourceTree } from '../../services/admin';
-import { productCategoryTree } from '../../services/product';
+import { productCategoryTree, productCategoryAdd, productCategoryUpdate, productCategoryUpdateStatus, productCategoryDelete } from '../../services/product';
export default {
namespace: 'productCategoryList',
@@ -12,7 +11,7 @@ export default {
effects: {
*add({ payload }, { call, put }) {
const { callback, body } = payload;
- const response = yield call(addResource, body);
+ const response = yield call(productCategoryAdd, body);
if (callback) {
callback(response);
}
@@ -23,7 +22,18 @@ export default {
},
*update({ payload }, { call, put }) {
const { callback, body } = payload;
- const response = yield call(updateResource, body);
+ 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);
}
@@ -33,13 +43,11 @@ export default {
});
},
*delete({ payload }, { call, put }) {
- const response = yield call(deleteResource, payload);
+ const response = yield call(productCategoryDelete, payload);
message.info('删除成功!');
yield put({
- type: 'treeSuccess',
- payload: {
- list: response.data,
- },
+ type: 'tree',
+ payload: {},
});
},
*tree({ payload }, { call, put }) {
diff --git a/admin-web/src/pages/Product/ProductCategoryList.js b/admin-web/src/pages/Product/ProductCategoryList.js
index bcace4d86..2709c7dcf 100644
--- a/admin-web/src/pages/Product/ProductCategoryList.js
+++ b/admin-web/src/pages/Product/ProductCategoryList.js
@@ -3,7 +3,7 @@
import React, { PureComponent, Fragment } from 'react';
import { connect } from 'dva';
import moment from 'moment';
-import { Card, Form, Input, Select, Button, Modal, message, Table, Divider } from 'antd';
+import {Card, Form, Input, Select, Button, Modal, message, Table, Divider, InputNumber} from 'antd';
import PageHeaderWrapper from '@/components/PageHeaderWrapper';
import styles from './ProductCategoryList.less';
@@ -43,46 +43,34 @@ const CreateForm = Form.create()(props => {
okText={okText}
onCancel={() => handleModalVisible()}
>
-
- {form.getFieldDecorator('displayName', {
- rules: [{ required: true, message: '请输入菜单展示名字!', min: 2 }],
- initialValue: initValues.displayName,
- })()}
-
-
- {form.getFieldDecorator('handler', {
- initialValue: initValues.handler,
- })()}
-
-
+
{form.getFieldDecorator('name', {
- rules: [{ required: true, message: '请输入资源名字!' }],
+ rules: [{ required: true, message: '请输入分类名!', min: 2 }],
initialValue: initValues.name,
})()}
-
+
+ {form.getFieldDecorator('picUrl', {
+ initialValue: initValues.handler,
+ })()}
+
+
{form.getFieldDecorator('pid', {
- rules: [{ required: true, message: '请输入父级编号!' }],
+ rules: [{ required: true, message: '请输入父分类编号!' }],
initialValue: initValues.pid,
})()}
- 根节点为 0
-
+
{form.getFieldDecorator('sort', {
- rules: [{ required: true, message: '请输入菜单排序!' }],
+ rules: [{ required: true, message: '请输入排序值!' }],
initialValue: initValues.sort,
- })()}
+ })()}
-
- {form.getFieldDecorator('type', {
- rules: [{ required: true, message: '请选择资源类型!' }],
- initialValue: 1,
- })(
-
- )}
+
+ {form.getFieldDecorator('description', {
+ rules: [{ required: true, message: '请输入描述!' }],
+ initialValue: initValues.description,
+ })()}
);
@@ -149,6 +137,30 @@ class ProductCategoryList extends PureComponent {
}
};
+ handleStatus(row) {
+ const { dispatch, data } = this.props;
+
+ const title = row.status === 1 ? '确认禁用?' : '确认开启?';
+ const updateStatus = row.status === 1 ? 2 : 1;
+
+ Modal.confirm({
+ title: `${title}`,
+ content: `${row.name}`,
+ onOk() {
+ dispatch({
+ type: 'productCategoryList/updateStatus',
+ payload: {
+ body: {
+ id: row.id,
+ status: updateStatus,
+ }
+ },
+ });
+ },
+ onCancel() {},
+ });
+ }
+
handleDelete(row) {
const { dispatch } = this.props;
Modal.confirm({
@@ -223,7 +235,6 @@ class ProductCategoryList extends PureComponent {
this.handleModalVisible(true, 'update', record)}>更新
-
this.handleStatus(record)}>
{statusText}
diff --git a/admin-web/src/services/product.js b/admin-web/src/services/product.js
index 50a91d4d7..402a2c3e7 100644
--- a/admin-web/src/services/product.js
+++ b/admin-web/src/services/product.js
@@ -9,22 +9,29 @@ export async function productCategoryTree(params) {
});
}
-export async function dictionaryAdd(params) {
- return request(`/admin-api/admins/data_dict/add?${stringify(params)}`, {
+export async function productCategoryAdd(params) {
+ return request(`/product-api/admins/category/add?${stringify(params)}`, {
method: 'POST',
body: {},
});
}
-export async function dictionaryUpdate(params) {
- return request(`/admin-api/admins/data_dict/update?${stringify(params)}`, {
+export async function productCategoryUpdate(params) {
+ return request(`/product-api/admins/category/update?${stringify(params)}`, {
method: 'POST',
body: {},
});
}
-export async function dictionaryDelete(params) {
- return request(`/admin-api/admins/data_dict/delete?${stringify(params)}`, {
+export async function productCategoryUpdateStatus(params) {
+ return request(`/product-api/admins/category/update_status?${stringify(params)}`, {
+ method: 'POST',
+ body: {},
+ });
+}
+
+export async function productCategoryDelete(params) {
+ return request(`/product-api/admins/category/delete?${stringify(params)}`, {
method: 'POST',
});
}
\ No newline at end of file
diff --git a/product/product-service-impl/src/main/java/cn/iocoder/mall/product/service/ProductCategoryServiceImpl.java b/product/product-service-impl/src/main/java/cn/iocoder/mall/product/service/ProductCategoryServiceImpl.java
index 02019e8ef..6ac41e459 100644
--- a/product/product-service-impl/src/main/java/cn/iocoder/mall/product/service/ProductCategoryServiceImpl.java
+++ b/product/product-service-impl/src/main/java/cn/iocoder/mall/product/service/ProductCategoryServiceImpl.java
@@ -93,7 +93,8 @@ public class ProductCategoryServiceImpl implements ProductCategoryService {
return ServiceExceptionUtil.error(ProductErrorCodeEnum.PRODUCT_CATEGORY_STATUS_EQUALS.getCode());
}
// 更新商品分类
- ProductCategoryDO updateProductCategory = new ProductCategoryDO().setStatus(status);
+ ProductCategoryDO updateProductCategory = new ProductCategoryDO()
+ .setId(productCategoryId).setStatus(status);
productCategoryMapper.update(updateProductCategory);
// TODO 操作日志
return CommonResult.success(true);
@@ -113,7 +114,8 @@ public class ProductCategoryServiceImpl implements ProductCategoryService {
// TODO 芋艿:考虑下,是否需要判断下该分类下是否有商品
// TODO 芋艿,需要补充下,还有子分类
// 标记删除商品分类
- ProductCategoryDO updateProductCategory = new ProductCategoryDO().setId(productCategoryId);
+ ProductCategoryDO updateProductCategory = new ProductCategoryDO()
+ .setId(productCategoryId);
updateProductCategory.setDeleted(BaseDO.DELETED_YES);
productCategoryMapper.update(updateProductCategory);
// TODO 操作日志