import React from 'react';
import { AutoComplete, Icon, Button, Input, InputNumber, Select, Spin, Table, message, Modal, Row, Col, DatePicker } from 'antd';
import ajax from 'jquery/src/ajax/xhr.js';
import $ from 'jquery/src/ajax';
import moment from 'moment';
import './techAchievement.less';
import { orderStatusList } from '../../dataDic.js';
import { befoFile, getSearchUrl, getOrderStatus, companySearch } from '../../tools.js';
import BatchImport from './batchImport';
import throttle from '../../throttle.js';
const AchievementDetail = React.createClass({
getInitialState () {
return {
visible: false,
loading: false,
columns: [
{
title: '状态',
dataIndex: 'status',
key: 'status',
render: text => { return getOrderStatus(text) }
}, {
title: '操作时间',
dataIndex: 'recordTimeFormattedDate',
key: 'recordTimeFormattedDate',
}, {
title: '管理员',
dataIndex: 'operator',
key: 'operator',
}, {
title: '备注',
dataIndex: 'comment',
key: 'comment',
}
],
dataSource: [],
};
},
loadLogs (id) {
this.setState({
loading: true
});
$.ajax({
method: "get",
dataType: "json",
crossDomain: false,
url: globalConfig.context + "/api/admin/portal/order/achievementOrderLog",
data: {
achievementOrderId: id
},
success: function (data) {
let theArr = [];
if (!data.data) {
if (data.error && data.error.length) {
message.warning(data.error[0].message);
};
} else {
for (let i = 0; i < data.data.length; i++) {
let thisdata = data.data[i];
theArr.push({
key: i,
recordTime: thisdata.recordTime,
status: thisdata.status,
comment: thisdata.comment,
operator: thisdata.operator,
recordTimeFormattedDate: thisdata.recordTimeFormattedDate
});
};
};
this.setState({
dataSource: theArr
});
}.bind(this),
}).always(function () {
this.setState({
loading: false
});
}.bind(this));
},
handleSubmit (e) {
//keyword长度判断
if (this.state.orderStatus || this.state.comment || this.state.recordTime) {
if (this.state.orderStatus && this.state.comment && this.state.recordTime) {
} else {
message.warning('请填写完整的状态流转记录!');
return;
};
};
this.setState({
loading: true
});
$.ajax({
method: "POST",
dataType: "json",
crossDomain: false,
url: globalConfig.context + '/api/admin/portal/order/updateAchievementOrder',
data: {
id: this.props.data.id,
achievementId: this.props.data.achievementId,
status: this.state.orderStatus || this.props.data.status,
recordTimeFormattedDate: this.state.recordTime ? this.state.recordTime.format("YYYY-MM-DD HH:mm:ss") : undefined,
comment: this.state.comment,
paymentId: this.state.paymentId,
paymentType: this.state.paymentType,
paymentValue: this.state.paymentValue,
transferPrice: this.state.transferPrice,
}
}).done(function (data) {
this.setState({
loading: false
});
if (!data.error.length) {
message.success('保存成功!');
this.handleOk();
} else {
message.warning(data.error[0].message);
};
}.bind(this));
},
handleCancel (e) {
this.setState({
visible: false,
});
this.props.closeDesc(false);
},
handleOk (e) {
this.setState({
visible: false,
});
this.props.closeDesc(false, true);
},
componentWillReceiveProps (nextProps) {
if (!this.state.visible && nextProps.showDesc && nextProps.data) {
this.loadLogs(nextProps.data.id);
this.state.paymentId = nextProps.data.paymentId;
this.state.paymentType = nextProps.data.paymentType;
this.state.paymentValue = nextProps.data.paymentValue;
this.state.transferPrice = nextProps.data.transferPrice;
this.state.orderStatus = undefined;
this.state.comment = undefined;
this.state.recordTime = undefined;
};
this.state.visible = nextProps.showDesc;
},
render () {
let theData = this.props.data;
if (theData) {
return (
);
} else {
return
}
},
});
const AchievementOrderList = React.createClass({
loadData (pageNo, apiUrl) {
this.setState({
loading: true
});
$.ajax({
method: "get",
dataType: "json",
crossDomain: false,
url: globalConfig.context + (apiUrl || this.props['data-listApiUrl']),
data: {
pageNo: pageNo || 1,
pageSize: this.state.pagination.pageSize,
status: this.state.status,
username: ((apiUrl || this.props['data-listApiUrl']).indexOf('org') != -1) ? null : this.state.searchName,
unitName: ((apiUrl || this.props['data-listApiUrl']).indexOf('org') != -1) ? this.state.searchName : null
},
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,
id: thisdata.id, //线索单/意向单ID
serialNumber: thisdata.serialNumber, //线索单/意向单编号
achievementId: thisdata.achievementId, //科技需求ID
createTime: thisdata.createTime,
status: thisdata.status, //线索单/意向单状态
paymentvalue: thisdata.paymentvalue,
name: thisdata.name, //成果名称,
achievementSerialNumber: thisdata.achievementSerialNumber, //科技成果编号
deletedSign: thisdata.deletedSign, //科技成果删除标记
auditStatus: thisdata.auditStatus, //科技成果审核状态 //个人用户名称
theName: thisdata.username || thisdata.unitName,
uid: thisdata.uid, //个人用户ID
createTimeFormattedDate: thisdata.createTimeFormattedDate, //接单时间
paymentId: thisdata.paymentId,
paymentTime: thisdata.paymentTime,
paymentTimeFormattedDate: thisdata.paymentTimeFormattedDate,
paymentType: thisdata.paymentType,
paymentValue: thisdata.paymentValue,
transferPrice: thisdata.transferPrice
});
};
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));
},
handleSearch (e) {
if (this.props['data-detailApiUrl'].indexOf('org') != -1) {
$.ajax({
method: "get",
dataType: "json",
crossDomain: false,
url: globalConfig.context + "/api/admin/achievement/orgOwner",
data: { name: e },
success: function (data) {
let theArr = [];
let theObj = {};
if (!data.data) {
if (data.error && data.error.length) {
message.warning(data.error[0].message);
};
} else if (!$.isEmptyObject(data.data)) {
data.data.map(function (item) {
theArr.push(item.unitName);
theObj[item.unitName] = item.uid;
});
};
this.setState({
searchData: theArr,
dataSourceObj: theObj
});
}.bind(this),
});
} else {
$.ajax({
method: "get",
dataType: "json",
crossDomain: false,
url: globalConfig.context + "/api/admin/achievement/userOwner",
data: { name: e },
success: function (data) {
let theArr = [];
let theObj = {};
if (!data.data) {
if (data.error && data.error.length) {
message.warning(data.error[0].message);
};
} else if (!$.isEmptyObject(data.data)) {
for (let item in data.data) {
theArr.push(data.data[item]);
theObj[data.data[item]] = item;
};
};
this.setState({
dataSource: theArr,
dataSourceObj: theObj
});
}.bind(this),
});
};
},
getInitialState () {
return {
searchData: [],
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: 'serialNumber',
key: 'serialNumber',
}, {
title: '成果名称',
dataIndex: 'name',
key: 'name',
}, {
title: '成果编号',
dataIndex: 'achievementSerialNumber',
key: 'achievementSerialNumber',
}, {
title: '订单所有人',
dataIndex: 'theName',
key: 'theName',
}, {
title: '订单状态',
dataIndex: 'status',
key: 'status',
render: (text, record) => { return getOrderStatus(text); }
}, {
title: '订单金额',
dataIndex: 'paymentValue',
key: 'paymentValue',
}, {
title: '接单时间',
dataIndex: 'createTimeFormattedDate',
key: 'createTimeFormattedDate',
}
],
dataSource: [],
};
},
componentWillMount () {
this.state.therottleSearch = throttle(this.handleSearch, 1000, { leading: false }).bind(this);
let theArr = [], typeArr = [];
orderStatusList.map(function (item) {
theArr.push(
{item.key}
)
});
this.state.demandTypeOption = typeArr;
this.state.orderStatusOption = theArr;
this.loadData();
},
componentWillReceiveProps (nextProps) {
if (this.props['data-listApiUrl'] != nextProps['data-listApiUrl']) {
this.state.selectedRowKeys = [];
this.state.selectedRows = [];
this.state.status = undefined;
this.state.searchName = undefined;
this.state.searchData = [];
this.loadData(null, nextProps['data-listApiUrl']);
};
},
tableRowClick (record, index) {
this.state.RowData = record;
this.setState({
showDesc: true
});
},
closeDesc (e, s) {
this.state.showDesc = e;
if (s) {
this.loadData();
};
},
search () {
this.loadData();
},
reset () {
this.state.uid = undefined;
this.state.searchName = undefined;
this.state.status = undefined;
this.loadData();
},
render () {
return (
{this.props['data-listApiUrl'].indexOf('org') == -1 ? 个人成果订单管理 : 组织成果订单管理}
{
this.setState({ searchName: e });
}} />
);
}
});
export default AchievementOrderList;