"use strict";

var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
exports.__esModule = true;
exports.delImage = delImage;
exports.downloadImage = downloadImage;
exports.getChildList = getChildList;
exports.saveImage = saveImage;
var _message = _interopRequireDefault(require("@alifd/next/lib/message"));
var _request = _interopRequireDefault(require("../../utils/request"));
// 上传文件
function saveImage(data) {
  return new Promise(function (resolve, reject) {
    (0, _request["default"])({
      url: '/api/gzmpc-lowcode/file/upload',
      method: 'post',
      data: data,
      headers: {
        'Content-Type': 'multipart/form-data;'
      }
    }).then(function (res) {
      resolve(res.data);
      _message["default"].success('上传成功');
    })["catch"](function (err) {
      reject(err);
    });
  });
}

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

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

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