import { createStore } from 'vuex'
import state from './state'
import mutations from './mutations'
import actions from './actions'

export type ThemeType = 'manage' | 'service' | 'safety'
export interface ViewType {
  name: string
  type: string
  id?: string
}

export interface CommunityInfoProp {
  bigscreenCommunityName: string // 小区名称
  chargingPile: number //充电桩
  totCommunity: number //小区数
  totCmp: number //物业企业数
  totForOld: number //为老设施
  parkingSpace: number //车棚
  totHous: number //总户数
  communityList: { sectName: string; sectId: string }[] // 小区列表
  icMember: unknown[] // 业委会列表
}
export interface IssueProp {
  date: string //日期
  securityScore: number //安全
  cleanScore: number //干净
  orderlyScore: number //有序
  totalScore: number //综合评分
}

export interface CombineProp {
  cleanList: { [key: string]: any }[]
  securityList: { [key: string]: any }[]
  orderlyList: { [key: string]: any }[]
  [key: string]: { [key: string]: any }[]
}

export interface DutySumProp {
  comprehensiveNum: number //综合管理数量
  comprehensiveEndNum: number //综合管理已结数量
  streetNum: number //街面管理数量
  streetEndNum: number //街面管理已结数量
  communityEndNum: number //小区管理已结数量
  communityNum: number //小区管理数量
}

export interface YousubidaRankProp {
  comprehensiveNum: 0 //综合数量
  comprehensiveDispatchNum: 0 //综合派遣数量
  streetNum: 0 //街道数量
  streetDispatchNum: 0 //街道派遣数量
  communityDispatchNum: 0 //小区数量
  communityNum: 0 //小区派遣数量
}
export interface DutyDataProp {
  week: { [key: string]: unknown }[]
  month: { [key: string]: unknown }[]
  day: { [key: string]: unknown }[]
  [key: string]: { [key: string]: any }[]
}

export interface GlobalStateProps {
  showLoading: boolean
  curView: ViewType
  curMapType: string
  showCommunityPoints: boolean
  readonly zhenxing: any
  readonly weihai: any
  readonly workArea1: any
  readonly workArea2: any
  readonly workArea3: any
  readonly viewOptions: ViewType[]
  readonly communityOptions: ViewType[]
  curTheme: ThemeType
  propertySummary: { [key: string]: number }
  caseList: unknown[]
  pubulicSafeGateSenteryShehuiwuye: { [key: string]: number }[]
  pubulicSafeGateSenteryZhiguangongfang: { [key: string]: number }[]
  pubulicSafeMap: unknown[]
  pubulicSafeTruePeople: { [key: string]: number }
  pubulicSafeHouse: { [key: string]: any }
  pubulicSafeNonResident: { [key: string]: any }
  pubulicSafeHouseStKind: { [key: string]: number }
  pubulicSafeTrueCompany: { [key: string]: number }
  pubulicSafeSOSMaterail: { [key: string]: number }
  pubulicSafeBuildings: unknown[]
  pubulicSafePieData: unknown[]
  pubulicSafeNewFindNum: { [key: string]: number }
  pubulicSafeOutHouseWall: any[]
  pubulicLeftCommandSystem: { [key: string]: string }
  pubulicLeftStreetPower: any[]
  pubulicLeftParty: { [key: string]: number }
  pubulicLeftEconomic: { [key: string]: string }

  /** 小区页面 */
  communityInfo: Partial<CommunityInfoProp>
  issueData: IssueProp[]
  scoreIssue: any
  combineData: CombineProp

  /** 工作站 */
  stationInfo: { [key: string]: unknown }
  dutySum: Partial<DutySumProp>
  dutyList: { [key: string]: any }[]
  dutyRank: Partial<DutyDataProp>
  dutyEvents: Partial<DutyDataProp>
  dutyPlaces: Partial<DutyDataProp>
  dutyRanking: Partial<DutyDataProp>

  /** 公共管理 */
  yousubidaRank: Partial<YousubidaRankProp>
  classificationRank: any[]
  urgentCase: any[]
  todayCase: { [key: string]: number }
  stageCase: { [key: string]: number }
  workstationKind: any[]
  workstationKindPiEData: { [key: string]: number }
  trackEvent: any[]
  analysisRank: Partial<DutyDataProp>
  moreHappenAddr: Partial<DutyDataProp>
}

export default createStore<GlobalStateProps>({
  state,
  mutations,
  actions,
})
