systemMessage.jsx 9.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257
  1. import React from 'react';
  2. import { Icon, Button, Input, Select, Spin, Table, message, DatePicker } from 'antd';
  3. import $ from 'jquery/src/ajax';
  4. import moment from 'moment';
  5. import NewDesc from '@/administration/messagePush/messagePhoto/messageDesc';
  6. import '@/account/demand/techDemand.less';
  7. import '@/administration/news/news.less';
  8. const DemandList = React.createClass({
  9. loadData(pageNo) {
  10. this.state.data = [];
  11. this.setState({
  12. selectedRowKeys:[],
  13. page:pageNo,
  14. loading: true
  15. });
  16. $.ajax({
  17. method: "get",
  18. dataType: "json",
  19. crossDomain: false,
  20. url: globalConfig.context + "/api/admin/message/getMessageList",
  21. data: {
  22. pageNo: pageNo || 1,
  23. pageSize: this.state.pagination.pageSize,
  24. messageCode: this.state.nameSearch, //短信模板
  25. subject:2,
  26. sendStartTime: this.state.releaseDate[0],
  27. sendEndTime: this.state.releaseDate[1],
  28. },
  29. success: function (data) {
  30. let theArr = [];
  31. if (!data.data || !data.data.list) {
  32. if (data.error && data.error.length) {
  33. message.warning(data.error[0].message);
  34. };
  35. } else {
  36. for (let i = 0; i < data.data.list.length; i++) {
  37. let thisdata = data.data.list[i];
  38. theArr.push({
  39. key: i,
  40. id: thisdata.id,
  41. messageCode: thisdata.code,
  42. isSend:thisdata.isSend,
  43. admin:thisdata.admin?thisdata.admin:'管理员',
  44. createTime:thisdata.createTime?(new Date(thisdata.createTime)).toLocaleString():'',
  45. releaseDate:thisdata.sendTime?(new Date(thisdata.sendTime)).toLocaleString():''
  46. });
  47. };
  48. };
  49. this.state.pagination.current = data.data.pageNo;
  50. this.state.pagination.total = data.data.totalCount;
  51. if(data.data&&data.data.list&&!data.data.list.length){
  52. this.state.pagination.current=0;
  53. this.state.pagination.total=0;
  54. };
  55. this.setState({
  56. dataSource: theArr,
  57. pagination: this.state.pagination
  58. });
  59. }.bind(this),
  60. }).always(function () {
  61. this.setState({
  62. loading: false
  63. });
  64. }.bind(this));
  65. },
  66. getInitialState() {
  67. return {
  68. searchMore: true,
  69. validityPeriodDate: [],
  70. releaseDate: [],
  71. selectedRowKeys: [],
  72. selectedRows: [],
  73. loading: false,
  74. pagination: {
  75. defaultCurrent: 1,
  76. defaultPageSize: 10,
  77. showQuickJumper: true,
  78. pageSize: 10,
  79. onChange: function (page) {
  80. this.loadData(page);
  81. }.bind(this),
  82. showTotal: function (total) {
  83. return '共' + total + '条数据';
  84. }
  85. },
  86. columns: [
  87. {
  88. title: '短信模板',
  89. dataIndex: 'messageCode',
  90. key: 'messageCode',
  91. },
  92. {
  93. title: '创建人',
  94. dataIndex: 'admin',
  95. key: 'admin'
  96. },
  97. {
  98. title: '推送时间',
  99. dataIndex: 'releaseDate',
  100. key: 'releaseDate'
  101. },
  102. {
  103. title: '操作',
  104. dataIndex: 'caozuo',
  105. key: 'caozuo',
  106. render:(text,recard) => {
  107. return <div className="btnRight">
  108. {!recard.isSend?<Button type="danger" style={{ margin:10 }} onClick={(e)=>{e.stopPropagation(),this.del(recard)}}>删除</Button>:''}
  109. </div>
  110. }
  111. }
  112. ],
  113. dataSource: [],
  114. searchTime: [,]
  115. };
  116. },
  117. //发布
  118. submission(record){
  119. this.setState({
  120. loading:true
  121. });
  122. $.ajax({
  123. method: "get",
  124. dataType: "json",
  125. crossDomain: false,
  126. url: globalConfig.context + "/api/admin/message/sendMessage",
  127. data: {
  128. messageId:record.id,
  129. }
  130. }).done(function (data) {
  131. if (!data.error.length) {
  132. message.success('推送成功.');
  133. this.setState({
  134. loading: false,
  135. });
  136. this.loadData(this.state.page)
  137. } else {
  138. message.warning(data.error[0].message);
  139. };
  140. }.bind(this));
  141. },
  142. componentWillMount() {
  143. this.loadData();
  144. },
  145. del(recard) {
  146. this.setState({
  147. loading:true
  148. })
  149. $.ajax({
  150. method: "POST",
  151. dataType: "json",
  152. crossDomain: false,
  153. url: globalConfig.context + "/api/admin/message/updMessageById",
  154. data: {
  155. id: recard.id,
  156. title: recard.title,
  157. subject:2, //消息类别 0-系统消息
  158. isDraft:1, //是否草稿 0-否 1-是
  159. deleteSign:1, //删除标识 0-否 ,1-是
  160. isSend:0, //是否发送0-否 1-是
  161. body:recard.body
  162. }
  163. }).done(function (data) {
  164. if (!data.error.length) {
  165. message.success('删除成功!');
  166. this.setState({
  167. loading: false
  168. });
  169. if(this.state.pagination.total%10==1){
  170. this.loadData((this.state.page)-1);
  171. }else{
  172. this.loadData(this.state.page);
  173. }
  174. } else {
  175. message.warning(data.error[0].message);
  176. };
  177. }.bind(this));
  178. },
  179. addClick() {
  180. this.state.RowData = {};
  181. this.setState({
  182. showDesc: true
  183. });
  184. },
  185. closeDesc(e, s) {
  186. this.state.showDesc = e;
  187. if (s) {
  188. this.loadData(this.state.page);
  189. };
  190. },
  191. search() {
  192. this.loadData();
  193. },
  194. reset() {
  195. this.state.nameSearch = '';
  196. this.state.releaseDate = [];
  197. this.loadData();
  198. },
  199. searchSwitch() {
  200. this.setState({
  201. searchMore: !this.state.searchMore
  202. });
  203. },
  204. render() {
  205. const rowSelection = {
  206. selectedRowKeys: this.state.selectedRowKeys,
  207. onChange: (selectedRowKeys, selectedRows) => {
  208. this.setState({
  209. selectedRows: selectedRows.slice(-1),
  210. selectedRowKeys: selectedRowKeys.slice(-1)
  211. });
  212. }
  213. };
  214. const { RangePicker } = DatePicker;
  215. const hasSelect = this.state.selectedRowKeys.length;
  216. return (
  217. <div className="user-content" >
  218. <div className="content-title">
  219. <span>手机短信消息推送管理</span>
  220. <div style={{float:'right'}}>
  221. <Button type="primary" onClick={this.addClick}>添加消息<Icon type="plus" /></Button>
  222. </div>
  223. </div>
  224. <div className="user-search">
  225. <Input placeholder="短信模板"
  226. value={this.state.nameSearch}
  227. onChange={(e) => { this.setState({ nameSearch: e.target.value }); }} />
  228. <span>推送时间 : </span>
  229. <RangePicker
  230. style={{marginRight:10}}
  231. value={[this.state.releaseDate[0] ? moment(this.state.releaseDate[0]) : null,
  232. this.state.releaseDate[1] ? moment(this.state.releaseDate[1]) : null]}
  233. onChange={(data, dataString) => { this.setState({ releaseDate: dataString }); }} />
  234. <Button type="primary" onClick={this.search}>搜索</Button>
  235. <Button onClick={this.reset}>重置</Button>
  236. </div>
  237. <div className="patent-table">
  238. <Spin spinning={this.state.loading}>
  239. <Table columns={this.state.columns}
  240. dataSource={this.state.dataSource}
  241. rowSelection={rowSelection}
  242. pagination={this.state.pagination}
  243. />
  244. </Spin>
  245. </div>
  246. <NewDesc
  247. data={this.state.RowData}
  248. showDesc={this.state.showDesc}
  249. closeDesc={this.closeDesc} />
  250. </div >
  251. );
  252. }
  253. });
  254. export default DemandList;