import request from '@/utils/request.js'
import Vue from 'vue'
export function fileUpload(data) {
    return request({
        url: '/common/upload',
        method: 'post',
        data,
        headers: {
            'Content-Type': 'multipart/form-data',
            'image': 'true',

        },
        onUploadProgress: progressEvent => {
            let complete = (progressEvent.loaded / progressEvent.total * 100 | 0)
            const loading = Vue.prototype.$loading({
                lock: true,
                text: complete + '%',
                spinner: 'el-icon-loading',
                background: 'rgba(0, 0, 0, 0.7)'
            });

            let comp = setInterval(() => {
                if (complete == 100) {
                    clearInterval(comp)
                    loading.close()
                }
            }, 1000)
        }
    })
}
export function fileImport(data) {
    return request({
        url: '/basis/stitutionsdrugMgr/importdrug',
        method: 'post',
        data,
        headers: {
            'Content-Type': 'multipart/form-data',
            'image': 'true',

        },
        onUploadProgress: progressEvent => {
            let complete = (progressEvent.loaded / progressEvent.total * 100 | 0)
            const loading = Vue.prototype.$loading({
                lock: true,
                text: '正在导入,' + complete + '%',
                spinner: 'el-icon-loading',
                background: 'rgba(0, 0, 0, 0.7)'
            });

            let comp = setInterval(() => {
                if (complete == 100) {
                    clearInterval(comp)
                    loading.close()
                }
            }, 1000)
        }
    })
}