import { TypeI5Tree } from '@/pages/Isystem/I5organization/data'
import { AppDispatch } from '@/store'
import http from '@/utils/http'

/**
 * 标签 - 获取树列表
 */
export const E1_APIgetTree = (callFu?: (data: TypeI5Tree[]) => void): any => {
  return async (dispatch: AppDispatch) => {
    const res = await http.get('cms/tag/getTree')
    if (res.code === 0) {
      callFu && callFu(res.data || [])
      dispatch({ type: 'E1/getTree', payload: res.data || [] })
    }
  }
}

/**
 * 标签 - 删除
 */
export const E1_APIdel = (id: string) => {
  return http.get(`cms/tag/remove/${id}`)
}

/**
 * 标签 - 获取详情
 */
export const E1_APIgetInfo = (id: string) => {
  return http.get(`cms/tag/detail/${id}`)
}

/**
 * 标签 - 新增或修改
 */
export const E1_APIsave = (data: any) => {
  return http.post('cms/tag/save', { ...data, type: 'tag' })
}
