123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. import React, { useState, useEffect } from 'react';
  2. import { Card, Form, Button, message, Input } from 'antd';
  3. import ProCard from '@ant-design/pro-card';
  4. import { getWithdrawalDetail, updateWithdrawal } from '@/services/withdrawal'
  5. import { PageHeaderWrapper } from '@ant-design/pro-layout';
  6. import { history } from 'umi';
  7. const { TextArea } = Input;
  8. const FormItem = Form.Item;
  9. const formItemLayout = { labelCol: { span: 6 }, wrapperCol: { span: 14 } };
  10. const goBack = () => {
  11. history.goBack();
  12. };
  13. export default (props) => {
  14. const { location } = props;
  15. const { id } = location.query;
  16. const [withdrawal, setWithdrawal] = useState();
  17. const [remarks, setRemarks] = useState()
  18. const [loading, setLoading] = useState(false)
  19. const handleAudit = (val) => {
  20. if (remarks) {
  21. if (val == 1 && withdrawal.amountLeft < withdrawal.money) {
  22. message.success('合作社余额小于提现余额时不能提现');
  23. return
  24. }
  25. setLoading(true)
  26. updateWithdrawal(withdrawal.withdrawalId, { ...withdrawal, auditStatus: val, auditRemark: remarks }).then(() => {
  27. message.success('操作成功');
  28. goBack()
  29. setLoading(false)
  30. }).catch(err => {
  31. console.log(err.message)
  32. setLoading(false)
  33. })
  34. }
  35. else {
  36. message.success('请输入处理结果');
  37. }
  38. }
  39. useEffect(() => {
  40. getWithdrawalDetail(id).then((res) => {
  41. setWithdrawal(res)
  42. setRemarks(res.auditRemark)
  43. }).catch((err) => {
  44. console.log(err.message)
  45. });
  46. }, [id])
  47. return (
  48. <PageHeaderWrapper
  49. extra='合作社余额小于提现余额时不能提现'
  50. >
  51. <Card>
  52. <Form {...formItemLayout}>
  53. <FormItem label="申请人">
  54. {withdrawal?.userName}
  55. </FormItem>
  56. <FormItem label="联系电话">
  57. {withdrawal?.phone}
  58. </FormItem>
  59. <FormItem label="合作社">
  60. {withdrawal?.orgName}
  61. </FormItem>
  62. <FormItem label="合作社余额">
  63. {withdrawal?.amountLeft / 100}
  64. </FormItem>
  65. <FormItem label="提现银行">
  66. {withdrawal?.bankCard.ownerBank}
  67. </FormItem>
  68. <FormItem label="提现账户">
  69. {withdrawal?.bankCard.cardNo}
  70. </FormItem>
  71. <FormItem label="申请金额">
  72. {withdrawal?.money / 100}
  73. </FormItem>
  74. <FormItem label="处理结果">
  75. {
  76. withdrawal?.auditStatus == 0 ?
  77. <TextArea placeholder='请输入处理结果(必填)' rows='3' style={{ width: '350px' }} value={remarks} onChange={(e) => setRemarks(e.target.value)} /> :
  78. remarks
  79. }
  80. </FormItem>
  81. <FormItem label=" " colon={false}>
  82. {
  83. withdrawal?.auditStatus == 0 &&
  84. <>
  85. <Button type="primary" loading={loading} style={{ marginRight: '16px' }} onClick={() => handleAudit(1)}>
  86. 同意
  87. </Button>
  88. <Button type="primary" loading={loading} style={{ marginRight: '16px' }} onClick={() => handleAudit(2)}>
  89. 拒绝
  90. </Button>
  91. </>
  92. }
  93. <Button type="default" onClick={() => goBack()}>
  94. 返回
  95. </Button>
  96. </FormItem>
  97. </Form>
  98. </Card>
  99. </PageHeaderWrapper>
  100. );
  101. };