longyi пре 6 месеци
родитељ
комит
7b3adbf72f
3 измењених фајлова са 157 додато и 39 уклоњено
  1. 63 37
      template/erp/returngoods.html
  2. 47 1
      template/erp/returngoods_caiwu.html
  3. 47 1
      template/erp/returngoods_check.html

+ 63 - 37
template/erp/returngoods.html

@@ -335,44 +335,70 @@ function explortExcel(data,filename){
 
     let  sheet = XLSX.utils.json_to_sheet(data)
 
-    let colWidths = [],
-    colNames = Object.keys(data[0]) // 所有列的名称数组
-
-    // 计算每一列的所有单元格宽度
-    // 先遍历行
-    data.forEach((row) => {
-    // 列序号
-    let index = 0
-    // 遍历列
-    for (const key in row) {
-        if (colWidths[index] == null) colWidths[index] = []
-
-            switch (typeof row[key]) {
-            case 'string':
-            case 'number':
-            case 'boolean':
-                colWidths[index].push(getCellWidth(row[key]))
-                break
-            case 'object':
-            case 'function':
-                colWidths[index].push(0)
-                break
+    
+    sheet['!cols'] = [
+            //订单号
+            {
+                 wch:20,
+            },
+            //订单编码
+            {
+                 wch:20,
+            },
+            //店铺名称
+            {
+                 wch:18,
+            },
+            //状态
+            {
+                 wch:15,
+            },
+            //登记原因
+            {
+                 wch:25,
+            },
+            //备注信息
+            {
+                 wch:35,
+            },
+            //售后类型
+            {
+                 wch:15,
+            },
+            //重发单号
+            {
+                 wch:20,
+            },
+            //退款金额
+            {
+                 wch:10,
+            },
+            //登记人
+            {
+                 wch:10,
+            },
+            //登记时间
+            {
+                 wch:21,
+            },
+            //仓库品名
+            {
+                 wch:35,
+            },
+            //快递方式
+            {
+                 wch:14,
+            },
+            //运单号
+            {
+                 wch:23,
+            },
+            //出库时间
+            {
+                 wch:21,
             }
-            index++
-        }
-    })
-
-    sheet['!cols'] = []
-    // 每一列取最大值最为列宽
-    colWidths.forEach((widths, index) => {
-        // 计算列头的宽度
-        widths.push(getCellWidth(colNames[index]))
-        // 设置最大值为列宽
-        console.log(Math.max(...widths))
-        sheet['!cols'].push({ wch: Math.max(...widths) })
-    })
-
-
+            
+        ];
 
 
     let workbook = XLSX.utils.book_new();

+ 47 - 1
template/erp/returngoods_caiwu.html

@@ -119,7 +119,11 @@ function excelexport(){
                 if (a.data.length > 0){
                     $(".ts p").html(a.msg);
                     $(".ts").fadeIn();
-                    explortExcel(a.data,"退货单列表.xlsx")
+                    const now = new Date();
+                    const dateString = now.toISOString().split('T')[0];
+                    const [year, month, day] = dateString.split('-');
+                    let filename = "售后登记清单"+year+month+day+".xlsx";
+                    explortExcel(a.data,filename)
                 }else{
                     $(".ts p").html("没有数据");
                     $(".ts").fadeIn();
@@ -134,6 +138,48 @@ function explortExcel(data,filename){
     
     let  sheet = XLSX.utils.json_to_sheet(data)
     let workbook = XLSX.utils.book_new();
+      sheet['!cols'] = [
+            //订单号
+            {
+                 wch:20,
+            },
+            //订单编码
+            {
+                 wch:20,
+            },
+            //店铺名称
+            {
+                 wch:18,
+            },
+            //状态
+            {
+                 wch:15,
+            },
+            //登记原因
+            {
+                 wch:25,
+            },
+           
+            //售后类型
+            {
+                 wch:15,
+            },
+            //重发单号
+            {
+                 wch:20,
+            },
+            //退款金额
+            {
+                 wch:10,
+            },
+           
+            //登记时间
+            {
+                 wch:21,
+            }
+           
+            
+        ];
     XLSX.utils.book_append_sheet(workbook, sheet, "Sheet1");
     XLSX.writeFile(workbook, filename);
 }

+ 47 - 1
template/erp/returngoods_check.html

@@ -203,7 +203,11 @@ function excelexport(){
                 if (a.data.length > 0){
                     $(".ts p").html(a.msg);
                     $(".ts").fadeIn();
-                    explortExcel(a.data,"退货单列表.xlsx")
+                    const now = new Date();
+                    const dateString = now.toISOString().split('T')[0];
+                    const [year, month, day] = dateString.split('-');
+                    let filename = "售后登记清单"+year+month+day+".xlsx";
+                    explortExcel(a.data,filename)
                 }else{
                     $(".ts p").html("没有数据");
                     $(".ts").fadeIn();
@@ -218,6 +222,48 @@ function explortExcel(data,filename){
     
     let  sheet = XLSX.utils.json_to_sheet(data)
     let workbook = XLSX.utils.book_new();
+    sheet['!cols'] = [
+            //订单号
+            {
+                 wch:20,
+            },
+            //订单编码
+            {
+                 wch:20,
+            },
+            //店铺名称
+            {
+                 wch:18,
+            },
+            //状态
+            {
+                 wch:15,
+            },
+            //登记原因
+            {
+                 wch:25,
+            },
+           
+            //售后类型
+            {
+                 wch:15,
+            },
+            //重发单号
+            {
+                 wch:20,
+            },
+            //退款金额
+            {
+                 wch:10,
+            },
+           
+            //登记时间
+            {
+                 wch:21,
+            }
+           
+            
+        ];
     XLSX.utils.book_append_sheet(workbook, sheet, "Sheet1");
     XLSX.writeFile(workbook, filename);
 }