后端 + 前端:优惠劵列表
This commit is contained in:
@@ -1,16 +1,15 @@
|
||||
import {message} from 'antd';
|
||||
import {
|
||||
addProductRecommend,
|
||||
deleteProductRecommend,
|
||||
queryProductRecommend,
|
||||
updateProductRecommend,
|
||||
updateProductRecommendStatus,
|
||||
addCouponCardTemplate,
|
||||
getCouponCardTemplatePage,
|
||||
} from '../../services/promotion';
|
||||
import PaginationHelper from '../../../helpers/PaginationHelper';
|
||||
|
||||
const SEARCH_PARAMS_DEFAULT = {
|
||||
type: 1,
|
||||
// type: 1,
|
||||
};
|
||||
|
||||
export default {
|
||||
@@ -40,7 +39,10 @@ export default {
|
||||
});
|
||||
|
||||
// 请求
|
||||
const response = yield call(queryProductRecommend, payload);
|
||||
const response = yield call(getCouponCardTemplatePage, {
|
||||
...payload,
|
||||
type: 1
|
||||
});
|
||||
// 响应
|
||||
yield put({
|
||||
type: 'setAll',
|
||||
@@ -48,7 +50,7 @@ export default {
|
||||
list: response.data.list,
|
||||
pagination: PaginationHelper.formatPagination(response.data, payload),
|
||||
searchParams: {
|
||||
type: payload.type
|
||||
// type: payload.type
|
||||
}
|
||||
},
|
||||
});
|
||||
|
||||
@@ -32,7 +32,14 @@ const SelectOption = Select.Option;
|
||||
const { TreeNode } = Tree;
|
||||
const RangePicker = DatePicker.RangePicker;
|
||||
const status = ['未知', '正常', '禁用'];
|
||||
const types = ['未知', '新品推荐', '热卖推荐'];
|
||||
const rangeType = {
|
||||
10: '所有可用',
|
||||
20: '部分商品可用',
|
||||
21: '部分商品不可用',
|
||||
30: '部分分类可用',
|
||||
31: '部分分类不可用'};
|
||||
const preferentialType = ['未知', '代金卷', '折扣卷'];
|
||||
const dateType = ['未知', '固定日期', '领取日期'];
|
||||
|
||||
// 列表
|
||||
function List ({ dataSource, loading, pagination, searchParams, dispatch,
|
||||
@@ -44,7 +51,7 @@ function List ({ dataSource, loading, pagination, searchParams, dispatch,
|
||||
content: `${record.productSpuId}`,
|
||||
onOk() {
|
||||
dispatch({
|
||||
type: 'productRecommendList/updateStatus',
|
||||
type: 'couponCardTemplateList/updateStatus',
|
||||
payload: {
|
||||
id: record.id,
|
||||
status: record.status === 1 ? 2 : 1,
|
||||
@@ -55,48 +62,91 @@ function List ({ dataSource, loading, pagination, searchParams, dispatch,
|
||||
});
|
||||
}
|
||||
|
||||
function handleDelete(record) {
|
||||
Modal.confirm({
|
||||
title: `确认删除?`,
|
||||
content: `${record.productSpuId}`,
|
||||
onOk() {
|
||||
dispatch({
|
||||
type: 'productRecommendList/delete',
|
||||
payload: {
|
||||
id: record.id,
|
||||
},
|
||||
});
|
||||
},
|
||||
onCancel() {},
|
||||
});
|
||||
}
|
||||
// function handleDelete(record) {
|
||||
// Modal.confirm({
|
||||
// title: `确认删除?`,
|
||||
// content: `${record.productSpuId}`,
|
||||
// onOk() {
|
||||
// dispatch({
|
||||
// type: 'couponCardTemplateList/delete',
|
||||
// payload: {
|
||||
// id: record.id,
|
||||
// },
|
||||
// });
|
||||
// },
|
||||
// onCancel() {},
|
||||
// });
|
||||
// }
|
||||
|
||||
const columns = [
|
||||
{
|
||||
title: '推荐类型',
|
||||
dataIndex: 'type',
|
||||
title: '名称',
|
||||
dataIndex: 'title',
|
||||
},
|
||||
{
|
||||
title: '类型',
|
||||
dataIndex: 'preferentialType',
|
||||
render(val) {
|
||||
return <span>{types[val]}</span>; // TODO 芋艿,此处要改
|
||||
return <span>{preferentialType[val]}</span>;
|
||||
},
|
||||
},
|
||||
{
|
||||
title: '商品',
|
||||
dataIndex: 'productSpuId',
|
||||
title: '优惠内容',
|
||||
render(val, record) {
|
||||
let content;
|
||||
// priceAvailable;
|
||||
if (record.priceAvailable === 0) {
|
||||
content = '无门槛,';
|
||||
} else {
|
||||
content = '满 ' + record.priceAvailable / 100 + ' 元,';
|
||||
}
|
||||
if (record.preferentialType === 1) {
|
||||
content += '减 ' + record.priceOff / 100 + ' 元';
|
||||
} else {
|
||||
content += '打' + record.percentOff / 100.0 + '折';
|
||||
if (record.discountPriceLimit) {
|
||||
content += ', 最多减 ' + record.discountPriceLimit / 100 + ' 元';
|
||||
}
|
||||
}
|
||||
return content;
|
||||
}
|
||||
},
|
||||
{
|
||||
title: '排序值',
|
||||
dataIndex: 'sort',
|
||||
title: '可使用商品',
|
||||
dataIndex: 'rangeType',
|
||||
render: val => <span>{rangeType[val]}</span>,
|
||||
},
|
||||
{
|
||||
title: '有效期',
|
||||
render(val, record) {
|
||||
let content = dateType[record.dateType] + ' ';
|
||||
// priceAvailable;
|
||||
if (record.dateType === 1) {
|
||||
content += moment(new Date(record.validStartTime)).format('YYYY-MM-DD')
|
||||
+ '~' + moment(new Date(record.validEndTime)).format('YYYY-MM-DD');
|
||||
} else if (record.dateType === 2) {
|
||||
content += record.fixedStartTerm + '-' + record.fixedEndTerm + ' 天';
|
||||
}
|
||||
return content;
|
||||
}
|
||||
},
|
||||
{
|
||||
title: '已领取/剩余',
|
||||
// 已使用 TODO 芋艿
|
||||
// 支付金额(元) TODO 芋艿
|
||||
// 客单价(元) TODO 芋艿
|
||||
render(val, record) {
|
||||
return `${record.statFetchNum} / ` + (record.total - record.statFetchNum);
|
||||
}
|
||||
},
|
||||
{
|
||||
title: '状态',
|
||||
dataIndex: 'status',
|
||||
render(val) {
|
||||
return <span>{status[val]}</span>; // TODO 芋艿,此处要改
|
||||
},
|
||||
render: val => <span>{status[val]}</span>,
|
||||
},
|
||||
{
|
||||
title: '备注',
|
||||
dataIndex: 'memo',
|
||||
title: '使用说明',
|
||||
dataIndex: 'description',
|
||||
},
|
||||
{
|
||||
title: '创建时间',
|
||||
@@ -105,7 +155,7 @@ function List ({ dataSource, loading, pagination, searchParams, dispatch,
|
||||
},
|
||||
{
|
||||
title: '操作',
|
||||
width: 360,
|
||||
width: 120,
|
||||
render: (text, record) => {
|
||||
const statusText = record.status === 1 ? '禁用' : '开启'; // TODO 芋艿,此处要改
|
||||
return (
|
||||
@@ -115,15 +165,15 @@ function List ({ dataSource, loading, pagination, searchParams, dispatch,
|
||||
<a className={styles.tableDelete} onClick={() => handleStatus(record)}>
|
||||
{statusText}
|
||||
</a>
|
||||
{
|
||||
record.status === 2 ?
|
||||
<span>
|
||||
<Divider type="vertical" />
|
||||
<a className={styles.tableDelete} onClick={() => handleDelete(record)}>
|
||||
删除
|
||||
</a>
|
||||
</span> : null
|
||||
}
|
||||
{/*{*/}
|
||||
{/* record.status === 2 ?*/}
|
||||
{/* <span>*/}
|
||||
{/* <Divider type="vertical" />*/}
|
||||
{/* <a className={styles.tableDelete} onClick={() => handleDelete(record)}>*/}
|
||||
{/* 删除*/}
|
||||
{/* </a>*/}
|
||||
{/* </span> : null*/}
|
||||
{/*}*/}
|
||||
</Fragment>
|
||||
);
|
||||
},
|
||||
@@ -132,7 +182,7 @@ function List ({ dataSource, loading, pagination, searchParams, dispatch,
|
||||
|
||||
function onPageChange(page) { // 翻页
|
||||
dispatch({
|
||||
type: 'productRecommendList/query',
|
||||
type: 'couponCardTemplateList/query',
|
||||
payload: {
|
||||
pageNo: page.current,
|
||||
pageSize: page.pageSize,
|
||||
@@ -164,7 +214,7 @@ const SearchForm = Form.create()(props => {
|
||||
|
||||
function search() {
|
||||
dispatch({
|
||||
type: 'productRecommendList/query',
|
||||
type: 'couponCardTemplateList/query',
|
||||
payload: {
|
||||
...PaginationHelper.defaultPayload,
|
||||
...form.getFieldsValue()
|
||||
@@ -369,7 +419,7 @@ const AddOrUpdateForm = Form.create()(props => {
|
||||
initialValue: formVals.dateType,
|
||||
})(
|
||||
<Select placeholder="请选择" style={{ maxWidth: 200, width: '100%' }} onChange={onDateTypeChange}>
|
||||
<SelectOption value="1">固定日期</SelectOption>
|
||||
<SelectOption value="1"></SelectOption>
|
||||
<SelectOption value="2">领取日期</SelectOption>
|
||||
</Select>
|
||||
)}
|
||||
@@ -452,10 +502,10 @@ const AddOrUpdateForm = Form.create()(props => {
|
||||
);
|
||||
});
|
||||
|
||||
@connect(({ productRecommendList }) => ({
|
||||
@connect(({ couponCardTemplateList }) => ({
|
||||
// list: productRecommend.list,
|
||||
// pagination: productRecommend.pagination,
|
||||
...productRecommendList,
|
||||
...couponCardTemplateList,
|
||||
}))
|
||||
|
||||
// 主界面
|
||||
@@ -465,7 +515,7 @@ class CouponCardTemplateLists extends PureComponent {
|
||||
componentDidMount() {
|
||||
const { dispatch } = this.props;
|
||||
dispatch({
|
||||
type: 'productRecommendList/query',
|
||||
type: 'couponCardTemplateList/query',
|
||||
payload: {
|
||||
...PaginationHelper.defaultPayload
|
||||
},
|
||||
@@ -475,7 +525,7 @@ class CouponCardTemplateLists extends PureComponent {
|
||||
handleModalVisible = (modalVisible, modalType, record) => {
|
||||
const { dispatch } = this.props;
|
||||
dispatch({
|
||||
type: 'productRecommendList/setAll',
|
||||
type: 'couponCardTemplateList/setAll',
|
||||
payload: {
|
||||
modalVisible,
|
||||
modalType,
|
||||
|
||||
@@ -67,6 +67,12 @@ export async function deleteProductRecommend(params) {
|
||||
|
||||
// coupon
|
||||
|
||||
export async function getCouponCardTemplatePage(params) {
|
||||
return request(`/promotion-api/admins/coupon/template/page?${stringify(params)}`, {
|
||||
method: 'GET',
|
||||
});
|
||||
}
|
||||
|
||||
export async function addCouponCardTemplate(params) {
|
||||
return request(`/promotion-api/admins/coupon/template/add_card?${stringify(params)}`, {
|
||||
method: 'POST',
|
||||
|
||||
Reference in New Issue
Block a user