<template>
    <!-- 点击excel导入之后的弹窗：excel导入 -->
    <div class="excel-inputWindow">
        <div class="excel-titleWords">
            excel导入
            <div class="excel-closeIcon">
                <i class="el-icon-close" @click="closeExcelWindow"></i>
            </div>
        </div>
        <div class="folder-area">
            <div class="name-boxDiv">
                名称
            </div>
            <el-input class="excelFolder-Input" v-model="fullExcelNameFolder" placeholder=""></el-input>

            <el-upload ref="upload" action="#" multiple :limit="1" :file-list="fileList" :auto-upload="false"
                :show-file-list="false" accept=".xls,.xlsx" :on-change="handleChange">
                <el-button class="excelFolder-search" slot="trigger" type="primary" @click="clearFilesBeforeUpload">浏览
                </el-button>
            </el-upload>
        </div>
        <div class="confirmORcancel-button">
            <el-button class="excelFolder-confirm-button" type="primary" @click="confirm">确认
            </el-button>
            <el-button class="excelFolder-cancel-button" type="primary" @click="closeExcelWindow">取消</el-button>
        </div>
    </div>
</template>

<script>
import { mapState } from 'vuex';
import {
    getXQTBListViaExcelSelect
} from '@/api/xqglApi.js';
export default {
    name: "excelPop",
    components: {},
    data() {
        return {
            fullExcelNameFolder: '',
            fileList: [],
        };
    },
    computed: {
        ...mapState("xqgl", ['parentId']),
    },
    watch: {

    },
    methods: {
        closeExcelWindow() {
            this.$emit('closePop');
        },
        confirm() {
            getXQTBListViaExcelSelect(this.excelUploadFile).then(res => {
                if (res.code === 200) {
                    this.$emit('comfirm');
                    this.$emit('closePop');
                }
            });
        },
        //excel上传时，为后端传输数据准备该接口的  data
        handleChange(file, fileList) {
            this.fullExcelNameFolder = file.name
            console.log('fileList:', fileList);
            let tempExcelFileFormData = new FormData();
            let tempExcelFile = file.raw;
            tempExcelFileFormData.append("file", tempExcelFile);
            tempExcelFileFormData.append("parentId", this.parentId);
            this.excelUploadFile = tempExcelFileFormData;
            console.log("this.excelUploadFile:", this.excelUploadFile);
        },
        //excel文件上传时，清空之情的待上传文件
        clearFilesBeforeUpload() {
            this.$refs.upload.clearFiles()
        },
    },
    mounted() {

    }
};
</script>

<style lang='scss' scoped>
.excel-inputWindow {
    width: 356px;
    height: 194px;
    position: absolute;
    top: 74px;
    left: 100%;
    z-index: 1;
    background: url('@/assets/ClipImage/dikuang/tanchuang/exceldaoru.png');
    background-size: 100% 100%;

    .excel-titleWords {
        width: 320px;
        height: 32px;
        line-height: 32px;
        text-align: center;
        position: relative;
        top: 34px;
        background-color: #0095ff;
        margin: 0px 18px;
        font-family: 'SourceHanSansCN-Bold';
        font-size: 14px;
        color: #fff;

        .excel-closeIcon {
            float: right;
            margin-right: 12px;
            cursor: pointer;
        }
    }

    .folder-area {
        width: 320px;
        height: 64px;
        position: relative;
        top: 17px;
        margin: 17px 18px;
        font-family: 'SourceHanSansCN-Regular';
        color: #fff;
        display: flex;
        justify-content: space-between;
        align-items: center;

        .name-boxDiv {
            width: 24px;
            height: 12px;
            font-size: 12px;
        }

        // /deep/ .excelFolder-Input {
        //     width: 210px;
        //     height: 30px;
        //     background-color: rgba(299, 299, 299, 0.3);

        //     // opacity: 0.3;
        //     /deep/ .el-input__inner {
        //         height: 30px;
        //         line-height: 30px;
        //         border: none;
        //         color: #fff;
        //         padding: 0 8px;
        //         background: transparent;
        //     }

        // }

        /deep/ .excelFolder-search {
            width: 60px;
            height: 30px;
            background-color: #006ebb;
            border-radius: 4px;
            padding: 0;
        }
    }

    .confirmORcancel-button {
        width: 320px;
        height: 30px;
        display: flex;
        justify-content: space-around;
        align-items: center;
        margin: 0 18px;

        .excelFolder-confirm-button,
        .excelFolder-cancel-button {
            width: 92px;
            height: 30px;
            background: url('@/assets/ClipImage/anniu/quxiao_link.png');
            background-size: 100% 100%;
            border: none;
            padding: 0;
            margin: 0;
            font-family: SourceHanSansCN-Regular;
        }

        .excelFolder-confirm-button {
            background: url('@/assets/ClipImage/anniu/queren_link.png');
        }

        .excelFolder-confirm-button:hover {
            background: url('@/assets/ClipImage/anniu/queren_hover.png');
        }

        .excelFolder-confirm-button:focus {
            background: url('@/assets/ClipImage/anniu/queren_check.png');
        }

        .excelFolder-cancel-button {
            background: url('@/assets/ClipImage/anniu/quxiao_link.png');
        }

        .excelFolder-cancel-button:hover {
            background: url('@/assets/ClipImage/anniu/quxiao_hover.png');
        }

        .excelFolder-cancel-button:focus {
            background: url('@/assets/ClipImage/anniu/quxiao_check.png');
        }
    }
}
</style>
<style lang="scss">
.excelFolder-Input {
    width: 210px;
    height: 30px;
    background-color: rgba(299, 299, 299, 0.3);

    .el-input__inner {
        height: 30px;
        line-height: 30px;
        border: none;
        color: #fff;
        padding: 0 8px;
        background: transparent;
    }

}
</style>
