<template>
    <div class="app-container">
            <el-form  ref="queryForm" size="small" :inline="true" label-width="68px">
                <el-form-item label="模板" prop="name" >
                    <el-select v-model="selectedOption" ref="mySelect" size="mini" @change="handleOptionChange" filterable placeholder="请选择您要查看的模板">
                        <!--  <el-option label="自设的模板名" value="使用空白模板"></el-option>-->
                        <el-option
                            v-for="item in depss" :key="item.id" :label="item.templateName" :value="item.id">
                        </el-option>
                    </el-select>
                </el-form-item>
                <el-form-item label="规则" prop="roleid">
                    <el-select v-model="selectedRule" ref="mySelect" size="mini" @change="handleRuleChange" filterable placeholder="请选择您要查看的规则"  >
                        <el-option
                            v-for="iem in luckyrule" :key="iem.id" :label="iem.roleName" :value="iem.id">
                        </el-option>
                    </el-select>
                </el-form-item>
                <el-form-item label="时间" prop="date">
                    <el-date-picker
                        @change="handledateChange"
                        v-model="date"
                        type="month"
                        placeholder="选择月">
                    </el-date-picker>
                </el-form-item>
                <el-form-item label="所属矿区" prop="mining">
                    <el-select v-model="mining" placeholder="请选择矿区" @change="handleminingChange">
                        <el-option label="东欢坨矿" :value="1"></el-option>
                        <el-option label="范矿" :value="2"></el-option>
                        <el-option label="林西矿" :value="3"></el-option>
                        <el-option label="吕矿" :value="4"></el-option>
                        <el-option label="钱家营矿" :value="5"></el-option>
                        <el-option label="唐山矿" :value="6"></el-option>
                    </el-select>
                </el-form-item>
                <el-form-item>
                    <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
                </el-form-item>
            </el-form>
            <el-row :gutter="10" class="mb8">
                <el-col :span="1.5">
                    <el-button
                        type="warning"
                        plain
                        icon="el-icon-upload2"
                        size="mini"
                        @click="handleExport"
                    >导出</el-button>
                </el-col>
                <el-col :span="1.5">
                    <el-upload
                        type="file"
                        name="file"
                        ref="upload"
                        :before-upload="handleFileChange"
                        action=''
                        accept='.xlsx'
                        :limit="1"
                        :file-list="fileList"
                        :disabled="disableNextButton"
                        :show-file-list=false
                    >
                        <el-button  plain size="mini" icon="el-icon-download" type="primary"  :disabled="disableNextButton" @click="rulesdate">导入</el-button>
                    </el-upload>
                </el-col>
            </el-row>
        <!-- luckysheet容器 -->
        <div
            id="luckysheet"
            style="margin: 0px; padding: 0px; position: absolute; width: 100%; height:80vh; z-index: 0"
        >
        </div>
        <div v-if="showMask" class="mask">
            <div class="loading-spinner"></div>
        </div>

    </div>
</template>


<script>
import {selectActSuppliesHistorydata ,addActSuppliesSixMinesSummaryTable,addActSuppliesImportTable} from "@/api/Actsupplies/cleaning_rule";
import { getSuppliesTemplate, listSuppliesTemplate,roleList,materialConvert,roleListid,materialList} from "@/api/ruoyi-myLuckyexcel/myluckyexcel";
import {addInsert}from "@/api/system/historydata"
/*import luckysheet from 'luckysheet'*/
import LuckyExcel from 'luckyexcel'
//导入库export.js 这个文件是es6的，不能在普通的HTML文件直接引入js文件（虽然都是js文件，但是有区别，具体请百度es6与es5）！需要把es6转es5才可以直接引入使用！
/*import {materialList} from "@/api/ruoyi-myLuckyexcel/myluckyexcel";*/
import { exportExcel } from '../../../../public/exportExcel';
import { v4 as uuidv4 } from 'uuid';

var fileName="新建XLSX工作表"; //定义表名
var rule=[];
var tempId;
var roleId;
var uuid1;
var trueORfalse=false;
var modify=false;
export default {
    name: "Mymodule",
    data() {
        return {
            showMask:false,
            uuid:'',
            //弹出页面的表名
            from_name : "",
            // 是否显示弹出层
            dialogVisible : false,
            selectedOption:'',
            selectedRule:'',
            luckysheetData: '',
            fileList:[],
            disableNextButton: true,
            luckyrule:[],
            depss:[],
            // 表单参数
            from: {},
            date: '',
            mining:'',
            froms: {
                hId : "",
                projectId : "",
                projectName : "",
                departmentName : "",
                number  : "",
                nuitPrice : "",
                money : "",
                createBy  : "",
                hDate : null,
                mining : ""

            },
            fromimport: {
                hId : "",
                hDate : null,
                mining : "",
                a1 : "",
                a2 : "",
                a3 : "",
                a4 : "",
                a5 : "",
                a6 : "",
                a7 : "",
                a8 : "",
                a9 : "",
                a10 : "",
                a11 : "",
                a12 : "",
                a13 : "",
                a14 : "",
                a15 : "",
                a16 : "",
                a17 : "",
                a18 : "",
                a19 : "",
                a20 : "",
                a21 : "",
                a22 : "",
                a23 : "",
                a24 : "",
                a25 : "",
                a26 : "",
                a27 : "",
                a28 : "",
                a29 : "",
                a30 : "",
                a31 : "",
                a32 : "",
                a33 : "",
                a34 : "",
                a35 : "",
                a36 : "",
                a37 : "",
                a38 : "",
                a39 : "",
                a40 : "",
                a41 : "",
                a42 : "",
                a43 : "",
                a44 : "",
                a45 : "",
                a46 : "",
                a47 : "",
                a48 : "",
                a49 : "",
                a50 : "",
                a51 : "",
                a52 : "",
                a53 : "",
                a54 : "",
                a55 : "",
                a56 : "",
                a57 : "",
                a58 : "",
                a59 : "",
                a60 : "",
                a61 : "",
                a62 : "",
                a63 : "",
            },
            /*fromimport: {},*/
            dfrom:{},
            // 查询参数
            queryParams: {
                status:0
            },

        };
    },
    created() {
//刷新页面时进行的操作
        this.getList();
    },
    mounted() {

        this.init();
        fileName="新建XLSX工作表";
    },
    methods:{

        /** 判断是否选择时间*/
        rulesdate(){
            if (this.date==''||this.date==null){
                this.disableNextButton=true;
                this.$message.error('请选择时间日期！');
            }else if (this.mining==''||this.mining==null){
                this.disableNextButton=true;
                this.$message.error('请选择所属矿区！');
            }
        },
        handledateChange(){
            if (this.date==''||this.date==null||this.date==undefined){
                this.disableNextButton=true;
            }else {
                this.disableNextButton=false;
            }

        },
        handleminingChange(){
            if (this.date==''||this.date==null||this.date==undefined){
                this.disableNextButton=true;
            }else {
                this.disableNextButton=false;
            }
        },

        /** 页面刷新时展示的数据*/
        getList() {
            listSuppliesTemplate(this.queryParams).then(response => {
                this.depss = response.rows;
            });

        },
        /** 下拉选和页面luckysheet绑定 */
        handleOptionChange() {
            this.selectedRule='';
            this.disableNextButton = this.selectedRule === '';
            //根据选中的下拉选项值获取相应的信息
            getSuppliesTemplate(this.selectedOption).then(response => {
                if(this.selectedOption===7){
                    trueORfalse=true;
                }else{
                    trueORfalse=false;
                }
                modify=false;
                tempId= this.selectedOption;
                uuid1=this.uuid=uuidv4().substring(0,8);

                const sysSupplies = response.rows;
                this.luckysheetData = sysSupplies[0].templateContent;
                //将接收到的json存到json_data中
                //const json_data = response.data;
                var json_data = JSON.parse(sysSupplies[0].templateContent);
                roleList(this.selectedOption).then(response => {
                    this.luckyrule = response.rows;
                });
                let suffixArr = sysSupplies[0].templateName.split('.');
                fileName = suffixArr[0];
                //luckysheet.destroy()
                luckysheet.create({
                    container: "luckysheet", // Luckysheet 的容器元素 ID
                    title: fileName, // Excel 文件名
                    data: json_data, // Excel 数据
                    showinfobar: false, //是否显示顶部名称栏
                    lang:'zh',
                });
            }).catch(() => {
                // 处理错误逻辑，这里是一个空的错误处理函数
                this.$message.error('查询失败,发生未知错误!');
            });
        },
        /** 规则下拉选 调佣后端的方法*/
        handleRuleChange(){
            if (this.selectedOption==='') {
                this.selectedRule='';
                this.$message.warning("选择规则前请先选择模板!");
                return ; // 如果按钮被禁用，提前返回，避免执行下一步操作
            }
            this.disableNextButton = this.selectedRule === '';
            roleListid(this.selectedRule).then(response => {
                roleId=this.selectedRule;
                rule=response.rows;
            });
            if(tempId===7){
                getSuppliesTemplate(7).then(response => {
                    uuid1=this.uuid=uuidv4().substring(0,8);

                    // 通过遍历this.luckyrule找到对应的iem.roleName
                    for (let i = 0; i < this.luckyrule.length; i++) {
                        if (this.luckyrule[i].id === this.selectedRule) {
                            let name = this.luckyrule[i].roleName;
                            fileName=name.slice(0,-2);
                            break;
                        }
                    }
                    modify=false;
                    const sysSupplies = response.rows;
                    this.luckysheetData = sysSupplies[0].templateContent;
                    let json_data = JSON.parse(sysSupplies[0].templateContent);
                    //luckysheet.destroy()
                    luckysheet.create({
                        container: "luckysheet", // Luckysheet 的容器元素 ID
                        title: fileName, // Excel 文件名
                        data: json_data, // Excel 数据
                        showinfobar: false, //是否显示顶部名称栏
                        lang:'zh',
                    });
                }).catch(() => {
                    // 处理错误逻辑，这里是一个空的错误处理函数
                    this.$message.error('查询失败,发生未知错误!');
                });
            }


        },
        /** 回车事件和保存提交绑定 */
        /*handleEnter(event) {
            if (event.keyCode === 13) {
                event.preventDefault(); // 阻止默认的回车事件
                // 触发确定操作
                this.submit_from();
            }
        },*/
        /** 重置按钮操作 */
        resetQuery() {
            //刷新下拉选框内容
            fileName="新建XLSX工作表";
            this.selectedOption='';
            this.disableNextButton='';
            this.selectedRule='';
            this.luckyrule=[];
            trueORfalse=false;
            modify=false;
            uuid1='';
            //刷新luckysheet表格
            this.init();
        },
        /** Luckyexcel文档 */
        init() {
            let options = {
                container: 'luckysheet', //luckysheet为容器id
                title:'',
                lang:'zh',
                showinfobar:false,
                data:[
                    {
                        "name": "sheet1", //工作表名称
                        "color": "", //工作表颜色
                        "index": 0, //工作表索引
                        "status": 1, //激活状态
                        "order": 0, //工作表的下标
                        "hide": 0,//是否隐藏
                        "row": 8, //行数
                        "column": 10, //列数
                        "defaultRowHeight": 19, //自定义行高
                        "defaultColWidth": 73, //自定义列宽
                        "celldata": [


                        ], //初始化使用的单元格数据
                        "config": {
                            "merge": {
                            }, //合并单元格
                            "rowlen":{}, //表格行高
                            "columnlen":{}, //表格列宽
                            "rowhidden":{}, //隐藏行
                            "colhidden":{}, //隐藏列
                            "borderInfo":{

                            }, //边框
                            "authority":{}, //工作表保护
                        },
                    },
                    /*{
                      "name": "Sheet2",
                      "color": "",
                      "index": 1,
                      "status": 0,
                      "order": 1,
                      "celldata": [],
                      "config": {}
                    },
                    {
                      "name": "Sheet3",
                      "color": "",
                      "index": 2,
                      "status": 0,
                      "order": 2,
                      "celldata": [],
                      "config": {},
                    }*/
                ]

            }
            luckysheet.create(options);

        },
        /** 导入事件*/
        //导入Promise方法
        /*async handleFileChange(evt) {
            if(modify){
                this.$confirm('再次导入将会清空表内数据,是否继续操作？', '注意!!!', {
                    confirmButtonText: '确定',
                    cancelButtonText: '取消',
                    type: 'warning'
                }).then(async () => {
                    // 确认继续后刷新页面返回模板
                    getSuppliesTemplate(7).then(response => {
                        const sysSupplies = response.rows;
                        this.luckysheetData = sysSupplies[0].templateContent;
                        let json_data = JSON.parse(sysSupplies[0].templateContent);
                        //luckysheet.destroy()
                        luckysheet.create({
                            container: "luckysheet", // Luckysheet 的容器元素 ID
                            title: fileName, // Excel 文件名
                            data: json_data, // Excel 数据
                            showinfobar: false, //是否显示顶部名称栏
                            lang:'zh',
                        });
                        modify=false;
                    }).then(async ()=>{
                        //将导入数据替换保存
                        let exx;
                        this.showMask = true;
                        const cons = new Promise((resolve, reject) => {
                            LuckyExcel.transformExcelToLucky(evt, exportJson => {
                                exx = exportJson;
                                resolve(exx);
                            });
                        });
                        try {
                            const exportJson = await cons;
                            await this.summary(exportJson);

                            //this.submit(exportJson);
                        } catch (Error) {
                            this.$message({
                                message: Error.message,
                                type: "error"
                            });

                        } finally {
                            // 导入完成后关闭遮罩层
                            this.showMask = false;
                        }

                    }).catch(() => {
                        // 处理错误逻辑，这里是一个空的错误处理函数
                        this.$message.error('查询失败,模板未找到,请联系管理员进行处理!');
                    });
                }).catch(() => {
                    // 用户点击了取消按钮
                    //this.$message({type: 'info', message: '操作已取消'});
                });
            }else{
                let exx;
                this.showMask = true;
                const cons = new Promise((resolve, reject) => {
                    LuckyExcel.transformExcelToLucky(evt, exportJson => {
                        exx = exportJson;
                        resolve(exx);
                    });
                });
                try {
                    const exportJson = await cons;
                    await this.summary(exportJson);

                    this.submit(exportJson);

                } catch (Error) {
                    this.$message({
                        message: Error.message,
                        type: "error"});

                }finally {
                    // 导入完成后关闭遮罩层
                    this.showMask = false;}
            }

        },*/
        async handleFileChange(evt) {
            if(modify){
                this.$confirm('再次导入将会清空表内数据,是否继续操作？', '注意!!!', {
                    confirmButtonText: '确定',
                    cancelButtonText: '取消',
                    type: 'warning'
                }).then(async () => {
                    // 确认继续后刷新页面返回模板
                    getSuppliesTemplate(7).then(response => {
                        const sysSupplies = response.rows;
                        this.luckysheetData = sysSupplies[0].templateContent;
                        let json_data = JSON.parse(sysSupplies[0].templateContent);
                        //luckysheet.destroy()
                        luckysheet.create({
                            container: "luckysheet", // Luckysheet 的容器元素 ID
                            title: fileName, // Excel 文件名
                            data: json_data, // Excel 数据
                            showinfobar: false, //是否显示顶部名称栏
                            lang:'zh',
                        });
                        modify=false;
                    }).then(async ()=>{
                        this.showMask = true;
                        //将导入数据替换保存
                            LuckyExcel.transformExcelToLucky(evt, exportJson => {
                                this.summary(exportJson)
                                    .then(async() => {
                                        //this.submit(exportJson);
                                    })
                                    .catch(error => {
                                        this.$message({
                                            message: error.message,
                                            type: "error"
                                        });
                                        console.log(error.message);
                                        console.log("这里是最外面的地方");
                                    })
                                    .finally(() => {
                                        // 导入完成后关闭遮罩层
                                        this.showMask = false;
                                    });
                        });
                    }).catch(() => {
                        // 处理错误逻辑，这里是一个空的错误处理函数
                        this.$message.error('查询失败,模板未找到,请联系管理员进行处理!');
                    });
                }).catch(() => {
                    // 用户点击了取消按钮
                    this.$message({type: 'info', message: '操作已取消'});
                });
            }else{

                this.showMask = true;
                    LuckyExcel.transformExcelToLucky(evt, exportJson => {
                        this.summary(exportJson)
                            .then(async() => {
                                //this.submit(exportJson);
                            })
                            .catch(error => {
                                this.$message({
                                    message: error.message,
                                    type: "error"
                                });
                                console.log(error.message);
                                console.log("这里是最外面的地方");
                            })
                            .finally(() => {
                                // 导入完成后关闭遮罩层
                                this.showMask = false;
                            });
                    });


            }

        },
        /** 物料转换汇总到页面*/
        summary(exportJson){
            // 记录开始时间
            const startTime = new Date().getTime();
            let sysRulez;
            let sysRules;
            let sysConver;
            let value=[];
            let data;
            //获取规则  sysRulez是物料转换  sysRules是数据汇总规则  13
            for(let i=0;i<rule.length;i++){
                if (rule[i].convertStatus==1){
                    sysRulez = JSON.parse(rule[i].detailContent);
                }
                if(rule[i].convertStatus==2){
                    if (parseInt(rule[i].detailYS)===1){
                        sysConver = JSON.parse(rule[i].detailContent)
                    }else {
                        sysRules = JSON.parse(rule[i].detailContent);
                    }
                }
            }
            try {
                //获取物料转换的sheet表
                data=window.luckysheet.transToData(exportJson.sheets[sysRulez[0].se].celldata);
            }
            catch (err){
                throw new Error("导入失败,所选文件或规则有误");
            }
            //获取物料转换中导入表的列,用来获取物料名
            let key_i=parseInt(sysRulez[0].ce);
            //获取物料转换的数据
            for (let i=0;i<sysRules.length;i++){
                //value.push(data[sysRules[i].re][sysRules[i].ce].m);
                value.push(sysRules[i].ce);
            }

            return new Promise((resolve, reject) => {
                const asyncTasks = [];
                switch (tempId) {
                    case 2:
                    {
                        let departmentMap = new Map();
                        let departments = [];
                        departmentMap.set('原煤', ['综一队', '综二队', '综三队', '开一区', '开二区', '准备一区', '准备二区', '掘进一区', '掘进二区', '掘进三区', '开拓项目部', '巷修区', '井运区', '通风区', '机电运转中心', '皮带运输中心']);
                        departmentMap.set('风选煤', '洗煤厂');
                        departmentMap.set('制造费用', ['机电检修中心', '地测科', '设备管理科', '旧品利用中心', '机修加工中心', '网络安全与信息通讯中心', '保卫科', '煤质管理科', '迁建科', '综合服务中心']);
                        departmentMap.set('管理费用', ['财务部', '综合办公室', '纪委监察科', '工会', '团委', '安全管理部', '经营管理部', '党委组织部（人力资源部）', '党委宣传部', '生产技术部', '机电运输部', '科协', '节能环保法律办公室', '党委组织部', '人力资源部']);
                        try{
                            for (let i = parseFloat(sysRulez[0].re) + 1; i < data.length; i++) {
                                let n = parseInt(sysRules[0].ce) + 2;
                                if (data[i][key_i] != null && data[i][n] != null) {
                                    let num = data[i][n].m;
                                    //根据得到的num,找到对应的key
                                    let keyy = getKeyByValue(departmentMap, num);
                                    departments.push(keyy);
                                } else {
                                    departments.push(null);
                                }
                            }

                        }catch(err){
                            throw new Error("导入失败,导入文件与模板规则不匹");
                        }
                        for (let key of departmentMap.keys()) {

                            let map = new Map();
                            let smallMat = [];

                            try {
                                for (let i = parseFloat(sysRulez[0].re) + 1; i < data.length; i++) {

                                    if (data[i][key_i] != null && departments[i - 1] === key) {
                                        let num = data[i][key_i].m;
                                        smallMat.push(num);
                                    } else {
                                        smallMat.push(null);
                                    }
                                }
                            }catch(err){
                                throw new Error("导入失败,导入文件与模板规则不匹");
                            }

                            asyncTasks.push(
                                new Promise((innerResolve, innerReject) => {
                                    const allNull = smallMat.every(item =>item===null);
                                    if (allNull ) {
                                        throw new Error("导入失败,导入文件错误,所选文件与模板规则不匹");
                                    }
                            materialConvert(smallMat)
                                .then(response => {
                                    let array = response.rows;

                                    //luckysheet.setCellValue(12, 1, {bg:"#FF0000"})
                                    for (let i = parseFloat(sysRulez[0].re) + 1; i < data.length; i++) {
                                        let values = [];
                                        if (data[i][13] != null && departments[i - 1] === key && data[i][key_i] != null) {
                                            for (let j = 0; j < value.length; j++) {
                                                try{
                                                    let a = parseFloat(data[i][value[j]].v);
                                                    values.push(a);
                                                }catch (err){
                                                    throw new Error("导入失败,导入文件不匹");
                                                }

                                            }
                                            //插入多个value的值
                                            let index = smallMat.indexOf(data[i][key_i].m);
                                            let key = array[index];
                                            if (map.has(key)) {
                                                let oldValues = map.get(key);
                                                for (let i = 0; i < values.length; i++) {
                                                    values[i] = parseFloat(parseFloat(values[i] + oldValues[i]).toFixed(2));
                                                }
                                                map.set(key, values);
                                            } else {
                                                map.set(key, values);
                                            }
                                        }
                                    }
                                    //循环得到汇总结果

                                    if (map.size === 0) {
                                        throw new Error("导入失败,导入文件错误");
                                    }
                                    let cells;
                                    let warn;
                                    let rowss = luckysheet.find(key);
                                    if (rowss.length != 0) {
                                        for (let i = 0; i < sysRules.length; i++) {
                                            map.forEach((value, key) => {
                                                let searchResult = luckysheet.find(key);
                                                if (searchResult.length != 0 && key != null) {
                                                    cells = searchResult[0].column;
                                                    luckysheet.setCellValue(rowss[0].row, cells, value[i]);
                                                    luckysheet.setCellValue(rowss[0].row, cells, {
                                                        "ct": {
                                                            "fa": "General",
                                                            "t": "n"
                                                        }
                                                    });
                                                }else{
                                                    warn++;
                                                }
                                            });
                                        }
                                    }
                                    if (warn / sysRules.length === map.size) {
                                        throw new Error("导入文件与所选模板规则不匹配");
                                    } else if (warn > 0) {
                                        this.$message({
                                            message: "还有"+warn/sysRules.length+"条大类未能匹配到",
                                            type: "warning"});
                                    }
                                    resolve(response.rows);
                                    innerResolve(); // 标记当前异步任务完成

                                }).catch(Error => {

                                //必须加,不能删除
                                innerReject(Error); // 异步请求出错
                            });
                                }));
                        }
                    }
                        break;
                    case 6: {
                        let deps = [];
                        let exps = [];
                        let map = new Map();
                        let smallMat = [];
                        try{
                            for (let i = parseFloat(sysRulez[0].re) + 1; i < data.length; i++) {
                                if (data[i][key_i] != null) {
                                    let num = data[i][key_i].m;
                                    let dep = data[i][1].m;
                                    let exp = data[i][14].m;
                                    smallMat.push(num);
                                    deps.push(dep);
                                    exps.push(exp);
                                } else {
                                    smallMat.push(null);
                                    deps.push(null);
                                    exps.push(null);
                                }
                            }
                        }catch(err){
                            throw new Error("导入失败,导入文件与模板规则不匹");
                        }

                        asyncTasks.push(
                            new Promise((innerResolve, innerReject) => {
                                const allNull = smallMat.every(item =>item===null);
                                const allNull1 = deps.every(item =>item===null);
                                const allNull2 = exps.every(item =>item===null);
                                if (allNull || allNull1 ||allNull2) {
                                    throw new Error("导入失败,导入文件错误,所选文件与模板规则不匹");
                                }

                                materialConvert(smallMat)
                                    .then(response => {

                                        let array = response.rows;
                                        //console.log(array);
                                        //luckysheet.setCellValue(12, 1, {bg:"#FF0000"})
                                        for (let i = parseFloat(sysRulez[0].re) + 1, k = 0; i < data.length; i++, k++) {
                                            let values = [];
                                            if (data[i][key_i] != null) {
                                                for (let j = 0; j < value.length; j++) {
                                                    try{
                                                        let a = parseFloat(data[i][value[j]].v);
                                                        values.push(a);
                                                    }catch(err){
                                                        throw new Error("导入失败,导入文件不匹");
                                                    }

                                                }
                                                //插入多个value的值
                                                let key = exps[k] + '/' + deps[k] + '/' + array[k];
                                                if (map.has(key)) {
                                                    let oldValues = map.get(key);
                                                    for (let i = 0; i < values.length; i++) {
                                                        values[i] = parseFloat(parseFloat(values[i] + oldValues[i]).toFixed(2));
                                                    }
                                                    map.set(key, values);
                                                } else {
                                                    map.set(key, values);
                                                }
                                            }

                                        }
                                        //循环得到汇总结果
                                        console.log(map);
                                        if (map.size === 0) {
                                            throw new Error("导入失败,导入文件错误");
                                        }
                                        //循环得到汇总结果
                                        let cells;
                                        let rowws;
                                        let con=0;
                                        let warn=0;
                                        for (let i = 0; i < sysRules.length; i++) {
                                            map.forEach((value, key) => {
                                                const suffixArr = key.split('/'), mat = suffixArr[2], depp = suffixArr[1],
                                                    expp = suffixArr[0];
                                                //console.log(expp);console.log(depp);console.log(mat);
                                                let searchResult = luckysheet.find(expp);
                                                if (searchResult.length !== 0 ) {
                                                    rowws = searchResult[0].row;
                                                    for (let i = 1; i < 10000000000000000000000000; i++) {
                                                        let n = rowws + i;
                                                        let gg = luckysheet.getCellValue(n, 0);
                                                        if (gg!==null) {
                                                            con = rowws + i;
                                                            break;
                                                        }
                                                    }
                                                    searchResult= luckysheet.find(depp);
                                                    if(searchResult.length !== 0 ){

                                                        let k=0;
                                                        let r;
                                                        for(let i=0;i<searchResult.length;i++){
                                                            r = searchResult[i].row;

                                                            if(r<con&&r>=rowws){
                                                                k=1;
                                                                break;
                                                            }
                                                        }
                                                        if(k===1){
                                                            let matResult = luckysheet.find(mat);
                                                            if (matResult.length !== 0 && mat != null) {
                                                                cells = matResult[0].column;
                                                                luckysheet.setCellValue(r, cells, value[i]);
                                                                luckysheet.setCellValue(r, cells, {
                                                                    "ct": {
                                                                        "fa": "General",
                                                                        "t": "n"
                                                                    }
                                                                });
                                                            }else{
                                                                warn++;
                                                            }
                                                        }else{
                                                            warn++;
                                                        }
                                                    }

                                                }else{
                                                    warn++;
                                                }
                                            });
                                            if (warn / sysRules.length === map.size) {
                                                throw new Error("导入文件与所选模板规则不匹配");
                                            } else if (warn > 0) {
                                                this.$message({
                                                    message: "还有"+warn/sysRules.length+"条大类未能匹配到",
                                                    type: "warning"});
                                            }
                                            resolve(response.rows);
                                            innerResolve(); // 标记当前异步任务完成
                                        }

                                    }).catch(Error => {

                                    //必须加,不能删除
                                    innerReject(Error); // 异步请求出错
                                });
                            }));

                    }
                        break;
                    case 1: {
                        let map = new Map();
                        let smallMat = [];
                        try{
                            for (let i = parseInt(sysRulez[0].re) + 1; i < data.length; i++) {
                                if (data[i][key_i] != null) {
                                    let num = data[i][key_i].m;
                                    smallMat.push(num);
                                } else {
                                    smallMat.push(null);
                                }
                            }
                            for (let j = 0; j < value.length; j++) {
                                if (data[sysRulez[0].re][value[j]] != null) {
                                    let num = data[sysRulez[0].re][value[j]].m;
                                    smallMat.push(num);
                                } else {
                                    smallMat.push(null);
                                }
                            }
                        }catch(err){
                            throw new Error("导入失败,导入文件与模板规则不匹");
                        }
                        //console.log(smallMat);
                        asyncTasks.push(
                            new Promise((innerResolve, innerReject) => {
                                const allNull = smallMat.every(item =>item===null);
                                if (allNull ) {
                                    throw new Error("导入失败,导入文件错误,所选文件与模板规则不匹");
                                }
                                materialConvert(smallMat)
                                    .then(response => {
                                        let array = response.rows;
                                        //console.log(array);
                                        //luckysheet.setCellValue(12, 1, {bg:"#FF0000"})
                                        for (let i = parseInt(sysRulez[0].re) + 1; i < data.length; i++) {
                                            let values = [];
                                            if (data[i][key_i] != null) {
                                                for (let j = 0; j < value.length; j++) {
                                                    try{
                                                        let a = parseFloat(data[i][value[j]].v);
                                                        if (isNaN(a)) {
                                                            a = 0;
                                                        }
                                                        values.push(a);
                                                    }catch (err){
                                                        throw new Error("导入失败,导入文件不匹");
                                                    }
                                                }
                                            } else {
                                                break;
                                            }
                                            //插入多个value的值
                                            let index = smallMat.indexOf(data[i][key_i].m);
                                            let key = array[index];
                                            if (map.has(key)) {
                                                let oldValues = map.get(key);
                                                for (let i = 0; i < values.length; i++) {
                                                    values[i] = parseFloat(parseFloat(parseFloat(values[i]) + parseFloat(oldValues[i])).toFixed(2));
                                                }
                                                map.set(key, values);
                                            } else {
                                                map.set(key, values);
                                            }
                                        }
                                        if (map.size === 0) {
                                            throw new Error("导入失败,导入文件错误");
                                        }
                                        //循环得到汇总结果
                                        let row;
                                        let con;
                                        let warn=0;
                                        //console.log(map);
                                        map.forEach((value,key)=>{
                                            let searchResult;
                                            searchResult= luckysheet.find(key);
                                            if( searchResult==undefined ||searchResult.length === 0 || key === null){
                                                warn++;
                                            }
                                        })
                                        if (warn  === map.size) {
                                            throw new Error("导入文件与所选模板规则不匹配");
                                        }
                                        for (let i = 0; i < sysRules.length; i++) {
                                            map.forEach((value, key) => {

                                                let matchingCells = [];
                                                let name = data[sysRules[i].re][sysRules[i].ce].m
                                                if (name.includes("洗煤")) {
                                                    row = sysRules[i].rt;
                                                    con = parseInt(sysRules[i].rt) + 10;
                                                } else {
                                                    row = sysRules[i].rt;
                                                    con = 54;
                                                }
                                                for (; row <= con; row++) {
                                                    let cellValue = luckysheet.getCellValue(row, parseInt(sysRulez[0].ct));
                                                    if (cellValue === null) {
                                                    } else {
                                                        if (cellValue.includes(key)) {
                                                            luckysheet.setCellValue(row, sysRules[i].ct, value[i]);
                                                            luckysheet.setCellValue(row, sysRules[i].ct, {
                                                                "ct": {
                                                                    "fa": "General",
                                                                    "t": "n"
                                                                }
                                                            });
                                                            break;
                                                        }else{
                                                        }
                                                    }
                                                }
                                            });
                                        }
                                        let value2 = [];
                                        let map2 = new Map;
                                        for (let i = 0; i < sysConver.length; i++) {
                                            //value.push(data[sysRules[i].re][sysRules[i].ce].m);
                                            value2.push(sysConver[i].ce);
                                        }
                                        for (let i = parseInt(sysRulez[0].re) + 1; i < data.length; i++) {
                                            let values2 = [];
                                            if (data[i][key_i] != null) {
                                                for (let j = 0; j < value2.length; j++) {
                                                    try{
                                                        let a = parseFloat(data[i][value2[j]].v);
                                                        if (isNaN(a)) {
                                                            a = 0;
                                                        }
                                                        values2.push(a);
                                                    }catch (err){
                                                        throw new Error("导入失败,导入文件不匹");
                                                    }
                                                }
                                            } else {
                                                break;
                                            }
                                            //插入多个value的值
                                            let key = data[sysConver[0].re][sysConver[0].ce].v;
                                            if (map2.has(key)) {
                                                let oldValues = map2.get(key);
                                                for (let i = 0; i < values2.length; i++) {
                                                    values2[i] = parseFloat(parseFloat(parseFloat(values2[i]) + parseFloat(oldValues[i])).toFixed(2));
                                                }
                                                map2.set(key, values2);
                                            } else {
                                                map2.set(key, values2);
                                            }
                                        }
                                        if (map2.size === 0) {
                                            throw new Error("导入失败,导入文件错误");
                                        }
                                        //console.log(map2);
                                        map2.forEach((value, key) => {
                                            let searchResult;
                                            searchResult= luckysheet.find(key);
                                            if( searchResult!==undefined && searchResult.length !== 0 || key !== null){
                                                for (let i = 0; i < value.length; i++) {
                                                    luckysheet.setCellValue(searchResult[0].row, sysConver[i].ct, value[i]);
                                                    luckysheet.setCellValue(searchResult[0].row, sysConver[i].ct, {
                                                        "ct": {
                                                            "fa": "General",
                                                            "t": "n"
                                                        }
                                                    });
                                                }
                                            }else{
                                                warn++;
                                            }
                                        })
                                        if (warn  === map.size+map2.size) {
                                            throw new Error("导入文件与所选模板规则不匹配");
                                        } else if (warn > 0) {
                                            this.$message({
                                                message: "还有"+warn+"条大类未能匹配到",
                                                type: "warning"});
                                        }
                                        resolve(response.rows);
                                        innerResolve(); // 标记当前异步任务完成
                                    }).catch(Error => {
                                    console.log("这里是单个异步请求出错处");
                                    //必须加,不能删除
                                    innerReject(Error); // 异步请求出错
                                });
                            }));
                    }
                        break;
                    //李志昊版
                    case 7: {
                        let map = new Map();
                        let smallMat = [];
                        let newsmallMat=[];
                        let p=0;
                        let deps = [];
                        try {
                            for (let i = parseFloat(sysRulez[0].re) + 1; i < data.length; i++) {
                                if (data[i][sysRulez[1].ce] != null && data[i][key_i] != null) {
                                    let num = data[i][key_i].m;
                                    let dep = data[i][sysRulez[1].ce].m;
                                    smallMat.push(num);
                                    newsmallMat.push({'index':p,'code':num});
                                    p++;
                                    deps.push(dep);
                                } else {
                                    smallMat.push(null);
                                    deps.push(null);
                                }
                            }
                        }catch(err){
                            throw new Error("导入失败,导入文件与模板规则不匹");
                        }
                        asyncTasks.push(
                            new Promise((innerResolve, innerReject) => {
                                const allNull = smallMat.every(item =>item===null);
                                if (allNull ) {
                                    throw new Error("导入失败,导入文件错误,所选文件与模板规则不匹");
                                }
                                function sortArray(array) {
                                    array.sort((a, b) => b.code.length - a.code.length)
                                    return array
                                }

                                materialList().then(response => {
                                    /*let SixMateriel=[];
                                    let MaterielCode=[];
                                    let NewMarterielCode=[];
                                    let SixList=[];
                                    let newSmasll =newsmallMat;
                                    let m=0
                                    SixMateriel=response.rows.slice(92,246);
                                    for(var i=0;i<SixMateriel.length;i++){
                                        if(SixMateriel[i].code!==null){
                                            MaterielCode.push(SixMateriel[i])
                                        }
                                    }
                                    NewMarterielCode= sortArray(MaterielCode)
                                    for (let i = 0; i < NewMarterielCode.length; i++) {
                                        for (let j = 0; j < newSmasll.length; j++) {
                                            if(newSmasll[j] !== null){
                                                m++
                                                if (NewMarterielCode[i].code==newSmasll[j].code.slice(0,NewMarterielCode[i].code.length)) {
                                                    SixList[newSmasll[j].index]=NewMarterielCode[i].codes;
                                                    newSmasll.splice(j,1);
                                                    j--;
                                                }
                                            }
                                        }
                                    }
                                    //console.log(newSmasll)
                                    for (let k = 0; k < newSmasll.length; k++) {
                                        SixList[newSmasll[k].index]='11';
                                        m++;
                                    }
                                    //console.log(m)
                                    //console.log(SixList,'1231231231231')
                                    this.NewSixList=SixList*/

                                    let SixMateriel=[];
                                    let MaterielCode=[];
                                    let NewMarterielCode=[];
                                    let SixList=[];
                                    let newSmasll =smallMat;
                                    SixMateriel=response.rows;
                                    NewMarterielCode= sortArray(SixMateriel)
                                    console.log("新的转换规则有"+NewMarterielCode.length+"条");
                                    // //转化编码
                                    let p=0;
                                    for(var i=0;i<newSmasll.length;i++){
                                        for (var j = 0; j < NewMarterielCode.length; j++) {
                                            if(newSmasll[i] !== null){
                                                if(newSmasll[i].slice(0,NewMarterielCode[j].code.length)==NewMarterielCode[j].code){
                                                    SixList[i]=NewMarterielCode[j].codes
                                                    p++
                                                    break
                                                }else{
                                                    SixList[i]='11'
                                                    p++
                                                }
                                            }
                                        }
                                    }
                                    console.log(p)
                                    let newSixList=SixList
                                    console.log(newSixList)


                                    for (let i = parseFloat(sysRulez[0].re) + 1, k = 0; i < data.length; i++, k++) {
                                        let values = [];
                                        if (data[i][key_i] != null) {
                                            for (let j = 0; j < value.length; j++) {
                                                try {
                                                    let a = parseFloat(data[i][value[j]].v);
                                                    values.push(a);
                                                } catch (err) {
                                                    this.$message({
                                                        message: "导入失败,导入文件不匹",
                                                        type: "error"
                                                    });
                                                    innerReject(error); // 异步请求出错
                                                }
                                            }
                                            //console.log(SixList)
                                            let key = SixList[k] + '/' + deps[k];
                                            if (map.has(key)) {
                                                let oldValues = map.get(key);
                                                for (let i = 0; i < values.length; i++) {
                                                    values[i] = parseFloat(parseFloat(values[i] + oldValues[i]).toFixed(2));
                                                }
                                                map.set(key, values);
                                            } else {
                                                map.set(key, values);
                                            }
                                        }

                                    }
                                    console.log(map);
                                    //循环得到汇总结果
                                    if (map.size === 0) {
                                        throw new Error("导入失败,导入文件错误");
                                    }
                                    //返回单元格第二行的数据
                                    //let celn=luckysheet.getcellvalue(1);
                                    //返回当前工作表第1列数据
                                    //let cown=luckysheet.getcellvalue(null,0);
                                    let config;
                                    let bord = {
                                        "rangeType": "range",
                                        "borderType": "border-all",
                                        "style": "1",
                                        "color": "#000000",
                                        "range": [{
                                            "row": [0, 0],
                                            "column": [0, 0]
                                        }]
                                    }
                                    let warn = 0;
                                    map.forEach((value, key) => {
                                        let rowws;
                                        const suffixArr = key.split('/'), mat = suffixArr[0], depp = suffixArr[1];
                                        //返回当前工作表第1列数据
                                        let cown=luckysheet.getcellvalue(null,0);
                                        for(let i=0;i<cown.length;i++){
                                            if(cown[i]==null){
                                                continue;
                                            }
                                            if(cown[i].v==undefined){
                                                continue;
                                            }
                                            if(cown[i].v==mat){
                                                rowws=i;
                                                break;
                                            }
                                        }
                                        //let searchResult = luckysheet.find(mat,{isWholeWord:true});
                                        if (rowws != undefined) {
                                            //rowws = searchResult[0].row;
                                            luckysheet.insertRow(rowws + 1);
                                            let vll1 = luckysheet.getCellValue(rowws, sysRulez[0].ct);
                                            luckysheet.setCellValue(rowws + 1, sysRulez[0].ct, {
                                                "ct": {
                                                    "fa": "@",
                                                    "t": "n"
                                                }
                                            });
                                            luckysheet.setCellValue(rowws + 1, sysRulez[0].ct, vll1);
                                            let vll2 = luckysheet.getCellValue(rowws, parseInt(sysRulez[0].ct) + 1);
                                            luckysheet.setCellValue(rowws + 1, parseInt(sysRulez[0].ct) + 1, vll2);
                                            //输出部门数量金额
                                            luckysheet.setCellValue(rowws + 1, sysRulez[1].ct, depp);
                                            for (let i = 0; i < sysRules.length; i++) {
                                                luckysheet.setCellValue(rowws + 1, sysRules[i].ct, value[i]);
                                                //修改单元格样式
                                                /*luckysheet.setCellValue(rowws+g, sysRules[i].ct, {
                                                "ct": {
                                                    "fa": "General",
                                                    "t": "n"
                                                }
                                            });*/
                                            }
                                            //输出单价
                                            luckysheet.setCellValue(rowws + 1, parseInt(sysRules[0].ct) + 1, value[1] / value[0]);
                                            //修改单价样式
                                            /*luckysheet.setCellValue(rowws+g,parseInt(sysRules[0].ct)+1,{
                                            "ct": {
                                                "fa": "0.0000",
                                                "t": "n"
                                            }
                                        });*/
                                            config = luckysheet.getConfig(0);
                                            bord.range[0].row = [rowws + 1, rowws + 1];
                                            bord.range[0].column = [0, parseInt(sysRules[sysRules.length - 1].ct)];
                                            config.borderInfo.push(bord);
                                            luckysheet.setConfig(config);
                                            modify = true;
                                        } else {
                                            warn++;
                                        }
                                    });
                                    if (warn === map.size) {
                                        throw new Error("导入文件与所选模板规则不匹配");
                                    } else if (warn > 0) {
                                        this.$message({
                                            message: "还有" + warn + "条大类未能匹配到",
                                            type: "warning"
                                        });
                                    }
                                    // 记录结束时间
                                    const endTime = new Date().getTime();
                                    // 计算执行时间（以毫秒为单位）
                                    const executionTime = endTime - startTime;
                                    // 输出执行时间
                                    console.log(`代码执行时间：${executionTime} 毫秒`);
                                    resolve(response.rows);
                                    innerResolve(); // 标记当前异步任务完成

                                    /*let find1 = luckysheet.find("合计");
                                let number = parseInt(find1[0].row)-1;
                                luckysheet.setCellValue(find1[0].row, sysRules[sysRules.length-1].ct, "=SUM(F2:F"+number+")")*/

                                }).catch(Error => {

                                    //必须加,不能删除
                                    innerReject(Error); // 异步请求出错
                                });
                            }));
                    }
                        break;
                    //张凯林版本
                    /*case 7: {
                        let map = new Map();
                        let smallMat = [];
                        let deps = [];
                        let t = 0;
                        try {
                            for (let i = parseFloat(sysRulez[0].re) + 1; i < data.length; i++) {
                                if (data[i][sysRulez[1].ce] != null && data[i][key_i] != null) {
                                    let num = data[i][key_i].m;
                                    let dep = data[i][sysRulez[1].ce].m;
                                    smallMat.push({index:t,code:num});
                                    deps.push(dep);
                                    t++;
                                } else {

                                }
                            }
                            //console.log("smallMat="+smallMat);
                        }catch(err){
                            throw new Error("导入失败,导入文件与模板规则不匹");
                        }
                        asyncTasks.push(
                            new Promise((innerResolve, innerReject) => {
                                const allNull = smallMat.every(item =>item===null);
                                if (allNull ) {
                                    throw new Error("导入失败,导入文件错误,所选文件与模板规则不匹");
                                }
                                //一部分报表的数据
                                //console.log('----->',smallMat);


                                materialList().then( response => {
                                    //六矿物料编码数据
                                    // console.log(response.rows,'ymy');
                                    let array = response.rows;
                                    //有code的数据
                                    // console.log(array,"<-------->");
                                    //六矿六位编码
                                    let newSix = [];
                                    for (let i = 0; i < array.length; i++) {
                                        if(array[i].code.length==6){
                                            newSix.push(array[i]);
                                        }
                                    }
                                    // console.log('6666666666666',newSix);
                                    //六矿四位编码
                                    let newFour = [];
                                    for (let u = 0; u < array.length; u++) {
                                        if(array[u].code.length==4){
                                            newFour.push(array[u]);
                                        }
                                    }
                                    // console.log('444444444444444',newFour);
                                    //六矿二位编码
                                    let newTwo = [];
                                    for (let l = 0; l < array.length; l++) {
                                        if(array[l].code.length==2){
                                            newTwo.push(array[l]);
                                        }
                                    }
                                    // console.log('22222222222222',newTwo);
                                    //转换六位
                                    let a = [];
                                    for (let h = 0; h < smallMat.length; h++) {
                                        for (let s = 0; s < newSix.length; s++) {
                                            if(smallMat[h].code.slice(0,6) == newSix[s].code){
                                                smallMat[h].code = newSix[s].codes;
                                                a.push(smallMat[h]);
                                            }
                                        }
                                    }
                                    //console.log('ssssssssss',a);
                                    //删除方法
                                    const result = smallMat.filter(item => item.code.length <= 4).map(item =>({index:item.index,code:item.code}) );
                                    let i = 0;
                                    while (i < smallMat.length) {
                                        if (smallMat[i].code.length <= 4) {
                                            smallMat[i] = smallMat[smallMat.length - 1];
                                            smallMat.length--;
                                        } else {
                                            i++;
                                        }
                                    }
                                    //console.log(smallMat);
                                    //转换四位
                                    let b = [];
                                    for (let h = 0; h < smallMat.length; h++) {
                                        for (let s = 0; s < newFour.length; s++) {
                                            if(smallMat[h].code.slice(0,4) == newFour[s].code){
                                                smallMat[h].code = newFour[s].codes;
                                                b.push(smallMat[h]);
                                            }
                                        }

                                    }
                                    //console.log('fffffffffffff',b);
                                    //console.log('原数组',smallMat);
                                    let uniqueB = [...new Set(b.map(obj => obj.index))].map(index => b.find(obj => obj.index === index));
                                    // 622
                                    //console.log('fffffffffffff', uniqueB);

                                    //删除方法
                                    const re = smallMat.filter(item => item.code.length <= 4).map(item =>({index:item.index,code:item.code}) );
                                    let ii = 0;
                                    while (ii < smallMat.length) {
                                        if (smallMat[ii].code.length == 4) {
                                            smallMat[ii] = smallMat[smallMat.length - 1];
                                            smallMat.length--;
                                        } else {
                                            ii++;
                                        }
                                    }
                                    //console.log(smallMat);

                                    //转换二位
                                    let c = [];
                                    for (let h = 0; h < smallMat.length; h++) {
                                        for (let s = 0; s < newTwo.length; s++) {
                                            if(smallMat[h].code.slice(0,2) == newTwo[s].code){
                                                smallMat[h].code = newTwo[s].codes;
                                                c.push(smallMat[h]);
                                            }
                                        }
                                    }
                                    //console.log('tttttttttt',c);
                                    //删除方法
                                    const sult = smallMat.filter(item => item.code.length <= 4).map(item =>({index:item.index,code:item.code}) );
                                    let iii = 0;
                                    while (iii < smallMat.length) {
                                        if (smallMat[iii].code.length <= 4) {
                                            smallMat[iii] = smallMat[smallMat.length - 1];
                                            smallMat.length--;
                                        } else {
                                            iii++;
                                        }
                                    }
                                    //console.log(smallMat);
                                    //转换其他
                                    for (let other = 0; other < smallMat.length; other++) {
                                        if( smallMat[other].code.length == '10'){
                                            smallMat[other].code = 11;
                                        }
                                    }
                                    //console.log(smallMat);
                                    //合并
                                    let newSmallMat = [...a,...uniqueB,...c,...smallMat];
                                    //console.log(newSmallMat);
                                    //索引排序
                                    function newSort(arr){
                                        arr.sort((a,b) => a.index - b.index)
                                        return arr;
                                    }
                                    let newSortArray = newSort(newSmallMat);
                                    //console.log(newSortArray);
                                    for (let i = parseFloat(sysRulez[0].re) + 1, k = 0; i < data.length; i++, k++) {
                                        let values = [];
                                        if (data[i][key_i] != null) {
                                            for (let j = 0; j < value.length; j++) {
                                                try{
                                                    let a = parseFloat(data[i][value[j]].v);
                                                    values.push(a);
                                                }catch (err){
                                                    this.$message({
                                                        message: "导入失败,导入文件不匹",
                                                        type: "error"
                                                    });
                                                    innerReject(error); // 异步请求出错
                                                }

                                            }
                                            //插入多个value的值
                                            //此方法只适用于一对一唯一值
                                            /!*let index = smallMat.indexOf(data[i][key_i].m);
                                        let key = array[index];*!/
                                            let key = newSortArray[k].code + '/' + deps[k];
                                            if (map.has(key)) {
                                                let oldValues = map.get(key);
                                                for (let i = 0; i < values.length; i++) {
                                                    values[i] = parseFloat(parseFloat(values[i] + oldValues[i]).toFixed(2));
                                                }
                                                map.set(key, values);
                                            } else {
                                                map.set(key, values);
                                            }
                                        }

                                    }
                                    //循环得到汇总结果
                                    console.log(map);
                                    if (map.size === 0) {
                                        throw new Error("导入失败,导入文件错误");
                                    }
                                    //返回单元格第二行的数据
                                    //let celn=luckysheet.getcellvalue(1);
                                    //返回当前工作表第1列数据
                                    //let cown=luckysheet.getcellvalue(null,0);
                                    let rowws;
                                    let config;
                                    let bord = {
                                        "rangeType": "range",
                                        "borderType": "border-all",
                                        "style": "1",
                                        "color": "#000000",
                                        "range": [{
                                            "row": [0, 0],
                                            "column": [0, 0]
                                        }]
                                    }
                                    let warn=0;
                                    map.forEach((value, key) => {
                                        const suffixArr = key.split('/'), mat = suffixArr[0], depp = suffixArr[1];
                                        //console.log(mat);console.log(depp);
                                        let searchResult = luckysheet.find(mat);
                                        if (searchResult.length != 0 && key != null) {
                                            rowws = searchResult[0].row;
                                            luckysheet.insertRow(rowws + 1);
                                            let vll1=luckysheet.getCellValue(rowws,sysRulez[0].ct);
                                            luckysheet.setCellValue(rowws+1, sysRulez[0].ct, {
                                                "ct": {
                                                    "fa": "@",
                                                    "t": "n"
                                                }
                                            });
                                            luckysheet.setCellValue(rowws + 1, sysRulez[0].ct, vll1);
                                            let vll2=luckysheet.getCellValue(rowws,parseInt(sysRulez[0].ct)+1);
                                            luckysheet.setCellValue(rowws + 1, parseInt(sysRulez[0].ct)+1, vll2);
                                            //输出部门数量金额



                                            luckysheet.setCellValue(rowws + 1, sysRulez[1].ct, depp);
                                            for (let i = 0; i < sysRules.length; i++) {
                                                luckysheet.setCellValue(rowws + 1, sysRules[i].ct, value[i]);
                                                //修改单元格样式
                                                /!*luckysheet.setCellValue(rowws+g, sysRules[i].ct, {
                                                "ct": {
                                                    "fa": "General",
                                                    "t": "n"
                                                }
                                            });*!/
                                            }
                                            //输出单价
                                            luckysheet.setCellValue(rowws + 1, parseInt(sysRules[0].ct) + 1, value[1] / value[0]);
                                            //修改单价样式
                                            /!*luckysheet.setCellValue(rowws+g,parseInt(sysRules[0].ct)+1,{
                                            "ct": {
                                                "fa": "0.0000",
                                                "t": "n"
                                            }
                                        });*!/
                                            config = luckysheet.getConfig(0);
                                            bord.range[0].row = [rowws + 1, rowws + 1];
                                            bord.range[0].column = [0, parseInt(sysRules[sysRules.length - 1].ct)];
                                            config.borderInfo.push(bord);
                                            luckysheet.setConfig(config);
                                            modify=true;
                                        } else{
                                            warn++;
                                        }
                                    });
                                    if (warn === map.size) {
                                        throw new Error("导入文件与所选模板规则不匹配");
                                    } else if (warn > 0) {
                                        this.$message({
                                            message: "还有"+warn+"条大类未能匹配到",
                                            type: "warning"});
                                    }
                                    const endTime = new Date();
                                    // 计算执行时间（以毫秒为单位）
                                    const executionTime = endTime - startTime;
                                    // 输出执行时间
                                    console.log(`代码执行时间：${executionTime} 毫秒`);
                                    resolve(response.rows);
                                    innerResolve(); // 标记当前异步任务完成
                                    /!*let find1 = luckysheet.find("合计");
                                let number = parseInt(find1[0].row)-1;
                                luckysheet.setCellValue(find1[0].row, sysRules[sysRules.length-1].ct, "=SUM(F2:F"+number+")")*!/
                                }).catch(Error => {
                                    console.log("这里是单个异步请求出错处");
                                    //必须加,不能删除
                                    innerReject(Error); // 异步请求出错
                                });
                            }));

                    }
                        break;*/
                    default :
                    {
                        let map = new Map();
                        let smallMat = [];
                        try{
                        for (let i = parseFloat(sysRulez[0].re) + 1; i < data.length; i++) {
                            if (data[i][key_i] != null) {
                                let num = data[i][key_i].m;
                                smallMat.push(num);
                            } else {
                                smallMat.push(null);
                            }
                        }
                        } catch(err){
                                throw new Error("导入失败,导入文件与模板规则不匹");
                            }
                        asyncTasks.push(
                            new Promise((innerResolve, innerReject) => {
                                const allNull = smallMat.every(item =>item===null);
                                if (allNull ) {
                                    throw new Error("导入失败,导入文件错误,所选文件与模板规则不匹");
                                }
                                materialConvert(smallMat)
                                    .then(response => {
                                        let array = response.rows;
                                        for (let i = parseFloat(sysRulez[0].re) + 1; i < data.length; i++) {
                                            let values = [];
                                            let index;
                                            if (data[i][key_i] != null) {
                                                for (let j = 0; j < value.length; j++) {
                                                    try{
                                                        let a = parseFloat(data[i][value[j]].v);
                                                        values.push(a);
                                                    }catch (err){
                                                        throw new Error("导入失败,导入文件不匹");
                                                    }

                                                }
                                                //插入多个value的值
                                                index = smallMat.indexOf(data[i][key_i].m);
                                                let key = array[index];
                                                if (map.has(key)) {
                                                    let oldValues = map.get(key);
                                                    for (let i = 0; i < values.length; i++) {
                                                        values[i] = parseFloat(parseFloat(values[i] + oldValues[i]).toFixed(2));
                                                    }
                                                    map.set(key, values);
                                                } else {
                                                    map.set(key, values);
                                                }
                                            }

                                        }
                                        //循环得到汇总结果

                                        if (map.size === 0) {
                                            throw new Error("导入失败,导入文件错误");
                                        }
                                        let rowws;
                                        let warn = 0;
                                        for (let i = 0; i < sysRules.length; i++) {
                                            map.forEach((value, key) => {
                                                let searchResult;
                                                    searchResult= luckysheet.find(key);
                                                if (searchResult!==undefined && searchResult.length !== 0 && key != null) {
                                                    rowws = searchResult[0].row;
                                                    luckysheet.setCellValue(rowws, sysRules[i].ct, value[i]);
                                                    luckysheet.setCellValue(rowws, sysRules[i].ct, {
                                                        "ct": {
                                                            "fa": "General",
                                                            "t": "n"
                                                        }
                                                    });
                                                } else {
                                                    warn++;
                                                }
                                            });
                                        }
                                        if (warn / sysRules.length === map.size) {
                                            throw new Error("导入文件与所选模板规则不匹配");
                                        } else if (warn > 0) {
                                            this.$message({
                                                message: "还有"+warn/sysRules.length+"条大类未能匹配到",
                                                type: "warning"});
                                        }
                                        resolve(response.rows);
                                        innerResolve(); // 标记当前异步任务完成
                                    }).catch(Error => {

                                        //必须加,不能删除
                                    innerReject(Error); // 异步请求出错
                                });
                            }));
                    }
                        break;
                }
                //切换到想要的sheet
                luckysheet.setSheetActive(0);
                Promise.all(asyncTasks)
                    .then(() => {
                        resolve(); // 所有异步请求执行完成
                    })
                    .catch(Error => {

                        reject(Error); // 异步请求出错
                    });
            });
        },
        /** 保存导入文件和生成文件 */
        submit(contents){

            const name = contents.info.name;
            const obj=contents.sheets;
            let list=[];
            //导入文件内容转json
            let str = JSON.stringify(obj)// 对象转化为字符串
            let objsheet = luckysheet.getAllSheets() // 得到表的数据
            //生成文件转json
            let strsheet = JSON.stringify(objsheet)// 对象转化为字符串
            this.from.templateId=this.dfrom.templateId=tempId;
            this.from.importUuid=this.dfrom.importUuid=uuid1;
            this.from.roleId=this.dfrom.roleId=roleId;
            this.dfrom.historyName=name+'(导入文件)';
            this.dfrom.historyContent=str;
            this.dfrom.identifyingCode=0;

            let date = new Date(this.date);

            let fullYear = date.getFullYear();
            let month = ("0" + (date.getMonth() + 1)).slice(-2);
            let datastr = fullYear + month;
            this.dfrom.date = datastr
            this.dfrom.mining = this.mining
            this.from.status=this.dfrom.status=0;
            list.push(this.dfrom);
            this.from.historyName=fileName+'(生成文件)';
            this.from.historyContent=strsheet;
            this.from.identifyingCode=1;
            this.from.date = datastr;
            list.push(this.from);

            addInsert(list).then(response=>{
                if(response.code==200){
                    this.$message({
                        message: '保存成功', type: 'success'
                    })
                }
            });


        },
        /** 导出设置 */
        handleExport: debounce(function() {
            // 处理点击事件
            exportExcel(luckysheet.getAllSheets(),fileName,trueORfalse);

            // 清洗数据
            selectActSuppliesHistorydata().then(response => {

                var  data = response.data;

                for (let i = 0; i < data.length; i++) {
                    if(data[i].identifyingCode == 1){
                        /*生成表*/
                        let jsonDataa = JSON.parse(data[i].historyContent);
                        for (let j = 0; j < jsonDataa.length; j++) {
                            let  dataa=window.luckysheet.transToData(jsonDataa[j].celldata);
                            debugger
                            for (let k = 2; k < dataa.length; k++) {
                                if(dataa[k][1] == null){
                                    continue;
                                }
                                let a0;
                                let a1;
                                let a3;
                                let a4;
                                let a5;
                                let a6;

                                if(dataa[k][0] != null){
                                    a0= dataa[k][0].v;
                                    if(a0 == undefined){
                                        a0="";
                                    }
                                }

                                if(dataa[k][1] != null){
                                    a1= dataa[k][1].v;
                                    if(a1 == undefined){
                                        a1="";
                                    }
                                }

                                if(dataa[k][3] != null){
                                    a3= dataa[k][3].v;
                                    if(a3 == undefined){
                                        a3="";
                                    }
                                }

                                if(dataa[k][4] != null){
                                    a4= dataa[k][4].v;
                                    if(a4 == undefined){
                                        a4="";
                                    }
                                }

                                if(dataa[k][5] != null){
                                    a5= dataa[k][5].v;
                                    if(a5 == undefined){
                                        a5="";
                                    }
                                }

                                if(dataa[k][6] != null){
                                    a6= dataa[k][6].v;
                                    if(a6 == undefined){
                                        a6="";
                                    }
                                }

                                if(data[i].id != null){
                                    this.froms.hId = data[i].id;
                                    this.froms.projectId =a0;
                                    this.froms.projectName =a1;
                                    this.froms.departmentName =a3;
                                    this.froms.number =a4;
                                    this.froms.nuitPrice =a5;
                                    this.froms.money =a6;
                                    this.froms.createBy = data[i].createBy;
                                    this.froms.hDate = data[i].date;
                                    this.froms.mining = data[i].mining;
                                    addActSuppliesSixMinesSummaryTable(this.froms).then(response => {});
                                }
                            }
                        }
                    }else {
                        /*导入表*/

                        let jsonDatab = JSON.parse(data[i].historyContent);
                        for (let q = 0; q < jsonDatab.length; q++) {
                            //获取行数据
                            let  datab=window.luckysheet.transToData(jsonDatab[q].celldata);
                            for (let w = 0; w < datab.length; w++) {
                                //判断当前行是否为空
                                if(datab[w][0] == null){
                                    continue;
                                }
                                if(datab[w][0].v == null || datab[w][0].v ==undefined){
                                    continue;
                                }

                                let b1 ;
                                if(datab[w][0] != null){
                                    b1= datab[w][0].v;
                                    if(b1 == undefined){
                                        b1="";
                                    }
                                }

                                let b2 ;
                                if(datab[w][1] != null){
                                    b2= datab[w][1].v;
                                    if(b2 == undefined){
                                        b2="";
                                    }
                                }

                                let b3 ;
                                if(datab[w][2] != null){
                                    b3= datab[w][2].v;
                                    if(b3 == undefined){
                                        b3="";
                                    }
                                }

                                let b4 ;
                                if(datab[w][3] != null){
                                    b4= datab[w][3].v;
                                    if(b4 == undefined){
                                        b4="";
                                    }
                                }


                                let b5 ;
                                if(datab[w][4] != null){
                                    b5= datab[w][4].v;
                                    if(b5 == undefined){
                                        b5="";
                                    }
                                }


                                let b6 ;
                                if(datab[w][5] != null){
                                    b6= datab[w][5].v;
                                    if(b6 == undefined){
                                        b6="";
                                    }
                                }

                                let b7 ;
                                if(datab[w][6] != null){
                                    b7= datab[w][6].v;
                                    if(b7 == undefined){
                                        b7="";
                                    }
                                }
                                let b8 ;
                                if(datab[w][7] != null){
                                    b8= datab[w][7].v;
                                    if(b8 == undefined){
                                        b8="";
                                    }
                                }
                                let b9 ;
                                if(datab[w][8] != null){
                                    b9= datab[w][8].v;
                                    if(b9 == undefined){
                                        b9="";
                                    }
                                }
                                let b10 ;
                                if(datab[w][9] != null){
                                    b10= datab[w][9].v;
                                    if(b10 == undefined){
                                        b10="";
                                    }
                                }
                                let b11 ;
                                if(datab[w][10] != null){
                                    b11= datab[w][10].v;
                                    if(b11 == undefined){
                                        b11="";
                                    }
                                }
                                let b12 ;
                                if(datab[w][11] != null){
                                    b12= datab[w][11].v;
                                    if(b12 == undefined){
                                        b12="";
                                    }
                                }
                                let b13 ;
                                if(datab[w][12] != null){
                                    b13= datab[w][12].v;
                                    if(b13 == undefined){
                                        b13="";
                                    }
                                }
                                let b14 ;
                                if(datab[w][13] != null){
                                    b14= datab[w][13].v;
                                    if(b14 == undefined){
                                        b14="";
                                    }
                                }
                                let b15 ;
                                if(datab[w][14] != null){
                                    b15= datab[w][14].v;
                                    if(b15 == undefined){
                                        b15="";
                                    }
                                }
                                let b16 ;

                                if(datab[w][15] != null){
                                    b16= datab[w][15].v;
                                    if(b16 == undefined){
                                        b16="";
                                    }
                                }
                                let b17 ;
                                if(datab[w][16] != null){
                                    b17= datab[w][16].v;
                                    if(b17 == undefined){
                                        b17="";
                                    }
                                }
                                let b18 ;
                                if(datab[w][17] != null){
                                    b18= datab[w][17].v;
                                    if(b18 == undefined){
                                        b18="";
                                    }
                                }
                                let b19 ;
                                if(datab[w][18] != null){
                                    b19= datab[w][18].v;
                                    if(b19 == undefined){
                                        b19="";
                                    }
                                }
                                let b20 ;
                                if(datab[w][19] != null){
                                    b20= datab[w][19].v;
                                    if(b20 == undefined){
                                        b20="";
                                    }
                                }
                                let b21 ;
                                if(datab[w][20] != null){
                                    b21= datab[w][20].v;
                                    if(b21 == undefined){
                                        b21="";
                                    }
                                }
                                let b22 ;
                                if(datab[w][21] != null){
                                    b22= datab[w][21].v;
                                    if(b22 == undefined){
                                        b22="";
                                    }
                                }
                                let b23 ;
                                if(datab[w][22] != null){
                                    b23= datab[w][22].v;
                                    if(b23 == undefined){
                                        b23="";
                                    }
                                }
                                let b24 ;
                                if(datab[w][23] != null){
                                    b24= datab[w][23].v;
                                    if(b24 == undefined){
                                        b24="";
                                    }
                                }
                                let b25 ;
                                if(datab[w][24] != null){
                                    b25= datab[w][24].v;
                                    if(b25 == undefined){
                                        b25="";
                                    }
                                }
                                let b26 ;
                                if(datab[w][25] != null){
                                    b26= datab[w][25].v;
                                    if(b26 == undefined){
                                        b26="";
                                    }
                                }
                                let b27 ;
                                if(datab[w][26] != null){
                                    b27= datab[w][26].v;
                                    if(b27 == undefined){
                                        b27="";
                                    }
                                }
                                let b28 ;
                                if(datab[w][27] != null){
                                    b28= datab[w][27].v;
                                    if(b28 == undefined){
                                        b28="";
                                    }
                                }
                                let b29 ;
                                if(datab[w][28] != null){
                                    b29= datab[w][28].v;
                                    if(b29 == undefined){
                                        b29="";
                                    }
                                }
                                let b30 ;
                                if(datab[w][29] != null){
                                    b30= datab[w][29].v;
                                    if(b30 == undefined){
                                        b30="";
                                    }
                                }
                                let b31 ;
                                if(datab[w][30] != null){
                                    b31= datab[w][30].v;
                                    if(b31 == undefined){
                                        b31="";
                                    }
                                }
                                let b32 ;
                                if(datab[w][31] != null){
                                    b32= datab[w][31].v;
                                    if(b32 == undefined){
                                        b32="";
                                    }
                                }
                                let b33 ;
                                if(datab[w][32] != null){
                                    b33= datab[w][32].v;
                                    if(b33 == undefined){
                                        b33="";
                                    }
                                }
                                let b34 ;
                                if(datab[w][33] != null){
                                    b34= datab[w][33].v;
                                    if(b34 == undefined){
                                        b34="";
                                    }
                                }
                                let b35 ;
                                if(datab[w][34] != null){
                                    b35= datab[w][34].v;
                                    if(b35 == undefined){
                                        b35="";
                                    }
                                }
                                let b36 ;
                                if(datab[w][35] != null){
                                    b36= datab[w][35].v;
                                    if(b36 == undefined){
                                        b36="";
                                    }
                                }
                                let b37 ;
                                if(datab[w][36] != null){
                                    b37= datab[w][36].v;
                                    if(b37 == undefined){
                                        b37="";
                                    }
                                }
                                let b38 ;
                                if(datab[w][37] != null){
                                    b38= datab[w][37].v;
                                    if(b38 == undefined){
                                        b38="";
                                    }
                                }
                                let b39 ;
                                if(datab[w][38] != null){
                                    b39= datab[w][38].v;
                                    if(b39 == undefined){
                                        b39="";
                                    }
                                }
                                let b40 ;
                                if(datab[w][39] != null){
                                    b40= datab[w][39].v;
                                    if(b40 == undefined){
                                        b40="";
                                    }
                                }
                                let b41 ;
                                if(datab[w][40] != null){
                                    b41= datab[w][40].v;
                                    if(b41 == undefined){
                                        b41="";
                                    }
                                }
                                let b42 ;
                                if(datab[w][41] != null){
                                    b42= datab[w][41].v;
                                    if(b42 == undefined){
                                        b42="";
                                    }
                                }
                                let b43 ;
                                if(datab[w][42] != null){
                                    b43= datab[w][42].v;
                                    if(b43 == undefined){
                                        b43="";
                                    }
                                }
                                let b44 ;
                                if(datab[w][43] != null){
                                    b44= datab[w][43].v;
                                    if(b44 == undefined){
                                        b44="";
                                    }
                                }
                                let b45 ;
                                if(datab[w][44] != null){
                                    b45= datab[w][44].v;
                                    if(b45 == undefined){
                                        b45="";
                                    }
                                }
                                let b46 ;
                                if(datab[w][45] != null){
                                    b46= datab[w][45].v;
                                    if(b46 == undefined){
                                        b46="";
                                    }
                                }
                                let b47 ;
                                if(datab[w][46] != null){
                                    b47= datab[w][46].v;
                                    if(b47 == undefined){
                                        b47="";
                                    }
                                }
                                let b48 ;
                                if(datab[w][47] != null){
                                    b48= datab[w][47].v;
                                    if(b48 == undefined){
                                        b48="";
                                    }
                                }
                                let b49 ;
                                if(datab[w][48] != null){
                                    b49= datab[w][48].v;
                                    if(b49 == undefined){
                                        b49="";
                                    }
                                }
                                let b50 ;
                                if(datab[w][49] != null){
                                    b50= datab[w][49].v;
                                    if(b50 == undefined){
                                        b50="";
                                    }
                                }
                                let b51 ;
                                if(datab[w][50] != null){
                                    b51= datab[w][50].v;
                                    if(b51 == undefined){
                                        b51="";
                                    }
                                }
                                let b52 ;
                                if(datab[w][51] != null){
                                    b52= datab[w][51].v;
                                    if(b52 == undefined){
                                        b52="";
                                    }
                                }
                                let b53 ;
                                if(datab[w][52] != null){
                                    b53= datab[w][52].v;
                                    if(b53 == undefined){
                                        b53="";
                                    }
                                }
                                let b54 ;
                                if(datab[w][53] != null){
                                    b54= datab[w][53].v;
                                    if(b54 == undefined){
                                        b54="";
                                    }
                                }
                                let b55 ;
                                if(datab[w][54] != null){
                                    b55= datab[w][54].v;
                                    if(b55 == undefined){
                                        b55="";
                                    }
                                }
                                let b56 ;
                                if(datab[w][55] != null){
                                    b56= datab[w][55].v;
                                    if(b56 == undefined){
                                        b56="";
                                    }
                                }
                                let b57 ;
                                if(datab[w][56] != null){
                                    b57= datab[w][56].v;
                                    if(b57 == undefined){
                                        b57="";
                                    }
                                }
                                let b58 ;
                                if(datab[w][57] != null){
                                    b58= datab[w][57].v;
                                    if(b58 == undefined){
                                        b58="";
                                    }
                                }
                                let b59 ;
                                if(datab[w][58] != null){
                                    b59= datab[w][58].v;
                                    if(b59 == undefined){
                                        b59="";
                                    }
                                }
                                let b60 ;
                                if(datab[w][59] != null){
                                    b60= datab[w][59].v;
                                    if(b60 == undefined){
                                        b60="";
                                    }
                                }
                                let b61 ;
                                if(datab[w][60] != null){
                                    b61= datab[w][60].v;
                                    if(b61 == undefined){
                                        b61="";
                                    }
                                }
                                let b62 ;
                                if(datab[w][61] != null){
                                    b62= datab[w][61].v;
                                    if(b62 == undefined){
                                        b62="";
                                    }
                                }
                                let b63 ;
                                if(datab[w][62] != null){
                                    b63= datab[w][62].v;
                                    if(b63 == undefined){
                                        b63="";
                                    }
                                }

                                if(data[i].id != null){
                                    this.fromimport.hId = data[i].id;
                                    this.fromimport.hDate = data[i].date;
                                    this.fromimport.mining = data[i].mining;
                                    this.fromimport.a1 = b1;
                                    this.fromimport.a2 = b2;
                                    this.fromimport.a3 = b3;
                                    this.fromimport.a4 = b4;
                                    this.fromimport.a5 = b5;
                                    this.fromimport.a6 = b6;
                                    this.fromimport.a7 = b7;
                                    this.fromimport.a8 = b8;
                                    this.fromimport.a9 = b9;
                                    this.fromimport.a10 = b10;
                                    this.fromimport.a11 = b11;
                                    this.fromimport.a12 = b12;
                                    this.fromimport.a13 = b13;
                                    this.fromimport.a14 = b14;
                                    this.fromimport.a15 = b15;
                                    this.fromimport.a16 = b16;
                                    this.fromimport.a17 = b17;
                                    this.fromimport.a18 = b18;
                                    this.fromimport.a19 = b19;
                                    this.fromimport.a20 = b20;
                                    this.fromimport.a21 = b21;
                                    this.fromimport.a22 = b22;
                                    this.fromimport.a23 = b23;
                                    this.fromimport.a24 = b24;
                                    this.fromimport.a25 = b25;
                                    this.fromimport.a26 = b26;
                                    this.fromimport.a27 = b27;
                                    this.fromimport.a28 = b28;
                                    this.fromimport.a29 = b29;
                                    this.fromimport.a30 = b30;
                                    this.fromimport.a31 = b31;
                                    this.fromimport.a32 = b32;
                                    this.fromimport.a33 = b33;
                                    this.fromimport.a34 = b34;
                                    this.fromimport.a35 = b35;
                                    this.fromimport.a36 = b36;
                                    this.fromimport.a37 = b37;
                                    this.fromimport.a38 = b38;
                                    this.fromimport.a39 = b39;
                                    this.fromimport.a40 = b40;
                                    this.fromimport.a41 = b41;
                                    this.fromimport.a42 = b42;
                                    this.fromimport.a43 = b43;
                                    this.fromimport.a44 = b44;
                                    this.fromimport.a45 = b45;
                                    this.fromimport.a46 = b46;
                                    this.fromimport.a47 = b47;
                                    this.fromimport.a48 = b48;
                                    this.fromimport.a49 = b49;
                                    this.fromimport.a50 = b50;
                                    this.fromimport.a51 = b51;
                                    this.fromimport.a52 = b52;
                                    this.fromimport.a53=  b53;
                                    this.fromimport.a54 = b54;
                                    this.fromimport.a55 = b55;
                                    this.fromimport.a56 = b56;
                                    this.fromimport.a57 = b57;
                                    this.fromimport.a58 = b58;
                                    this.fromimport.a59 = b59;
                                    this.fromimport.a60 = b60;
                                    this.fromimport.a61 = b61;
                                    this.fromimport.a62 = b62;
                                    this.fromimport.a63 = b63;

                                }
                                addActSuppliesImportTable(this.fromimport).then(response => {});
                            }
                        }
                    }
                }
            });

        }, 500), // 设置延迟时间，单位为毫秒
    }
// 配置项111
};
// debounce函数定义
function debounce(func, delay) {
    let timer;
    return function () {
        const context = this;
        const args = arguments;
        clearTimeout(timer);
        timer = setTimeout(function () {
            func.apply(context, args);
        }, delay);
    };
}
function getKeyByValue(map, value) {
    for (let [key, val] of map) {
        if (val === value) {
            return key;
        }
        if (Array.isArray(val) && val.includes(value)) {
            return key;
        }
    }
}
function generateUUID() {
    let array = new Uint32Array(4);
    window.crypto.getRandomValues(array);
    return array.join("-");
}
</script>
<style>
.mask {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    display: flex;
    justify-content: center;
    align-items: center;
}

.loading-spinner {
    /* 添加你的加载动画样式 */
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: 4px solid #f3f3f3;
    border-top: 4px solid #3498db;
    animation: spin 1s linear infinite;
}
@keyframes spin {
    0% {
        transform: rotate(0deg);
    }
    100% {
        transform: rotate(360deg);
    }
}
</style>
