payRecord.js 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589
  1. //initialUnitPrice 即是单价也可是官费
  2. import React,{Component} from 'react';
  3. import {Button, DatePicker, Form, Input, message, Modal, Spin} from "antd";
  4. import $ from "jquery/src/ajax";
  5. import moment from "moment";
  6. const layout = {
  7. labelCol: {
  8. span: 8,
  9. },
  10. wrapperCol: {
  11. span: 16,
  12. },
  13. };
  14. const formItemLayout = {
  15. labelCol: { span: 8 },
  16. wrapperCol: { span: 14 },
  17. };
  18. const confirm = Modal.confirm;
  19. class PayRecord extends Component{
  20. constructor(props) {
  21. super(props);
  22. this.state={
  23. loading: false,
  24. paymentLogs: [],
  25. paymentDetails: {},
  26. financialPaymentList: [],
  27. }
  28. this.examineOperation = this.examineOperation.bind(this);
  29. this.noExamineOperation = this.noExamineOperation.bind(this);
  30. this.handleSubmit = this.handleSubmit.bind(this);
  31. }
  32. componentDidMount() {
  33. this.getSelectPaymentLog(); //付款日志
  34. this.getPaymentDetails(); //支付详情
  35. this.getSelectfinancialPayment(); //财务付款列表
  36. }
  37. //付款日志
  38. getSelectPaymentLog(){
  39. this.setState({
  40. loading: true
  41. });
  42. $.ajax({
  43. type: 'get',
  44. cache: false,
  45. url: globalConfig.context + "/api/admin/company/selectPaymentLog",
  46. dataType: "json",
  47. data: {
  48. id: this.props.payId
  49. },
  50. success: function (data) {
  51. this.setState({
  52. loading: false
  53. });
  54. if (!data.data) {
  55. if (data.error && data.error.length) {
  56. message.warning(data.error[0].message);
  57. };
  58. } else {
  59. this.setState({
  60. paymentLogs: data.data
  61. })
  62. };
  63. }.bind(this),
  64. }).always(function () {
  65. this.setState({
  66. loading: false
  67. });
  68. }.bind(this));
  69. }
  70. //支付详情
  71. getPaymentDetails(){
  72. this.setState({
  73. loading: true
  74. });
  75. $.ajax({
  76. type: 'get',
  77. cache: false,
  78. url: globalConfig.context + "/api/admin/company/OrderPaymentDetails",
  79. dataType: "json",
  80. data: {
  81. id: this.props.payId
  82. },
  83. success: function (data) {
  84. this.setState({
  85. loading: false
  86. });
  87. if (!data.data) {
  88. if (data.error && data.error.length) {
  89. message.warning(data.error[0].message);
  90. };
  91. } else {
  92. this.setState({
  93. paymentDetails: data.data
  94. })
  95. };
  96. }.bind(this),
  97. }).always(function () {
  98. this.setState({
  99. loading: false
  100. });
  101. }.bind(this));
  102. }
  103. //财务付款列表
  104. getSelectfinancialPayment(){
  105. this.setState({
  106. loading: true
  107. });
  108. $.ajax({
  109. type: 'get',
  110. cache: false,
  111. url: globalConfig.context + "/api/admin/company/selectfinancialPayment",
  112. dataType: "json",
  113. data: {
  114. id: this.props.payId
  115. },
  116. success: function (data) {
  117. this.setState({
  118. loading: false
  119. });
  120. if (!data.data) {
  121. if (data.error && data.error.length) {
  122. message.warning(data.error[0].message);
  123. };
  124. } else {
  125. this.setState({
  126. financialPaymentList: data.data
  127. })
  128. };
  129. }.bind(this),
  130. }).always(function () {
  131. this.setState({
  132. loading: false
  133. });
  134. }.bind(this));
  135. }
  136. handleSubmit(e,status = 0){
  137. //0审核 1待支付 2驳回 3已支付 4取消(0重新发起,1通过审核,2驳回)
  138. e.preventDefault();
  139. this.props.form.validateFieldsAndScroll((err, values) => {
  140. if (err) {
  141. console.log(err)
  142. return;
  143. }
  144. const { paymentDetails } = this.state;
  145. this.setState({
  146. loading: true
  147. })
  148. let data = {
  149. id: this.props.payId,
  150. paymentAmount: paymentDetails.paymentAmount,
  151. // paymentStatus: paymentDetails.paymentStatus, //支付状态 0半款 1全款
  152. status: status,//0 发起 1通过 2驳回(0重新发起,1通过审核,2驳回)
  153. }
  154. Object.assign(data,values)
  155. $.ajax({
  156. type: 'post',
  157. url: globalConfig.context + "/api/admin/company/updateOrderPayment",
  158. dataType: "json",
  159. data: data,
  160. }).done((res) => {
  161. if (res.error && res.error.length) {
  162. message.error(res.error[0].message);
  163. } else {
  164. message.success(
  165. status === 0 ? "重新申请成功" :
  166. status === 1 ? "通过审核操作成功" :
  167. status === 2 ? "驳回操作成功" :
  168. status === 3 ? "支付操作成功" :
  169. status === 4 ? "取消操作成功" :''
  170. );
  171. this.props.changeVisible();
  172. }
  173. }).always(() => {
  174. this.setState({
  175. loading: false
  176. })
  177. });
  178. })
  179. }
  180. //新增财务付款
  181. addfinancialPayment(e,index) {
  182. e.preventDefault();
  183. let financialPaymentList = this.state.financialPaymentList.concat();
  184. if(!financialPaymentList[index].partyAmount){
  185. message.error('请填写正确的付款金额 ');
  186. return;
  187. }
  188. if(!financialPaymentList[index].paymentTimes){
  189. message.error('请选择时间 ');
  190. return;
  191. }
  192. let time = moment(financialPaymentList[index].paymentTimes).format('YYYY-MM-DD HH:mm:ss');
  193. this.setState({
  194. loading: true
  195. })
  196. let data = {
  197. pid: this.props.payId,
  198. partyAmount: financialPaymentList[index]['partyAmount'],
  199. paymentTimes: time,
  200. }
  201. $.ajax({
  202. type: 'post',
  203. url: globalConfig.context + "/api/admin/company/addfinancialPayment",
  204. dataType: "json",
  205. data: data,
  206. }).done((res) => {
  207. if (res.error && res.error.length) {
  208. message.error(res.error[0].message);
  209. } else {
  210. message.success("新增成功");
  211. let arr = this.state.financialPaymentList.concat();
  212. arr[index].isSave= true;
  213. arr[index].id= res.data;
  214. this.setState({
  215. financialPaymentList: arr
  216. });
  217. // this.getSelectfinancialPayment();
  218. }
  219. }).always(() => {
  220. this.setState({
  221. loading: false
  222. })
  223. });
  224. }
  225. //删除财务付款
  226. deleteFinancialPayment(e,index){
  227. e.preventDefault();
  228. if(!this.state.financialPaymentList[index]['id']){
  229. let arr = this.state.financialPaymentList.concat();
  230. arr.splice(index,1);
  231. this.setState({
  232. financialPaymentList: arr
  233. });
  234. return;
  235. }
  236. this.setState({
  237. loading: true
  238. })
  239. $.ajax({
  240. type: 'post',
  241. url: globalConfig.context + "/api/admin/company/deleteFinancialPayment",
  242. dataType: "json",
  243. data: {
  244. id: this.state.financialPaymentList[index]['id']
  245. },
  246. }).done((res) => {
  247. if (res.error && res.error.length) {
  248. message.error(res.error[0].message);
  249. } else {
  250. let arr = this.state.financialPaymentList.concat();
  251. arr.splice(index,1);
  252. this.setState({
  253. financialPaymentList: arr
  254. });
  255. message.success("删除成功");
  256. }
  257. }).always(() => {
  258. this.setState({
  259. loading: false
  260. })
  261. });
  262. }
  263. //0审核 1驳回 2待支付 3已支付 4取消
  264. noExamineOperation(){
  265. return (
  266. this.state.paymentDetails.status === 2 ? <Form.Item>
  267. <Button type="primary" htmlType="submit">
  268. 重新发起申请
  269. </Button>
  270. <Button type="danger" style={{float:'right'}} onClick={(e)=>{
  271. let _this = this;
  272. confirm({
  273. title: '删除提醒?',
  274. content: '您确定要删除它吗?',
  275. onOk() {
  276. _this.handleSubmit(e,4);
  277. },
  278. onCancel() {},
  279. });
  280. }}>
  281. 删除
  282. </Button>
  283. </Form.Item> : <div/>
  284. )
  285. }
  286. examineOperation() {
  287. const { getFieldDecorator } = this.props.form;
  288. return (
  289. this.state.paymentDetails.status === 0 ? <Form.Item>
  290. {getFieldDecorator('auditNotes', {
  291. rules: [{ required: true, message: '请输入备注!' }],
  292. })(
  293. <Input style={{ width: '200px' }} placeholder="请输入备注" type={'textarea'}/>
  294. )}
  295. <Button type="primary" style={{marginLeft:'15px'}} onClick={(e)=>{
  296. this.handleSubmit(e,2);
  297. }}>
  298. 驳回
  299. </Button>
  300. <Button type="primary" style={{marginLeft:'15px'}} onClick={(e)=>{
  301. this.handleSubmit(e,1);
  302. }}>
  303. 通过
  304. </Button>
  305. </Form.Item> : this.state.paymentDetails.status === 1 ?
  306. this.state.financialPaymentList.map((value,index)=>(
  307. <div key={index} style={{display:'flex',flexFlow:'row nowrap',alignItems:'center',paddingTop:'15px'}}>
  308. <Form.Item label="付款时间:" style={{marginBottom:'0px !important',display:'flex',flexFlow:'row nowrap',alignItems:'center'}}>
  309. <DatePicker
  310. showTime
  311. disabled={value.isSave || value.id}
  312. format="YYYY-MM-DD HH:mm:ss"
  313. style={{ width: '200px' }}
  314. placeholder="请选择付款时间"
  315. value={value.paymentTimes && moment(value.paymentTimes, 'YYYY-MM-DD HH:mm:ss')}
  316. defaultValue={value.paymentTimes && moment(value.paymentTimes, 'YYYY-MM-DD HH:mm:ss')}
  317. onChange={(value)=>{
  318. let arr = this.state.financialPaymentList.concat();
  319. arr[index].paymentTimes = value;
  320. this.setState({
  321. financialPaymentList:arr
  322. })
  323. }}
  324. />
  325. </Form.Item>
  326. <Form.Item label="付款金额(万元):" style={{paddingLeft:'20px',marginBottom:'0px !important',display:'flex',flexFlow:'row nowrap',alignItems:'center'}}>
  327. <Input
  328. disabled={value.isSave || value.id}
  329. style={{ width: '100px' }}
  330. placeholder="请输入付款金额"
  331. type={'number'}
  332. value={value.partyAmount && value.partyAmount}
  333. defaultValue={value.partyAmount && value.partyAmount}
  334. onChange={(e)=>{
  335. let arr = this.state.financialPaymentList.concat();
  336. arr[index].partyAmount = e.target.value;
  337. this.setState({
  338. financialPaymentList:arr
  339. })
  340. }}
  341. />
  342. </Form.Item>
  343. {value.id ? false : !value.isSave ? <Button style={{marginLeft:'20px',}} type="primary" onClick={(e)=>{
  344. this.addfinancialPayment(e,index)
  345. }}>
  346. 保存
  347. </Button> : <div/>}
  348. <Button type="primary" style={{marginLeft:'20px',}} onClick={(e)=>{
  349. this.deleteFinancialPayment(e,index);
  350. }}>
  351. 删除
  352. </Button>
  353. </div>
  354. )) : <div/>
  355. )
  356. }
  357. render() {
  358. const { getFieldDecorator } = this.props.form;
  359. const { paymentLogs,paymentDetails,financialPaymentList } = this.state;
  360. return(
  361. <Modal
  362. className='payRecordComponent'
  363. width={700}
  364. maskClosable={false}
  365. footer={null}
  366. visible={this.props.visible}
  367. onCancel={() => {
  368. this.props.changeVisible();
  369. }}
  370. >
  371. <Spin spinning={this.state.loading}>
  372. <div>
  373. {/*0第三方 1催款 2官费*/}
  374. <div>{paymentDetails.chooseType === 2 ? '申请支付官费' : '申请支付外包费用'}</div>
  375. <Form
  376. {...layout}
  377. name="basic"
  378. initialValues={{
  379. remember: true,
  380. }}
  381. onSubmit={(e)=>{
  382. this.handleSubmit(e)
  383. }}
  384. >
  385. <Form.Item
  386. {...formItemLayout}
  387. className='formItemStyle'
  388. label="付款单位/个人:"
  389. >
  390. <div>{paymentDetails.companyName}</div>
  391. </Form.Item>
  392. {/*0第三方 1催款 2官费*/}
  393. <Form.Item
  394. {...formItemLayout}
  395. className='formItemStyle'
  396. label={'单价(万元):'}
  397. >
  398. <div>
  399. {/* projectType 0正常 1专利 2软著 3审计*/}
  400. {/* isAuditPayment 是否为财务*/}
  401. {/* chooseType 0第三方 1催款 2官费*/}
  402. {/*{*/}
  403. {/* (paymentDetails.chooseType === 2 || this.props.projectType === 2 || (this.props.projectType === 3 && this.props.patentType === 0) ) && !this.props.isAuditPayment?*/}
  404. {/* '***':*/}
  405. {/* paymentDetails.initialUnitPrice*/}
  406. {/*}*/}
  407. {paymentDetails.initialUnitPrice}
  408. </div>
  409. </Form.Item>
  410. <Form.Item
  411. {...formItemLayout}
  412. className='formItemStyle'
  413. label="数量:"
  414. >
  415. {getFieldDecorator('initialQuantity', {
  416. initialValue: parseInt(paymentDetails.initialQuantity),
  417. rules: [{ required: false, message: '请输入數量!' }],
  418. })(
  419. <Input disabled={true} style={{ width: '200px' }} placeholder="请输入數量" type={'number'}/>
  420. )}
  421. </Form.Item>
  422. <Form.Item
  423. {...formItemLayout}
  424. className='formItemStyle'
  425. label="总价(万元):"
  426. >
  427. <div>{paymentDetails.initialTotalAmount}</div>
  428. </Form.Item>
  429. {/*官费不显示已付*/}
  430. {paymentDetails.chooseType !== 2 ? <Form.Item
  431. {...formItemLayout}
  432. className='formItemStyle'
  433. label="已付(万元):"
  434. >
  435. <div>{paymentDetails.initialPaymentAmount}</div>
  436. </Form.Item> : <div/>}
  437. {/*0第三方 1催款 2官费*/}
  438. {/* projectType 0正常 1专利 2软著 3审计*/}
  439. {
  440. paymentDetails.chooseType === 2 || this.props.projectType === 1 || this.props.projectType === 2 ?
  441. <Form.Item
  442. {...formItemLayout}
  443. className='formItemStyle'
  444. label="本次申请支付数量:"
  445. >
  446. {getFieldDecorator('quantity', {
  447. initialValue: paymentDetails.quantity,
  448. rules: [{ required: true, message: '请输入本次申请支付数量!' }],
  449. })(
  450. <Input
  451. type={'number'}
  452. style={{ width: '200px' }}
  453. disabled={ this.props.isAuditPayment ? this.state.paymentDetails.status !== 0 : this.state.paymentDetails.status !== 2}
  454. placeholder="请输入本次申请支付数量"/>
  455. )}
  456. </Form.Item> : <div/>
  457. }
  458. <Form.Item
  459. {...formItemLayout}
  460. className='formItemStyle'
  461. label="本次申请支付金额(万元):"
  462. >
  463. {getFieldDecorator('applicationAmount', {
  464. initialValue: paymentDetails.applicationAmount,
  465. rules: [
  466. {
  467. required: !(this.props.isAuditPayment ? this.state.paymentDetails.status !== 0 : this.state.paymentDetails.status !== 2),
  468. message: '请输入本次申请支付金额!'
  469. }
  470. ],
  471. })(
  472. <Input
  473. type={'number'}
  474. style={{ width: '200px' }}
  475. disabled={ this.props.isAuditPayment ? this.state.paymentDetails.status !== 0 : this.state.paymentDetails.status !== 2}
  476. placeholder="请输入本次申请支付金额"/>
  477. )}
  478. </Form.Item>
  479. <Form.Item
  480. {...formItemLayout}
  481. className='formItemStyle'
  482. label="备注:"
  483. >
  484. {
  485. (!this.props.isAuditPayment && this.state.paymentDetails.status === 2) ?
  486. getFieldDecorator('remarks', {
  487. initialValue: paymentDetails.remarks,
  488. rules: [{ required: true, message: '请输入备注!' }],
  489. })(
  490. <Input style={{ width: '200px' }} placeholder="请输入备注" type={'textarea'}/>
  491. ) : <div>{paymentDetails.remarks}</div>
  492. }
  493. </Form.Item>
  494. <div className='payStateList'>
  495. <div className='listTitle' style={{color:'#F00'}}>
  496. 支付状态:
  497. <span style={{paddingLeft:'20px'}}>
  498. {
  499. //0审核 1待支付 2驳回 3已支付 4取消
  500. paymentDetails.status === 0 ? '待'+paymentDetails.financeName+'审核' :
  501. paymentDetails.status === 1 ? '待'+paymentDetails.financeName+'支付' :
  502. paymentDetails.status === 2 ? '待重新提交' :
  503. paymentDetails.status === 3 ? '已完成支付' : '已取消'
  504. }
  505. </span>
  506. </div>
  507. <div className='payList'>
  508. {
  509. paymentLogs.map((value,key)=>(
  510. <div key={key} style={{
  511. paddingBottom: '2px',
  512. }}>
  513. <span style={{paddingRight:'8px'}}>{value.aname+':'}</span>
  514. {value.createTimes}
  515. <span style={{
  516. paddingLeft:'8px',
  517. wordBreak: 'break-all'
  518. }}>
  519. {
  520. value.status === 0 ? '(发起)' :
  521. value.status === 1 ? '(通过)': '(驳回)'
  522. }
  523. {value.remarks}
  524. </span>
  525. </div>
  526. ))
  527. }
  528. </div>
  529. </div>
  530. {paymentDetails.status === 1 || paymentDetails.status === 3 || paymentDetails.status === 4 ?<div style={{ borderTop: '1px #000 dashed'}}>
  531. <div className='listTitle' style={{display:'block',fontSize:'15px'}}>
  532. 上传付费凭证-财务
  533. <span style={{fontSize:'10px',paddingLeft:'10px'}}>实际付款(万元): {paymentDetails.paymentAmount}</span>
  534. {paymentDetails.status === 1 && this.props.isAuditPayment ?
  535. <Button style={{marginLeft:'20px'}} type="primary" onClick={()=>{
  536. let arr = this.state.financialPaymentList.concat();
  537. arr.push({});
  538. this.setState({
  539. financialPaymentList: arr
  540. })
  541. }}>
  542. 增加付款凭证
  543. </Button> : <div/>
  544. }
  545. </div>
  546. {!(paymentDetails.status === 1 && this.props.isAuditPayment) ? <div className='payList'>
  547. {
  548. financialPaymentList.map((value,key)=>(
  549. <div key={key} className='payitem'>
  550. 付款时间: {value.paymentTimes}
  551. <span style={{paddingLeft:'25px'}}>付款金额(万元): {value.partyAmount}</span>
  552. </div>
  553. ))
  554. }
  555. </div> : <div/>}
  556. </div> : <div/>}
  557. {
  558. this.props.isAuditPayment ? this.examineOperation() : this.noExamineOperation()
  559. }
  560. {this.props.isAuditPayment && paymentDetails.status === 1 ? <Button style={{marginLeft:'20px'}} type="primary" onClick={(e)=>{
  561. this.handleSubmit(e,3);
  562. }}>
  563. 完成支付
  564. </Button> : <div/>}
  565. </Form>
  566. </div>
  567. </Spin>
  568. </Modal>
  569. )
  570. }
  571. }
  572. const WrappedNormalLoginForm = Form.create()(PayRecord);
  573. export default WrappedNormalLoginForm