rizhi.js 3.9 KB

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