index.jsx 3.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  1. import React from 'react';
  2. import Taro from '@tarojs/taro';
  3. import { View } from '@tarojs/components';
  4. import { Cell, CellGroup, Field, Button } from '@antmjs/vantui';
  5. import Page from '@/layouts/index';
  6. import Uploader from '@/components/Uploader/index';
  7. import { getTaIssueById } from '@/services/taissue';
  8. import { getTaOrgIssueByIssueId } from '@/services/taorgissue';
  9. import IssueInfo from '../../components/issue-info';
  10. import Apply from './components/Apply';
  11. const status = {
  12. delay: '延期申请中',
  13. reject: '驳回申请中',
  14. end: '办结申请中',
  15. }
  16. export default (props) => {
  17. const router = Taro.useRouter();
  18. const { id, act } = router.params;
  19. const [loading, setLoading] = React.useState(false);
  20. const [issue, setIssue] = React.useState();
  21. const [orgIssue, setOrgIssue] = React.useState({});
  22. const [
  23. readOnly,
  24. statusTxt,
  25. showEditBtn,
  26. ] = React.useMemo(() => {
  27. if (!orgIssue.issueId) return [];
  28. return [
  29. issue?.applyId,
  30. status[orgIssue.result],
  31. orgIssue.processStatus == 'start' && !issue?.applyId
  32. ]
  33. }, [issue, orgIssue.issueId]);
  34. const setFormData = (key, value) => {
  35. setOrgIssue({
  36. ...(orgIssue || {}),
  37. [key]: value,
  38. })
  39. }
  40. React.useEffect(() => {
  41. if (id) {
  42. setLoading(true)
  43. getTaIssueById(id).then(res => {
  44. setLoading(false);
  45. setIssue(res);
  46. }).catch(() => {
  47. setLoading(false);
  48. });
  49. getTaOrgIssueByIssueId(id).then(res => setOrgIssue(res));
  50. }
  51. }, [id]);
  52. return (
  53. <Page loading={loading}>
  54. <IssueInfo issue={issue} />
  55. <CellGroup style={{marginTop: '20px'}}>
  56. <Cell title="整改结果" />
  57. <Field
  58. type="textarea"
  59. readonly={readOnly}
  60. autosize={{ minHeight: '120px' }}
  61. value={orgIssue.result}
  62. onChange={e => setFormData('result', e.detail)}
  63. />
  64. </CellGroup>
  65. <CellGroup style={{marginTop: '20px'}}>
  66. <Cell title="拍照或视频" border={false} />
  67. <Cell
  68. renderTitle={
  69. <Uploader disabled={readOnly} value={orgIssue.attachList} onChange={e => setFormData('attachList',e)} />
  70. }
  71. />
  72. </CellGroup>
  73. {
  74. readOnly && (
  75. <CellGroup style={{marginTop: '20px'}}>
  76. <Cell title="状态" value={statusTxt} />
  77. </CellGroup>
  78. )
  79. }
  80. {
  81. !readOnly && (
  82. <View style={{marginTop: '20px', padding: 'var(--main-space)'}}>
  83. <View>
  84. {
  85. showEditBtn ?
  86. <Button block type="primary">保存修改</Button> :
  87. <Apply block type="primary" applyType="end" orgIssue={orgIssue}>申请办结</Apply>
  88. }
  89. </View>
  90. {
  91. !showEditBtn && (
  92. <View style={{marginTop: '20px'}}>
  93. <Apply block type="primary" applyType="org-verify" orgIssue={orgIssue}>申请审核</Apply>
  94. </View>
  95. )
  96. }
  97. <View style={{marginTop: '20px', display: 'flex' }}>
  98. <Apply
  99. block
  100. plain
  101. hairline
  102. type="info"
  103. applyType="delay"
  104. orgIssue={orgIssue}
  105. >申请延期</Apply>
  106. <Apply
  107. block
  108. plain
  109. hairline
  110. type="danger"
  111. applyType="reject"
  112. orgIssue={orgIssue}
  113. style={{marginLeft: 'var(--main-space)'}}
  114. >申请驳回</Apply>
  115. </View>
  116. </View>
  117. )
  118. }
  119. </Page>
  120. )
  121. }