payRecord.js 25 KB

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