|
@@ -2,12 +2,14 @@ import React from 'react';
|
2
|
2
|
import Taro from '@tarojs/taro';
|
3
|
3
|
import { View } from '@tarojs/components';
|
4
|
4
|
import Page from '@/layouts/index';
|
5
|
|
-import { Cell, CellGroup, Field, Button, Radio, RadioGroup } from '@antmjs/vantui';
|
|
5
|
+import { Cell, CellGroup, Field, Button, Radio, RadioGroup, Dialog } from '@antmjs/vantui';
|
6
|
6
|
import Uploader from '@/components/Uploader/index';
|
7
|
7
|
import { putTaIssueApply, getTaIssueApplyById } from '@/services/taissueapply';
|
8
|
8
|
import { warn } from '@/utils/message';
|
9
|
9
|
import { APPLY_PASS, APPLY_REJECT, PROCESS_APPLY_DELAY, PROCESS_APPLY_REJECT } from '@/utils/biz';
|
10
|
10
|
import { getTaOrgIssueByIssueId } from '@/services/taorgissue';
|
|
11
|
+import { copyTaIssue, getTaIssueById } from '@/services/taissue';
|
|
12
|
+import { getSysOrgById } from '@/services/sysorg';
|
11
|
13
|
import Issue from '../components/Issue';
|
12
|
14
|
import useTitle from '../useTitle';
|
13
|
15
|
|
|
@@ -20,10 +22,14 @@ export default (props) => {
|
20
|
22
|
const [loading, setLoading] = React.useState(false);
|
21
|
23
|
const [applyInfo, setApplyInfo] = React.useState({});
|
22
|
24
|
const [orgIssue, setOrgIssue] = React.useState({});
|
23
|
|
-
|
|
25
|
+
|
24
|
26
|
const [submitting, setSubmitting] = React.useState(false);
|
25
|
27
|
const [formData, setFormData] = React.useState({});
|
26
|
|
-
|
|
28
|
+
|
|
29
|
+ const dialogId = React.useMemo(() => `dialog-${Math.random().toString(36).substring(2, 7)}`, []);
|
|
30
|
+ const [loading2, setLoading2] = React.useState(false);
|
|
31
|
+ const [issue, setIssue] = React.useState();
|
|
32
|
+
|
27
|
33
|
useTitle(applyType);
|
28
|
34
|
|
29
|
35
|
const setFieldValue = (key, value) => {
|
|
@@ -32,13 +38,13 @@ export default (props) => {
|
32
|
38
|
[key]: value,
|
33
|
39
|
})
|
34
|
40
|
}
|
35
|
|
-
|
|
41
|
+
|
36
|
42
|
const onSubmit = () => {
|
37
|
43
|
try {
|
38
|
44
|
warn(!formData.verifyStatus, '请选择审批结果');
|
39
|
45
|
warn(!formData.verifyDesc && formData.verifyStatus == 'reject', '请填写审批说明');
|
40
|
46
|
} catch (e) {
|
41
|
|
- return ;
|
|
47
|
+ return;
|
42
|
48
|
}
|
43
|
49
|
|
44
|
50
|
const data = {
|
|
@@ -48,13 +54,13 @@ export default (props) => {
|
48
|
54
|
|
49
|
55
|
setSubmitting(true);
|
50
|
56
|
putTaIssueApply(data.applyId, data).then(() => {
|
51
|
|
- Taro.navigateBack({delta: 1});
|
|
57
|
+ Taro.navigateBack({ delta: 1 });
|
52
|
58
|
setSubmitting(false);
|
53
|
59
|
}).catch(() => {
|
54
|
60
|
setSubmitting(false);
|
55
|
61
|
})
|
56
|
62
|
}
|
57
|
|
-
|
|
63
|
+
|
58
|
64
|
React.useEffect(() => {
|
59
|
65
|
if (id) {
|
60
|
66
|
setLoading(true);
|
|
@@ -70,15 +76,73 @@ export default (props) => {
|
70
|
76
|
setLoading(false);
|
71
|
77
|
});
|
72
|
78
|
}
|
|
79
|
+
|
|
80
|
+ if (id) {
|
|
81
|
+ setLoading(true)
|
|
82
|
+ getTaIssueById(id).then(res => {
|
|
83
|
+ setLoading(false);
|
|
84
|
+ if (res.orgId) {
|
|
85
|
+ getSysOrgById(res.orgId).then(r => {
|
|
86
|
+ setIssue({
|
|
87
|
+ ...res,
|
|
88
|
+ orgName: r?.name
|
|
89
|
+ });
|
|
90
|
+ }).catch(() => {
|
|
91
|
+ setIssue(res);
|
|
92
|
+ })
|
|
93
|
+ } else {
|
|
94
|
+ setIssue(res);
|
|
95
|
+ }
|
|
96
|
+ }).catch(() => {
|
|
97
|
+ setLoading(false);
|
|
98
|
+ });
|
|
99
|
+ }
|
73
|
100
|
}, [id]);
|
74
|
|
-
|
|
101
|
+
|
|
102
|
+ // 复制
|
|
103
|
+ const onCopy = () => {
|
|
104
|
+ console.log('<------------------------------------>')
|
|
105
|
+ Dialog.confirm({
|
|
106
|
+ title: '复制问题单',
|
|
107
|
+ message: '确认复制当前问题单?',
|
|
108
|
+ selector: dialogId,
|
|
109
|
+ }).then((value) => {
|
|
110
|
+ console.log('2value', value);
|
|
111
|
+ if ('confirm' === value) {
|
|
112
|
+ setLoading2(true)
|
|
113
|
+ copyTaIssue(issue.issueId).then(res => {
|
|
114
|
+ setLoading2(false)
|
|
115
|
+
|
|
116
|
+ // Dialog 有 bug,
|
|
117
|
+ // 使用 setTimeout 延迟一会规避一下
|
|
118
|
+ const t = setTimeout(() => {
|
|
119
|
+ clearTimeout(t);
|
|
120
|
+ Dialog.confirm({
|
|
121
|
+ title: '复制成功',
|
|
122
|
+ message: `新问题单号: ${res.issueId}, 是否跳转`,
|
|
123
|
+ selector: dialogId,
|
|
124
|
+ }).then((value2) => {
|
|
125
|
+ if ('confirm' === value2) {
|
|
126
|
+ Taro.navigateTo({
|
|
127
|
+ url: `/pages/issue/edit/index?id=${res.issueId}`
|
|
128
|
+ })
|
|
129
|
+ }
|
|
130
|
+ });
|
|
131
|
+ }, 200);
|
|
132
|
+ }).catch(() => {
|
|
133
|
+ setLoading2(false)
|
|
134
|
+ })
|
|
135
|
+ }
|
|
136
|
+ })
|
|
137
|
+ }
|
|
138
|
+
|
75
|
139
|
return (
|
76
|
140
|
<Page loading={loading}>
|
77
|
141
|
<Issue issueId={issueId} />
|
78
|
|
-
|
79
|
|
- {
|
|
142
|
+
|
|
143
|
+ {
|
80
|
144
|
applyInfo.applyType == PROCESS_APPLY_DELAY && (
|
81
|
|
- <CellGroup style={{marginTop: '20px'}}>
|
|
145
|
+ <CellGroup style={{ marginTop: '20px' }}>
|
82
|
146
|
<Cell
|
83
|
147
|
title="延期日期"
|
84
|
148
|
value={applyInfo.content}
|
|
@@ -92,11 +156,11 @@ export default (props) => {
|
92
|
156
|
/>
|
93
|
157
|
</CellGroup>
|
94
|
158
|
)
|
95
|
|
- }
|
|
159
|
+ }
|
96
|
160
|
|
97
|
|
- {
|
|
161
|
+ {
|
98
|
162
|
applyInfo.applyType == PROCESS_APPLY_REJECT && (
|
99
|
|
- <CellGroup style={{marginTop: '20px'}}>
|
|
163
|
+ <CellGroup style={{ marginTop: '20px' }}>
|
100
|
164
|
<Cell title="申请说明" />
|
101
|
165
|
<Field
|
102
|
166
|
readonly
|
|
@@ -106,11 +170,11 @@ export default (props) => {
|
106
|
170
|
/>
|
107
|
171
|
</CellGroup>
|
108
|
172
|
)
|
109
|
|
- }
|
|
173
|
+ }
|
110
|
174
|
|
111
|
|
- {
|
|
175
|
+ {
|
112
|
176
|
applyInfo.applyType != PROCESS_APPLY_DELAY && applyInfo.applyType != PROCESS_APPLY_REJECT && (
|
113
|
|
- <CellGroup style={{marginTop: '20px'}}>
|
|
177
|
+ <CellGroup style={{ marginTop: '20px' }}>
|
114
|
178
|
<Cell title="整改结果" />
|
115
|
179
|
<Field
|
116
|
180
|
readonly
|
|
@@ -118,7 +182,7 @@ export default (props) => {
|
118
|
182
|
autosize={{ minHeight: '120px' }}
|
119
|
183
|
value={orgIssue.result}
|
120
|
184
|
/>
|
121
|
|
-
|
|
185
|
+
|
122
|
186
|
<Cell title="整改照片" border={false} />
|
123
|
187
|
<Cell
|
124
|
188
|
renderTitle={
|
|
@@ -130,9 +194,9 @@ export default (props) => {
|
130
|
194
|
/>
|
131
|
195
|
</CellGroup>
|
132
|
196
|
)
|
133
|
|
- }
|
134
|
|
-
|
135
|
|
- <CellGroup style={{marginTop: '20px'}}>
|
|
197
|
+ }
|
|
198
|
+
|
|
199
|
+ <CellGroup style={{ marginTop: '20px' }}>
|
136
|
200
|
<Cell
|
137
|
201
|
title="审批结果"
|
138
|
202
|
>
|
|
@@ -153,9 +217,13 @@ export default (props) => {
|
153
|
217
|
onChange={(e) => setFieldValue('verifyDesc', e.detail)}
|
154
|
218
|
/>
|
155
|
219
|
</CellGroup>
|
156
|
|
- <View style={{marginTop: '20px', padding: 'var(--main-space)'}}>
|
157
|
|
- <Button block type="primary" loading={submitting} onClick={onSubmit}>审 批</Button>
|
158
|
|
- </View>
|
|
220
|
+ <CellGroup>
|
|
221
|
+ <View style={{ marginTop: '20px', display: 'flex' }}>
|
|
222
|
+ <Dialog id={dialogId} />
|
|
223
|
+ <Button block type="primary" loading={submitting} onClick={onSubmit} style={{ flex: 5, marginLeft: 'var(--main-space)' }}>审 批</Button>
|
|
224
|
+ <Button block type="info" loading={loading2} onClick={onCopy} style={{ flex: 1, margin: '0 var(--main-space)' }}>复制</Button>
|
|
225
|
+ </View>
|
|
226
|
+ </CellGroup>
|
159
|
227
|
</Page>
|
160
|
228
|
)
|
161
|
229
|
}
|