
export default {
  namespaced: true,
  state: {
    caseInfo: {},
  },
  mutations: {
    init (state, data) {
      state.caseInfo = data
    }
  },
  actions: {
    GetCaseInfo ({ commit }, payload) {
      return new Promise((resolve) => {
        this.$ajax(this.$api.cms.caseDetail.url, {
          method: this.$api.cms.caseDetail.method,
          urlData: {
            id: payload.id
          }
        }).then(res => {
          commit('init', res)
          resolve()
        })
      })
    },
    AddCaseInfo ({ commit }, payload) {
      return new Promise((resolve) => {
        this.$ajax(this.$api.cms.addCase.url, {
          method: this.$api.cms.addCase.method,
          data: payload
        }).then((res) => {
          resolve(res)
        })
      })
    },
    UpdateCaseInfo ({ commit }, payload) {
      return new Promise((resolve) => {
        this.$ajax(this.$api.cms.editCase.url, {
          method: this.$api.cms.editCase.method,
          urlData: {
            id: payload.id
          },
          data: payload
        }).then(res => {
          resolve()
        })
      })
    },
    SetNull ({ commit }) {
      commit('init', {
        IsAllCourse: 1,
        Status: 0,
      })
    },
    UpdateInfo ({ commit }, payload) {
      commit('init', payload)
    }
  }
}
