import { api,createApiUrl,downloadFile } from '~/utils/axios';

/**
 * 获取系统字典树
 * @return {Promise} api
 */
export function getDictionaryTree() {
  return api.get('Dictionary.Dictionary/getDictionaryTree', {
    isTransformResponse: true
  });
}
/**
 * 更新字典
 * @param {Object} data
 * @return {Promise} api
 */
export function addDictionary(data) {
  return api.post('Dictionary.Dictionary/addDictionary', data, {
    isTransformResponse: true,
    isShowSuccessMessage: true,
    errorMessageText: '添加失败'
  });
}
/**
 * 更新字典
 * @param {Object} data
 * @return {Promise} api
 */
export function updateDictionary(data) {
  return api.post('Dictionary.Dictionary/updateDictionary', data, {
    isTransformResponse: true,
    isShowSuccessMessage: true,
    errorMessageText: '更新失败'
  });
}
/**
 * 删除字典
 * @param {Object} data
 * @return {Promise} api
 */
export function deleteDictionary(data) {
  return api.post('Dictionary.Dictionary/deleteDictionary', data, {
    isTransformResponse: true,
    isShowSuccessMessage: true,
    errorMessageText: '删除失败'
  });
}
/**
 * 获取字典列表
 * @param {Object} data
 * @return {Promise} api
 */
export function getDictionaryList(data) {
  return api.post('Dictionary.Dictionary/getDictionaryList', data, {
    isTransformResponse: true
  });
}
/**
 * 获取客户文化程度
 * @return {Promise} api
 */
export function getCustomerCultureDictionaryList() {
  return getDictionaryList({
    dictionary_parent_guid: 'f704d1c6-0d68-781b-d128-cbb3c111b9e4'
  });
}

/**
 * 下载字典模板
 * @param {Object} data
 * @return {Promise} api
 */
 export function downloadTemplate(data) {
  downloadFile(createApiUrl('Dictionary.Dictionary/downloadTemplate'), data);
}

/**
 * 导入字典
 * @param {Object} data
 * @return {Promise} api
 */
export const importExcel = createApiUrl('Dictionary.Dictionary/importExcel');
