rizhi.js 4.0 KB

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