Riku
2024-07-08 04e9d32ac49bf5a38adf3cd7dab6bff6e346eefd
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
// 区域筛选的逻辑管理
 
import { defineStore } from 'pinia'
import dayjs from 'dayjs'
 
export const useAreaStore = defineStore('area', {
  state: () => {
    return {
      area: {
        provincecode: undefined,
        provincename: undefined,
        citycode: undefined,
        cityname: undefined,
        districtcode: undefined,
        districtname: undefined,
        starttime: undefined,
        endtime: undefined,
        scensetypeid: undefined
      }
    }
  },
  actions: {
    // 设置行政区划信息
    setLocation(location) {
      this.area.provincecode = location.pCode
      this.area.provincename = location.pName
      this.area.citycode = location.cCode
      this.area.cityname = location.cName
      this.area.districtcode = location.dCode
      this.area.districtname = location.dName
    },
    // 设置时间为给定时间对应当日的头尾
    setTimeOneDay(time) {
      const d = time ? dayjs(time) : dayjs()
      this.area.starttime = d.startOf('day').format('YYYY-MM-DD HH:mm:ss')
      this.area.endtime = d.endOf('day').format('YYYY-MM-DD HH:mm:ss')
    },
    // 设置场景类型
    setSceneType(t) {
      this.area.scensetypeid = t
    }
  }
})