/* update:2018/07/16 author:liting */ import React from 'react'; import $ from 'jquery/src/ajax'; import { Form, Button, Input, Select,Rate, Spin, Table, message, Modal, Tooltip, Switch, DatePicker } from 'antd'; import { getOrderType } from '@/tools.js'; import moment from 'moment'; //主体 const Order = Form.create()( React.createClass({ loadData(pageNo) { this.state.data = []; this.setState({ loading: true, page: pageNo }); $.ajax({ method: 'get', dataType: 'json', crossDomain: false, url: globalConfig.context + '/api/user/jtOrder/list', data: { pageNo: pageNo || 1, pageSize: this.state.pagination.pageSize, orderNo: this.state.numberSearch, userType:0, orderType:10, commodityName: this.state.entryNameSearch, sellerName: this.state.companyNameSearch, startCreateDate: this.state.releaseDate[0], endCreateDate: this.state.releaseDate[1] }, success: function(data) { let theArr = []; 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]; theArr.push({ key: i, sellerId: thisdata.sellerId, buyerId:thisdata.buyerId, orderNo:thisdata.orderNo, commodityId:thisdata.commodityId, commodityType:thisdata.commodityType, orderAmount:thisdata.orderAmount, commodityName:thisdata.commodityName, sellerName:thisdata.sellerName!=null?thisdata.sellerName:'佚名', sellerMobile:thisdata.sellerMobile, createTime: thisdata.createTime ? new Date(thisdata.createTime).toLocaleString() : '' }); } this.state.pagination.current = data.data.pageNo; this.state.pagination.total = data.data.totalCount; } this.setState({ dataSource: theArr, pagination: this.state.pagination }); }.bind(this) }).always( function() { this.setState({ loading: false }); }.bind(this) ); }, getInitialState() { return { searchMore: true, selectedRowKeys: [], selectedRows: [], loading: false, releaseDate: [], pagination: { defaultCurrent: 1, defaultPageSize: 10, showQuickJumper: true, pageSize: 10, onChange: function(page) { this.loadData(page); this.setState({ selectedRowKeys: [] }); }.bind(this), showTotal: function(total) { return '共' + total + '条数据'; } }, columns: [ { title: '订单编号', dataIndex: 'orderNo', key: 'orderNo' }, { title: '订单类型', dataIndex: 'commodityType', key: 'commodityType', render: (text) => { return getOrderType(text); } }, { title: '订单日期', dataIndex: 'createTime', key: 'createTime' }, { title: '订单金额(万元)', dataIndex: 'orderAmount', key: 'orderAmount', render:(text)=>{ return text?text:'面议' } }, { title: '顾问名称', dataIndex: 'sellerName', key: 'sellerName', }, { title: '联系方式', dataIndex: 'sellerMobile', key: 'sellerMobile' }, { title: '评价', dataIndex: 'pingjia', key: 'pingjia', render:(text,recard)=>{ return } } ], dataSource: [] }; }, componentWillMount() { this.loadData(); }, //项目列表整行点击 tableRowClick(record, index) { this.state.RowData = record; this.setState({ editvisible: true }); }, edithandleCancel(e) { this.setState({ editvisible: false }); }, search() { this.loadData(); }, //评价 evaluate(recard){ this.setState({ remark:'', star:undefined, orderNo:recard.orderNo, ids:recard.commodityId, evaluateVisible:true }) }, evaluateOk(){ this.setState({ evaluateVisible:false }) }, evaluateCancel(){ this.setState({ evaluateVisible:false }) }, //评价 evaluateSubmit(e){ e.preventDefault(); if(!this.state.remark){ message.warning('请填写评价内容'); return; } if(!this.state.star){ message.warning('请选择评星等级'); return; } this.setState({ loading:true }) $.ajax({ method:"post", dataType:'json', url:globalConfig.context+'/api/user/comment/apply', data:{ commodityId:this.state.ids, content:this.state.remark, star:this.state.star, orderNo:this.state.orderNo }, success:function(data){ if(data&&data.error.length){ message.error(data.error[0].message); return; } message.success('提交成功,感谢您的评价!') this.loadData(this.state.page); }.bind(this) }).always( function() { this.setState({ evaluateVisible:false, loading: false }); }.bind(this) ); }, //搜索部分的清零 reset() { this.state.numberSearch = ''; this.state.typeSearch = undefined; this.state.companyNameSearch = ''; this.state.entryNameSearch = ''; this.state.releaseDate = []; this.state.searchMore=true; this.loadData(); }, searchSwitch() { this.setState({ searchMore: !this.state.searchMore }); }, render() { const FormItem = Form.Item; const rowSelection = { selectedRowKeys: this.state.selectedRowKeys, onChange: (selectedRowKeys, selectedRows) => { this.setState({ selectedRows: selectedRows.slice(-1), selectedRowKeys: selectedRowKeys.slice(-1) }); } }; const { RangePicker } = DatePicker; const theData = this.state.RowData || {}; return (