|
@@ -1,45 +1,72 @@
|
1
|
|
-import React from 'react';
|
2
|
|
-import Taro from '@tarojs/taro';
|
3
|
|
-import { View } from '@tarojs/components';
|
4
|
|
-import { Button } from '@antmjs/vantui';
|
5
|
|
-import { postTaIssue } from '@/services/taissue';
|
6
|
|
-import { warn } from '@/utils/message';
|
7
|
|
-
|
|
1
|
+import React from "react";
|
|
2
|
+import Taro from "@tarojs/taro";
|
|
3
|
+import { View } from "@tarojs/components";
|
|
4
|
+import { Button } from "@antmjs/vantui";
|
|
5
|
+import { postTaIssue, postIssueAssigned } from "@/services/taissue";
|
|
6
|
+import { warn } from "@/utils/message";
|
|
7
|
+import { useModel } from "@/store";
|
|
8
|
+import {
|
|
9
|
+ ROLE_INSPECTOR
|
|
10
|
+} from "@/utils/user";
|
8
|
11
|
export default (props) => {
|
9
|
|
-
|
10
|
12
|
const { formData } = props;
|
11
|
|
-
|
|
13
|
+ const { duty } = useModel("user");
|
12
|
14
|
const [loading, setLoading] = React.useState(false);
|
13
|
15
|
|
|
16
|
+ console.log(ROLE_INSPECTOR == duty);
|
|
17
|
+
|
|
18
|
+ function jump() {
|
|
19
|
+ return Taro.navigateBack({
|
|
20
|
+ delta: 1,
|
|
21
|
+ fail: () => {
|
|
22
|
+ Taro.reLaunch({
|
|
23
|
+ url: "/pages/home/index",
|
|
24
|
+ });
|
|
25
|
+ },
|
|
26
|
+ });
|
|
27
|
+ }
|
|
28
|
+
|
14
|
29
|
// 新增问题单
|
15
|
30
|
const onSubmit = () => {
|
|
31
|
+ console.log(formData);
|
16
|
32
|
try {
|
17
|
|
- warn(!formData.addr, '请填写地址')
|
18
|
|
- warn(!formData.locId, '请选择点位')
|
19
|
|
- warn(!formData.content, '请填写问题描述')
|
20
|
|
- warn(!formData.typeId, '请选择问题分类')
|
21
|
|
- warn(!formData.attachList || formData.attachList.length < 1, '请上传照片')
|
|
33
|
+ warn(!formData.addr, "请填写地址");
|
|
34
|
+ warn(!formData.locId, "请选择点位");
|
|
35
|
+ warn(!formData.content, "请填写问题描述");
|
|
36
|
+ warn(!formData.typeId, "请选择问题分类");
|
|
37
|
+ warn(
|
|
38
|
+ !formData.attachList || formData.attachList.length < 1,
|
|
39
|
+ "请上传照片"
|
|
40
|
+ );
|
22
|
41
|
} catch (e) {
|
23
|
42
|
return;
|
24
|
43
|
}
|
25
|
44
|
|
26
|
|
- setLoading(true)
|
27
|
|
- postTaIssue(formData).then(() => {
|
28
|
|
- setLoading(false);
|
29
|
|
- Taro.navigateBack({
|
30
|
|
- delta: 1,
|
31
|
|
- fail: () => {
|
32
|
|
- Taro.reLaunch({
|
33
|
|
- url: '/pages/home/index'
|
34
|
|
- });
|
35
|
|
- }
|
|
45
|
+ setLoading(true);
|
|
46
|
+ postTaIssue(formData)
|
|
47
|
+ .then((res) => {
|
|
48
|
+ const data = { ...res, ...formData };
|
|
49
|
+ console.log(data);
|
|
50
|
+ ROLE_INSPECTOR == duty
|
|
51
|
+ ? postIssueAssigned({ ...data, nextOrg: formData.orgId })
|
|
52
|
+ .then(() => {
|
|
53
|
+ setLoading(false);
|
|
54
|
+ jump();//跳转
|
|
55
|
+ })
|
|
56
|
+ .catch((e) => {
|
|
57
|
+ console.log(e);
|
|
58
|
+ setLoading(false);
|
|
59
|
+ })
|
|
60
|
+ : jump();
|
|
61
|
+ })
|
|
62
|
+ .catch(() => {
|
|
63
|
+ setLoading(false);
|
36
|
64
|
});
|
37
|
|
- }).catch(() => {
|
38
|
|
- setLoading(false);
|
39
|
|
- })
|
40
|
|
- }
|
|
65
|
+ };
|
41
|
66
|
|
42
|
67
|
return (
|
43
|
|
- <Button block type="primary" loading={loading} onClick={onSubmit}>提交</Button>
|
44
|
|
- )
|
45
|
|
-}
|
|
68
|
+ <Button block type="primary" loading={loading} onClick={onSubmit}>
|
|
69
|
+ 提交
|
|
70
|
+ </Button>
|
|
71
|
+ );
|
|
72
|
+};
|