rizhi.js 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186
  1. import React, { Component } from "react";
  2. import { Modal, Table, Button, message, Spin } from "antd";
  3. import $ from "jquery/src/ajax";
  4. import "./table.less";
  5. // import ReactToPrint from "react-to-print";
  6. const status = [
  7. {
  8. value: "0",
  9. key: "发起"
  10. },
  11. {
  12. value: "1",
  13. key: "审核中"
  14. },
  15. {
  16. value: "2",
  17. key: "通过"
  18. },
  19. {
  20. value: "3",
  21. key: "驳回"
  22. }
  23. ];
  24. const getStatus = function(e) {
  25. if (e || e == 0) {
  26. let str = e.toString();
  27. let theType = "";
  28. status.map(function(item) {
  29. if (item.value == str) {
  30. theType = item.key;
  31. }
  32. });
  33. return theType;
  34. }
  35. };
  36. class Rizhi extends Component {
  37. constructor(props) {
  38. super(props);
  39. this.state = {
  40. visible: false,
  41. dataSource: [],
  42. loading: false,
  43. columns: [
  44. {
  45. title: "创建时间",
  46. dataIndex: "createTimes",
  47. key: "createTimes",
  48. width: 180
  49. },
  50. {
  51. title: "操作人名称",
  52. dataIndex: "aname",
  53. key: "aname",
  54. width: 150
  55. },
  56. {
  57. title: "状态",
  58. dataIndex: "status",
  59. key: "status",
  60. width: 150,
  61. render: text => {
  62. return getStatus(text);
  63. }
  64. },
  65. {
  66. title: "备注",
  67. dataIndex: "remarks",
  68. key: "remarks",
  69. render: text => {
  70. return <div style={{ width: 300 }}>{text}</div>;
  71. }
  72. }
  73. ]
  74. };
  75. }
  76. loadData() {
  77. this.setState({
  78. loading: true
  79. });
  80. $.ajax({
  81. method: "get",
  82. dataType: "json",
  83. crossDomain: false,
  84. url: globalConfig.context + "/api/admin/orderChange/orderChangeLogList",
  85. data: {
  86. changeId: this.props.changeId
  87. },
  88. success: function(data) {
  89. if (data.error.length || data.data.list == "") {
  90. if (data.error && data.error.length) {
  91. message.warning(data.error[0].message);
  92. }
  93. } else {
  94. this.setState({
  95. dataSource: data.data
  96. });
  97. }
  98. }.bind(this)
  99. }).always(
  100. function() {
  101. this.setState({
  102. loading: false
  103. });
  104. }.bind(this)
  105. );
  106. }
  107. changeModal() {
  108. this.setState({
  109. visible: !this.state.visible
  110. });
  111. }
  112. render() {
  113. return (
  114. <div
  115. style={{
  116. display: "inline-block",
  117. verticalAlign: "top",
  118. marginLeft: 60
  119. }}
  120. >
  121. <Button
  122. style={{ position: "relative", zIndex: 999 }}
  123. onClick={() => {
  124. this.loadData();
  125. this.changeModal();
  126. }}
  127. >
  128. 查看变更日志
  129. </Button>
  130. {/* <div>
  131. {this.state.dataSource.map((item) => <div>{item.aname}</div> )}
  132. </div> */}
  133. <Modal
  134. maskClosable={false}
  135. visible={this.state.visible}
  136. title="变更日志"
  137. footer=""
  138. width={800}
  139. onCancel={() => {
  140. this.changeModal();
  141. }}
  142. >
  143. <Spin spinning={this.state.loading}>
  144. <div
  145. ref={e => {
  146. this.refs = e;
  147. }}
  148. style={{marginTop:20}}
  149. >
  150. <h2 style={{ textAlign: "center", marginBottom: 10 }}>
  151. 合同变更日志
  152. </h2>
  153. <Table
  154. columns={this.state.columns}
  155. dataSource={this.state.dataSource}
  156. pagination={false}
  157. />
  158. </div>
  159. </Spin>
  160. {/* <ReactToPrint
  161. trigger={() => (
  162. <div className="clearfix">
  163. <Button
  164. type="primary"
  165. style={{ float: "right", marginTop: 10 }}
  166. >
  167. 打印
  168. </Button>
  169. </div>
  170. )}
  171. content={() => this.refs}
  172. /> */}
  173. </Modal>
  174. </div>
  175. );
  176. }
  177. }
  178. export default Rizhi;