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/consultorder/list", data: { pageNo: pageNo || 1, pageSize: this.state.pagination.pageSize, number: this.state.searchNumber, toNumber: this.state.searchToNumber, id: this.state.searchId, paymentId: this.state.searchPaymentId, state: this.state.searchState }, 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, price: thisdata.price, orderState: thisdata.orderState, orderTime: thisdata.orderTime, orderTimeFormatted: thisdata.orderTimeFormatted, userId: thisdata.userId, toUserId: thisdata.toUserId, nickname: thisdata.nickname, number: thisdata.number, toNickname: thisdata.toUsername || thisdata.toNickname, toNumber: thisdata.toNumber, paymentTime: thisdata.paymentTime, paymentTimeFormatted: thisdata.paymentTimeFormatted, paymentValue: thisdata.paymentValue, paymentType: thisdata.paymentType, paymentId: thisdata.paymentId, }); }; 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, selectedRows: [], selectedRowKeys: [], data: [], modalData: {}, visible: false, delVisible: false, searchTime: [], loading: false, 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: 'number', key: 'number', }, { title: '用户名称', dataIndex: 'nickname', key: 'nickname' }, { title: '专家编号', dataIndex: 'toNumber', key: 'toNumber', }, { title: '专家名称', dataIndex: 'toNickname', key: 'toNickname' }, { title: '订单状态', dataIndex: 'orderState', key: 'orderState', render: (text, record) => { if (text == 1) { return '已支付' } else if (text == 9) { return '已取消' } else if (text == 2) { return '支付中' } else { let now = new Date(); let endTime = new Date(record.orderTime + 24 * 60 * 60 * 1000 * 15) if (now > endTime) { return '已失效' } else { return '未支付' } } } }, { title: '生成时间', dataIndex: 'orderTimeFormatted', key: 'orderTimeFormatted', }, { title: '支付金额', dataIndex: 'price', key: 'price', render: (index, record) => { if (record.paymentValue && record.paymentValue != 0) { return record.paymentValue } else { return index } } }, { title: '支付时间', dataIndex: 'paymentTimeFormatted', key: 'paymentTimeFormatted', }, { title: '支付流水', dataIndex: 'paymentId', key: 'paymentId' } ], dataSource: [] }; }, componentWillMount () { this.loadData(); }, search () { this.loadData(); }, reset () { this.state.searchNumber = undefined; this.state.searchToNumber = undefined; this.state.searchId = undefined; this.state.searchPaymentId = undefined; this.state.searchState = undefined; this.state.searchTime = []; this.loadData(); }, submit () { if (this.state.modalData.paymentType == 1 && !this.state.modalData.paymentTimeFormatted) { message.warning('状态为已支付时支付时间必填'); return } this.setState({ loading: true }); $.ajax({ method: "post", dataType: "json", crossDomain: false, url: globalConfig.context + "/api/admin/consultorder/update", data: { id: this.state.modalData.id, paymentValue: this.state.modalData.paymentValue, orderState: this.state.modalData.orderState, paymentTime: this.state.modalData.paymentTimeFormatted, 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/consultorder/del", 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 (
专家咨询订单列表
{ this.setState({ searchNumber: e.target.value }); }} /> { this.setState({ searchToNumber: e.target.value }); }} /> { this.setState({ searchId: e.target.value }); }} /> { this.setState({ searchPaymentId: e.target.value }); }} />
订单生成时间: { this.setState({ searchTime: dataString }); }} />
{ this.state.modalData = {}; }} onCancel={() => { this.setState({ visible: false }) }} >
订单金额
{this.state.modalData.price}
实际支付金额
{ this.state.modalData.paymentValue = e; this.setState({ modalData: this.state.modalData }); }} />
支付方式
{ this.state.modalData.paymentType = e.target.value; this.setState({ modalData: this.state.modalData }); }} />
流水号
{ this.state.modalData.paymentId = e.target.value; this.setState({ modalData: this.state.modalData }); }} />
支付状态
{ this.state.modalData.orderState = e.target.value; this.setState({ modalData: this.state.modalData }); }} > 未支付 已支付
支付时间
{ this.state.modalData.paymentTimeFormatted = str; this.setState({ modalData: this.state.modalData }); }} />
{ this.setState({ delVisible: false }) }} >
是否确定删除这条记录?删除后数据不可恢复!
); } }); export default OrderList;