123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152 |
- import React, { Component } from "react";
- 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";
- class TablePopup extends Component {
- constructor(props) {
- super(props);
- this.state = {
- changeList: [],
- dataSource: [],
- pagination: {
- defaultCurrent: 1,
- defaultPageSize: 10,
- showQuickJumper: true,
- pageSize: 10,
- onChange: function (page) {
- this.loadData(page);
- }.bind(this),
- showTotal: function (total) {
- return "共" + total + "条数据";
- },
- },
- searchValues: this.props.searchConfig || {},
- contactsOption: [],
- departmentLoading: false,
- };
- this.loadData = this.loadData.bind(this);
- this.onRefresh = this.onRefresh.bind(this);
- }
- loadData(pageNo) {
- this.setState({
- loading: true,
- });
- let searchInfor = {
- pageNo: pageNo || 1,
- pageSize: this.state.pagination.pageSize,
- };
- if (this.props.query) {
- let obj = JSON.parse(JSON.stringify(this.props.query));
- searchInfor = Object.assign(searchInfor, obj);
- }
- if (Object.keys(this.state.searchValues).length > 0) {
- let obj1 = JSON.parse(JSON.stringify(this.state.searchValues));
- searchInfor = Object.assign(searchInfor, obj1);
- }
- $.ajax({
- method: "get",
- dataType: "json",
- crossDomain: false,
- url: globalConfig.context + this.props.tabelApi,
- data: searchInfor,
- success: function (data) {
- ShowModal(this);
- this.setState({
- loading: false,
- });
- if (data.error && data.error.length === 0) {
- this.props.searchOperation && this.props.searchOperation(searchInfor);
- 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,
- });
- }
- } else {
- message.warning(data.error[0].message);
- }
- }.bind(this),
- }).always(
- function () {
- this.setState({
- loading: false,
- });
- }.bind(this)
- );
- }
- componentDidMount() {
- this.loadData();
- // if(this.props.searchList){
- // let arr = this.props.searchList.filter(v=>v.type === 'departmentSelect')
- // let arr1 = this.props.searchList.filter(v=>v.defaultValue)
- // if(arr.length > 0){
- // this.selectSuperId();
- // }
- // if(arr1.length > 0){
- // for(let i of arr1){
- // this.state.searchValues[i.dataKey] = i.defaultValue
- // }
- // }
- // }
- }
- //刷新页面
- onRefresh(lv) {
- if (lv) {
- this.loadData();
- } else {
- this.loadData(this.state.pageNo);
- }
- }
- render() {
- return (
- <div className="patent-table">
- <Spin spinning={this.state.loading}>
- <Table
- bordered
- size="middle"
- scroll={this.props.scroll}
- columns={
- this.state.changeList.length > 0
- ? this.state.changeList
- : this.props.columns
- }
- dataSource={this.state.dataSource}
- pagination={this.state.pagination}
- />
- </Spin>
- </div>
- );
- }
- }
- export default TablePopup;
|