systemMessage.jsx 9.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263
  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. title: this.state.messageCode, //短信模板
  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.messageCode,
  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. // tableRowClick(record, index) {
  146. // this.state.RowData = record;
  147. // this.setState({
  148. // showDesc: true
  149. // });
  150. // },
  151. del(recard) {
  152. this.setState({
  153. loading:true
  154. })
  155. $.ajax({
  156. method: "POST",
  157. dataType: "json",
  158. crossDomain: false,
  159. url: globalConfig.context + "/api/admin/message/updMessageById",
  160. data: {
  161. id: recard.id,
  162. title: recard.title,
  163. subject:2, //消息类别 0-系统消息
  164. isDraft:1, //是否草稿 0-否 1-是
  165. deleteSign:1, //删除标识 0-否 ,1-是
  166. isSend:0, //是否发送0-否 1-是
  167. body:recard.body
  168. }
  169. }).done(function (data) {
  170. if (!data.error.length) {
  171. message.success('删除成功!');
  172. this.setState({
  173. loading: false
  174. });
  175. if(this.state.pagination.total%10==1){
  176. this.loadData((this.state.page)-1);
  177. }else{
  178. this.loadData(this.state.page);
  179. }
  180. } else {
  181. message.warning(data.error[0].message);
  182. };
  183. }.bind(this));
  184. },
  185. addClick() {
  186. this.state.RowData = {};
  187. this.setState({
  188. showDesc: true
  189. });
  190. },
  191. closeDesc(e, s) {
  192. this.state.showDesc = e;
  193. if (s) {
  194. this.loadData(this.state.page);
  195. };
  196. },
  197. search() {
  198. this.loadData();
  199. },
  200. reset() {
  201. this.state.nameSearch = '';
  202. this.state.releaseDate = [];
  203. this.loadData();
  204. },
  205. searchSwitch() {
  206. this.setState({
  207. searchMore: !this.state.searchMore
  208. });
  209. },
  210. render() {
  211. const rowSelection = {
  212. selectedRowKeys: this.state.selectedRowKeys,
  213. onChange: (selectedRowKeys, selectedRows) => {
  214. this.setState({
  215. selectedRows: selectedRows.slice(-1),
  216. selectedRowKeys: selectedRowKeys.slice(-1)
  217. });
  218. }
  219. };
  220. const { RangePicker } = DatePicker;
  221. const hasSelect = this.state.selectedRowKeys.length;
  222. return (
  223. <div className="user-content" >
  224. <div className="content-title">
  225. <span>手机短信消息推送管理</span>
  226. <div style={{float:'right'}}>
  227. <Button type="primary" onClick={this.addClick}>添加消息<Icon type="plus" /></Button>
  228. </div>
  229. </div>
  230. <div className="user-search">
  231. <Input placeholder="短信模板"
  232. value={this.state.nameSearch}
  233. onChange={(e) => { this.setState({ nameSearch: e.target.value }); }} />
  234. <span>推送时间 : </span>
  235. <RangePicker
  236. style={{marginRight:10}}
  237. value={[this.state.releaseDate[0] ? moment(this.state.releaseDate[0]) : null,
  238. this.state.releaseDate[1] ? moment(this.state.releaseDate[1]) : null]}
  239. onChange={(data, dataString) => { this.setState({ releaseDate: dataString }); }} />
  240. <Button type="primary" onClick={this.search}>搜索</Button>
  241. <Button onClick={this.reset}>重置</Button>
  242. </div>
  243. <div className="patent-table">
  244. <Spin spinning={this.state.loading}>
  245. <Table columns={this.state.columns}
  246. dataSource={this.state.dataSource}
  247. rowSelection={rowSelection}
  248. pagination={this.state.pagination}
  249. />
  250. </Spin>
  251. </div>
  252. <NewDesc
  253. data={this.state.RowData}
  254. showDesc={this.state.showDesc}
  255. closeDesc={this.closeDesc} />
  256. </div >
  257. );
  258. }
  259. });
  260. export default DemandList;