coupon.jsx 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293
  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/messageIn/messageDesc';
  6. import '@/account/demand/techDemand.less';
  7. import '@/administration/news/news.less';
  8. import {getCouponCome,getCouponAuthStates} from '@/tools.js';
  9. import {couponCome} from '@/dataDic.js';
  10. const DemandList = React.createClass({
  11. loadData(pageNo) {
  12. this.state.data = [];
  13. this.setState({
  14. selectedRowKeys:[],
  15. page:pageNo,
  16. loading: true
  17. });
  18. $.ajax({
  19. method: "get",
  20. dataType: "json",
  21. crossDomain: false,
  22. url: globalConfig.context + "/open/api/admin/voucherDetail/selectList",
  23. data: {
  24. pageNo: pageNo || 1,
  25. pageSize: this.state.pagination.pageSize,
  26. name: this.state.name, //名称
  27. source: this.state.source, //来源
  28. status: this.state.status, //状态
  29. userMobile: this.state.userMobile, //用户手机号
  30. },
  31. success: function (data) {
  32. let theArr = [];
  33. if (!data.data || !data.data.list) {
  34. if (data.error && data.error.length) {
  35. message.warning(data.error[0].message);
  36. };
  37. } else {
  38. for (let i = 0; i < data.data.list.length; i++) {
  39. let thisdata = data.data.list[i];
  40. theArr.push({
  41. key: i,
  42. id: thisdata.id,
  43. name: thisdata.name,//名称
  44. money: thisdata.money,//面额
  45. source: thisdata.source,//来源
  46. starTime: thisdata.starTime,//领取时间
  47. endTime: thisdata.endTime,//截止时间
  48. useTime: thisdata.useTime, //使用时间
  49. status: thisdata.status,//状态
  50. userMobile: thisdata.userMobile,//使用人手机号
  51. durationDay: thisdata.durationDay,//期限
  52. });
  53. };
  54. };
  55. this.state.pagination.current = data.data.pageNo;
  56. this.state.pagination.total = data.data.totalCount;
  57. if(data.data&&data.data.list&&!data.data.list.length){
  58. this.state.pagination.current=0;
  59. this.state.pagination.total=0;
  60. };
  61. this.setState({
  62. dataSource: theArr,
  63. pagination: this.state.pagination
  64. });
  65. }.bind(this),
  66. }).always(function () {
  67. this.setState({
  68. loading: false
  69. });
  70. }.bind(this));
  71. },
  72. getInitialState() {
  73. return {
  74. searchMore: true,
  75. validityPeriodDate: [],
  76. releaseDate: [],
  77. selectedRowKeys: [],
  78. selectedRows: [],
  79. loading: false,
  80. pagination: {
  81. defaultCurrent: 1,
  82. defaultPageSize: 10,
  83. showQuickJumper: true,
  84. pageSize: 10,
  85. onChange: function (page) {
  86. this.loadData(page);
  87. }.bind(this),
  88. showTotal: function (total) {
  89. return '共' + total + '条数据';
  90. }
  91. },
  92. columns: [
  93. {
  94. title: '劵面名称',
  95. dataIndex: 'name',
  96. key: 'name',
  97. },
  98. {
  99. title: '面额',
  100. dataIndex: 'money',
  101. key: 'money',
  102. },
  103. {
  104. title: '领用时间',
  105. dataIndex: 'starTime',
  106. key: 'starTime'
  107. },
  108. {
  109. title: '截止时间',
  110. dataIndex: 'endTime',
  111. key: 'endTime'
  112. },
  113. {
  114. title: '来源',
  115. dataIndex: 'source',
  116. key: 'source',
  117. render: text => { return getCouponCome(text); }
  118. },
  119. {
  120. title: '状态',
  121. dataIndex: 'status',
  122. key: 'status',
  123. render: text => { return getCouponAuthStates(text); }
  124. },
  125. {
  126. title: '所属用户',
  127. dataIndex: 'userMobile',
  128. key: 'userMobile'
  129. },
  130. {
  131. title: '有效期限',
  132. dataIndex: 'durationDay',
  133. key: 'durationDay'
  134. }
  135. ],
  136. dataSource: [],
  137. searchTime: [,]
  138. };
  139. },
  140. //发布
  141. submission(record){
  142. this.setState({
  143. loading:true
  144. });
  145. $.ajax({
  146. method: "get",
  147. dataType: "json",
  148. crossDomain: false,
  149. url: globalConfig.context + "/api/admin/message/sendMessage",
  150. data: {
  151. messageId:record.id,
  152. }
  153. }).done(function (data) {
  154. if (!data.error.length) {
  155. message.success('推送成功.');
  156. this.setState({
  157. loading: false,
  158. });
  159. this.loadData(this.state.page)
  160. } else {
  161. message.warning(data.error[0].message);
  162. };
  163. }.bind(this));
  164. },
  165. componentWillMount() {
  166. this.loadData();
  167. },
  168. tableRowClick(record, index) {
  169. this.state.RowData = record;
  170. this.setState({
  171. showDesc: true
  172. });
  173. },
  174. del(recard) {
  175. this.setState({
  176. loading:true
  177. })
  178. $.ajax({
  179. method: "POST",
  180. dataType: "json",
  181. crossDomain: false,
  182. url: globalConfig.context + "/api/admin/message/updMessageById",
  183. data: {
  184. id: recard.id,
  185. title: recard.title,
  186. subject:0, //消息类别 0-系统消息
  187. isDraft:1, //是否草稿 0-否 1-是
  188. deleteSign:1, //删除标识 0-否 ,1-是
  189. isSend:0, //是否发送0-否 1-是
  190. body:recard.body
  191. }
  192. }).done(function (data) {
  193. if (!data.error.length) {
  194. message.success('删除成功!');
  195. this.setState({
  196. loading: false
  197. });
  198. if(this.state.pagination.total%10==1){
  199. this.loadData((this.state.page)-1);
  200. }else{
  201. this.loadData(this.state.page);
  202. }
  203. } else {
  204. message.warning(data.error[0].message);
  205. };
  206. }.bind(this));
  207. },
  208. addClick() {
  209. this.state.RowData = {};
  210. this.setState({
  211. showDesc: true
  212. });
  213. },
  214. closeDesc(e, s) {
  215. this.state.showDesc = e;
  216. if (s) {
  217. this.loadData(this.state.page);
  218. };
  219. },
  220. search() {
  221. this.loadData();
  222. },
  223. reset() {
  224. this.state.name = undefined;
  225. this.state.userMobile = undefined;
  226. this.state.status = undefined;
  227. this.state.source = undefined;
  228. this.loadData();
  229. },
  230. searchSwitch() {
  231. this.setState({
  232. searchMore: !this.state.searchMore
  233. });
  234. },
  235. render() {
  236. const rowSelection = {
  237. selectedRowKeys: this.state.selectedRowKeys,
  238. onChange: (selectedRowKeys, selectedRows) => {
  239. this.setState({
  240. selectedRows: selectedRows.slice(-1),
  241. selectedRowKeys: selectedRowKeys.slice(-1)
  242. });
  243. }
  244. };
  245. const { RangePicker } = DatePicker;
  246. const hasSelect = this.state.selectedRowKeys.length;
  247. return (
  248. <div className="user-content" >
  249. <div className="content-title">
  250. <span>抵用券管理</span>
  251. </div>
  252. <div className="user-search">
  253. <Input placeholder="券面名称"
  254. value={this.state.name}
  255. onChange={(e) => { this.setState({ name: e.target.value }); }} />
  256. <Input placeholder="用户手机号"
  257. value={this.state.userMobile}
  258. onChange={(e) => { this.setState({ userMobile: e.target.value }); }} />
  259. <Select placeholder="抵用券状态" style={{ width: 120 }}
  260. value={this.state.status}
  261. onChange={(e) => { this.setState({ status: e }) }}>
  262. <Select.Option value="0" >未使用</Select.Option>
  263. <Select.Option value="1" >已使用</Select.Option>
  264. </Select>
  265. <Select placeholder="抵用券来源" value={this.state.source} style={{ width: 120 }}
  266. onChange={(e)=>{this.setState({source:e})}}>
  267. {
  268. couponCome.map(function (item) {
  269. return <Select.Option key={item.value} >{item.key}</Select.Option>
  270. })
  271. }
  272. </Select>
  273. <Button type="primary" onClick={this.search}>搜索</Button>
  274. <Button onClick={this.reset}>重置</Button>
  275. </div>
  276. <div className="patent-table">
  277. <Spin spinning={this.state.loading}>
  278. <Table columns={this.state.columns}
  279. dataSource={this.state.dataSource}
  280. rowSelection={rowSelection}
  281. pagination={this.state.pagination}/>
  282. </Spin>
  283. </div>
  284. <NewDesc
  285. data={this.state.RowData}
  286. showDesc={this.state.showDesc}
  287. closeDesc={this.closeDesc} />
  288. </div >
  289. );
  290. }
  291. });
  292. export default DemandList;