import { serviceCaseCover, addCaseCover, getCaseListData, deleteServiceBatch, addCase, getCaseTypeListData, serviceCaseList, addServiceCase, deleteServiceCaseBatch, deleteCaseBatch, getCaseDetailById } from '@/api/case'

const servicecase = {
  namespaced: true,

  actions: {
    getCaseCover({ commit, state }, data) {
      return new Promise((resolve, reject) => {
        serviceCaseCover(data).then(response => {
          resolve(response)
        }).catch(error => {
          reject(error)
        })
      })
    },
    createCaseCover({ commit, state }, data) {
      return new Promise((resolve, reject) => {
        addCaseCover(data).then(response => {
          resolve(response)
        }).catch(error => {
          reject(error)
        })
      })
    },
    createCase({ commit, state }, data) {
      return new Promise((resolve, reject) => {
        addCase(data).then(response => {
          resolve(response)
        }).catch(error => {
          reject(error)
        })
      })
    },
    getCaseList({ commit, state }, data) {
      return new Promise((resolve, reject) => {
        getCaseListData(data).then(response => {
          resolve(response)
        }).catch(error => {
          reject(error)
        })
      })
    },
    getCaseTypeList({ commit, state }, data) {
      return new Promise((resolve, reject) => {
        getCaseTypeListData(data).then(response => {
          resolve(response)
        }).catch(error => {
          reject(error)
        })
      })
    },
    deleteService({ commit, state }, data) { // 删除 活动报名人员
      return new Promise((resolve, reject) => {
        deleteServiceBatch(data).then(response => {
          resolve(response)
        }).catch(error => {
          reject(error)
        })
      })
    },
    getServiceCaseList({ commit, state }, data) {
      return new Promise((resolve, reject) => {
        serviceCaseList(data).then(response => {
          resolve(response)
        }).catch(error => {
          reject(error)
        })
      })
    },
    addServiceCase({ commit, state }, data) {
      return new Promise((resolve, reject) => {
        addServiceCase(data).then(response => {
          resolve(response)
        }).catch(error => {
          reject(error)
        })
      })
    },
    deleteServiceCase({ commit, state }, data) { // 删除
      return new Promise((resolve, reject) => {
        deleteServiceCaseBatch(data).then(response => {
          resolve(response)
        }).catch(error => {
          reject(error)
        })
      })
    },
    deleteCase({ commit, state }, data) { // 删除
      return new Promise((resolve, reject) => {
        deleteCaseBatch(data).then(response => {
          resolve(response)
        }).catch(error => {
          reject(error)
        })
      })
    },
    getCaseDetail({ commit }, id) {
      return new Promise((resolve, reject) => {
        getCaseDetailById(id).then(response => {
          resolve(response)
        }).catch(error => {
          reject(error)
        })
      })
    }
  }
}

export default servicecase
