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

const servicecase = {
  namespaced: true,

  actions: {
    getCaseCover({ commit, state }, data) {
      return new Promise((resolve, reject) => {
        serviceCaseCover({ type: 'case', ...data }).then(response => {
          resolve(response)
        }).catch(error => {
          reject(error)
        })
      })
    },
    getMovementCover({ commit, state }, data) {
      return new Promise((resolve, reject) => {
        serviceCaseCover({ type: 'movement', ...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({ type: 'case', ...data }).then(response => {
          resolve(response)
        }).catch(error => {
          reject(error)
        })
      })
    },
    getMovementList({ commit, state }, data) {
      return new Promise((resolve, reject) => {
        getCaseListData({ type: 'movement', ...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)
        })
      })
    },
    getServiceMovementList({ commit, state }, data) {
      return new Promise((resolve, reject) => {
        serviceMovementList(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)
        })
      })
    },

    uploadImage({ commit }, date) {
      return new Promise((resolve, reject) => {
        uploadimage(date).then(response => {
          resolve(response)
        }).catch(error => {
          reject(error)
        })
      })
    }

  }
}

export default servicecase
