|
@@ -1,5 +1,5 @@
|
|
|
import React from 'react';
|
|
|
-import { Icon, Button, Input, InputNumber, Select, Spin, Table, message, Modal, Row, Col, DatePicker } from 'antd';
|
|
|
+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';
|
|
@@ -7,6 +7,7 @@ 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() {
|
|
@@ -278,9 +279,9 @@ const AchievementOrderList = React.createClass({
|
|
|
data: {
|
|
|
pageNo: pageNo || 1,
|
|
|
pageSize: this.state.pagination.pageSize,
|
|
|
- uid: this.state.uid,
|
|
|
- username: this.state.username,
|
|
|
- unitName: this.state.unitName
|
|
|
+ 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 = [];
|
|
@@ -325,10 +326,66 @@ const AchievementOrderList = React.createClass({
|
|
|
});
|
|
|
}.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 {
|
|
|
selectedRowKeys: [],
|
|
|
selectedRows: [],
|
|
|
+ searchData: [],
|
|
|
loading: false,
|
|
|
pagination: {
|
|
|
defaultCurrent: 1,
|
|
@@ -402,71 +459,8 @@ const AchievementOrderList = React.createClass({
|
|
|
dataSource: [],
|
|
|
};
|
|
|
},
|
|
|
- getCompanyList() {
|
|
|
- this.setState({
|
|
|
- loading: true
|
|
|
- });
|
|
|
- $.ajax({
|
|
|
- method: "get",
|
|
|
- dataType: "json",
|
|
|
- crossDomain: false,
|
|
|
- url: globalConfig.context + "/api/admin/demand/unitNames",
|
|
|
- success: function (data) {
|
|
|
- let theArr = [];
|
|
|
- if (!data.data) {
|
|
|
- if (data.error && data.error.length) {
|
|
|
- message.warning(data.error[0].message);
|
|
|
- };
|
|
|
- } else {
|
|
|
- data.data.map(function (item) {
|
|
|
- theArr.push(
|
|
|
- <Select.Option value={item.uid} key={item.uid}>{item.unitName}</Select.Option>
|
|
|
- )
|
|
|
- });
|
|
|
- };
|
|
|
- this.setState({
|
|
|
- companyOption: theArr
|
|
|
- });
|
|
|
- }.bind(this),
|
|
|
- }).always(function () {
|
|
|
- this.setState({
|
|
|
- loading: false
|
|
|
- });
|
|
|
- }.bind(this));
|
|
|
- },
|
|
|
- getUserList() {
|
|
|
- this.setState({
|
|
|
- loading: true
|
|
|
- });
|
|
|
- $.ajax({
|
|
|
- method: "get",
|
|
|
- dataType: "json",
|
|
|
- crossDomain: false,
|
|
|
- url: globalConfig.context + "/api/admin/demand/userNames",
|
|
|
- success: function (data) {
|
|
|
- let theArr = [];
|
|
|
- if (!data.data) {
|
|
|
- if (data.error && data.error.length) {
|
|
|
- message.warning(data.error[0].message);
|
|
|
- };
|
|
|
- } else {
|
|
|
- data.data.map(function (item) {
|
|
|
- theArr.push(
|
|
|
- <Select.Option value={item.uid} key={item.uid}>{item.username}</Select.Option>
|
|
|
- )
|
|
|
- });
|
|
|
- };
|
|
|
- this.setState({
|
|
|
- userOption: theArr
|
|
|
- });
|
|
|
- }.bind(this),
|
|
|
- }).always(function () {
|
|
|
- this.setState({
|
|
|
- loading: false
|
|
|
- });
|
|
|
- }.bind(this));
|
|
|
- },
|
|
|
componentWillMount() {
|
|
|
+ this.state.therottleSearch = throttle(this.handleSearch, 1000, { leading: false }).bind(this);
|
|
|
let theArr = [], typeArr = [];
|
|
|
orderStatusList.map(function (item) {
|
|
|
theArr.push(
|
|
@@ -485,14 +479,15 @@ const AchievementOrderList = React.createClass({
|
|
|
// };
|
|
|
// };
|
|
|
this.loadData();
|
|
|
- this.getCompanyList();
|
|
|
- this.getUserList();
|
|
|
},
|
|
|
componentWillReceiveProps(nextProps) {
|
|
|
if (this.props['data-listApiUrl'] != nextProps['data-listApiUrl']) {
|
|
|
- this.loadData(null, 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) {
|
|
@@ -512,8 +507,7 @@ const AchievementOrderList = React.createClass({
|
|
|
},
|
|
|
reset() {
|
|
|
this.state.uid = undefined;
|
|
|
- this.state.username = undefined;
|
|
|
- this.state.unitName = undefined;
|
|
|
+ this.state.searchName = undefined;
|
|
|
this.state.status = undefined;
|
|
|
this.loadData();
|
|
|
},
|
|
@@ -539,22 +533,15 @@ const AchievementOrderList = React.createClass({
|
|
|
onChange={(e) => { this.setState({ status: e }) }}>
|
|
|
{this.state.orderStatusOption}
|
|
|
</Select>
|
|
|
- {this.props['data-listApiUrl'].indexOf('org') == -1 ? <Select placeholder="选择用户名" style={{ width: 260 }}
|
|
|
- value={this.state.username}
|
|
|
- notFoundContent="未获取到用户列表"
|
|
|
- showSearch
|
|
|
- filterOption={companySearch}
|
|
|
- onChange={(e) => { this.setState({ username: e }) }}>
|
|
|
- {this.state.userOption}
|
|
|
- </Select> :
|
|
|
- <Select placeholder="选择用户名" style={{ width: 260 }}
|
|
|
- value={this.state.unitName}
|
|
|
- notFoundContent="未获取到用户列表"
|
|
|
- showSearch
|
|
|
- filterOption={companySearch}
|
|
|
- onChange={(e) => { this.setState({ unitName: e }) }}>
|
|
|
- {this.state.companyOption}
|
|
|
- </Select>}
|
|
|
+ <AutoComplete
|
|
|
+ dataSource={this.state.searchData}
|
|
|
+ style={{ width: 200 }}
|
|
|
+ onSearch={this.state.therottleSearch}
|
|
|
+ placeholder="输入成果所有人"
|
|
|
+ onSelect={(e) => {
|
|
|
+ //this.setState({ searchName: e });
|
|
|
+ this.state.searchName = e;
|
|
|
+ }} />
|
|
|
<Button type="primary" onClick={this.search}>搜索</Button>
|
|
|
<Button onClick={this.reset}>重置</Button>
|
|
|
</div>
|