rizhi.js 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159
  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. console.log(this.props.changeId);
  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. <Table
  141. columns={this.state.columns}
  142. dataSource={this.state.dataSource}
  143. pagination={false}
  144. />
  145. </Spin>
  146. </Modal>
  147. </div>
  148. );
  149. }
  150. }
  151. export default Rizhi;