import ajax from '../../util/ajax'
import api from '../../util/api'

export default {
  namespaced: true,
  state: {
    recordList: [],
  },
  mutations: {
    updateList (state, payload) {
      state.recordList = payload || []
    },
  },
  actions: {
    GetRecordList ({ commit }, payload) {
      ajax(api.caseManager.getRecordList.url, {
        method: api.caseManager.getRecordList.method,
        queryData: {
          ...payload,
        }
      }).then(res => {
        commit('updateList', res)
        if (payload.callback) {
          payload.callback()
        }
      })
    },
    AddRecord ({ commit }, payload) {
      ajax(api.caseManager.addRecord.url, {
        method: api.caseManager.addRecord.method,
        data: {
          ...payload,
        }
      }).then(res => {
        if (payload.callback) {
          payload.callback()
        }
      })
    },
  }
}
