applyPaymentModal.js 9.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224
  1. import React,{Component} from 'react';
  2. import {Button, Form, Input, message, Modal, Spin} from "antd";
  3. import propType from 'prop-types';
  4. import $ from "jquery";
  5. const layout = {
  6. labelCol: {
  7. span: 8,
  8. },
  9. wrapperCol: {
  10. span: 16,
  11. },
  12. };
  13. const formItemLayout = {
  14. labelCol: { span: 8 },
  15. wrapperCol: { span: 14 },
  16. };
  17. class ApplyPaymentModal extends Component{
  18. // static propTypes = {
  19. // visible: PropTypes.bool.isRequired,
  20. // changeVisible: PropTypes.func.isRequired,
  21. // }
  22. //
  23. // static defaultProps = {
  24. // visible: false,
  25. // changeVisible: ()=>{},
  26. // }
  27. constructor(props) {
  28. super(props);
  29. this.state={
  30. loading: false
  31. }
  32. }
  33. //申请付款
  34. handleSubmit(e){
  35. e.preventDefault();
  36. this.props.form.validateFieldsAndScroll((err, values) => {
  37. if (err) {
  38. return;
  39. }
  40. this.setState({
  41. loading: true
  42. })
  43. values.tid = this.props.tid;
  44. if(this.props.nodeId){ //催款
  45. values.nodeId = this.props.nodeId;
  46. values.chooseType = 1; //支付选择 0第三方 1催款
  47. }else{
  48. values.chooseType = 0 //支付选择 0第三方 1催款
  49. }
  50. values.paymentType = 0; //支付类型 0第三方 1官费(用来做判断发起区别)
  51. $.ajax({
  52. method: 'POST',
  53. dataType: 'json',
  54. crossDomain: false,
  55. url: globalConfig.context + '/api/admin/company/addOrderPayment',
  56. data: values,
  57. }).done(
  58. function (data) {
  59. this.setState({
  60. loading: false,
  61. })
  62. if (!data.error.length) {
  63. this.props.changeVisible();
  64. this.props.onRefresh();
  65. message.success('申请成功!')
  66. } else {
  67. message.warning(data.error[0].message)
  68. }
  69. }.bind(this)
  70. )
  71. })
  72. }
  73. render() {
  74. const { getFieldDecorator } = this.props.form;
  75. const { previewPayInfor } = this.props;
  76. if(!previewPayInfor){
  77. return;
  78. }
  79. return(
  80. <Modal
  81. maskClosable={false}
  82. footer={null}
  83. visible={this.props.visible}
  84. onCancel={() => {
  85. this.props.changeVisible();
  86. }}
  87. >
  88. <Spin spinning={this.state.loading}>
  89. <div>
  90. <div>支付供应商费用</div>
  91. <Form
  92. {...layout}
  93. name="basic"
  94. initialValues={{
  95. remember: true,
  96. }}
  97. onSubmit={(e)=>{
  98. this.handleSubmit(e)
  99. }}
  100. >
  101. <Form.Item
  102. {...formItemLayout}
  103. style={{
  104. display:'flex'
  105. }}
  106. label="付款单位/个人:"
  107. >
  108. {getFieldDecorator('companyName', {
  109. initialValue: previewPayInfor.companyName,
  110. rules: [{
  111. required: false,
  112. message: '请输入付款单位/个人!',
  113. }],
  114. })(
  115. <Input
  116. style={{ width: '200px' }}
  117. placeholder="请输入付款单位/个人"
  118. />
  119. )}
  120. </Form.Item>
  121. {/*<Form.Item*/}
  122. {/* {...formItemLayout}*/}
  123. {/* style={{*/}
  124. {/* display:'flex'*/}
  125. {/* }}*/}
  126. {/* label="单价(万元):"*/}
  127. {/*>*/}
  128. {/* {getFieldDecorator('unitPrice', {*/}
  129. {/* rules: [{ required: true, message: '请输入单价!' }],*/}
  130. {/* })(*/}
  131. {/* <Input style={{ width: '200px' }} placeholder="请输入单价" type={'number'}/>*/}
  132. {/* )}*/}
  133. {/*</Form.Item>*/}
  134. <Form.Item
  135. {...formItemLayout}
  136. style={{
  137. display:'flex'
  138. }}
  139. label="数量:"
  140. >
  141. {getFieldDecorator('quantity', {
  142. initialValue: parseInt(previewPayInfor.quantity),
  143. rules: [{ required: false, message: '请输入數量!' }],
  144. })(
  145. <Input disabled={previewPayInfor.quantity <= 1} style={{ width: '200px' }} placeholder="请输入數量" type={'number'}/>
  146. )}
  147. </Form.Item>
  148. {/*<Form.Item*/}
  149. {/* {...formItemLayout}*/}
  150. {/* style={{*/}
  151. {/* display:'flex'*/}
  152. {/* }}*/}
  153. {/* label="总价(万元):"*/}
  154. {/*>*/}
  155. {/* {getFieldDecorator('totalPrice', {*/}
  156. {/* rules: [{ required: false, message: '请输入总价!' }],*/}
  157. {/* })(*/}
  158. {/* <Input style={{ width: '200px' }} placeholder="请输入总价" type={'number'}/>*/}
  159. {/* )}*/}
  160. {/*</Form.Item>*/}
  161. <Form.Item
  162. {...formItemLayout}
  163. style={{
  164. display:'flex'
  165. }}
  166. label="已付(万元):"
  167. >
  168. {getFieldDecorator('totalPrice', {
  169. initialValue: parseFloat(previewPayInfor.partyAmount),
  170. rules: [{ required: false, message: '请输入已付金额!' }],
  171. })(
  172. <Input disabled={true} style={{ width: '200px' }} placeholder="请输入已付金额" type={'number'}/>
  173. )}
  174. </Form.Item>
  175. <Form.Item
  176. {...formItemLayout}
  177. style={{
  178. display:'flex'
  179. }}
  180. label="本次申请支付金额(万元):"
  181. >
  182. {getFieldDecorator('applicationAmount', {
  183. initialValue: parseFloat(previewPayInfor.totalAmount) - parseFloat(previewPayInfor.partyAmount),
  184. rules: [{ required: true, message: '请输入本次申请支付金额!' }],
  185. })(
  186. <Input style={{ width: '200px' }} placeholder="请输入本次申请支付金额" type={'number'}/>
  187. )}
  188. </Form.Item>
  189. <Form.Item
  190. {...formItemLayout}
  191. style={{
  192. display:'flex'
  193. }}
  194. label="备注:"
  195. >
  196. {getFieldDecorator('remarks', {
  197. rules: [{ required: true, message: '请输入备注!' }],
  198. })(
  199. <Input style={{ width: '200px' }} placeholder="请输入备注" type={'textarea'}/>
  200. )}
  201. </Form.Item>
  202. <Form.Item>
  203. <Button type="primary" htmlType="submit">
  204. 确定申请支付
  205. </Button>
  206. </Form.Item>
  207. </Form>
  208. </div>
  209. </Spin>
  210. </Modal>
  211. )
  212. }
  213. }
  214. const WrappedNormalLoginForm = Form.create()(ApplyPaymentModal);
  215. export default WrappedNormalLoginForm