rizhi.js 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182
  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. onClick={() => {
  123. this.loadData();
  124. this.changeModal();
  125. }}
  126. >
  127. 查看变更日志
  128. </Button>
  129. <Modal
  130. maskClosable={false}
  131. visible={this.state.visible}
  132. title="变更日志"
  133. footer=""
  134. width={800}
  135. onCancel={() => {
  136. this.changeModal();
  137. }}
  138. >
  139. <Spin spinning={this.state.loading}>
  140. <div
  141. ref={e => {
  142. this.refs = e;
  143. }}
  144. style={{marginTop:20}}
  145. >
  146. <h2 style={{ textAlign: "center", marginBottom: 10 }}>
  147. 合同变更日志
  148. </h2>
  149. <Table
  150. columns={this.state.columns}
  151. dataSource={this.state.dataSource}
  152. pagination={false}
  153. />
  154. </div>
  155. </Spin>
  156. <ReactToPrint
  157. trigger={() => (
  158. <div className="clearfix">
  159. <Button
  160. type="primary"
  161. style={{ float: "right", marginTop: 10 }}
  162. >
  163. 打印
  164. </Button>
  165. </div>
  166. )}
  167. content={() => this.refs}
  168. />
  169. </Modal>
  170. </div>
  171. );
  172. }
  173. }
  174. export default Rizhi;