import { getWorkticketDetails } from '@/api/jobReservation.js'
const dangerList = {
  namespaced: true,
  state: {
    dangerSrcList: [], // 隐患来源数据
    dangerTypeList: [], // 隐患类型数据
    getAreaTree: [], // 区域数据
    getDeptTree: [], // 部门数据
    getDeptUserTree: [], // 部门用户数据
    contractorList: [], // 承包商
    contractorUserList: [], // 承包商用户
    workticketData: {} // 作业数据

  },
  mutations: {
    GETSRC (state, data) {
      state.dangerSrcList = data.list
    },
    GETTYPE (state, data) {
      state.dangerTypeList = data.list
    },
    GETTREE (state, data) {
      state.getAreaTree = data.list
    },
    GETDEPT (state, data) {
      state.getDeptTree = data.list
    },
    GETUESR (state, data) {
      state.getDeptUserTree = data.list
    },
    GETCONTRACTOR (state, data) {
      state.contractorList = data.list
    },
    GETCONTRACTORUSER (state, data) {
      state.contractorUserList = data.list
    },
    WORKTICKETDATA (state, data) {
      state.workticketData = data
    }
  },
  actions: {
    getSrc ({ commit }, val) {
      commit('GETSRC', val)
    },
    getType ({ commit }, val) {
      commit('GETTYPE', val)
    },
    getTree ({ commit }, val) {
      commit('GETTREE', val)
    },
    getDept ({ commit }, val) {
      commit('GETDEPT', val)
    },
    getUser ({ commit }, val) {
      commit('GETUESR', val)
    },
    async getWorkticketData ({ commit }, val) {
      const { data } = await getWorkticketDetails(val)
      if (data.code === 200) {
        commit('WORKTICKETDATA', data.data)
      } else {
        commit('WORKTICKETDATA', {})
      }
    }
  },
  getters: {}
}
export default dangerList
