receivable.jsx 9.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196
  1. import React from 'react';
  2. import $ from 'jquery/src/ajax';
  3. import { Form, Button, Input, Select, Spin,InputNumber, message, Modal ,DatePicker} from 'antd';
  4. import {transactionChannel} from '@/dataDic.js';
  5. import moment from 'moment';
  6. const Receivable=React.createClass({
  7. getInitialState() {
  8. return {
  9. loading: false,
  10. visible:false,
  11. showDesc:false,
  12. data:{}
  13. };
  14. },
  15. //保存
  16. handleSubmit(e){
  17. e.preventDefault();
  18. if(this.state.settlementAmount === ''){
  19. message.warning('请填写金额');
  20. return false;
  21. }
  22. if(!this.state.transactionChannel){
  23. message.warning('请选择交易外联');
  24. return false;
  25. }
  26. if(!this.state.contractNo){
  27. message.warning('请填写合同编号');
  28. return false;
  29. }
  30. if(!this.state.financialPayTimes){
  31. message.warning('请选择财务流水时间');
  32. return false;
  33. }
  34. this.setState({
  35. loading: true
  36. });
  37. let data = this.props.data || {};
  38. $.ajax({
  39. method: "post",
  40. dataType: "json",
  41. async:true,
  42. url: globalConfig.context + this.props.api,
  43. data: {
  44. orderNo: data.orderNo,
  45. payeeId:data.companyId,
  46. payerId:data.buyerId,
  47. contractNo:this.state.contractNo,
  48. transactionAmount: this.state.settlementAmount,
  49. transactionSubject: ~((this.props.title).indexOf('退款'))?'2':'0',
  50. transactionChannel: this.state.transactionChannel,
  51. financialPayNo:this.state.financialPayNo,
  52. financialPayTimes:this.state.financialPayTimes,
  53. remarks:this.state.remarks
  54. }
  55. }).done(function (data) {
  56. this.setState({
  57. loading: false
  58. });
  59. if (!data.error.length) {
  60. message.success('操作成功!');
  61. this.onShow();
  62. } else {
  63. message.warning(data.error[0].message);
  64. }
  65. }.bind(this));
  66. },
  67. onCancel(){
  68. this.setState({
  69. visible:false
  70. })
  71. this.props.closeDesc(false,false);
  72. },
  73. onShow() {
  74. this.setState({
  75. visible: false,
  76. });
  77. this.props.closeDesc(false, true);
  78. },
  79. componentWillMount() {
  80. this.setState({
  81. transactionProject:undefined,
  82. settlementAmount:undefined,
  83. transactionChannel:undefined,
  84. financialPayNo:'',
  85. financialPayTimes:undefined,
  86. remarks:''
  87. })
  88. },
  89. componentWillReceiveProps(nextProps) {
  90. this.state.visible=nextProps.showDesc;
  91. this.setState({
  92. transactionProject:undefined,
  93. settlementAmount:undefined,
  94. transactionChannel:'2',
  95. financialPayNo:'',
  96. financialPayTimes:undefined,
  97. remarks:'',
  98. contractNo:nextProps.data.contractNo
  99. })
  100. },
  101. render() {
  102. const theData = this.props.data || {};
  103. const FormItem = Form.Item;
  104. const formItemLayout = {
  105. labelCol: { span: 8 },
  106. wrapperCol: { span: 12 },
  107. };
  108. return (
  109. <div className="user-content" >
  110. <Modal maskClosable={false} visible={this.state.visible}
  111. onOk={this.onShow} onCancel={this.onCancel}
  112. width='800px'
  113. title={this.props.title}
  114. footer=''
  115. className="admin-desc-content">
  116. <Form layout="horizontal" onSubmit={this.handleSubmit} >
  117. <Spin spinning={this.state.loading}>
  118. <div className="clearfix">
  119. <FormItem className="half-item" {...formItemLayout} label="付款方">
  120. <span>{theData.buyerName}</span>
  121. </FormItem>
  122. <FormItem className="half-item" {...formItemLayout} label="收款方">
  123. <span>{theData.companyName}</span>
  124. </FormItem>
  125. <FormItem className="half-item" {...formItemLayout} label={<span><strong style={{color:'#f00'}}>*</strong>金额</span>}>
  126. <InputNumber min={0} max={9999} placeholder="金额"
  127. value={this.state.settlementAmount}
  128. onChange={(e)=>{this.setState({settlementAmount:e})}}
  129. />
  130. <span style={{ marginLeft: '5px' }}>万元</span>
  131. </FormItem>
  132. <FormItem className="half-item" {...formItemLayout} label="流水科目">
  133. <span>{~((this.props.title).indexOf('退款'))?'退款':'代收'}</span>
  134. </FormItem>
  135. <FormItem className="half-item" {...formItemLayout} label={<span><strong style={{color:'#f00'}}>*</strong>交易外联</span>}>
  136. <Select placeholder="交易外联"
  137. value={this.state.transactionChannel}
  138. onChange={(e)=>{this.setState({transactionChannel:e})}}
  139. >
  140. {
  141. transactionChannel.map(function (item) {
  142. return <Select.Option value={item.value} key={item.key}>{item.key}</Select.Option>
  143. })
  144. }
  145. </Select>
  146. </FormItem>
  147. <FormItem className="half-item" {...formItemLayout} label="订单编号">
  148. <span>{theData.orderNo}</span>
  149. </FormItem>
  150. {/* !theData.contractNo? */}
  151. {true?<FormItem className="half-item" {...formItemLayout} label={<span><strong style={{color:'#f00'}}>*</strong>合同编号</span>} >
  152. <Input placeholder="合同编号"
  153. value={this.state.contractNo}
  154. onChange={(e) => { this.setState({ contractNo: e.target.value }); }} />
  155. </FormItem>:<FormItem className="half-item" {...formItemLayout} label="合同编号" >
  156. <span>{theData.contractNo}</span>
  157. </FormItem>}
  158. <FormItem className="half-item" {...formItemLayout} label="财务流水编号">
  159. <Input placeholder="财务流水编号"
  160. value={this.state.financialPayNo}
  161. onChange={(e) => { this.setState({ financialPayNo: e.target.value }); }} />
  162. </FormItem>
  163. <FormItem className="half-item" {...formItemLayout} label={<span><strong style={{color:'#f00'}}>*</strong>财务流水时间</span>}>
  164. <DatePicker
  165. showTime
  166. format="YYYY-MM-DD"
  167. onOk={(e)=>{console.log(e)}}
  168. value={this.state.financialPayTimes ? moment(this.state.financialPayTimes) : null}
  169. onChange={(data, dataString) => { this.setState({ financialPayTimes: dataString }); }} />
  170. </FormItem>
  171. <FormItem labelCol={{ span: 4 }} wrapperCol={{ span: 16 }} label="备注">
  172. <Input
  173. type="textarea"
  174. rows={4}
  175. placeholder="请输入备注"
  176. value={this.state.remarks}
  177. onChange={(e) => {
  178. this.setState({ remarks: e.target.value });
  179. }}
  180. />
  181. </FormItem>
  182. <FormItem wrapperCol={{ span: 12, offset:4 }}>
  183. <Button type="primary" htmlType="submit" style={{marginRight:30}}>确认</Button>
  184. <Button type="default" onClick={()=>{this.onCancel()}}>取消</Button>
  185. </FormItem>
  186. </div>
  187. </Spin>
  188. </Form>
  189. </Modal>
  190. </div>
  191. );
  192. }
  193. });
  194. export default Form.create()(Receivable);