index.jsx 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224
  1. import React from 'react';
  2. import { Spin, Button, Tabs, Table, message } from 'antd';
  3. import ajax from 'jquery/src/ajax/xhr.js'
  4. import $ from 'jquery/src/ajax';
  5. import './index.less';
  6. const TabPane = Tabs.TabPane;
  7. const MessageModal = React.createClass({
  8. getInitialState() {
  9. return {
  10. visible: false,
  11. loading: false,
  12. pagination: {
  13. defaultCurrent: 1,
  14. defaultPageSize: 10,
  15. showQuickJumper: true,
  16. pageSize: 10,
  17. onChange: function (page) {
  18. this.loadReaded(page);
  19. }.bind(this),
  20. showTotal: function (total) {
  21. return '共' + total + '条数据';
  22. }
  23. },
  24. UnreadPagination: {
  25. defaultCurrent: 1,
  26. defaultPageSize: 10,
  27. showQuickJumper: true,
  28. pageSize: 10,
  29. onChange: function (page) {
  30. this.loadUnread(page);
  31. }.bind(this),
  32. showTotal: function (total) {
  33. return '共' + total + '条数据';
  34. }
  35. },
  36. columns: [
  37. {
  38. title: '编号',
  39. dataIndex: 'key',
  40. key: 'key'
  41. }, {
  42. title: '类型',
  43. dataIndex: 'noticeType',
  44. key: 'noticeType',
  45. render: (text, record) => {
  46. return(<span>{record.noticeTypeName}</span>)
  47. }
  48. }, {
  49. title: '时间',
  50. dataIndex: 'createTimeFormattedDate',
  51. key: 'createTimeFormattedDate'
  52. }, {
  53. title: '内容',
  54. dataIndex: 'content',
  55. key: 'content',
  56. }, {
  57. title: '公司',
  58. dataIndex: 'unitName',
  59. key: 'unitName',
  60. }, {
  61. title: '业务员',
  62. dataIndex: 'principle',
  63. key: 'principle',
  64. }
  65. ],
  66. data: []
  67. };
  68. },
  69. loadReaded(pageNo) {
  70. this.state.data = [];
  71. this.setState({
  72. loading: true
  73. });
  74. $.ajax({
  75. method: "get",
  76. dataType: "json",
  77. crossDomain: false,
  78. url: globalConfig.context + "/api/admin/notice/readed1",
  79. data: {
  80. pageNo: pageNo || 1,
  81. pageSize: this.state.pagination.pageSize,
  82. }
  83. }).done((data) => {
  84. if (!data.data) {
  85. if (data.error && data.error.length) {
  86. message.warning(data.error[0].message);
  87. return;
  88. };
  89. };
  90. this.state.data = [];
  91. for (let i = 0; i < data.data.list.length; i++) {
  92. let thisdata = data.data.list[i];
  93. this.state.data.push({
  94. key: i + 1,
  95. id: thisdata.id,
  96. rid: thisdata.rid,
  97. uid: thisdata.uid,
  98. aid: thisdata.aid,
  99. noticeType: thisdata.noticeType,
  100. year: thisdata.year,
  101. noticeTypeName: thisdata.noticeTypeName,
  102. content: thisdata.content,
  103. createTime: thisdata.createTime,
  104. createTimeFormattedDate: thisdata.createTimeFormattedDate,
  105. principle: thisdata.principle,
  106. unitName: thisdata.unitName
  107. });
  108. };
  109. this.state.pagination.current = data.data.pageNo;
  110. this.state.pagination.total = data.data.totalCount;
  111. this.setState({
  112. dataSource: this.state.data,
  113. pagination: this.state.pagination
  114. });
  115. }).always(function () {
  116. this.setState({
  117. loading: false
  118. });
  119. }.bind(this));
  120. },
  121. loadUnread(pageNo) {
  122. this.state.data = [];
  123. this.setState({
  124. loading: true
  125. });
  126. $.ajax({
  127. method: "get",
  128. dataType: "json",
  129. crossDomain: false,
  130. url: globalConfig.context + "/api/admin/notice/unread2",
  131. data: {
  132. pageNo: pageNo || 1,
  133. pageSize: this.state.UnreadPagination.pageSize,
  134. }
  135. }).done((data) => {
  136. if (!data.data) {
  137. if (data.error && data.error.length) {
  138. message.warning(data.error[0].message);
  139. return;
  140. };
  141. };
  142. this.state.data = [];
  143. for (let i = 0; i < data.data.list.length; i++) {
  144. let thisdata = data.data.list[i];
  145. this.state.data.push({
  146. key: i + 1,
  147. id: thisdata.id,
  148. rid: thisdata.rid,
  149. uid: thisdata.uid,
  150. aid: thisdata.aid,
  151. noticeType: thisdata.noticeType,
  152. year: thisdata.year,
  153. noticeTypeName: thisdata.noticeTypeName,
  154. content: thisdata.content,
  155. createTime: thisdata.createTime,
  156. createTimeFormattedDate: thisdata.createTimeFormattedDate,
  157. principle: thisdata.principle,
  158. unitName: thisdata.unitName
  159. });
  160. };
  161. this.state.UnreadPagination.current = data.data.pageNo;
  162. this.state.UnreadPagination.total = data.data.totalCount;
  163. this.setState({
  164. unreadData: this.state.data,
  165. UnreadPagination: this.state.UnreadPagination
  166. });
  167. }).always(function () {
  168. this.setState({
  169. loading: false
  170. });
  171. }.bind(this));
  172. },
  173. componentWillMount() {
  174. // this.loadReaded();
  175. // this.loadUnread();
  176. },
  177. render() {
  178. return (
  179. <div className="set-content">
  180. <div className="set-title">
  181. <span>消息中心</span>
  182. </div>
  183. <Spin spinning={this.state.loading} className='spin-box'>
  184. <Tabs defaultActiveKey="1">
  185. <Tabs.TabPane tab="新信息" key="1">
  186. <Table columns={this.state.columns}
  187. dataSource={this.state.unreadData}
  188. pagination={this.state.UnreadPagination} />
  189. </Tabs.TabPane>
  190. <Tabs.TabPane tab="已读信息" key="2">
  191. <Table columns={this.state.columns}
  192. dataSource={this.state.dataSource}
  193. pagination={this.state.pagination} />
  194. </Tabs.TabPane>
  195. </Tabs>
  196. </Spin>
  197. </div>
  198. );
  199. }
  200. });
  201. const Index = React.createClass({
  202. getInitialState() {
  203. return {
  204. loading: false
  205. };
  206. },
  207. render() {
  208. return (
  209. <div className="manage-content">
  210. <div>
  211. <Spin spinning={this.state.loading} className='spin-box'>
  212. <div className="index-content">
  213. <MessageModal />
  214. </div>
  215. </Spin>
  216. </div>
  217. </div>
  218. )
  219. }
  220. });
  221. export default Index;