1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
| import { fetchSubtasksByProType } from '../../services/inspection/fetchInspection';
| import { fetchScene } from '../../services/inspection/fetchScene';
| import { fetchUserMap } from '../../services/usercenter/fetchUser';
| import dayjs from 'dayjs';
| import { toTime, toPeriod } from '../../utils/period';
|
| /**
| * 监管问题分析统计相关信息逻辑
| */
| export const useAnalysis = Behavior({
| data: {
| thisSubtasks: [],
| lastSubtasks: [],
| problemType: '',
| problemCount: 0,
| },
| methods: {
| onChartClick(params) {
| const { name, value } = params;
| this.setData({
| problemType: name,
| problemCount: value,
| });
| if (name) {
| this.fetchSubTasks();
| }
| },
|
| fetchSubTasks(page) {
| const { problemType } = this.data;
| const params = this._getParamsArea();
| // 本月统计
| const f1 = fetchSubtasksByProType({
| area: params,
| pType: problemType,
| }).then(res => {
| this.setData({ thisSubtasks: res.data });
| return res.head;
| });
| // 上月统计
| params.starttime = dayjs(params.starttime).subtract(1, 'month').format('YYYY-MM-DD HH:mm:ss');
| params.endtime = dayjs(params.endtime).subtract(1, 'month').format('YYYY-MM-DD HH:mm:ss');
| const f2 = fetchSubtasksByProType({
| area: params,
| pType: problemType,
| }).then(res => {
| this.setData({ lastSubtasks: res.data });
| return res.head;
| });
| // 统一获取
| return Promise.all([f1, f2]).then(res => {
| return res[0];
| });
| },
|
| fetchUserId(subtask) {
| return fetchUserMap(subtask.scenseid).then(res => {
| return res.tzUserId;
| });
| },
|
| navToDetail(e) {
| const { index } = e.currentTarget.dataset;
| const { inspection, sceneTypeText, sceneTypeValue, time } = this.data;
| const subtask = this.data.thisSubtasks[index];
| // this.fetchUserId(subtask).then(userId => {
| // wx.navigateTo({
| // url: '/pages/enterprise/detail/index',
| // success: result => {
| // result.eventChannel.emit('acceptEnterpriseData', {
| // subtask: subtask,
| // enterprise: {
| // id: userId,
| // name: subtask.scensename,
| // sceneType: sceneTypeText,
| // sceneTypeId: sceneTypeValue,
| // district: inspection.districtName,
| // },
| // period: toPeriod(time),
| // });
| // },
| // });
| // });
| fetchScene(subtask.scenseid).then(res => {
| wx.navigateTo({
| url: '/pages/inspection/detail/index',
| success: result => {
| result.eventChannel.emit('acceptInspectionDetailData', {
| scene: res,
| time: time,
| });
| },
| });
| });
| },
| },
| });
|
|