Merge remote-tracking branch 'origin/master'

This commit is contained in:
sin 2019-03-15 22:59:52 +08:00
commit c8488fc278
4 changed files with 76 additions and 48 deletions

View File

@ -1,6 +1,5 @@
import { message } from 'antd'; import { message } from 'antd';
import { addResource, updateResource, deleteResource, resourceTree } from '../../services/admin'; import { productCategoryTree, productCategoryAdd, productCategoryUpdate, productCategoryUpdateStatus, productCategoryDelete } from '../../services/product';
import { productCategoryTree } from '../../services/product';
export default { export default {
namespace: 'productCategoryList', namespace: 'productCategoryList',
@ -12,7 +11,7 @@ export default {
effects: { effects: {
*add({ payload }, { call, put }) { *add({ payload }, { call, put }) {
const { callback, body } = payload; const { callback, body } = payload;
const response = yield call(addResource, body); const response = yield call(productCategoryAdd, body);
if (callback) { if (callback) {
callback(response); callback(response);
} }
@ -23,7 +22,18 @@ export default {
}, },
*update({ payload }, { call, put }) { *update({ payload }, { call, put }) {
const { callback, body } = payload; 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) { if (callback) {
callback(response); callback(response);
} }
@ -33,13 +43,11 @@ export default {
}); });
}, },
*delete({ payload }, { call, put }) { *delete({ payload }, { call, put }) {
const response = yield call(deleteResource, payload); const response = yield call(productCategoryDelete, payload);
message.info('删除成功!'); message.info('删除成功!');
yield put({ yield put({
type: 'treeSuccess', type: 'tree',
payload: { payload: {},
list: response.data,
},
}); });
}, },
*tree({ payload }, { call, put }) { *tree({ payload }, { call, put }) {

View File

@ -3,7 +3,7 @@
import React, { PureComponent, Fragment } from 'react'; import React, { PureComponent, Fragment } from 'react';
import { connect } from 'dva'; import { connect } from 'dva';
import moment from 'moment'; 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 PageHeaderWrapper from '@/components/PageHeaderWrapper';
import styles from './ProductCategoryList.less'; import styles from './ProductCategoryList.less';
@ -43,46 +43,34 @@ const CreateForm = Form.create()(props => {
okText={okText} okText={okText}
onCancel={() => handleModalVisible()} onCancel={() => handleModalVisible()}
> >
<FormItem labelCol={{ span: 5 }} wrapperCol={{ span: 15 }} label="菜单展示名"> <FormItem labelCol={{ span: 5 }} wrapperCol={{ span: 15 }} label="分类名">
{form.getFieldDecorator('displayName', {
rules: [{ required: true, message: '请输入菜单展示名字!', min: 2 }],
initialValue: initValues.displayName,
})(<Input placeholder="请输入" />)}
</FormItem>
<FormItem labelCol={{ span: 5 }} wrapperCol={{ span: 15 }} label="操作">
{form.getFieldDecorator('handler', {
initialValue: initValues.handler,
})(<Input placeholder="请输入" />)}
</FormItem>
<FormItem labelCol={{ span: 5 }} wrapperCol={{ span: 15 }} label="资源名字">
{form.getFieldDecorator('name', { {form.getFieldDecorator('name', {
rules: [{ required: true, message: '请输入资源名字!' }], rules: [{ required: true, message: '请输入分类名!', min: 2 }],
initialValue: initValues.name, initialValue: initValues.name,
})(<Input placeholder="请输入" />)} })(<Input placeholder="请输入" />)}
</FormItem> </FormItem>
<FormItem labelCol={{ span: 5 }} wrapperCol={{ span: 15 }} label="父级资源编号"> <FormItem labelCol={{ span: 5 }} wrapperCol={{ span: 15 }} label="分类图片">
{form.getFieldDecorator('picUrl', {
initialValue: initValues.handler,
})(<Input placeholder="请输入" />)}
</FormItem>
<FormItem labelCol={{ span: 5 }} wrapperCol={{ span: 15 }} label="父分类编号">
{form.getFieldDecorator('pid', { {form.getFieldDecorator('pid', {
rules: [{ required: true, message: '请输入父级编号!' }], rules: [{ required: true, message: '请输入父分类编号!' }],
initialValue: initValues.pid, initialValue: initValues.pid,
})(<Input placeholder="请输入" />)} })(<Input placeholder="请输入" />)}
<span>根节点为 0</span>
</FormItem> </FormItem>
<FormItem labelCol={{ span: 5 }} wrapperCol={{ span: 15 }} label="排序"> <FormItem labelCol={{ span: 5 }} wrapperCol={{ span: 15 }} label="排序">
{form.getFieldDecorator('sort', { {form.getFieldDecorator('sort', {
rules: [{ required: true, message: '请输入菜单排序!' }], rules: [{ required: true, message: '请输入排序' }],
initialValue: initValues.sort, initialValue: initValues.sort,
})(<Input placeholder="请输入" />)} })(<InputNumber placeholder="请输入" />)}
</FormItem> </FormItem>
<FormItem labelCol={{ span: 5 }} wrapperCol={{ span: 15 }} label="资源类型"> <FormItem labelCol={{ span: 5 }} wrapperCol={{ span: 15 }} label="描述">
{form.getFieldDecorator('type', { {form.getFieldDecorator('description', {
rules: [{ required: true, message: '请选择资源类型!' }], rules: [{ required: true, message: '请输入描述!' }],
initialValue: 1, initialValue: initValues.description,
})( })(<Input.TextArea placeholder="请输入" />)}
<Select showSearch style={selectStyle} placeholder="请选择">
<Option value={1}>菜单</Option>
<Option value={2}>Url</Option>
</Select>
)}
</FormItem> </FormItem>
</Modal> </Modal>
); );
@ -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) { handleDelete(row) {
const { dispatch } = this.props; const { dispatch } = this.props;
Modal.confirm({ Modal.confirm({
@ -223,7 +235,6 @@ class ProductCategoryList extends PureComponent {
<Fragment> <Fragment>
<a onClick={() => this.handleModalVisible(true, 'update', record)}>更新</a> <a onClick={() => this.handleModalVisible(true, 'update', record)}>更新</a>
<Divider type="vertical"/> <Divider type="vertical"/>
<Divider type="vertical"/>
<a className={styles.tableDelete} onClick={() => this.handleStatus(record)}> <a className={styles.tableDelete} onClick={() => this.handleStatus(record)}>
{statusText} {statusText}
</a> </a>

View File

@ -9,22 +9,29 @@ export async function productCategoryTree(params) {
}); });
} }
export async function dictionaryAdd(params) { export async function productCategoryAdd(params) {
return request(`/admin-api/admins/data_dict/add?${stringify(params)}`, { return request(`/product-api/admins/category/add?${stringify(params)}`, {
method: 'POST', method: 'POST',
body: {}, body: {},
}); });
} }
export async function dictionaryUpdate(params) { export async function productCategoryUpdate(params) {
return request(`/admin-api/admins/data_dict/update?${stringify(params)}`, { return request(`/product-api/admins/category/update?${stringify(params)}`, {
method: 'POST', method: 'POST',
body: {}, body: {},
}); });
} }
export async function dictionaryDelete(params) { export async function productCategoryUpdateStatus(params) {
return request(`/admin-api/admins/data_dict/delete?${stringify(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', method: 'POST',
}); });
} }

View File

@ -93,7 +93,8 @@ public class ProductCategoryServiceImpl implements ProductCategoryService {
return ServiceExceptionUtil.error(ProductErrorCodeEnum.PRODUCT_CATEGORY_STATUS_EQUALS.getCode()); 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); productCategoryMapper.update(updateProductCategory);
// TODO 操作日志 // TODO 操作日志
return CommonResult.success(true); return CommonResult.success(true);
@ -113,7 +114,8 @@ public class ProductCategoryServiceImpl implements ProductCategoryService {
// TODO 芋艿考虑下是否需要判断下该分类下是否有商品 // TODO 芋艿考虑下是否需要判断下该分类下是否有商品
// TODO 芋艿需要补充下还有子分类 // TODO 芋艿需要补充下还有子分类
// 标记删除商品分类 // 标记删除商品分类
ProductCategoryDO updateProductCategory = new ProductCategoryDO().setId(productCategoryId); ProductCategoryDO updateProductCategory = new ProductCategoryDO()
.setId(productCategoryId);
updateProductCategory.setDeleted(BaseDO.DELETED_YES); updateProductCategory.setDeleted(BaseDO.DELETED_YES);
productCategoryMapper.update(updateProductCategory); productCategoryMapper.update(updateProductCategory);
// TODO 操作日志 // TODO 操作日志