systemMessage.jsx 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291
  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/messageOut/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.nameSearch, //需求名称
  25. subject:1,
  26. isSend:this.state.auditStatusSearch,
  27. sendStartTime: this.state.releaseDate[0],
  28. sendEndTime: this.state.releaseDate[1],
  29. },
  30. success: function (data) {
  31. let theArr = [];
  32. if (!data.data || !data.data.list) {
  33. if (data.error && data.error.length) {
  34. message.warning(data.error[0].message);
  35. };
  36. } else {
  37. for (let i = 0; i < data.data.list.length; i++) {
  38. let thisdata = data.data.list[i];
  39. theArr.push({
  40. key: i,
  41. id: thisdata.id,
  42. title: thisdata.title,
  43. isSend:thisdata.isSend,
  44. admin:thisdata.admin?thisdata.admin:'管理员',
  45. body: thisdata.body,
  46. rowId:thisdata.resourceId,
  47. resourceType:thisdata.resourceType,
  48. resourceName:thisdata.resourceName,
  49. createTime:thisdata.createTime?(new Date(thisdata.createTime)).toLocaleString():'',
  50. releaseDate:thisdata.sendTime?(new Date(thisdata.sendTime)).toLocaleString():''
  51. });
  52. };
  53. };
  54. this.state.pagination.current = data.data.pageNo;
  55. this.state.pagination.total = data.data.totalCount;
  56. if(data.data&&data.data.list&&!data.data.list.length){
  57. this.state.pagination.current=0;
  58. this.state.pagination.total=0;
  59. };
  60. this.setState({
  61. dataSource: theArr,
  62. pagination: this.state.pagination
  63. });
  64. }.bind(this),
  65. }).always(function () {
  66. this.setState({
  67. loading: false
  68. });
  69. }.bind(this));
  70. },
  71. getInitialState() {
  72. return {
  73. searchMore: true,
  74. validityPeriodDate: [],
  75. releaseDate: [],
  76. selectedRowKeys: [],
  77. selectedRows: [],
  78. loading: false,
  79. pagination: {
  80. defaultCurrent: 1,
  81. defaultPageSize: 10,
  82. showQuickJumper: true,
  83. pageSize: 10,
  84. onChange: function (page) {
  85. this.loadData(page);
  86. }.bind(this),
  87. showTotal: function (total) {
  88. return '共' + total + '条数据';
  89. }
  90. },
  91. columns: [
  92. {
  93. title: '消息标题',
  94. dataIndex: 'title',
  95. key: 'title',
  96. render: text => { return text&&text.length>16?text.substr(0,16)+'...':text}
  97. },
  98. {
  99. title: '消息内容',
  100. dataIndex: 'body',
  101. key: 'body',
  102. render: text => { return text&&text.length>16?text.substr(0,16)+'...':text}
  103. },
  104. {
  105. title: '创建人',
  106. dataIndex: 'admin',
  107. key: 'admin'
  108. },
  109. {
  110. title: '创建时间',
  111. dataIndex: 'createTime',
  112. key: 'createTime'
  113. },
  114. {
  115. title: '推送时间',
  116. dataIndex: 'releaseDate',
  117. key: 'releaseDate'
  118. },
  119. {
  120. title: '操作',
  121. dataIndex: 'caozuo',
  122. key: 'caozuo',
  123. render:(text,recard) => {
  124. return <div className="btnRight">
  125. {!recard.isSend?<Button type="primary" style={{ background: "#3fcf9e", border: "none", color: "#fff" }} onClick={(e)=>{e.stopPropagation();this.submission(recard)}}>推送</Button>:''}
  126. {!recard.isSend?<Button type="danger" style={{ margin:10 }} onClick={(e)=>{e.stopPropagation(),this.del(recard)}}>删除</Button>:''}
  127. </div>
  128. }
  129. }
  130. ],
  131. dataSource: [],
  132. searchTime: [,]
  133. };
  134. },
  135. //发布
  136. submission(record){
  137. if(!record.rowId){
  138. message.warning('请选择具体推送内容');
  139. return;
  140. }
  141. this.setState({
  142. loading:true
  143. });
  144. $.ajax({
  145. method: "get",
  146. dataType: "json",
  147. crossDomain: false,
  148. url: globalConfig.context + "/api/admin/message/sendMessage",
  149. data: {
  150. messageId:record.id,
  151. }
  152. }).done(function (data) {
  153. if (!data.error.length) {
  154. message.success('推送成功.');
  155. this.setState({
  156. loading: false,
  157. });
  158. this.loadData(this.state.page)
  159. } else {
  160. message.warning(data.error[0].message);
  161. };
  162. }.bind(this));
  163. },
  164. componentWillMount() {
  165. this.loadData();
  166. },
  167. tableRowClick(record, index) {
  168. this.state.RowData = record;
  169. this.setState({
  170. showDesc: true
  171. });
  172. },
  173. del(recard) {
  174. this.setState({
  175. loading:true
  176. })
  177. $.ajax({
  178. method: "POST",
  179. dataType: "json",
  180. crossDomain: false,
  181. url: globalConfig.context + "/api/admin/message/updMessageById",
  182. data: {
  183. id: recard.id,
  184. title: recard.title,
  185. subject:1, //消息类别 0-系统消息
  186. isDraft:1, //是否草稿 0-否 1-是
  187. deleteSign:1, //删除标识 0-否 ,1-是
  188. isSend:0, //是否发送0-否 1-是
  189. body:recard.body
  190. }
  191. }).done(function (data) {
  192. if (!data.error.length) {
  193. message.success('删除成功!');
  194. this.setState({
  195. loading: false
  196. });
  197. if(this.state.pagination.total%10==1){
  198. this.loadData((this.state.page)-1);
  199. }else{
  200. this.loadData(this.state.page);
  201. }
  202. } else {
  203. message.warning(data.error[0].message);
  204. };
  205. }.bind(this));
  206. },
  207. addClick() {
  208. this.state.RowData = {};
  209. this.setState({
  210. showDesc: true
  211. });
  212. },
  213. closeDesc(e, s) {
  214. this.state.showDesc = e;
  215. if (s) {
  216. this.loadData(this.state.page);
  217. };
  218. },
  219. search() {
  220. this.loadData();
  221. },
  222. reset() {
  223. this.state.nameSearch = '';
  224. this.state.releaseDate = [];
  225. this.state.auditStatusSearch = undefined;
  226. this.loadData();
  227. },
  228. searchSwitch() {
  229. this.setState({
  230. searchMore: !this.state.searchMore
  231. });
  232. },
  233. render() {
  234. const rowSelection = {
  235. selectedRowKeys: this.state.selectedRowKeys,
  236. onChange: (selectedRowKeys, selectedRows) => {
  237. this.setState({
  238. selectedRows: selectedRows.slice(-1),
  239. selectedRowKeys: selectedRowKeys.slice(-1)
  240. });
  241. }
  242. };
  243. const { RangePicker } = DatePicker;
  244. const hasSelect = this.state.selectedRowKeys.length;
  245. return (
  246. <div className="user-content" >
  247. <div className="content-title">
  248. <span>APP推送消息管理</span>
  249. <div style={{float:'right'}}>
  250. <Button type="primary" onClick={this.addClick}>添加消息<Icon type="plus" /></Button>
  251. </div>
  252. </div>
  253. <div className="user-search">
  254. <Input placeholder="消息标题"
  255. value={this.state.nameSearch}
  256. onChange={(e) => { this.setState({ nameSearch: e.target.value }); }} />
  257. <Select placeholder="推送状态" style={{ width: 120 }}
  258. value={this.state.auditStatusSearch}
  259. onChange={(e) => { this.setState({ auditStatusSearch: e }) }}>
  260. <Select.Option value="0" >草稿</Select.Option>
  261. <Select.Option value="1" >已推送</Select.Option>
  262. </Select>
  263. <span>推送时间 : </span>
  264. <RangePicker
  265. style={{marginRight:10}}
  266. value={[this.state.releaseDate[0] ? moment(this.state.releaseDate[0]) : null,
  267. this.state.releaseDate[1] ? moment(this.state.releaseDate[1]) : null]}
  268. onChange={(data, dataString) => { this.setState({ releaseDate: dataString }); }} />
  269. <Button type="primary" onClick={this.search}>搜索</Button>
  270. <Button onClick={this.reset}>重置</Button>
  271. </div>
  272. <div className="patent-table systemMessageList">
  273. <Spin spinning={this.state.loading}>
  274. <Table columns={this.state.columns}
  275. dataSource={this.state.dataSource}
  276. rowSelection={rowSelection}
  277. pagination={this.state.pagination}
  278. onRowClick={this.tableRowClick} />
  279. </Spin>
  280. </div>
  281. <NewDesc
  282. data={this.state.RowData}
  283. showDesc={this.state.showDesc}
  284. closeDesc={this.closeDesc} />
  285. </div >
  286. );
  287. }
  288. });
  289. export default DemandList;