vouchers.jsx 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289
  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 '@/account/demand/techDemand.less';
  6. import '@/administration/news/news.less';
  7. import {getCouponCome,getCouponAuthStates} from '@/tools.js';
  8. import {couponCome} from '@/dataDic.js';
  9. const DemandList = React.createClass({
  10. loadData(pageNo) {
  11. this.state.data = [];
  12. this.setState({
  13. selectedRowKeys:[],
  14. page:pageNo,
  15. loading: true
  16. });
  17. $.ajax({
  18. method: "get",
  19. dataType: "json",
  20. crossDomain: false,
  21. url: globalConfig.context + "/api/admin/voucherDetail/selectList",
  22. data: {
  23. pageNo: pageNo || 1,
  24. pageSize: this.state.pagination.pageSize,
  25. name: this.state.name, //名称
  26. source: this.state.source, //来源
  27. status: this.state.status, //状态
  28. userMobile: this.state.userMobile, //用户手机号
  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. name: thisdata.name,//名称
  43. money: thisdata.money,//面额
  44. source: thisdata.source,//来源
  45. starTime: thisdata.starTime,//领取时间
  46. endTime: thisdata.endTime,//截止时间
  47. useTime: thisdata.useTime, //使用时间
  48. status: thisdata.status,//状态
  49. userMobile: thisdata.userMobile,//使用人手机号
  50. durationDay: thisdata.durationDay,//期限
  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: 'name',
  95. key: 'name',
  96. },
  97. {
  98. title: '数量(枚)',
  99. dataIndex: 'money',
  100. key: 'money',
  101. },
  102. {
  103. title: '领用时间',
  104. dataIndex: 'starTime',
  105. key: 'starTime'
  106. },
  107. {
  108. title: '截止时间',
  109. dataIndex: 'endTime',
  110. key: 'endTime'
  111. },
  112. {
  113. title: '来源',
  114. dataIndex: 'source',
  115. key: 'source',
  116. render: text => { return getCouponCome(text); }
  117. },
  118. {
  119. title: '状态',
  120. dataIndex: 'status',
  121. key: 'status',
  122. render: text => { return getCouponAuthStates(text); }
  123. },
  124. {
  125. title: '所属用户',
  126. dataIndex: 'userMobile',
  127. key: 'userMobile'
  128. },
  129. {
  130. title: '有效期限',
  131. dataIndex: 'durationDay',
  132. key: 'durationDay'
  133. }
  134. ],
  135. dataSource: [],
  136. searchTime: [,]
  137. };
  138. },
  139. //发布
  140. submission(record){
  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:0, //消息类别 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.name = undefined;
  224. this.state.userMobile = undefined;
  225. this.state.status = undefined;
  226. this.state.source = undefined;
  227. this.loadData();
  228. },
  229. searchSwitch() {
  230. this.setState({
  231. searchMore: !this.state.searchMore
  232. });
  233. },
  234. render() {
  235. const rowSelection = {
  236. selectedRowKeys: this.state.selectedRowKeys,
  237. onChange: (selectedRowKeys, selectedRows) => {
  238. this.setState({
  239. selectedRows: selectedRows.slice(-1),
  240. selectedRowKeys: selectedRowKeys.slice(-1)
  241. });
  242. }
  243. };
  244. const { RangePicker } = DatePicker;
  245. const hasSelect = this.state.selectedRowKeys.length;
  246. return (
  247. <div className="user-content" >
  248. <div className="content-title">
  249. <span>抵用券管理</span>
  250. </div>
  251. <div className="user-search">
  252. <Input placeholder="券面名称"
  253. value={this.state.name}
  254. onChange={(e) => { this.setState({ name: e.target.value }); }} />
  255. <Input placeholder="用户手机号"
  256. value={this.state.userMobile}
  257. onChange={(e) => { this.setState({ userMobile: e.target.value }); }} />
  258. <Select placeholder="抵用券状态" style={{ width: 120 }}
  259. value={this.state.status}
  260. onChange={(e) => { this.setState({ status: e }) }}>
  261. <Select.Option value="0" >未使用</Select.Option>
  262. <Select.Option value="1" >已使用</Select.Option>
  263. <Select.Option value="2" >已过期</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. </div >
  285. );
  286. }
  287. });
  288. export default DemandList;