|
@@ -1,29 +1,30 @@
|
|
|
import React from 'react';
|
|
|
-import { Icon, Button, Input, Select, Spin, Table, message, DatePicker ,Modal,Form} from 'antd';
|
|
|
+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/messageIn/messageDesc';
|
|
|
+import NewDesc from '@/administration/messagePush/messageOut/selectContent';
|
|
|
import '@/account/demand/techDemand.less';
|
|
|
import '@/administration/news/news.less';
|
|
|
import {getCouponCome,getCouponAuthState} from '@/tools.js';
|
|
|
-import {couponCome} from '@/dataDic.js';
|
|
|
+
|
|
|
const DemandList = React.createClass({
|
|
|
loadData(pageNo) {
|
|
|
- this.state.data = [];
|
|
|
this.setState({
|
|
|
selectedRowKeys:[],
|
|
|
page:pageNo,
|
|
|
- loading: true
|
|
|
+ loading: true,
|
|
|
+ visibleSel:false,
|
|
|
+ selData:{}
|
|
|
});
|
|
|
$.ajax({
|
|
|
method: "get",
|
|
|
dataType: "json",
|
|
|
crossDomain: false,
|
|
|
- url: globalConfig.context + "/open/api/user/voucher/selectList",
|
|
|
+ url: globalConfig.context + "/api/user/voucher/selectList",
|
|
|
data: {
|
|
|
pageNo: pageNo || 1,
|
|
|
pageSize: this.state.pagination.pageSize,
|
|
|
- name: this.state.name, //券面名称
|
|
|
+ name: this.state.nameSearch, //券面名称
|
|
|
},
|
|
|
success: function (data) {
|
|
|
let theArr = [];
|
|
@@ -68,6 +69,7 @@ const DemandList = React.createClass({
|
|
|
validityPeriodDate: [],
|
|
|
releaseDate: [],
|
|
|
visitModul:false,
|
|
|
+ data:{},
|
|
|
selectedRowKeys: [],
|
|
|
selectedRows: [],
|
|
|
loading: false,
|
|
@@ -88,12 +90,12 @@ const DemandList = React.createClass({
|
|
|
title: '劵面名称',
|
|
|
dataIndex: 'name',
|
|
|
key: 'name',
|
|
|
+ render: text => { return text&&text.length>16?text.substr(0,16)+'...':text}
|
|
|
},
|
|
|
{
|
|
|
title: '面额(元)',
|
|
|
dataIndex: 'money',
|
|
|
key: 'money',
|
|
|
- //render: text => { return text&&text.length>16?text.substr(0,16)+'...':text}
|
|
|
},
|
|
|
{
|
|
|
title: '抵用券有效期(天)',
|
|
@@ -134,7 +136,7 @@ const DemandList = React.createClass({
|
|
|
method: "post",
|
|
|
dataType: "json",
|
|
|
crossDomain: false,
|
|
|
- url: globalConfig.context + "/open/api/user/voucher/update",
|
|
|
+ url: globalConfig.context + "/api/user/voucher/update",
|
|
|
data: {
|
|
|
id:id,
|
|
|
activeState:"0"
|
|
@@ -155,65 +157,70 @@ const DemandList = React.createClass({
|
|
|
componentWillMount() {
|
|
|
this.loadData();
|
|
|
},
|
|
|
+ selContent(){
|
|
|
+ this.setState({
|
|
|
+ visibleSel:true,
|
|
|
+ selData:{
|
|
|
+ url:'/portal/service/jtProject/list',
|
|
|
+ privateProject:0,
|
|
|
+ auditStatus:2
|
|
|
+ }
|
|
|
+ })
|
|
|
+
|
|
|
+ },
|
|
|
//新增抵用券
|
|
|
newSubmit(e) {
|
|
|
e.preventDefault();
|
|
|
- if(!this.state.newName) {
|
|
|
- message.warning('请填写券面名称');
|
|
|
- return false;
|
|
|
- };
|
|
|
- if(!this.state.source) {
|
|
|
- message.warning('请确认券的来源');
|
|
|
- return false;
|
|
|
- };
|
|
|
- if(!this.state.money) {
|
|
|
- message.warning('请填写券面金额');
|
|
|
- return false;
|
|
|
- };
|
|
|
- if(!this.state.durationDay) {
|
|
|
- message.warning('请填写使用期限');
|
|
|
- return false;
|
|
|
- };
|
|
|
- $.ajax({
|
|
|
- method: "POST",
|
|
|
- dataType: "json",
|
|
|
- crossDomain: false,
|
|
|
- url: globalConfig.context + "/open/api/user/voucher/save",
|
|
|
- data: {
|
|
|
- name:this.state.newName,//抵用券名称
|
|
|
- source:this.state.source,//抵用券来源
|
|
|
- money:this.state.money,//抵用券面额
|
|
|
- durationDay:this.state.durationDay,//抵用券使用期限
|
|
|
- limitUse:0,//是否限定,在这里固定传0
|
|
|
+ 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));
|
|
|
}
|
|
|
- }).done(function (data) {
|
|
|
- if (!data.error.length) {
|
|
|
- message.success('新增成功!');
|
|
|
- this.setState({
|
|
|
- loading: false,
|
|
|
- visitModul:false
|
|
|
- });
|
|
|
-// if(this.state.pagination.total%10==1){
|
|
|
-// this.loadData((this.state.page)-1);
|
|
|
-// }else{
|
|
|
- this.loadData(this.state.page);
|
|
|
-// }
|
|
|
- } else {
|
|
|
- message.warning(data.error[0].message);
|
|
|
- };
|
|
|
- }.bind(this));
|
|
|
+ })
|
|
|
},
|
|
|
- //点击整行
|
|
|
-// tableRowClick(record, index) {
|
|
|
-// this.state.RowData = record;
|
|
|
-// this.setState({
|
|
|
-// visitModul: true
|
|
|
-// });
|
|
|
-// },
|
|
|
addClick() {
|
|
|
- this.state.RowData = {};
|
|
|
+ this.props.form.resetFields();
|
|
|
this.setState({
|
|
|
- visitModul: true
|
|
|
+ money:'',
|
|
|
+ durationDay:'',
|
|
|
+ visitModul: true,
|
|
|
+ limitProjectId:'',
|
|
|
+ objTitle:'',
|
|
|
});
|
|
|
},
|
|
|
closeDesc(e, s) {
|
|
@@ -226,20 +233,19 @@ const DemandList = React.createClass({
|
|
|
visitOk(e) {
|
|
|
this.setState({
|
|
|
visitModul: false
|
|
|
- });
|
|
|
+ });
|
|
|
},
|
|
|
//详情关闭
|
|
|
visitCancel(e) {
|
|
|
- this.state.fileList = [];
|
|
|
this.setState({
|
|
|
visitModul: false,
|
|
|
- });
|
|
|
+ });
|
|
|
},
|
|
|
search() {
|
|
|
this.loadData();
|
|
|
},
|
|
|
reset() {
|
|
|
- this.state.name = '';
|
|
|
+ this.state.nameSearch = '';
|
|
|
this.loadData();
|
|
|
},
|
|
|
searchSwitch() {
|
|
@@ -247,6 +253,20 @@ const DemandList = React.createClass({
|
|
|
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,
|
|
@@ -257,24 +277,25 @@ const DemandList = React.createClass({
|
|
|
});
|
|
|
}
|
|
|
};
|
|
|
+ const { getFieldDecorator } = this.props.form;
|
|
|
const FormItem = Form.Item;
|
|
|
- const { RangePicker } = DatePicker;
|
|
|
- const hasSelect = this.state.selectedRowKeys.length;
|
|
|
const formItemLayout = {
|
|
|
labelCol: { span: 6 },
|
|
|
- wrapperCol: { span: 14 },
|
|
|
- };
|
|
|
- const hasSelected = this.state.selectedRowKeys.length > 0;
|
|
|
+ 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>
|
|
|
+ <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.name}
|
|
|
- onChange={(e) => { this.setState({ name: e.target.value }); }} />
|
|
|
+ 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>
|
|
@@ -289,9 +310,9 @@ const DemandList = React.createClass({
|
|
|
</Spin>
|
|
|
</div>
|
|
|
<NewDesc
|
|
|
- data={this.state.RowData}
|
|
|
- showDesc={this.state.showDesc}
|
|
|
- closeDesc={this.closeDesc} />
|
|
|
+ data={this.state.selData}
|
|
|
+ visible={this.state.visibleSel}
|
|
|
+ visFun={this.visFun.bind(this)} />
|
|
|
<Modal
|
|
|
className="customeDetails"
|
|
|
footer=''
|
|
@@ -304,39 +325,40 @@ const DemandList = React.createClass({
|
|
|
<Form layout="horizontal" onSubmit={this.newSubmit} id="demand-form">
|
|
|
<Spin spinning={this.state.loading}>
|
|
|
<div className="clearfix" >
|
|
|
- <FormItem
|
|
|
- {...formItemLayout}
|
|
|
- label="劵面名称"
|
|
|
- >
|
|
|
- <Input placeholder="券面名称" value={this.state.newName} onChange={(e) => {
|
|
|
- this.setState({ newName: e.target.value }) }} />
|
|
|
- </FormItem>
|
|
|
- <FormItem
|
|
|
- {...formItemLayout}
|
|
|
- label="关联项目"
|
|
|
- >
|
|
|
-
|
|
|
- <Input placeholder="请输入关联项目关键字" value={this.state.source} style={{width:'80%'}} onChange={(e) => {
|
|
|
- this.setState({ source: e.target.value }) }} />
|
|
|
- <span>搜索</span>
|
|
|
- </FormItem>
|
|
|
- <FormItem
|
|
|
- {...formItemLayout}
|
|
|
- label="面额"
|
|
|
- >
|
|
|
- <Input placeholder="面额" style={{width:'95%'}} value={this.state.money} onChange={(e) => {
|
|
|
- this.setState({ money: e.target.value }) }} /> 元
|
|
|
- </FormItem>
|
|
|
- <FormItem
|
|
|
+ <FormItem {...formItemLayout} label="劵面名称">
|
|
|
+ {getFieldDecorator('name', {
|
|
|
+ rules: [ { required: true, message: '此项为必填项!' } ],
|
|
|
+ initialValue: theData.name
|
|
|
+ })(<Input placeholder="请输入劵面名称." maxLength={200}/>)}
|
|
|
+ </FormItem>
|
|
|
+ <FormItem
|
|
|
{...formItemLayout}
|
|
|
- label="使用期限"
|
|
|
+ label={<span><strong style={{color:'#f00'}}> * </strong>关联项目</span>}
|
|
|
>
|
|
|
- <Input placeholder="使用期限" style={{width:'95%'}} value={this.state.durationDay} onChange={(e) => {
|
|
|
- this.setState({ durationDay: e.target.value }) }} /> 天
|
|
|
+ <span>{this.state.objTitle}</span>
|
|
|
+ <Button
|
|
|
+ onClick={this.selContent.bind(this)}
|
|
|
+ type="primary"
|
|
|
+ style={{marginLeft:10}}>搜索</Button>
|
|
|
</FormItem>
|
|
|
- </div>
|
|
|
- <Button className="setSubmit" type="primary" htmlType="submit" style={{marginLeft:'150px'}}>保存</Button>
|
|
|
- <Button type="ghost" onClick={this.visitCancel} style={{marginLeft:'100px'}}>取消</Button>
|
|
|
+ <div className="clearfix">
|
|
|
+ <FormItem
|
|
|
+ {...formItemLayout}
|
|
|
+ label={<span><strong style={{color:'#f00'}}> * </strong>面额</span>}>
|
|
|
+ <div><InputNumber value={this.state.money}
|
|
|
+ onChange={(e)=>{this.setState({money:e})}} min={0} max={999999} step={0.01} 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} 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>
|
|
@@ -345,4 +367,4 @@ const DemandList = React.createClass({
|
|
|
}
|
|
|
});
|
|
|
|
|
|
-export default DemandList;
|
|
|
+export default Form.create()(DemandList);
|