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, }); }) .finally(() => { this.setData({ inspectionLoading: false }); }); }, onTabsChange(e) { this.setData({ tabIndex: e.detail.value }); }, 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, }); }, }); }, }, });