import _Message from "@alifd/next/es/message";
import request from "../../utils/request";
// 上传文件
export function saveImage(data) {
  return new Promise(function (resolve, reject) {
    request({
      url: '/api/gzmpc-lowcode/file/upload',
      method: 'post',
      data: data,
      headers: {
        'Content-Type': 'multipart/form-data;'
      }
    }).then(function (res) {
      resolve(res.data);
      _Message.success('上传成功');
    })["catch"](function (err) {
      reject(err);
    });
  });
}

// 下载文件
export function downloadImage(id) {
  return new Promise(function (resolve, reject) {
    request({
      url: "/api/gzmpc-lowcode/file/download?id=" + id,
      method: 'get',
      headers: {
        'Content-Type': 'multipart/form-data;'
      }
    }).then(function (res) {
      resolve(res);
      _Message.success('下载成功');
    })["catch"](function (err) {
      reject(err);
    });
  });
}

// 删除文件
export function delImage(data) {
  return new Promise(function (resolve, reject) {
    request({
      url: '/api/gzmpc-lowcode/file/delete',
      method: 'post',
      data: data,
      headers: {
        'Content-Type': 'multipart/form-data;'
      }
    }).then(function (res) {
      _Message.success('删除成功');
      resolve(res);
    })["catch"](function (err) {
      reject(err);
    });
  });
}

// 获取枚举值列表-子
export function getChildList(parentId) {
  return new Promise(function (resolve, reject) {
    request({
      url: "/api/gzmpc-lowcode/enum/child-list?parentId=" + parentId,
      method: "get"
    }).then(function (res) {
      resolve(res.data);
    });
  });
}