tablePopup.jsx 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152
  1. import React, { Component } from "react";
  2. import {
  3. Form,
  4. Button,
  5. DatePicker,
  6. Input,
  7. message,
  8. Select,
  9. Spin,
  10. Table,
  11. Tabs,
  12. AutoComplete,
  13. } from "antd";
  14. import { ShowModal } from "@/tools";
  15. // import { ChooseList } from "../../manageCenter/order/orderNew/chooseList";
  16. import $ from "jquery/src/ajax";
  17. // import moment from "moment";
  18. // import AutoCompleteSearch from "./autoCompleteSearch";
  19. class TablePopup extends Component {
  20. constructor(props) {
  21. super(props);
  22. this.state = {
  23. changeList: [],
  24. dataSource: [],
  25. pagination: {
  26. defaultCurrent: 1,
  27. defaultPageSize: 10,
  28. showQuickJumper: true,
  29. pageSize: 10,
  30. onChange: function (page) {
  31. this.loadData(page);
  32. }.bind(this),
  33. showTotal: function (total) {
  34. return "共" + total + "条数据";
  35. },
  36. },
  37. searchValues: this.props.searchConfig || {},
  38. contactsOption: [],
  39. departmentLoading: false,
  40. };
  41. this.loadData = this.loadData.bind(this);
  42. this.onRefresh = this.onRefresh.bind(this);
  43. }
  44. loadData(pageNo) {
  45. this.setState({
  46. loading: true,
  47. });
  48. let searchInfor = {
  49. pageNo: pageNo || 1,
  50. pageSize: this.state.pagination.pageSize,
  51. };
  52. if (this.props.query) {
  53. let obj = JSON.parse(JSON.stringify(this.props.query));
  54. searchInfor = Object.assign(searchInfor, obj);
  55. }
  56. if (Object.keys(this.state.searchValues).length > 0) {
  57. let obj1 = JSON.parse(JSON.stringify(this.state.searchValues));
  58. searchInfor = Object.assign(searchInfor, obj1);
  59. }
  60. $.ajax({
  61. method: "get",
  62. dataType: "json",
  63. crossDomain: false,
  64. url: globalConfig.context + this.props.tabelApi,
  65. data: searchInfor,
  66. success: function (data) {
  67. ShowModal(this);
  68. this.setState({
  69. loading: false,
  70. });
  71. if (data.error && data.error.length === 0) {
  72. this.props.searchOperation && this.props.searchOperation(searchInfor);
  73. if (data.data.list) {
  74. this.state.pagination.current = data.data.pageNo;
  75. this.state.pagination.total = data.data.totalCount;
  76. if (data.data && data.data.list && !data.data.list.length) {
  77. this.state.pagination.current = 0;
  78. this.state.pagination.total = 0;
  79. }
  80. this.setState({
  81. dataSource: this.props.dataProcessing
  82. ? this.props.dataProcessing(data)
  83. : data.data.list,
  84. pagination: this.state.pagination,
  85. pageNo: data.data.pageNo,
  86. });
  87. } else {
  88. this.setState({
  89. dataSource: this.props.dataProcessing
  90. ? this.props.dataProcessing(data)
  91. : data.data,
  92. pagination: false,
  93. });
  94. }
  95. } else {
  96. message.warning(data.error[0].message);
  97. }
  98. }.bind(this),
  99. }).always(
  100. function () {
  101. this.setState({
  102. loading: false,
  103. });
  104. }.bind(this)
  105. );
  106. }
  107. componentDidMount() {
  108. this.loadData();
  109. // if(this.props.searchList){
  110. // let arr = this.props.searchList.filter(v=>v.type === 'departmentSelect')
  111. // let arr1 = this.props.searchList.filter(v=>v.defaultValue)
  112. // if(arr.length > 0){
  113. // this.selectSuperId();
  114. // }
  115. // if(arr1.length > 0){
  116. // for(let i of arr1){
  117. // this.state.searchValues[i.dataKey] = i.defaultValue
  118. // }
  119. // }
  120. // }
  121. }
  122. //刷新页面
  123. onRefresh(lv) {
  124. if (lv) {
  125. this.loadData();
  126. } else {
  127. this.loadData(this.state.pageNo);
  128. }
  129. }
  130. render() {
  131. return (
  132. <div className="patent-table">
  133. <Spin spinning={this.state.loading}>
  134. <Table
  135. bordered
  136. size="middle"
  137. scroll={this.props.scroll}
  138. columns={
  139. this.state.changeList.length > 0
  140. ? this.state.changeList
  141. : this.props.columns
  142. }
  143. dataSource={this.state.dataSource}
  144. pagination={this.state.pagination}
  145. />
  146. </Spin>
  147. </div>
  148. );
  149. }
  150. }
  151. export default TablePopup;