rizhi.js 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158
  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. const status = [
  6. {
  7. value: "0",
  8. key: "发起"
  9. },
  10. {
  11. value: "1",
  12. key: "审核中"
  13. },
  14. {
  15. value: "2",
  16. key: "通过"
  17. },
  18. {
  19. value: "3",
  20. key: "驳回"
  21. }
  22. ];
  23. const getStatus = function(e) {
  24. if (e || e == 0) {
  25. let str = e.toString();
  26. let theType = "";
  27. status.map(function(item) {
  28. if (item.value == str) {
  29. theType = item.key;
  30. }
  31. });
  32. return theType;
  33. }
  34. };
  35. class Rizhi extends Component {
  36. constructor(props) {
  37. super(props);
  38. this.state = {
  39. visible: false,
  40. dataSource: [],
  41. loading: false,
  42. columns: [
  43. {
  44. title: "创建时间",
  45. dataIndex: "createTimes",
  46. key: "createTimes",
  47. width: 150
  48. },
  49. {
  50. title: "操作人名称",
  51. dataIndex: "aname",
  52. key: "aname",
  53. width: 150
  54. },
  55. {
  56. title: "状态",
  57. dataIndex: "status",
  58. key: "status",
  59. width: 150,
  60. render: text => {
  61. return getStatus(text);
  62. }
  63. },
  64. {
  65. title: "备注",
  66. dataIndex: "remarks",
  67. key: "remarks",
  68. render: text => {
  69. return <div style={{ width: 300 }}>{text}</div>;
  70. }
  71. }
  72. ]
  73. };
  74. }
  75. loadData() {
  76. this.setState({
  77. loading: true
  78. });
  79. $.ajax({
  80. method: "get",
  81. dataType: "json",
  82. crossDomain: false,
  83. url: globalConfig.context + "/api/admin/orderChange/orderChangeLogList",
  84. data: {
  85. changeId: this.props.changeId
  86. },
  87. success: function(data) {
  88. if (data.error.length || data.data.list == "") {
  89. if (data.error && data.error.length) {
  90. message.warning(data.error[0].message);
  91. }
  92. } else {
  93. this.setState({
  94. dataSource: data.data
  95. });
  96. }
  97. }.bind(this)
  98. }).always(
  99. function() {
  100. this.setState({
  101. loading: false
  102. });
  103. }.bind(this)
  104. );
  105. }
  106. changeModal() {
  107. this.setState({
  108. visible: !this.state.visible
  109. });
  110. }
  111. render() {
  112. return (
  113. <div
  114. style={{
  115. display: "inline-block",
  116. verticalAlign: "top",
  117. marginLeft: 60
  118. }}
  119. >
  120. <Button
  121. onClick={() => {
  122. this.loadData();
  123. this.changeModal();
  124. }}
  125. >
  126. 查看变更日志
  127. </Button>
  128. <Modal
  129. maskClosable={false}
  130. visible={this.state.visible}
  131. title="变更日志"
  132. footer=""
  133. width={800}
  134. onCancel={() => {
  135. this.changeModal();
  136. }}
  137. >
  138. <Spin spinning={this.state.loading}>
  139. <Table
  140. columns={this.state.columns}
  141. dataSource={this.state.dataSource}
  142. pagination={false}
  143. />
  144. </Spin>
  145. </Modal>
  146. </div>
  147. );
  148. }
  149. }
  150. export default Rizhi;