|
@@ -1,14 +1,15 @@
|
|
|
import React,{Component} from "react";
|
|
|
-import {Form, Button, DatePicker, Input, message, Select, Spin, Table, Tabs} from "antd";
|
|
|
+import {Form, Button, DatePicker, Input, message, Select, Spin, Table, Tabs, AutoComplete} from "antd";
|
|
|
import {
|
|
|
ShowModal,
|
|
|
} from "@/tools";
|
|
|
import {ChooseList} from "../../manageCenter/order/orderNew/chooseList";
|
|
|
import $ from "jquery/src/ajax";
|
|
|
import moment from "moment";
|
|
|
+import AutoCompleteSearch from './autoCompleteSearch';
|
|
|
|
|
|
const {TabPane} = Tabs;
|
|
|
-const { RangePicker } = DatePicker;
|
|
|
+const { RangePicker,MonthPicker } = DatePicker;
|
|
|
const FormItem = Form.Item
|
|
|
|
|
|
class TabelContent extends Component{
|
|
@@ -33,6 +34,7 @@ class TabelContent extends Component{
|
|
|
contactsOption:[]
|
|
|
}
|
|
|
this.loadData= this.loadData.bind(this);
|
|
|
+ this.resetAll= this.resetAll.bind(this);
|
|
|
this.exportExec= this.exportExec.bind(this);
|
|
|
this.selectSuperId= this.selectSuperId.bind(this);
|
|
|
}
|
|
@@ -41,32 +43,46 @@ class TabelContent extends Component{
|
|
|
this.setState({
|
|
|
loading:true
|
|
|
})
|
|
|
+ let data = {
|
|
|
+ pageNo: pageNo || 1,
|
|
|
+ pageSize: this.state.pagination.pageSize,
|
|
|
+ }
|
|
|
+ if(this.props.query){
|
|
|
+ data = Object.assign(data,this.props.query);
|
|
|
+ }
|
|
|
+ if(Object.keys(this.state.searchValues).length > 0){
|
|
|
+ data = Object.assign(data,this.state.searchValues);
|
|
|
+ }
|
|
|
$.ajax({
|
|
|
method: "get",
|
|
|
dataType: "json",
|
|
|
crossDomain: false,
|
|
|
url: globalConfig.context + this.props.tabelApi,
|
|
|
- data: {
|
|
|
- pageNo: pageNo || 1,
|
|
|
- pageSize: this.state.pagination.pageSize,
|
|
|
- },
|
|
|
+ data,
|
|
|
success: function(data) {
|
|
|
ShowModal(this);
|
|
|
this.setState({
|
|
|
loading:false
|
|
|
})
|
|
|
if (data.error && data.error.length === 0) {
|
|
|
- this.state.pagination.current = data.data.pageNo;
|
|
|
- this.state.pagination.total = data.data.totalCount;
|
|
|
- if (data.data && data.data.list && !data.data.list.length) {
|
|
|
- this.state.pagination.current = 0;
|
|
|
- this.state.pagination.total = 0;
|
|
|
+ if(data.data.list){
|
|
|
+ this.state.pagination.current = data.data.pageNo;
|
|
|
+ this.state.pagination.total = data.data.totalCount;
|
|
|
+ if (data.data && data.data.list && !data.data.list.length) {
|
|
|
+ this.state.pagination.current = 0;
|
|
|
+ this.state.pagination.total = 0;
|
|
|
+ }
|
|
|
+ this.setState({
|
|
|
+ dataSource: this.props.dataProcessing ? this.props.dataProcessing(data) : data.data.list,
|
|
|
+ pagination: this.state.pagination,
|
|
|
+ pageNo:data.data.pageNo
|
|
|
+ });
|
|
|
+ }else{
|
|
|
+ this.setState({
|
|
|
+ dataSource: this.props.dataProcessing ? this.props.dataProcessing(data) : data.data,
|
|
|
+ pagination: false,
|
|
|
+ });
|
|
|
}
|
|
|
- this.setState({
|
|
|
- dataSource: this.props.dataProcessing ? this.props.dataProcessing(data) : data.data.list,
|
|
|
- pagination: this.state.pagination,
|
|
|
- pageNo:data.data.pageNo
|
|
|
- });
|
|
|
}else{
|
|
|
message.warning(data.error[0].message);
|
|
|
}
|
|
@@ -81,23 +97,43 @@ class TabelContent extends Component{
|
|
|
}
|
|
|
|
|
|
exportExec(){
|
|
|
- let data = {
|
|
|
- clockStart:this.state.releaseDate[0],
|
|
|
- clockEnd:this.state.releaseDate[1],
|
|
|
- createStart:this.state.createReleaseDate[0],
|
|
|
- createEnd:this.state.createReleaseDate[1],
|
|
|
- depId:this.state.superId,
|
|
|
- aid:this.state.theTypes
|
|
|
- };
|
|
|
- for(let i of Object.keys(data)){
|
|
|
- if(!data[i]){
|
|
|
- delete data[i]
|
|
|
- }
|
|
|
+ message.config({
|
|
|
+ duration: 20,
|
|
|
+ });
|
|
|
+ let loading = message.loading('下载中...');
|
|
|
+ this.setState({
|
|
|
+ exportPendingLoading: true
|
|
|
+ })
|
|
|
+
|
|
|
+ let data ={};
|
|
|
+ data = Object.assign(data,this.state.searchValues);
|
|
|
+ if(this.props.exportExecProcessing){
|
|
|
+ data = this.props.exportExecProcessing(data);
|
|
|
}
|
|
|
- window.location.href =
|
|
|
- globalConfig.context +
|
|
|
- this.props.exportApi + "?" +
|
|
|
- $.param(data);
|
|
|
+
|
|
|
+ $.ajax({
|
|
|
+ method: "get",
|
|
|
+ dataType: "json",
|
|
|
+ crossDomain: false,
|
|
|
+ url: this.props.exportApi,
|
|
|
+ data,
|
|
|
+ success: function(data) {
|
|
|
+ if(data.error.length === 0){
|
|
|
+ this.download(data.data);
|
|
|
+ }else{
|
|
|
+ message.warning(data.error[0].message);
|
|
|
+ }
|
|
|
+ }.bind(this),
|
|
|
+ }).always(function() {
|
|
|
+ loading();
|
|
|
+ this.setState({
|
|
|
+ exportPendingLoading: false
|
|
|
+ })
|
|
|
+ }.bind(this));
|
|
|
+ }
|
|
|
+
|
|
|
+ download(fileName){
|
|
|
+ window.location.href = globalConfig.context + "/open/download?fileName=" + fileName
|
|
|
}
|
|
|
|
|
|
//获取上级组织
|
|
@@ -153,6 +189,14 @@ class TabelContent extends Component{
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ resetAll(){
|
|
|
+ this.setState({
|
|
|
+ searchValues: {}
|
|
|
+ },()=>{
|
|
|
+ this.loadData();
|
|
|
+ })
|
|
|
+ }
|
|
|
+
|
|
|
render() {
|
|
|
const { searchValues } = this.state;
|
|
|
return (
|
|
@@ -168,7 +212,7 @@ class TabelContent extends Component{
|
|
|
<Input
|
|
|
key={k}
|
|
|
placeholder={v.placeholder}
|
|
|
- value={v.value ? v.value : (v.defaultValue || undefined)}
|
|
|
+ value={searchValues[v.dataKey] ? searchValues[v.dataKey] : (v.defaultValue || undefined)}
|
|
|
style={v.style ? v.style : { width: 150, marginRight: 10}}
|
|
|
onChange={(e) => {
|
|
|
searchValues[v.dataKey] = e.target.value
|
|
@@ -178,6 +222,17 @@ class TabelContent extends Component{
|
|
|
}}
|
|
|
/>
|
|
|
</FormItem> :
|
|
|
+ v.type === 'autoComplete' ?
|
|
|
+ <AutoCompleteSearch
|
|
|
+ onSelect={(value)=>{
|
|
|
+ searchValues[v.dataKey] = value
|
|
|
+ this.setState({
|
|
|
+ searchValues: searchValues
|
|
|
+ });
|
|
|
+ }}
|
|
|
+ config={v}
|
|
|
+ />
|
|
|
+ :
|
|
|
v.type === 'select' || v.type === 'departmentSelect' ?
|
|
|
<FormItem label={v.title} style={{marginTop:'-8px'}}>
|
|
|
<Spin spinning={this.state.departmentLoading}>
|
|
@@ -189,6 +244,10 @@ class TabelContent extends Component{
|
|
|
value={searchValues[v.dataKey] ? searchValues[v.dataKey] : (v.defaultValue || undefined)}
|
|
|
onChange={(e) => {
|
|
|
searchValues[v.dataKey] = String(e);
|
|
|
+ if(v.type === 'departmentSelect'){
|
|
|
+ let arr = this.state.contactsOption.filter(v=>String(v.value) === String(e))
|
|
|
+ searchValues['depName'] = arr[0].label;
|
|
|
+ }
|
|
|
this.setState({
|
|
|
searchValues: searchValues
|
|
|
});
|
|
@@ -214,24 +273,37 @@ class TabelContent extends Component{
|
|
|
</Spin>
|
|
|
</FormItem>: v.type === 'times' ?
|
|
|
<FormItem label={v.title}>
|
|
|
- <RangePicker
|
|
|
- style={{marginRight:'10px',marginTop: '2px'}}
|
|
|
- value={[
|
|
|
- searchValues[v.dataKey[0]]
|
|
|
- ? moment(searchValues[v.dataKey[0]])
|
|
|
- : null,
|
|
|
- searchValues[v.dataKey[1]]
|
|
|
- ? moment(searchValues[v.dataKey[1]])
|
|
|
- : null,
|
|
|
- ]}
|
|
|
- onChange={(data, dataString) => {
|
|
|
- searchValues[v.dataKey[0]] = String(dataString[0]);
|
|
|
- searchValues[v.dataKey[1]] = String(dataString[1]);
|
|
|
- this.setState({
|
|
|
- searchValues: searchValues
|
|
|
- });
|
|
|
- }}
|
|
|
- />
|
|
|
+ {
|
|
|
+ v.format === 'YYYY/MM' ?
|
|
|
+ <MonthPicker
|
|
|
+ value={searchValues[v.dataKey] ? moment(searchValues[v.dataKey]) : null}
|
|
|
+ style={{marginRight:'10px',marginTop: '2px'}}
|
|
|
+ onChange={(data, dataString) => {
|
|
|
+ searchValues[v.dataKey] = String(dataString);
|
|
|
+ this.setState({
|
|
|
+ searchValues: searchValues
|
|
|
+ });
|
|
|
+ }}
|
|
|
+ />:
|
|
|
+ <RangePicker
|
|
|
+ style={{marginRight:'10px',marginTop: '2px'}}
|
|
|
+ value={[
|
|
|
+ searchValues[v.dataKey[0]]
|
|
|
+ ? moment(searchValues[v.dataKey[0]])
|
|
|
+ : null,
|
|
|
+ searchValues[v.dataKey[1]]
|
|
|
+ ? moment(searchValues[v.dataKey[1]])
|
|
|
+ : null,
|
|
|
+ ]}
|
|
|
+ onChange={(data, dataString) => {
|
|
|
+ searchValues[v.dataKey[0]] = String(dataString[0]);
|
|
|
+ searchValues[v.dataKey[1]] = String(dataString[1]);
|
|
|
+ this.setState({
|
|
|
+ searchValues: searchValues
|
|
|
+ });
|
|
|
+ }}
|
|
|
+ />
|
|
|
+ }
|
|
|
</FormItem>: null
|
|
|
))
|
|
|
}
|
|
@@ -255,7 +327,7 @@ class TabelContent extends Component{
|
|
|
</TabPane>
|
|
|
{this.props.exportApi && <TabPane tab="导出" key="3">
|
|
|
<div style={{ float: "left" }}>
|
|
|
- <Button onClick={this.exportExec} style={{ margin: 10 }}>导出excel</Button>
|
|
|
+ <Button loading={this.state.exportPendingLoading} onClick={this.exportExec} style={{ margin: 10 }}>导出excel</Button>
|
|
|
</div>
|
|
|
</TabPane>}
|
|
|
</Tabs>
|
|
@@ -270,6 +342,7 @@ class TabelContent extends Component{
|
|
|
? this.state.changeList
|
|
|
: this.props.columns
|
|
|
}
|
|
|
+ onRowClick={this.props.onRowClick ? this.props.onRowClick : null}
|
|
|
dataSource={this.state.dataSource}
|
|
|
pagination={this.state.pagination}
|
|
|
/>
|