import axios from "axios"
import request from "@/utils/request"

// 文件方法
export default {
    up: function (data, config = {}) {
        return request({ // file: file
            headers: {
                "Content-Type": "multipart/form-data"
            },
            url: "/qdport-resource/oss/endpoint/put-file",
            method: "post",
            data,
            ...config
        })
    },

    rm: function (fileName) { // fileName: string
        request({
            headers: {
                "Content-Type": "application/x-www-form-urlencoded"
            },
            url: "/qdport-resource/oss/endpoint/remove-file",
            method: "post",
            data: {
                fileName
            }
        })
    },

    fileRemove: function (ids) {
        return request({
            headers: {
                "Content-Type": "application/x-www-form-urlencoded"
            },
            url: "/qdport-zcgx/file/remove",
            method: "post",
            data: {
                ids
            }
        })
    },

    download: function (url) { // url: string
        return axios({
            url,
            method: "get",
            responseType: "blob"
        })
    },

    import: function (url, excelUrl) { // 导入
        return request({
            url: `/qdport-zcgx/import/${url}`,
            method: "post",
            data: {
                excelUrl
            }
        })
    }
}