rizhi.js 4.3 KB

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