123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423 |
- import React from 'react';
- import { Icon, Button, Input, Select, Spin, Table, message, DatePicker, Modal, InputNumber, Radio } from 'antd';
- import ajax from 'jquery/src/ajax/xhr.js';
- import $ from 'jquery/src/ajax';
- import './content.less';
- import moment from 'moment';
- import { getTime } from '../../tools';
- const OrderList = React.createClass({
- loadData (pageNo) {
- this.state.data = [];
- this.setState({
- loading: true
- });
- $.ajax({
- method: "get",
- dataType: "json",
- crossDomain: false,
- url: globalConfig.context + "/api/admin/member/selectMemberOrderBa",
- data: {
- pageNo: pageNo || 1,
- pageSize: this.state.pagination.pageSize,
- id: this.state.searchOrderNumber,
- nickname: this.state.searchName,
- mobile: this.state.searchAftNumber,
- orderState: this.state.searchOrderStatus, //支付状态 0,1
- startTime: this.state.searchTime[0],
- endTime: this.state.searchTime[1]
- },
- success: function (data) {
- if (!data.data || !data.data.list) {
- if (data.error && data.error.length) {
- message.warning(data.error[0].message);
- };
- } else {
- for (let i = 0; i < data.data.list.length; i++) {
- let thisdata = data.data.list[i];
- this.state.data.push({
- key: i,
- id: thisdata.id,
- formattedOrderTime: thisdata.formattedOrderTime,
- formattedPaymentTime: thisdata.formattedPaymentTime,
- formattedValidTime: thisdata.formattedValidTime,
- gradeName: thisdata.gradeName,
- menberType: thisdata.menberType,
- nickname: thisdata.nickname,
- mobile: thisdata.mobile,
- orderState: thisdata.orderState,
- orderTime: thisdata.orderTime,
- paymentId: thisdata.paymentId,
- paymentTime: thisdata.paymentTime,
- paymentType: thisdata.paymentType,
- paymentValue: thisdata.paymentValue,
- price: thisdata.price,
- userId: thisdata.userId,
- validMonth: thisdata.validMonth,
- validTime: thisdata.validTime,
- });
- };
- this.state.pagination.current = data.data.pNo;
- this.state.pagination.total = data.data.countWhere;
- };
- this.setState({
- dataSource: this.state.data,
- pagination: this.state.pagination
- });
- }.bind(this),
- }).always(function () {
- this.setState({
- loading: false
- });
- }.bind(this));
- },
- getInitialState () {
- return {
- searchMore: true,
- data: [],
- modalData: {},
- visible: false,
- delVisible: false,
- searchTime: [],
- loading: false,
- selectedRowKeys: [],
- selectedRows: [],
- pagination: {
- defaultCurrent: 1,
- defaultPageSize: 10,
- showQuickJumper: true,
- pageSize: 10,
- onChange: function (page) {
- this.loadData(page);
- }.bind(this),
- showTotal: function (total) {
- return '共' + total + '条数据';
- }
- },
- columns: [
- {
- title: '订单编号',
- dataIndex: 'id',
- key: 'id',
- }, {
- title: '账号',
- dataIndex: 'mobile',
- key: 'mobile',
- }, {
- title: '认证名称',
- dataIndex: 'nickname',
- key: 'nickname',
- }, {
- title: '会员类型',
- dataIndex: 'gradeName',
- key: 'gradeName',
- }, {
- title: '订单状态',
- dataIndex: 'orderState',
- key: 'orderState',
- render: (text) => {
- if (text == 1) {
- return '已支付'
- } else {
- return '未支付'
- };
- }
- }, {
- title: '生成时间',
- dataIndex: 'formattedOrderTime',
- key: 'formattedOrderTime',
- }, {
- title: '支付时间',
- dataIndex: 'formattedPaymentTime',
- key: 'formattedPaymentTime',
- }, {
- title: '有效时间',
- dataIndex: 'formattedValidTime',
- key: 'formattedValidTime',
- render: (index, record) => {
- if (record.paymentTime && record.validMonth && record.orderState == 1) {
- return getTime(record.paymentTime) + ' -- ' + getTime(record.paymentTime, record.validMonth)
- }
- }
- }
- ],
- dataSource: []
- };
- },
- componentWillMount () {
- this.loadData();
- },
- search () {
- this.loadData();
- },
- reset () {
- this.state.searchOrderNumber = undefined;
- this.state.searchAftNumber = undefined;
- this.state.searchOrderStatus = undefined;
- this.state.searchName = undefined;
- this.state.searchTime = [];
- this.loadData();
- },
- submit () {
- if (this.state.modalData.paymentType == 1 && !this.state.modalData.formattedPaymentTime) {
- message.warning('状态为已支付时支付时间必填');
- return
- }
- this.setState({ loading: true });
- $.ajax({
- method: "post",
- dataType: "json",
- crossDomain: false,
- url: globalConfig.context + "/api/admin/member/updateMemberOrder",
- data: {
- id: this.state.modalData.id,
- userId: this.state.modalData.userId,
- memberRank: this.state.modalData.menberType,
- validMonth: this.state.modalData.validMonth,
- paymentValue: this.state.modalData.paymentValue,
- orderState: this.state.modalData.orderState,
- paymentTime: this.state.modalData.formattedPaymentTime,
- paymentType: this.state.modalData.paymentType,
- paymentId: this.state.modalData.paymentId
- }
- }).done(function (data) {
- if (!data.error.length) {
- message.success('保存成功!');
- this.setState({ loading: false, visible: false });
- this.loadData();
- } else {
- message.warning(data.error[0].message);
- }
- }.bind(this)).always(function () {
- this.setState({ loading: false });
- }.bind(this));
- },
- tableRowClick (record, index) {
- let theObj = {};
- for (let item in record) {
- theObj[item] = record[item]
- }
- this.state.modalData = theObj;
- this.setState({ visible: true });
- },
- deleteRow () {
- let deletedId;
- for (let idx = 0; idx < this.state.selectedRows.length; idx++) {
- let rowItem = this.state.selectedRows[idx];
- if (rowItem.orderState !== 0) {
- message.warning('订单状态不是未支付,无法删除!');
- this.setState({ delVisible: false });
- return;
- }
- if (rowItem.id) {
- deletedId = rowItem.id
- };
- };
- this.setState({
- selectedRowKeys: [],
- loading: deletedId.length > 0
- });
- $.ajax({
- method: "POST",
- dataType: "json",
- crossDomain: false,
- url: globalConfig.context + "/api/admin/member/delMemberOrder",
- data: {
- id: deletedId
- }
- }).done(function (data) {
- if (!data.error.length) {
- message.success('删除成功!');
- } else {
- message.warning(data.error[0].message);
- };
- this.setState({
- loading: false,
- delVisible: false
- });
- this.loadData();
- }.bind(this));
- },
- render () {
- const rowSelection = {
- selectedRowKeys: this.state.selectedRowKeys,
- onChange: (selectedRowKeys, selectedRows) => {
- this.setState({
- selectedRows: selectedRows.slice(-1),
- selectedRowKeys: selectedRowKeys.slice(-1)
- });
- }
- };
- const hasSelected = this.state.selectedRowKeys.length > 0;
- const { RangePicker } = DatePicker;
- const Option = Select.Option;
- return (
- <div className="user-content" >
- <div className="content-title">
- <span>会员订单列表</span>
- </div>
- <div className="user-search">
- <Input placeholder="订单编号" value={this.state.searchOrderNumber}
- onChange={(e) => { this.setState({ searchOrderNumber: e.target.value }); }} />
- <Input placeholder="用户账号" value={this.state.searchAftNumber}
- onChange={(e) => { this.setState({ searchAftNumber: e.target.value }); }} />
- <Input placeholder="认证名称" value={this.state.searchName}
- onChange={(e) => { this.setState({ searchName: e.target.value }); }} />
- <Select placeholder="订单状态" value={this.state.searchOrderStatus} style={{ width: 120 }}
- onChange={(e) => { this.setState({ searchOrderStatus: e }) }}>
- <Option value="0">未付款</Option>
- <Option value="1">已付款</Option>
- </Select>
- <div className="search-div">
- <span>订单生成时间:</span>
- <RangePicker
- allowClear={false}
- value={[this.state.searchTime[0] ? moment(this.state.searchTime[0]) : null,
- this.state.searchTime[1] ? moment(this.state.searchTime[1]) : null]}
- onChange={(data, dataString) => { this.setState({ searchTime: dataString }); }} />
- </div>
- <Button type="primary" onClick={this.search}>搜索</Button>
- <Button onClick={this.reset}>重置</Button>
- <Button style={{ background: "#3fcf9e", border: "none", color: "#fff" }}
- disabled={!hasSelected}
- onClick={() => { this.setState({ delVisible: true }) }}>删除<Icon type="minus" /></Button>
- </div>
- <div className="patent-table">
- <Spin spinning={this.state.loading}>
- <Table className="no-all-select"
- columns={this.state.columns}
- dataSource={this.state.dataSource}
- rowSelection={rowSelection}
- style={{
- cursor: 'pointer',
- }}
- pagination={this.state.pagination}
- onRowClick={this.tableRowClick} />
- </Spin>
- </div>
- <Modal title="订单详情" width={600} className="activity-modal"
- visible={this.state.visible}
- maskClosable={false}
- footer={null}
- afterClose={() => { this.state.modalData = {}; }}
- onCancel={() => { this.setState({ visible: false }) }} >
- <Spin spinning={this.state.loading}>
- <div className="clearfix">
- <div className="modal-box">
- <span className="modal-box-title">会员等级</span>
- <div className="modal-box-detail">
- <Select placeholder="选择会员等级"
- style={{ width: 120 }}
- value={this.state.modalData.menberType ? this.state.modalData.menberType.toString() : undefined}
- onChange={(e) => {
- this.state.modalData.menberType = e;
- this.setState({ modalData: this.state.modalData });
- }}>
- <Select.Option value="1">Lv.1</Select.Option>
- <Select.Option value="2">Lv.2</Select.Option>
- <Select.Option value="3">Lv.3</Select.Option>
- <Select.Option value="4">Lv.4</Select.Option>
- <Select.Option value="5">Lv.5</Select.Option>
- </Select>
- </div>
- </div>
- <div className="modal-box">
- <span className="modal-box-title">会员时长</span>
- <div className="modal-box-detail" style={{ width: '160px' }}>
- <InputNumber value={this.state.modalData.validMonth} step={1} onChange={(e) => {
- this.state.modalData.validMonth = e;
- this.setState({ modalData: this.state.modalData });
- }} />
- <span> 月</span>
- </div>
- </div>
- <div className="modal-box">
- <span className="modal-box-title">订单金额</span>
- <div className="modal-box-detail" style={{ width: '160px' }}>
- <span>{this.state.modalData.price}</span>
- <span> 元</span>
- </div>
- <span className="modal-box-title">实际支付金额</span>
- <div className="modal-box-detail" style={{ width: '160px' }}>
- <InputNumber value={this.state.modalData.paymentValue} step={0.01} onChange={(e) => {
- this.state.modalData.paymentValue = e;
- this.setState({ modalData: this.state.modalData });
- }} />
- <span> 元</span>
- </div>
- </div>
- <div className="modal-box">
- <span className="modal-box-title">支付方式</span>
- <div className="modal-box-detail" style={{ width: '160px' }}>
- <Input value={this.state.modalData.paymentType} onChange={(e) => {
- this.state.modalData.paymentType = e.target.value;
- this.setState({ modalData: this.state.modalData });
- }} />
- </div>
- <span className="modal-box-title">流水号</span>
- <div className="modal-box-detail" style={{ width: '160px' }}>
- <Input value={this.state.modalData.paymentId} onChange={(e) => {
- this.state.modalData.paymentId = e.target.value;
- this.setState({ modalData: this.state.modalData });
- }} />
- </div>
- </div>
- <div className="modal-box">
- <span className="modal-box-title">支付状态</span>
- <div className="modal-box-detail">
- <Radio.Group value={this.state.modalData.orderState}
- onChange={(e) => {
- this.state.modalData.orderState = e.target.value;
- this.setState({ modalData: this.state.modalData });
- }} >
- <Radio value={0}>未支付</Radio>
- <Radio value={1}>已支付</Radio>
- </Radio.Group>
- </div>
- </div>
- <div className="modal-box">
- <span className="modal-box-title">支付时间</span>
- <div className="modal-box-detail">
- <DatePicker style={{ width: '150px' }}
- showTime
- format="YYYY-MM-DD HH:mm:ss"
- placeholder="选择支付时间"
- value={this.state.modalData.formattedPaymentTime ? moment(this.state.modalData.formattedPaymentTime, "YYYY-MM-DD HH:mm:ss") : undefined}
- onChange={(t, str) => {
- this.state.modalData.formattedPaymentTime = str;
- this.setState({ modalData: this.state.modalData });
- }} />
- </div>
- </div>
- </div>
- <div className="modal-box" style={{ marginTop: '100px' }}>
- <Button type="primary" onClick={this.submit}>提交</Button>
- <Button type="ghost" onClick={() => { this.setState({ visible: false }) }}>取消</Button>
- </div>
- </Spin>
- </Modal>
- <Modal title="删除确认" width={600} className="activity-modal"
- visible={this.state.delVisible}
- maskClosable={false}
- footer={null}
- onCancel={() => { this.setState({ delVisible: false }) }} >
- <Spin spinning={this.state.loading}>
- <div className="clearfix">
- <div className="modal-box">
- <span>是否确定删除这条记录?删除后数据不可恢复!</span>
- </div>
- <div className="modal-box" >
- <Button type="primary" onClick={this.deleteRow}>提交</Button>
- <Button type="ghost" onClick={() => { this.setState({ delVisible: false }) }}>取消</Button>
- </div>
- </div>
- </Spin>
- </Modal>
- </div >
- );
- }
- });
- export default OrderList;
|