riku
2025-04-17 ec7f5ba1f7eb84507e1c8e7b6f66b1ecfbc22728
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
import {
  fetchInspectionStatistic,
  fetchSubtaskSummaryByArea,
} from '../../services/inspection/fetchInspection';
import dayjs from 'dayjs';
 
/**
 * 现场巡查监管相关信息获取逻辑
 */
export const useInsepction = Behavior({
  data: {
    tabIndex: 0,
    inspectionLoading: false,
    inspectionRes: [],
  },
  methods: {
    fetchInspection(page) {
      this.setData({ inspectionLoading: true });
      const { provinceCode, cityCode, districtCode, townCode, sceneTypeValue, time } = this.data;
      const eTime = dayjs(time).endOf('M').format('YYYY-MM-DD HH:mm:ss');
      fetchSubtaskSummaryByArea({
        provincecode: provinceCode,
        citycode: cityCode,
        districtcode: districtCode,
        towncode: townCode,
        scensetypeid: sceneTypeValue[0],
        starttime: time,
        endtime: eTime,
      })
        .then(res => {
          this.setData({
            inspectionRes: res.data,
          });
          this.fetchSupervisionByDistrict(this.data.tabIndex);
        })
        .finally(() => {
          this.setData({ inspectionLoading: false });
        });
    },
    onTabsChange(e) {
      this.setData({ tabIndex: e.detail.value });
      this.fetchSupervisionByDistrict(e.detail.value);
    },
 
    fetchSupervisionByDistrict(index) {
      if (this.data.inspectionRes.length == 0) return;
 
      const { sceneTypeValue } = this.data;
      const { provinceName, cityName, districtName } = this.data.inspectionRes[index];
      const params = { provinceName, cityName, districtName, sceneTypes: sceneTypeValue };
      this._fetchSupervision(1, params);
    },
 
    navToInspection(e) {
      const i1 = e.detail.index;
      const { inspectionRes, time, sceneTypeText, sceneTypeValue, tabIndex } = this.data;
      wx.navigateTo({
        url: '/pages/inspection/ranking/index',
        success: function (res) {
          res.eventChannel.emit('acceptInspectionData', {
            inspection: inspectionRes[tabIndex],
            time,
            sceneTypeText,
            sceneTypeValue,
          });
        },
      });
    },
    navToInspAnalysis(e) {
      const { inspectionRes, time, sceneTypeText, sceneTypeValue, tabIndex } = this.data;
      wx.navigateTo({
        url: '/pages/inspection/index',
        success: function (res) {
          res.eventChannel.emit('acceptInspectionData', {
            inspection: inspectionRes[tabIndex],
            time,
            sceneTypeText,
            sceneTypeValue,
          });
        },
      });
    },
  },
});