pyt
2025-04-10 2ec2a96d9bb31c24e806709ef8df1bd9172f8c02
src/view/Home.vue
@@ -115,7 +115,7 @@
            <div class="flex a-center p-3">
                <el-button type="primary" class="search" @click="exportExcel(false)">导出 | Export</el-button>
                <el-button type="primary" class="search" @click="importExcel">导入 | Import</el-button>
                <a type="primary" class="Download" @click="exportExcel([])">下载模板 | Download Template</a>
                <a type="primary" class="Download" @click="downloadTemplate">下载模板 | Download Template</a>
            </div>
            <el-table :data="tableData" style="width: 100%" border>
                <el-table-column width="200" prop="orderId" align="center">
@@ -391,6 +391,9 @@
        this.getLists()
    },
    methods: {
        downloadTemplate() {
            window.open('http://47.108.239.173/compass_template.xlsx', '_blank')
        },
        handleClick(e, type) {
            this.$router.push({
                path: '/addOrder',
@@ -486,35 +489,37 @@
            if (!arr) {
                let res = await exportList({ userExtra: localStorage.getItem('extra') })
                exportData = res.data.map(item => ({
                '集装箱号 | Container No.': item.ContainerNo,
                '提单号 | BOL No.': item.BolNo,
                '柜型 | Container Type': item.containerType,
                '船司 | Carrier': item.carrier,
                '船名航次 | Vessel Name and Voyage': item.vesselNameAndVoyage,
                '提柜地 | Pickup Location': item.pickupLocation,
                '预计到港 | ETA': item.eta,
                'SOC': item.soc,
                'DG': item.dg,
                '是否超重 | Overweight': item.overweight,
                '是否查验 | Exam/Inspection': item.exam,
                'DROP/LIVE': item.dropOrLive,
                'Hold': item.hold,
                '客户单号 | Customer Ref. No.': item.customerRefNo,
                '品名 | Commodity': item.commodity,
                '数量 | QTY': item.qty,
                '包装种类 | Packages': item.packages,
                '毛重 | Gr. Wt': item.GrWt,
                '毛重(磅) | Weight (LBs)': item.weightLBS,
                '体积 | Volume': item.volume,
                '收件人 | Consignee': item.consignee,
                '收件人公司 | Company Name': item.companyName,
                '邮编 | Postal Code': item.postalCode,
                '地址 | Address': item.address,
                '联系电话 | Tel': item.tel,
                '邮箱 | Email': item.email,
                '其他联系方式 | Other Contact Information': item.otherContactInformation,
                '备注 | Remarks': item.remarks
            }));
                    '集装箱号 | Container No.': item.ContainerNo,
                    '提单号 | BOL No.': item.BolNo,
                    '柜型 | Container Type': item.containerType,
                    '船司 | Carrier': item.carrier,
                    '船名航次 | Vessel Name and Voyage': item.vesselNameAndVoyage,
                    '提柜地 | Pickup Location': item.pickupLocation,
                    '预计到港 | ETA': item.eta,
                    'SOC': item.soc === '是' ? 'Y' : (item.soc === '否' ? 'N' : ''),
                    'DG': item.dg === '是' ? 'Y' : (item.dg === '否' ? 'N' : ''),
                    '是否超重 | Overweight': item.overweight === '是' ? 'Y' : (item.overweight === '否' ? 'N' : ''),
                    '是否查验 | Exam/Inspection': item.exam === '是' ? 'Y' : (item.exam === '否' ? 'N' : ''),
                    'DROP/LIVE': item.dropOrLive,
                    'Hold': item.hold === '等国内通知派送' ? '等国内通知派送|Client Hold' :
                           (item.hold === '扣柜放行' ? '扣柜放行|Client Release' :
                           (item.hold === '正常' ? '正常|Normal' : '')),
                    '客户单号 | Customer Ref. No.': item.customerRefNo,
                    '品名 | Commodity': item.commodity,
                    '数量 | QTY': item.qty,
                    '包装种类 | Packages': item.packages,
                    '毛重 | Gr. Wt': item.GrWt,
                    '毛重(磅) | Weight (LBs)': item.weightLBS,
                    '体积 | Volume': item.volume,
                    '收件人 | Consignee': item.consignee,
                    '收件人公司 | Company Name': item.companyName,
                    '邮编 | Postal Code': item.postalCode,
                    '地址 | Address': item.address,
                    '联系电话 | Tel': item.tel,
                    '邮箱 | Email': item.email,
                    '其他联系方式 | Other Contact Information': item.otherContactInformation,
                    '备注 | Remarks': item.remarks
                }));
            }
            // 准备导出数据
             
@@ -586,9 +591,8 @@
                            defval: '',
                            header: 1
                        });
                        // 获取表头并打印日志
                        const headers = jsonData[0];
                        const headers = jsonData[2];
                        // 验证模板格式
                        const requiredFields = [
                            '集装箱号 | Container No.',
@@ -629,7 +633,7 @@
                        }
                        // 转换数据格式
                        const transformedData = jsonData.slice(1).map(row => {
                        const transformedData = jsonData.slice(3).map(row => {
                            const item = {};
                            headers.forEach((header, index) => {
                                item[header] = row[index] || '';
@@ -644,12 +648,12 @@
                                vesselNameAndVoyage: item['船名航次 | Vessel Name and Voyage'],
                                pickupLocation: item['提柜地 | Pickup Location'],
                                eta: item['预计到港 | ETA'],
                                soc: item['SOC'],
                                dg: item['DG'],
                                overweight: item['是否超重 | Overweight'],
                                exam: item['是否查验 | Exam/Inspection'],
                                soc: item['SOC'] === 'Y' ? '是' : (item['SOC'] === 'N' ? '否' : ''),
                                dg: item['DG'] === 'Y' ? '是' : (item['DG'] === 'N' ? '否' : ''),
                                overweight: item['是否超重 | Overweight'] === 'Y' ? '是' : (item['是否超重 | Overweight'] === 'N' ? '否' : ''),
                                exam: item['是否查验 | Exam/Inspection'] === 'Y' ? '是' : (item['是否查验 | Exam/Inspection'] === 'N' ? '否' : ''),
                                dropOrLive: item['DROP/LIVE'],
                                hold: item['Hold'],
                                hold: item['Hold'] ? item['Hold'].split('|')[0] : '',
                                customerRefNo: item['客户单号 | Customer Ref. No.'],
                                commodity: item['品名 | Commodity'],
                                qty: item['数量 | QTY'],
@@ -667,9 +671,10 @@
                                remarks: item['备注 | Remarks']
                            };
                        });
                        // 使用post方法直接传递数组
                        iptOrder(transformedData).then(res => {
                            console.log(res,transformedData);
                            if (res) {
                                this.$message({
                                    message: '导入成功',