detail.jsx 5.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172
  1. import React, { useState, useEffect } from 'react';
  2. import { Card, Form, Button, Image, Input, message, Radio, Modal } from 'antd';
  3. import { PageHeaderWrapper } from '@ant-design/pro-layout';
  4. import { getApplicationDetail, updateAudit, getPetCardNo } from '@/services/application'
  5. import { history } from 'umi';
  6. const { TextArea } = Input;
  7. const FormItem = Form.Item;
  8. const formItemLayout = { labelCol: { span: 6 }, wrapperCol: { span: 14 } };
  9. const goBack = () => {
  10. history.goBack();
  11. };
  12. export default (props) => {
  13. const { location } = props;
  14. const { id } = location.query;
  15. const [application, setApplication] = useState({});
  16. const [rejectReason, setRejectReason] = useState();
  17. const [examineType, SetExamineType] = useState(1);
  18. const [loading, setLoading] = useState(false)
  19. const getAudit = (val) => {
  20. setLoading(true)
  21. updateAudit(id, { rejectReason: rejectReason, verifyStatus: val }).then(() => {
  22. message.success('操作成功');
  23. goBack()
  24. setLoading(false)
  25. }).catch(err => {
  26. console.log(err.message)
  27. setLoading(false)
  28. })
  29. }
  30. const handleAudit = () => {
  31. if ((examineType == 2 && rejectReason) || examineType == 1) {
  32. if (examineType == 1 && application.applyType == 'first') {
  33. getPetCardNo(application.petId).then((res) => {
  34. if (!res) {
  35. getAudit(examineType);
  36. } else {
  37. message.info('该宠物已有犬证,请拒绝犬主办证申请');
  38. }
  39. })
  40. } else {
  41. getAudit(examineType);
  42. }
  43. }
  44. else {
  45. message.success('请输入处理结果');
  46. }
  47. }
  48. //列表切换通知状态方法
  49. const handleOK = (record, data) => {
  50. const title = examineType == 1
  51. ? '您确定要通过该申请吗'
  52. : '您确定要拒绝该申请吗';
  53. Modal.confirm({
  54. title: title,
  55. okText: '确认',
  56. cancelText: '取消',
  57. onOk() {
  58. handleAudit()
  59. },
  60. });
  61. };
  62. useEffect(() => {
  63. getApplicationDetail(id).then((res) => {
  64. setApplication(res)
  65. setRejectReason(res.rejectReason)
  66. if (res.verifyStatus == 2) { SetExamineType(2) }
  67. }).catch((err) => {
  68. console.log(err.message)
  69. });
  70. }, [id])
  71. return (
  72. <PageHeaderWrapper >
  73. <Card>
  74. <Form {...formItemLayout}>
  75. <FormItem label="犬主">
  76. {application?.personName}
  77. </FormItem>
  78. <FormItem label="电话">
  79. {application?.phone}
  80. </FormItem>
  81. <FormItem label="犬名">
  82. {application?.petName}
  83. </FormItem>
  84. <FormItem label="性别">
  85. {
  86. application?.petSex == 1 ? '雄' :
  87. application?.petSex == 2 ? '雌' : '未说明性别'
  88. }
  89. </FormItem>
  90. <FormItem label="犬种">
  91. {application?.petType}
  92. </FormItem>
  93. <FormItem label="毛色">
  94. {application?.petColor}
  95. </FormItem>
  96. <FormItem label="照片">
  97. <Image src={application?.img1} width={100} />
  98. </FormItem>
  99. <FormItem label="养狗地址">
  100. {application?.address}
  101. </FormItem>
  102. <FormItem label="免疫证号">
  103. {application?.immunizationCode}
  104. </FormItem>
  105. <FormItem label="免疫证明">
  106. <Image src={application?.immunizationImg} width={100} />
  107. </FormItem>
  108. <FormItem label="最近免疫日期">
  109. {application?.immunizationDate}
  110. </FormItem>
  111. <FormItem label="申请类型">
  112. {
  113. application?.applyType == 'first' ? '办证' :
  114. application?.applyType == 'reissue' ? '补办' :
  115. application?.applyType == 'renewal' ? '续期' : ''
  116. }
  117. </FormItem>
  118. {
  119. application?.applyType !== 'renewal' &&
  120. <FormItem label="申领方式">
  121. {
  122. application?.applyMethod == '1' ? '上门自取' :
  123. application?.applyMethod == '2' ? '快递到家' : ''
  124. }
  125. </FormItem>
  126. }
  127. <FormItem label="付款状态">
  128. {
  129. application.payStatus === 0
  130. ? '待支付'
  131. : application.payStatus === 1
  132. ? '支付中'
  133. : application.payStatus === 2
  134. ? '已支付' : ''
  135. }
  136. </FormItem>
  137. <FormItem label="审核意见">
  138. <Radio.Group onChange={e =>{if(application.verifyStatus==0)SetExamineType(e.target.value)}} value={examineType}>
  139. <Radio value={1}>同意</Radio>
  140. <Radio value={2}>拒绝</Radio>
  141. </Radio.Group>
  142. </FormItem>
  143. {
  144. application.verifyStatus != 1 && examineType == 2 &&
  145. <FormItem label="驳回原因">
  146. <TextArea placeholder='请输入驳回原因' rows='3'
  147. style={{ width: '350px' }}
  148. value={rejectReason}
  149. readOnly={application.verifyStatus == 2}
  150. onChange={(e) => setRejectReason(e.target.value)}
  151. />
  152. </FormItem>
  153. }
  154. <FormItem label=" " colon={false}>
  155. {
  156. application.verifyStatus == 0 &&
  157. <Button type="primary" loading={loading} style={{ marginRight: '16px' }} onClick={handleOK}>
  158. 确定
  159. </Button>
  160. }
  161. <Button type="default" onClick={goBack}>
  162. 返回
  163. </Button>
  164. </FormItem>
  165. </Form>
  166. </Card>
  167. </PageHeaderWrapper>
  168. );
  169. };