审查视图

src/views/nmms_fast/DataImport.vue 5.0 KB
小范 authored
1 2 3
<template>
    <el-container>
        <el-main>
4
            <el-row>
小范 authored
5
                <el-row>
6 7 8 9 10 11 12 13
                    <el-col :span="24"><div class="grid-content"><p>请导入原始/理货数据:</p></div></el-col>
                </el-row>
                <el-row>
                    <el-col :span="24"><div class="grid-content"><h1>Please import original / tally data:</h1></div></el-col>
                </el-row>
            </el-row>
                <el-row style="margin-top: 60px">
                    <el-col :offset="4" :span="7" style="background-color: white;padding-top: 20px;padding-bottom: 20px;border-radius: 10px">
小范 authored
14 15
                        <el-upload
                                class="upload-demo"
16 17 18 19 20
                                action=""
                                :http-request="uploadOri"
                                :limit=1
                                :on-exceed="fileExceed"
                                accept="application/vnd.ms-excel,application/vnd.ms-excels"
21 22 23 24 25 26
                                ref="fileupload"
                                v-loading.fullscreen.lock="loading"
                                element-loading-text="正在上传原始数据"
                                element-loading-spinner="el-icon-loading"
                                element-loading-background="rgba(0,0,0,0.3)"
                        >
27 28
                            <el-button size="medium" type="primary">点击上传原始数据</el-button>
                            <div slot="tip" class="el-upload__tip">只能上传excel文件</div>
小范 authored
29 30
                        </el-upload>
                    </el-col>
31
                    <el-col :offset="2" :span="7" style="background-color: white;padding-top: 20px;padding-bottom: 20px;border-radius: 10px">
小范 authored
32 33
                        <el-upload
                                class="upload-demo"
34 35 36 37 38
                                action=""
                                :http-request="uploadTal"
                                :limit=1
                                :on-exceed="fileExceed2"
                                accept="application/vnd.ms-excel,application/vnd.ms-excels"
39 40 41 42 43
                                ref="fileupload"
                                v-loading.fullscreen.lock="loadings"
                                element-loading-text="正在上传理货数据"
                                element-loading-spinner="el-icon-loading"
                                element-loading-background="rgba(0,0,0,0.3)">
44 45
                            <el-button size="medium" type="success">点击上传理货数据</el-button>
                            <div slot="tip" class="el-upload__tip">只能上传excel文件</div>
小范 authored
46 47 48 49 50 51 52 53 54 55 56 57 58
                        </el-upload>
                    </el-col>
                </el-row>
        </el-main>
    </el-container>
</template>
<!--自定义CSS-->
<style scoped>
    .el-container{text-align: center}
    .el-main{margin:0 auto;height:400px;}
    p{font-size:25px;font-weight: bold;}
    .row-bg{padding:30px 0;}
    .el-form-item {margin-bottom: 0px;}
59 60 61 62
    .el-loading-spinner{
        top:60%;
        width: 120%;
    }
小范 authored
63 64 65
</style>

<script>
66
    import {upfile,upfiles} from "../../api/technological";
小范 authored
67 68 69
    export default {
        data() {
            return {
70 71
                loading:false,
                loadings:false,
72
                fileList: [],
小范 authored
73 74 75
            };
        },
        methods:{
76 77 78 79 80 81
            // excel 原始导入
            fileExceed(){
                this.$message.error('别贪心!一次只能上传一个哦~');
            },
            // 自定义上传 excel
            uploadOri (item) {
82
                this.loading = true;
83 84 85 86
                const form = new FormData()
                form.append('file', item.file);
                upfile(form).then(res =>{
                    if(res.data.count >0){
87
                        this.loading = false;
88 89
                        return this.$message.error('主单导入失败')
                    }else {
90
                        this.loading = false;
91 92 93 94 95 96 97 98 99 100
                        this.$message.success('主单导入成功')
                    }
                }).catch((e) => {})
            },
            // excel 理货导入
            fileExceed2(){
                this.$message.error('别贪心!一次只能上传一个哦~');
            },
            // 自定义上传 excel
            uploadTal (item) {
101
                this.loadings = true;
102 103 104 105
                const form = new FormData()
                form.append('file', item.file);
                upfiles(form).then(res =>{
                    if(res.data.count >0){
106
                        this.loadings = false;
107 108
                        return this.$message.error('主单导入失败')
                    }else {
109
                        this.loadings = false;
110 111 112 113
                        this.$message.success('主单导入成功')
                    }
                }).catch((e) => {})
            },
小范 authored
114 115 116 117 118 119 120 121 122
        },
        computed:{
        },
        /*渲染方法*/
        activated(){
        },
    };
</script>