applyPaymentModal.js 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350
  1. import React,{Component} from 'react';
  2. import {Button, Form, Input, message, Modal, Radio, Spin, InputNumber} from "antd";
  3. import $ from "jquery";
  4. const layout = {
  5. labelCol: {
  6. span: 8,
  7. },
  8. wrapperCol: {
  9. span: 16,
  10. },
  11. };
  12. const formItemLayout = {
  13. labelCol: { span: 8 },
  14. wrapperCol: { span: 14 },
  15. };
  16. class ApplyPaymentModal extends Component{
  17. constructor(props) {
  18. super(props);
  19. this.state={
  20. loading: false,
  21. paymentStatus: 0,
  22. }
  23. }
  24. //申请付款
  25. handleSubmit(e){
  26. e.preventDefault();
  27. this.props.form.validateFieldsAndScroll((err, values) => {
  28. if (err) {
  29. return;
  30. }
  31. if(values.quantity<1){
  32. message.warning('申请支付数量不能小于零');
  33. return false;
  34. }
  35. this.setState({
  36. loading: true
  37. })
  38. values.tid = this.props.tid;
  39. if(this.props.type === 2){
  40. values.chooseType = 2; //支付类型 0第三方 1催款 2官费
  41. }else{
  42. if(this.props.previewPayInfor.nodeId){ //催款
  43. values.nodeId = this.props.previewPayInfor.nodeId;
  44. values.chooseType = 1; //支付选择 0第三方 1催款 2官费
  45. values.tpcId = this.props.previewPayInfor.cid; //第三方机构id
  46. }else{
  47. values.chooseType = 0 //支付选择 0第三方 1催款 2官费
  48. values.tpcId = this.props.previewPayInfor.id; //第三方机构id
  49. }
  50. }
  51. values.companyName = values.companyName.split('-')[0];
  52. $.ajax({
  53. method: 'POST',
  54. dataType: 'json',
  55. crossDomain: false,
  56. url: globalConfig.context + '/api/admin/company/addOrderPayment',
  57. data: values,
  58. }).done(
  59. function (data) {
  60. this.setState({
  61. loading: false,
  62. })
  63. if (!data.error.length) {
  64. this.props.changeVisible();
  65. this.props.onRefresh();
  66. message.success('申请成功!')
  67. } else {
  68. message.warning(data.error[0].message)
  69. }
  70. }.bind(this)
  71. )
  72. })
  73. }
  74. render() {
  75. const { getFieldDecorator,setFieldsValue } = this.props.form;
  76. const { previewPayInfor } = this.props;
  77. if(this.props.type !== 2 && !previewPayInfor){return;}
  78. return(
  79. <Modal
  80. maskClosable={false}
  81. footer={null}
  82. visible={this.props.visible}
  83. onCancel={() => {
  84. this.props.changeVisible();
  85. }}
  86. >
  87. <Spin spinning={this.state.loading}>
  88. <div>
  89. <div>
  90. {
  91. this.props.type === 2 ? "支付供应商官费" : "支付供应商费用"
  92. }
  93. </div>
  94. <Form
  95. {...layout}
  96. name="basic"
  97. initialValues={{
  98. remember: true,
  99. }}
  100. onSubmit={(e)=>{
  101. this.handleSubmit(e)
  102. }}
  103. >
  104. <Form.Item
  105. {...formItemLayout}
  106. style={{
  107. display:'flex'
  108. }}
  109. label="付款单位/个人:"
  110. >
  111. {getFieldDecorator('companyName', {
  112. initialValue: this.props.type === 2 ? '国家知识产权局' : previewPayInfor.companyName,
  113. rules: [{
  114. required: true,
  115. message: '请输入付款单位/个人!',
  116. }],
  117. })(
  118. <Input
  119. style={{ width: '200px' }}
  120. placeholder="请输入付款单位/个人"
  121. />
  122. )}
  123. </Form.Item>
  124. {/* 0正常 1专利 2软著 3审计 */}
  125. {this.props.projectType === 1 && this.props.patentType === 1 ?<Form.Item
  126. {...formItemLayout}
  127. style={{
  128. display:'flex'
  129. }}
  130. label="支付状态:"
  131. >
  132. {getFieldDecorator('paymentStatus', {
  133. initialValue: this.state.paymentStatus,
  134. rules: [{ required: false, message: '请选择支付状态!' }],
  135. })(
  136. <Radio.Group onChange={(e)=>{
  137. this.setState({
  138. paymentStatus: e.target.value
  139. })
  140. if(e.target.value === 1){
  141. setFieldsValue({
  142. quantity:parseInt(previewPayInfor.quantity),
  143. applicationAmount:(previewPayInfor.partyAmount ?
  144. ((parseFloat(previewPayInfor.totalAmount) * 1000000) - (parseFloat(previewPayInfor.partyAmount) * 1000000)) / 1000000 :
  145. parseFloat(previewPayInfor.totalAmount))/2
  146. });
  147. } else if(e.target.value === 2){
  148. setFieldsValue({
  149. quantity:parseInt(previewPayInfor.quantity),
  150. applicationAmount:(previewPayInfor.partyAmount ?
  151. ((parseFloat(previewPayInfor.totalAmount) * 1000000) - (parseFloat(previewPayInfor.partyAmount) * 1000000)) / 1000000 :
  152. parseFloat(previewPayInfor.totalAmount))
  153. });
  154. }
  155. }}>
  156. <Radio value={0}>自定义</Radio>
  157. <Radio value={1}>半款</Radio>
  158. <Radio value={2}>全款</Radio>
  159. </Radio.Group>
  160. )}
  161. </Form.Item> : <div/>}
  162. {this.props.type !== 2 ? <Form.Item
  163. {...formItemLayout}
  164. style={{
  165. display:'flex'
  166. }}
  167. label="单价(万元):"
  168. >
  169. {/*可以查看单价 正常 审计 专利买卖
  170. 软著 专利申请 打星号 */}
  171. {
  172. isNaN(parseFloat(previewPayInfor.unitPrice)) ? previewPayInfor.unitPrice :
  173. getFieldDecorator('unitPrice', {
  174. initialValue:previewPayInfor.unitPrice,
  175. rules: [{ required: true, message: '请输入单价!' }],
  176. })(
  177. <Input disabled={true} style={{ width: '200px' }} placeholder="请输入单价" type={'number'}/>
  178. )
  179. }
  180. </Form.Item> : <div/>}
  181. {/*{*/}
  182. {/* this.props.type === 2 ?*/}
  183. {/* <Form.Item*/}
  184. {/* {...formItemLayout}*/}
  185. {/* style={{*/}
  186. {/* display:'flex'*/}
  187. {/* }}*/}
  188. {/* label="官费(万元):"*/}
  189. {/* >*/}
  190. {/* /!*costReduction 费减 0否 1 是*!/*/}
  191. {/* /!*reductionAmount 费减金额*!/*/}
  192. {/* /!*officialUnitPrice 官费单价*!/*/}
  193. {/* <div>*/}
  194. {/* {*/}
  195. {/* previewPayInfor.costReduction === 1 ?*/}
  196. {/* (isNaN(parseFloat(previewPayInfor.reductionAmount)) ? previewPayInfor.reductionAmount : parseFloat(previewPayInfor.reductionAmount)):*/}
  197. {/* (isNaN(parseFloat(previewPayInfor.officialUnitPrice)) ? previewPayInfor.officialUnitPrice : parseFloat(previewPayInfor.officialUnitPrice))*/}
  198. {/* }*/}
  199. {/* </div>*/}
  200. {/* </Form.Item> : <div/>*/}
  201. {/*}*/}
  202. <Form.Item
  203. {...formItemLayout}
  204. style={{
  205. display:'flex'
  206. }}
  207. label="数量(个):"
  208. >
  209. {this.props.type === 2 ? this.props.commodityQuantity : previewPayInfor.quantity}
  210. </Form.Item>
  211. {this.props.type !== 2 ? <Form.Item
  212. {...formItemLayout}
  213. style={{
  214. display:'flex'
  215. }}
  216. label="总价(万元):"
  217. >
  218. <div>
  219. {
  220. previewPayInfor.totalAmount
  221. }
  222. </div>
  223. </Form.Item> : null}
  224. <Form.Item
  225. {...formItemLayout}
  226. style={{
  227. display:'flex'
  228. }}
  229. label="本次申请支付数量:"
  230. >
  231. {getFieldDecorator('quantity', {
  232. initialValue: previewPayInfor.quantity,
  233. rules: [{ required: false, message: '请输入本次申请支付数量!' }],
  234. })(
  235. <InputNumber
  236. disabled={this.state.paymentStatus !== 0}
  237. style={{ width: '200px' }}
  238. precision={0}
  239. placeholder="请输入本次申请支付数量"
  240. onChange={(e)=>{
  241. if(this.props.projectType === 1 && this.props.patentType === 0){
  242. setFieldsValue({
  243. applicationAmount:e*previewPayInfor.unitPrice
  244. });
  245. }
  246. }}
  247. />
  248. )}
  249. </Form.Item>
  250. {/*0正常 1专利 2软著 3审计 只有专利里面的专利申请没有本次申请支付金额*/}
  251. {/*专利的官费申请 本次申请支付金额(万元) 不需要*/}
  252. {/*startType 1供应商 0外包*/}
  253. {/*
  254. 申请官费
  255. 本次申请支付数量 都可以修改
  256. 本次申请支付金额 都不显示
  257. 申请付款
  258. 供应商
  259. 第三方信息
  260. 本次申请支付数量 都可以修改
  261. 本次申请支付金额 专利申请类型不显示,专利买卖类型可以修改申请支付金额,其他类型也能修改
  262. 付款节点(专利申请无付款节点)
  263. 本次申请支付数量 都可以修改
  264. 本次申请支付金额 都可以修改
  265. 外包
  266. 第三方信息
  267. 本次申请支付数量 都可以修改
  268. 本次申请支付金额 专利申请不可以修改但显示(专利申请的申请金额会随支付数量乘以单价变化),其他类型可以修改
  269. 付款节点
  270. 本次申请支付数量 都可以修改
  271. 本次申请支付金额 专利申请不可以修改但显示(专利申请的申请金额会随支付数量乘以单价变化),其他类型可以修改
  272. */}
  273. {this.props.type !== 2 && !(this.props.startType === 1 ? (this.props.projectType === 1 && this.props.patentType === 0) : false) ? <Form.Item
  274. {...formItemLayout}
  275. style={{
  276. display:'flex'
  277. }}
  278. label="本次申请支付金额(万元):"
  279. >
  280. {getFieldDecorator('applicationAmount', {
  281. initialValue:this.props.type === 2 ?(
  282. ((previewPayInfor.costReduction === 1 ? previewPayInfor.reductionAmount : previewPayInfor.officialUnitPrice) * 1000000 * parseInt(previewPayInfor.quantity)) / 1000000
  283. ): (
  284. !isNaN(parseFloat(previewPayInfor.totalAmount)) && !isNaN(parseFloat(previewPayInfor.partyAmount))?
  285. (
  286. this.state.paymentStatus === 1 ?
  287. (previewPayInfor.partyAmount ?
  288. ((parseFloat(previewPayInfor.totalAmount) * 1000000) - (parseFloat(previewPayInfor.partyAmount) * 1000000)) / 1000000 :
  289. parseFloat(previewPayInfor.totalAmount)) / 2 :
  290. previewPayInfor.partyAmount ?
  291. ((parseFloat(previewPayInfor.totalAmount) * 1000000) - (parseFloat(previewPayInfor.partyAmount) * 1000000)) / 1000000 :
  292. parseFloat(previewPayInfor.totalAmount)
  293. ) : null
  294. ),
  295. rules: [{ required: true, message: '请输入本次申请支付金额!' }],
  296. })(
  297. <InputNumber
  298. min={0}
  299. disabled={this.state.paymentStatus !== 0 || (this.props.projectType === 1 && this.props.patentType === 0)}
  300. style={{ width: '200px' }}
  301. placeholder="请输入本次申请支付金额"/>
  302. )}
  303. </Form.Item> : null}
  304. <Form.Item
  305. {...formItemLayout}
  306. style={{
  307. display:'flex'
  308. }}
  309. label="备注:"
  310. >
  311. {getFieldDecorator('remarks', {
  312. rules: [{ required: true, message: '请输入备注!' }],
  313. })(
  314. <Input style={{ width: '200px' }} placeholder="请输入备注" type={'textarea'}/>
  315. )}
  316. </Form.Item>
  317. <Form.Item>
  318. <div style={{
  319. display: 'flex',
  320. justifyContent: 'center',
  321. }}>
  322. <Button type="primary" htmlType="submit" style={{width:'60%',height:'40px'}}>
  323. {this.props.type === 2 ? "确定申请付官费" : "确定申请支付"}
  324. </Button>
  325. </div>
  326. </Form.Item>
  327. </Form>
  328. </div>
  329. </Spin>
  330. </Modal>
  331. )
  332. }
  333. }
  334. const WrappedNormalLoginForm = Form.create()(ApplyPaymentModal);
  335. export default WrappedNormalLoginForm