Commit eeb6ce4b by chengming

积分商城

parent 81b76cfc
...@@ -80,7 +80,6 @@ class ActiveOption extends React.Component { ...@@ -80,7 +80,6 @@ class ActiveOption extends React.Component {
const { current, pageSize, record, type, activityName } = this.state; const { current, pageSize, record, type, activityName } = this.state;
const form = this.formRef.props.form; const form = this.formRef.props.form;
form.validateFields((err, values) => { form.validateFields((err, values) => {
console.log(values,record,'values');
if (err) { if (err) {
return; return;
} }
...@@ -91,6 +90,8 @@ class ActiveOption extends React.Component { ...@@ -91,6 +90,8 @@ class ActiveOption extends React.Component {
id: record.id, id: record.id,
productImg: values.productImg, productImg: values.productImg,
productName: values.productName, productName: values.productName,
startTime: values.effectiveTime[0].format('YYYY-MM-DD HH:mm:ss'),
endTime: values.effectiveTime[1].format('YYYY-MM-DD HH:mm:ss'),
point: values.point, point: values.point,
}, },
'', '',
...@@ -106,6 +107,8 @@ class ActiveOption extends React.Component { ...@@ -106,6 +107,8 @@ class ActiveOption extends React.Component {
{ {
productImg: values.productImg, productImg: values.productImg,
productName: values.productName, productName: values.productName,
startTime: values.effectiveTime[0].format('YYYY-MM-DD HH:mm:ss'),
endTime: values.effectiveTime[1].format('YYYY-MM-DD HH:mm:ss'),
point: values.point, point: values.point,
}, },
{ pageNo: current, pageSize: pageSize }, { pageNo: current, pageSize: pageSize },
......
import React from "react"; import React from "react";
import { Input, Button, Table, Modal, message, Pagination } from "antd"; import { Input, Button, Table, Modal, message, Pagination, Tabs } from "antd";
import { connect } from "react-redux"; import { connect } from "react-redux";
import Breadcrumb from "@/common/Breadcrumb"; import Breadcrumb from "@/common/Breadcrumb";
import moment from "moment";
import { import {
postUserList, postUserList,
postPointExchange, postPointExchange,
postPointExchangeApprovalList,
} from "./redux/action"; } from "./redux/action";
const Search = Input.Search; const Search = Input.Search;
const TabPane = Tabs.TabPane;
class CurrencyOption extends React.Component { class CurrencyOption extends React.Component {
constructor(props) { constructor(props) {
...@@ -20,19 +23,27 @@ class CurrencyOption extends React.Component { ...@@ -20,19 +23,27 @@ class CurrencyOption extends React.Component {
exchangeModalVisible: false, exchangeModalVisible: false,
selectedUser: null, selectedUser: null,
deductPoints: 0, deductPoints: 0,
loading: false loading: false,
key: 1,
}; };
this.callback = this.callback.bind(this);
} }
componentDidMount() { componentDidMount() {
// 加载用户列表数据 // 加载用户列表数据
this.props.postUserList({ name: "", pageNo: 1, pageSize: 20 }); this.props.postUserList({ name: "", pageNo: 1, pageSize: 10 });
// 加载申请列表数据
this.props.postPointExchangeApprovalList({ learnType: "point_exchange", pageNo: 1, pageSize: 10 });
} }
// 搜索处理 // 搜索处理
handleSearch = (value) => { handleSearch = (value) => {
this.props.postUserList({ name: value, pageNo: 1, pageSize: 20 }); this.props.postUserList({ name: value, pageNo: 1, pageSize: 10 });
}
callback(key) {
this.setState({
key: key - 0,
});
} }
// 显示兑换弹窗 // 显示兑换弹窗
showExchangeModal = (user) => { showExchangeModal = (user) => {
this.setState({ this.setState({
...@@ -73,7 +84,7 @@ class CurrencyOption extends React.Component { ...@@ -73,7 +84,7 @@ class CurrencyOption extends React.Component {
this.props.postUserList({ name: this.state.searchValue, pageNo: this.state.currentPage, pageSize: this.state.pageSize }); this.props.postUserList({ name: this.state.searchValue, pageNo: this.state.currentPage, pageSize: this.state.pageSize });
} }
render() { render() {
const { exchangeList, postUserList } = this.props; const { exchangeList, exchangeApprovalList, postUserList } = this.props;
// 表格列配置 // 表格列配置
const columns = [ const columns = [
{ {
...@@ -94,19 +105,19 @@ class CurrencyOption extends React.Component { ...@@ -94,19 +105,19 @@ class CurrencyOption extends React.Component {
key: "totalPoint", key: "totalPoint",
render: (text) => <span style={{ color: '#1890ff', fontWeight: 'bold' }}>{text}</span>, render: (text) => <span style={{ color: '#1890ff', fontWeight: 'bold' }}>{text}</span>,
}, },
{ // {
title: "操作", // title: "操作",
key: "action", // key: "action",
render: (text, record) => ( // render: (text, record) => (
<Button // <Button
type="primary" // type="primary"
size="small" // size="small"
onClick={() => this.showExchangeModal(record)} // onClick={() => this.showExchangeModal(record)}
> // >
兑换 // 兑换
</Button> // </Button>
), // ),
}, // },
]; ];
const pagination = { const pagination = {
showQuickJumper: true, showQuickJumper: true,
...@@ -123,7 +134,57 @@ class CurrencyOption extends React.Component { ...@@ -123,7 +134,57 @@ class CurrencyOption extends React.Component {
that.setState({ current: current, pageSize: pageSize }); that.setState({ current: current, pageSize: pageSize });
}, },
}; };
const columns1 = [
{
title: "用户名",
dataIndex: "name",
key: "name",
},
{
title: "姓名",
dataIndex: "accountName",
key: "accountName",
},
{
title: "兑换商品",
dataIndex: "learnName",
key: "learnName",
render: (text) => <span>{text ? text.split(':').pop() : ''}</span>,
},
{
title: "兑换时间",
dataIndex: "time",
key: "time",
render: (text) => <span>{moment(text).format('YYYY-MM-DD HH:mm:ss')}</span>,
},
{
title: "扣除积分",
dataIndex: "point",
key: "point",
ellipsis: true,
},
{
title: "积分余额",
dataIndex: "changeAfter",
key: "changeAfter",
render: (text) => <span style={{ color: '#1890ff', fontWeight: 'bold' }}>{text}</span>,
},
];
const pagination1 = {
showQuickJumper: true,
showSizeChanger: true,
total: exchangeApprovalList && exchangeApprovalList.total,
showTotal: total => `共 ${exchangeApprovalList.total} 条`,
pageSize: exchangeApprovalList && exchangeApprovalList.size,
onShowSizeChange(current, pageSize) {
postPointExchangeApprovalList({ pageNo: current, pageSize: pageSize });
that.setState({ current: current, pageSize: pageSize });
},
onChange(current, pageSize) {
postPointExchangeApprovalList({ pageNo: current, pageSize: pageSize });
that.setState({ current: current, pageSize: pageSize });
},
};
return ( return (
<div> <div>
<Breadcrumb title="积分兑换" /> <Breadcrumb title="积分兑换" />
...@@ -138,13 +199,28 @@ class CurrencyOption extends React.Component { ...@@ -138,13 +199,28 @@ class CurrencyOption extends React.Component {
enterButton enterButton
/> />
</div> </div>
<Tabs
activeKey={this.state.key.toString()}
onChange={this.callback}
>
<TabPane tab="用户列表" key="1">
<Table
columns={columns}
dataSource={exchangeList && exchangeList.records}
rowKey={record => record.userId}
pagination={pagination}
/>
</TabPane>
<TabPane tab="申请列表" key="2">
<Table
columns={columns1}
dataSource={exchangeApprovalList && exchangeApprovalList.records}
rowKey={record => record.id}
pagination={pagination1}
/>
</TabPane>
</Tabs>
<Table
columns={columns}
dataSource={exchangeList && exchangeList.records}
rowKey={record => record.userId}
pagination={pagination}
/>
</div> </div>
{/* 兑换弹窗 */} {/* 兑换弹窗 */}
...@@ -180,13 +256,17 @@ class CurrencyOption extends React.Component { ...@@ -180,13 +256,17 @@ class CurrencyOption extends React.Component {
function mapStateToProps(state, ownProps) { function mapStateToProps(state, ownProps) {
return { return {
exchangeList: state.point.exchangeList, exchangeList: state.point.exchangeList,
exchangeApprovalList: state.point.exchangeApprovalList,
param: state.uploadParam.param, param: state.uploadParam.param,
}; };
} }
function mapDispatchToProps(dispatch) { function mapDispatchToProps(dispatch) {
return { return {
postUserList: obj => dispatch(postUserList(obj)), postUserList: obj => dispatch(postUserList(obj)),
//兑换列表
postPointExchange: obj => dispatch(postPointExchange(obj)), postPointExchange: obj => dispatch(postPointExchange(obj)),
//申请列表
postPointExchangeApprovalList: obj => dispatch(postPointExchangeApprovalList(obj)),
}; };
} }
export default connect(mapStateToProps, mapDispatchToProps)(CurrencyOption); export default connect(mapStateToProps, mapDispatchToProps)(CurrencyOption);
\ No newline at end of file
...@@ -57,6 +57,16 @@ class activModalForm extends React.Component { ...@@ -57,6 +57,16 @@ class activModalForm extends React.Component {
sm: { span: 18 }, sm: { span: 18 },
}, },
}; };
let timeLayout = {
labelCol: {
xs: { span: 24 },
sm: { span: 4 },
},
wrapperCol: {
xs: { span: 24 },
sm: { span: 8 },
},
};
return ( return (
<Modal <Modal
visible={visible} visible={visible}
...@@ -76,7 +86,7 @@ class activModalForm extends React.Component { ...@@ -76,7 +86,7 @@ class activModalForm extends React.Component {
], ],
})( })(
<div> <div>
<UploadImageCover <UploadImageCover
details={record && record.productImg} details={record && record.productImg}
getImgUrl={this.getImgUrl} getImgUrl={this.getImgUrl}
disabled={type == "look" ? true : false} disabled={type == "look" ? true : false}
...@@ -102,6 +112,23 @@ class activModalForm extends React.Component { ...@@ -102,6 +112,23 @@ class activModalForm extends React.Component {
/> />
)} )}
</FormItem> </FormItem>
<FormItem {...formItemLayout} label="生效时间">
{getFieldDecorator("effectiveTime", {
initialValue: record && record.startTime && record.endTime ?
[moment(record.startTime), moment(record.endTime)] : undefined,
rules: [
{ required: true, message: "请选择生效时间" },
],
})(
<RangePicker
showTime={{ format: 'HH:mm' }}
format="YYYY-MM-DD HH:mm"
placeholder={['开始时间', '结束时间']}
disabled={type == "look" ? true : false}
style={{ width: '100%' }}
/>
)}
</FormItem>
<FormItem {...formItemLayout} label="所需积分"> <FormItem {...formItemLayout} label="所需积分">
{getFieldDecorator("point", { {getFieldDecorator("point", {
initialValue: record && record.point, initialValue: record && record.point,
......
...@@ -4,6 +4,7 @@ import { message } from "antd"; ...@@ -4,6 +4,7 @@ import { message } from "antd";
export const POINT_SET = "POINT_SET"; export const POINT_SET = "POINT_SET";
export const POINT_TABLE = "POINT_TABLE"; export const POINT_TABLE = "POINT_TABLE";
export const POINT_EXCHANGE = "POINT_EXCHANGE"; export const POINT_EXCHANGE = "POINT_EXCHANGE";
export const POINT_EXCHANGE_APPROVAL = "POINT_EXCHANGE_APPROVAL";
export const POINT_DETAILED = "POINT_DETAILED"; export const POINT_DETAILED = "POINT_DETAILED";
// 兑换 // 兑换
...@@ -37,6 +38,8 @@ const { ...@@ -37,6 +38,8 @@ const {
//兑换列表 //兑换列表
postUserListApi, postUserListApi,
postPointExchangeApi, postPointExchangeApi,
//申请列表
postPointExchangeApprovalListApi,
} = api; } = api;
//积分通用设置 //积分通用设置
...@@ -382,6 +385,20 @@ export function postUserList(data, callback) { ...@@ -382,6 +385,20 @@ export function postUserList(data, callback) {
}); });
}; };
} }
//获取申请列表
export function postPointExchangeApprovalList(data, callback) {
return dispatch => {
return request({
url: postPointExchangeApprovalListApi,
data: data,
}).then(res => {
dispatch({
type: POINT_EXCHANGE_APPROVAL,
data: res.data,
});
});
};
}
// 积分兑换 // 积分兑换
export function postPointExchange(data, callback) { export function postPointExchange(data, callback) {
return dispatch => { return dispatch => {
......
...@@ -28,6 +28,15 @@ export default { ...@@ -28,6 +28,15 @@ export default {
// {"userId":1314, "point": 2} // {"userId":1314, "point": 2}
postUserListApi: `POST ${services.webManage}/point/user/list`, postUserListApi: `POST ${services.webManage}/point/user/list`,
postPointExchangeApi: `POST ${services.webManage}/point/user/exchange`, postPointExchangeApi: `POST ${services.webManage}/point/user/exchange`,
//申请列表
// manage/point/details/list
// 入参:{
// "learnType":"point_exchange",
// "pageNo":1,
// "pageSize":10
// }
postPointExchangeApprovalListApi: `POST ${services.webManage}/point/details/list`,
postPointExchangeApprovalApi: `POST ${services.webManage}/point/user/exchange/approval`,
getExchangeSwitchApi: `GET ${services.webMall}/student/token/config/switch`, getExchangeSwitchApi: `GET ${services.webMall}/student/token/config/switch`,
getExchangeRuleApi: `GET ${services.webMall}/manage/tokenExchangeRule/get`, getExchangeRuleApi: `GET ${services.webMall}/manage/tokenExchangeRule/get`,
saveExchangeRuleApi: `POST ${services.webMall}/manage/tokenExchangeRule/save`, saveExchangeRuleApi: `POST ${services.webMall}/manage/tokenExchangeRule/save`,
......
...@@ -39,6 +39,11 @@ function point(state = initialState, action) { ...@@ -39,6 +39,11 @@ function point(state = initialState, action) {
return Object.assign({}, state, { return Object.assign({}, state, {
exchangeList: action.data, exchangeList: action.data,
}); });
//申请列表
case "POINT_EXCHANGE_APPROVAL":
return Object.assign({}, state, {
exchangeApprovalList: action.data,
});
//积分流水明细 //积分流水明细
case "POINT_DETAILED": case "POINT_DETAILED":
return Object.assign({}, state, { return Object.assign({}, state, {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment