| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375 | 
							- import React from 'react';
 
- import { Icon, Button, Input, InputNumber,Select, Spin, Table, message, DatePicker ,Modal,Form} from 'antd';
 
- import $ from 'jquery/src/ajax';
 
- import moment from 'moment';
 
- import NewDesc from '@/administration/messagePush/messageOut/selectContent';
 
- import '@/account/demand/techDemand.less';
 
- import '@/administration/news/news.less';
 
- import {getCouponCome,getCouponAuthState} from '@/tools.js';
 
- const DemandList = React.createClass({
 
-     loadData(pageNo) {
 
-         this.setState({
 
-             selectedRowKeys:[],
 
-             page:pageNo,
 
-             loading: true,
 
-             visibleSel:false,
 
-             selData:{}
 
-         });
 
-         $.ajax({
 
-             method: "get",
 
-             dataType: "json",
 
-             crossDomain: false,
 
-             url: globalConfig.context + "/api/user/voucher/selectList",
 
-             data: {
 
-                 pageNo: pageNo || 1,
 
-                 pageSize: this.state.pagination.pageSize,
 
-                 name: this.state.nameSearch, //券面名称
 
-             },
 
-             success: function (data) {
 
-                 let theArr = [];
 
-                 if (!data.data || !data.data.list) {
 
-                     if (data.error && data.error.length) {
 
-                         message.warning(data.error[0].message);
 
-                     };
 
-                 } else {
 
-                     for (let i = 0; i < data.data.list.length; i++) {
 
-                         let thisdata = data.data.list[i];
 
-                         theArr.push({
 
-                             key: i,
 
-                             id: thisdata.id,
 
-                             name: thisdata.name,//券面名称
 
-                             source:thisdata.source,//券面来源
 
-                             money:thisdata.money,//面额
 
-                             durationDay: thisdata.durationDay, //活动期限
 
-                             activeState: thisdata.activeState, //抵用券状态
 
-                         });
 
-                     };
 
-                 };
 
-                 this.state.pagination.current = data.data.pageNo;
 
-                 this.state.pagination.total = data.data.totalCount;
 
-                 if(data.data&&data.data.list&&!data.data.list.length){
 
- 					this.state.pagination.current=0;
 
- 					this.state.pagination.total=0;
 
- 				};
 
-                 this.setState({
 
-                     dataSource: theArr,
 
-                     pagination: this.state.pagination
 
-                 });
 
-             }.bind(this),
 
-         }).always(function () {
 
-             this.setState({
 
-                 loading: false
 
-             });
 
-         }.bind(this));
 
-     },
 
-     getInitialState() {
 
-         return {
 
-             searchMore: true,
 
-             validityPeriodDate: [],
 
-             releaseDate: [],
 
-             visitModul:false,
 
-             data:{},
 
-             selectedRowKeys: [],
 
-             selectedRows: [],
 
-             loading: false,
 
-             pagination: {
 
-                 defaultCurrent: 1,
 
-                 defaultPageSize: 10,
 
-                 showQuickJumper: true,
 
-                 pageSize: 10,
 
-                 onChange: function (page) {
 
-                     this.loadData(page);
 
-                 }.bind(this),
 
-                 showTotal: function (total) {
 
-                     return '共' + total + '条数据';
 
-                 }
 
-             },
 
-             columns: [
 
-                  {
 
-                     title: '劵面名称',
 
-                     dataIndex: 'name',
 
-                     key: 'name',
 
-                     render: text => { return text&&text.length>16?text.substr(0,16)+'...':text}
 
-                 },
 
-                 {
 
-                     title: '面额(元)',
 
-                     dataIndex: 'money',
 
-                     key: 'money',
 
-                 },
 
-                 {
 
-                     title: '抵用券有效期(天)',
 
-                     dataIndex: 'durationDay',
 
-                     key: 'durationDay'
 
-                 },
 
-                 {
 
-                     title: '抵用券来源',
 
-                     dataIndex: 'source',
 
-                     key: 'source',
 
-                     render: text => { return getCouponCome(text); }
 
-                 },
 
-                 {
 
-                     title: '抵用券状态',
 
-                     dataIndex: 'activeState',
 
-                     key: 'activeState',
 
-                     render: text => { return getCouponAuthState(text); }
 
-                 }
 
-             ],
 
-             dataSource: [],
 
-             searchTime: [,]
 
-         };
 
-     },
 
-     
 
-     //抵用券停用
 
-     block(){
 
-     	let id;
 
- 		for(let idx = 0; idx < this.state.selectedRows.length; idx++) {
 
- 			let rowItem = this.state.selectedRows[idx];
 
- 			if(rowItem.id) {
 
- 				id=rowItem.id;
 
- 			};
 
- 		};
 
-         this.setState({
 
-             loading:true
 
-         });
 
-         $.ajax({
 
-             method: "post",
 
-             dataType: "json",
 
-             crossDomain: false,
 
-             url: globalConfig.context + "/api/user/voucher/update",
 
-             data: {
 
-                 id:id,
 
-                 activeState:"0"
 
-             }
 
-         }).done(function (data) {
 
-             if (!data.error.length) {
 
-                 message.success('该劵已停用');
 
-                 this.loadData(this.state.page)
 
-             } else {
 
-                 message.warning(data.error[0].message);
 
-             };
 
-             this.setState({
 
-                 loading: false,
 
-             });
 
-         }.bind(this));
 
-     },
 
-     //进入页面
 
-     componentWillMount() {
 
-         this.loadData();
 
-     },
 
-     selContent(){
 
- 		this.setState({
 
-             visibleSel:true,
 
-             selData:{
 
-                 url:'/portal/service/jtProject/list',
 
-                 privateProject:0,
 
-                 auditStatus:2
 
-             }
 
-         })
 
-         
 
- 	},
 
-    //新增抵用券
 
-     newSubmit(e) {
 
-         e.preventDefault();
 
-         this.props.form.validateFields((err, values) => {
 
-             if(!err){
 
-                 if(!this.state.objTitle){
 
-                     message.warning('请选择关联项目!');
 
-                     return;
 
-                 }
 
-                 if(!this.state.money){
 
-                     message.warning('请输入金额!');
 
-                     return;
 
-                 }
 
-                 if(!this.state.durationDay){
 
-                     message.warning('请输入使用期限!');
 
-                     return;
 
-                 }
 
-                 $.ajax({
 
-                     method: "POST",
 
-                     dataType: "json",
 
-                     crossDomain: false,
 
-                     url: globalConfig.context + "/api/user/voucher/save",
 
-                     data: {
 
-                         name:values.name,//抵用券名称
 
-                         source:4,//抵用券来源
 
-                         money:this.state.money,//抵用券面额
 
-                         durationDay:this.state.durationDay,//抵用券使用期限
 
-                         limitUse:1,//是否限定,在这里固定传0
 
-                         limitProjectId:this.state.objData.id
 
-                     }
 
-                 }).done(function (data) {
 
-                     if (!data.error.length) {
 
-                         message.success('新增成功!');
 
-                         this.setState({
 
-                             loading: false,
 
-                             visitModul:false
 
-                         });
 
-                             this.loadData(this.state.page);
 
-                     } else {
 
-                         message.warning(data.error[0].message);
 
-                     };
 
-                 }.bind(this));
 
-             }
 
-         })
 
-     },
 
-     addClick() {
 
-         this.props.form.resetFields();
 
-         this.setState({
 
-             money:'',
 
-             durationDay:'',
 
-             visitModul: true,
 
-             limitProjectId:'',
 
-             objTitle:'',
 
-         });
 
-     },
 
-     closeDesc(e, s) {
 
-         this.state.showDesc = e;
 
-         if (s) {
 
-             this.loadData(this.state.page);
 
-         };
 
-     },
 
-     //详情打开
 
- 	visitOk(e) {
 
- 		this.setState({
 
- 			visitModul: false
 
-         });
 
- 	},
 
- 	//详情关闭
 
- 	visitCancel(e) {
 
- 		this.setState({
 
- 			visitModul: false,
 
-         });
 
- 	},
 
-     search() {
 
-         this.loadData();
 
-     },
 
-     reset() {
 
-         this.state.nameSearch = '';
 
-         this.loadData();
 
-     },
 
-     searchSwitch() {
 
-         this.setState({
 
-             searchMore: !this.state.searchMore
 
-         });
 
-     },
 
-     //搜索渲染值
 
-     visFun(state,data){
 
- 		if(state){
 
- 			this.setState({
 
- 				visibleSel:false,
 
- 				objData:data,
 
- 				objTitle:data.name
 
- 			});
 
- 		}else{
 
- 			this.setState({
 
- 				visibleSel:false,
 
- 			})
 
- 		}
 
- 	},
 
-     render() {
 
-         const rowSelection = {
 
-             selectedRowKeys: this.state.selectedRowKeys,
 
-             onChange: (selectedRowKeys, selectedRows) => {
 
-                 this.setState({
 
-                     selectedRows: selectedRows.slice(-1),
 
-                     selectedRowKeys: selectedRowKeys.slice(-1)
 
-                 });
 
-             }
 
-         };
 
-         const { getFieldDecorator } = this.props.form;
 
-         const FormItem = Form.Item;
 
-         const formItemLayout = {
 
- 			labelCol: { span: 6 },
 
- 			wrapperCol: { span: 12 },
 
-         };
 
-         let theData = this.state.data||{};
 
-         const hasSelected = this.state.selectedRowKeys.length > 0;
 
-         return (
 
-             <div className="user-content" >
 
-                 <div className="content-title">
 
-                     <span>券面管理</span>
 
-                 </div>
 
-                 <div className="user-search">
 
-               	  	<Button type="primary" onClick={this.addClick} style={{float:'right'}}>新增抵用劵<Icon type="plus" /></Button>
 
-                     <Input placeholder="劵面名称"
 
-                         value={this.state.nameSearch}
 
-                         onChange={(e) => { this.setState({ nameSearch: e.target.value }); }} />
 
-                     <Button type="primary" onClick={this.search}>搜索</Button>
 
-                     <Button onClick={this.reset}>重置</Button>
 
-                     <Button type="primary" onClick={this.block} disabled={!hasSelected}>停用<Icon type="plus" /></Button>
 
-                 </div>
 
-                 <div className="patent-table">
 
-                     <Spin spinning={this.state.loading}>
 
-                         <Table columns={this.state.columns}
 
-                             dataSource={this.state.dataSource}
 
-                             rowSelection={rowSelection}
 
-                             pagination={this.state.pagination}
 
-                             onRowClick={this.tableRowClick} />
 
-                     </Spin>
 
-                 </div>
 
-                 <NewDesc
 
-                     data={this.state.selData}
 
-                     visible={this.state.visibleSel}
 
- 				    visFun={this.visFun.bind(this)} />
 
-                 <Modal	
 
- 				      className="customeDetails"
 
- 				      footer=''
 
- 			          title="新增抵用券"
 
- 			          width='600px'
 
- 			          visible={this.state.visitModul}
 
- 			          onOk={this.visitOk}
 
- 					  onCancel={this.visitCancel}							          							          
 
- 			        >	
 
- 			    	<Form layout="horizontal" onSubmit={this.newSubmit} id="demand-form">
 
- 	                	<Spin spinning={this.state.loading}>
 
- 	                		<div className="clearfix" >
 
-                                 <FormItem {...formItemLayout} label="劵面名称">
 
-                                     {getFieldDecorator('name', {
 
-                                         rules: [ { required: true, message: '此项为必填项!' } ],
 
-                                         initialValue: theData.name
 
-                                     })(<Input placeholder="请输入劵面名称." maxLength={200}/>)}
 
-                                 </FormItem>
 
- 		                    	<FormItem 
 
- 				                     {...formItemLayout}
 
- 				                     label={<span><strong style={{color:'#f00'}}> * </strong>关联项目</span>}
 
- 			                        >
 
-                                     <span>{this.state.objTitle}</span>
 
- 			                        <Button 
 
- 									    onClick={this.selContent.bind(this)} 
 
-                                         type="primary" 
 
-                                         style={{marginLeft:10}}>搜索</Button>
 
- 		                    	 </FormItem>
 
-                                  <div className="clearfix">
 
-                                     <FormItem 
 
-                                         {...formItemLayout}
 
-                                         label={<span><strong style={{color:'#f00'}}> * </strong>面额</span>}>
 
-                                         <div><InputNumber value={this.state.money} 
 
-                                         formatter={(value)=>value}
 
-                                         parser={(val)=>parseInt(val)||0}
 
-                                         onChange={(e)=>{this.setState({money:e})}} min={0} max={999999} step={0
 
-                                         } placeholder="输入面额."/><span> 元</span></div>
 
-                                     </FormItem>
 
-                                     <FormItem 
 
-                                         {...formItemLayout}
 
-                                         label={<span><strong style={{color:'#f00'}}> * </strong>使用期限</span>}>
 
-                                         <div><InputNumber value={this.state.durationDay}
 
-                                             onChange={(e)=>{this.setState({durationDay:e})}}   
 
-                                             min={0} max={9999} step={0} 
 
-                                             formatter={(value)=>value}
 
-                                             parser={(val)=>parseInt(val)||0}
 
-                                             placeholder="输入天数"/><span> 天</span></div>
 
-                                     </FormItem>
 
-                                 </div>
 
- 	                    	</div>
 
-                             <Button className="setSubmit" type="primary" htmlType="submit" style={{marginLeft:140,marginBottom:20}}>保存</Button>  
 
-                             <Button  type="ghost" onClick={this.visitCancel}  style={{marginLeft:50}}>取消</Button>
 
- 	                	</Spin>
 
- 					</Form>	
 
- 			    </Modal>
 
-             </div>
 
-         );
 
-     }
 
- });
 
- export default  Form.create()(DemandList);
 
 
  |