Browse Source

2024-01-11 导出非活动拆单 加红色款

zhiquz 1 year ago
parent
commit
8bf45f7e62
3 changed files with 135 additions and 32 deletions
  1. BIN
      dist.zip
  2. 125 31
      src/pages/order/list.vue
  3. 10 1
      src/vendor/Export2Excel.js

BIN
dist.zip


+ 125 - 31
src/pages/order/list.vue

@@ -2269,7 +2269,7 @@ export default {
     exporOrderthuodongNew() {
       if (this.chooseList.length) {
         this.$request(chaidan({ id: this.chooseList.map(e => e.id) }), (res) => {
-          this.changeExcelStyle(res)
+          this.changeExcelStyle(res, 1)
         })
         // this.$request(chaidans({ id: this.chooseList.map(e => e.id) }), (res) => {
         //   this.expressData = res
@@ -2327,14 +2327,14 @@ export default {
           }
         }
         this.$request(chaidans(query), (res) => {
-          this.changeExcelStyle(res)
+          this.changeExcelStyle(res, 1)
         })
       }
     },
-    // 活动拆单新 改变导出表格 某一行文字颜色
-    changeExcelStyle(res) {
+    // 0非活动拆单 1活动拆单新 改变导出表格 某一行文字颜色
+    changeExcelStyle(res, v) {
       this.expressData = res
-      const exportData = this.getExportModuleNew()
+      const exportData = v === 0 ? this.getExportModule() : this.getExportModuleNew()
       const data = exportData.map(listItem => Object.keys(exportData[0]).map(j => listItem[j]))
       const header = Object.keys(moduleList)
       header.push('是否满箱')
@@ -2343,8 +2343,8 @@ export default {
 
       const aoa = data
       const date = new Date().toLocaleDateString().replace(/\//g, '-') // 名称不能包含以下任何字符:\ / ? * [
-      const filename = `${date}活动快递单导出.xlsx`
-      const ws_name = `${date}活动快递单`
+      const filename = `${date}${v === 0 ? '非' : ''}活动快递单导出.xlsx`
+      const ws_name = `${date}${v === 0 ? '非' : ''}活动快递单`
       const wb = XLSX.utils.book_new()
       const ws = XLSX.utils.aoa_to_sheet(aoa)
       var style = {
@@ -2398,18 +2398,7 @@ export default {
     async exporOrdertOrder() {
       if (this.chooseList.length) {
         this.$request(toExport({ id: this.chooseList.map(e => e.id) }), (res) => {
-          this.expressData = res
-          const exportData = this.getExportModule()
-          import('@/vendor/Export2Excel').then(excel => {
-            excel.export_json_to_excel({
-              header: Object.keys(moduleList),
-              data: exportData.map(listItem => Object.keys(exportData[0]).map(j => listItem[j])),
-              filename: `${new Date().toLocaleDateString()}非活动快递单导出`,
-              bookType: 'xlsx',
-              isCSV: true
-            })
-            this.dialog.export_order = false
-          })
+          this.changeExcelStyle(res, 0)
         })
       } else {
         let query = {}
@@ -2453,18 +2442,7 @@ export default {
           }
         }
         this.$request(toExport(query), (res) => {
-          this.expressData = res
-          const exportData = this.getExportModule()
-          import('@/vendor/Export2Excel').then(excel => {
-            excel.export_json_to_excel({
-              header: Object.keys(moduleList),
-              data: exportData.map(listItem => Object.keys(exportData[0]).map(j => listItem[j])),
-              filename: `${new Date().toLocaleDateString()}非活动快递单导出`,
-              bookType: 'xlsx',
-              isCSV: true
-            })
-            this.dialog.export_order = false
-          })
+          this.changeExcelStyle(res, 0)
         })
       }
     },
@@ -2479,6 +2457,8 @@ export default {
         let c = 0
         let d = 0
         let e = 0
+        let f = 0
+        let g = 0
         while (a < item['精装'].length) {
           const obj = Object.assign({}, moduleList)
           obj['订单编号'] = i
@@ -2498,6 +2478,8 @@ export default {
           obj['订单状态'] = info.status
           obj['支付状态'] = info.pay_status
           obj['体验店或专车'] = info.store
+          obj['是否满箱'] = '精装满箱'
+          obj['款式备注'] = '常规款'
           // obj['赠品'] = info.gift.map(item => `${item.name}${item.num}`).join(';')
           let num_all = 0
           if (item['精装'][a].sec_attr === '男女款') {
@@ -2547,6 +2529,7 @@ export default {
           obj['订单状态'] = info.status
           obj['支付状态'] = info.pay_status
           obj['体验店或专车'] = info.store
+          obj['是否满箱'] = `${item['普通'][b].main_attr === '高' ? '高腰' : item['普通'][b].main_attr === '青春' ? '青春' : '简约'}满箱`
           // obj['赠品'] = info.gift.map(item => `${item.name}${item.num}`).join(';')
           let num_all = 0
           if (item['普通'][b].sec_attr === '男女款') {
@@ -2596,6 +2579,8 @@ export default {
           obj['订单状态'] = info.status
           obj['支付状态'] = info.pay_status
           obj['体验店或专车'] = info.store
+          obj['是否满箱'] = ''
+          obj['款式备注'] = '常规款'
           // obj['赠品'] = info.gift.map(item => `${item.name}${item.num}`).join(';')
           let num_all = 0
           for (let j = 0; j < item['精装混合'][c].length; j++) {
@@ -2651,6 +2636,7 @@ export default {
           obj['订单状态'] = info.status
           obj['支付状态'] = info.pay_status
           obj['体验店或专车'] = info.store
+          obj['是否满箱'] = ''
           // obj['赠品'] = info.gift.map(item => `${item.name}${item.num}`).join(';')
           let num_all = 0
           for (let j = 0; j < item['普通混合'][d].length; j++) {
@@ -2687,6 +2673,114 @@ export default {
           out.push(obj)
           d++
         }
+        while (f < item['红色'].length) {
+          const obj = Object.assign({}, moduleList)
+          obj['订单编号'] = i
+          obj['下单时间'] = info.created_at
+          obj['所属客服'] = info.admin_name
+          obj['备注昵称'] = info.u_nickname
+          obj['下单人姓名'] = info.u_name
+          obj['下单人手机号'] = info.u_mobile
+          obj['收件人'] = info.username
+          obj['电话'] = info.mobile
+          obj['收件人省'] = info.province
+          obj['收件人市'] = info.city
+          obj['收件人区'] = info.town
+          obj['收件人街道地址'] = info.address
+          obj['备注'] = info.remark
+          obj['所属'] = info.belong
+          obj['订单状态'] = info.status
+          obj['支付状态'] = info.pay_status
+          obj['体验店或专车'] = info.store
+          obj['是否满箱'] = '红色满箱'
+          obj['款式备注'] = '红色'
+          // obj['赠品'] = info.gift.map(item => `${item.name}${item.num}`).join(';')
+          let num_all = 0
+          if (item['红色'][f].sec_attr === '男女款') {
+            const sex = item['红色'][f].size.split('-')[0]
+            let size = item['红色'][f].size.split('-')[1]
+            size = size === '3XL' ? 'XXXL' : size
+            if (sex === '男款') {
+              obj[size] = `${item['红色'][f].num}红`
+              num_all += item['红色'][f].num
+            } else {
+              obj['女' + size] = `${item['红色'][f].num}红`
+              num_all += item['红色'][f].num
+            }
+          } else {
+            if (item['红色'][f].size === '3XL') {
+              item['红色'][f].size = 'XXXL'
+            }
+            if (item['红色'][f].sec_attr === '男款') {
+              obj[item['红色'][f].size] = `${item['红色'][f].num}红`
+              num_all += item['红色'][f].num
+            }
+            if (item['红色'][f].sec_attr === '女款') {
+              obj['女' + item['红色'][f].size] = `${item['红色'][f].num}红`
+              num_all += item['红色'][f].num
+            }
+          }
+          obj['数据求和'] = num_all
+          out.push(obj)
+          f++
+        }
+        while (g < item['红色混合'].length) {
+          const obj = Object.assign({}, moduleList)
+          obj['订单编号'] = i
+          obj['下单时间'] = info.created_at
+          obj['所属客服'] = info.admin_name
+          obj['备注昵称'] = info.u_nickname
+          obj['下单人姓名'] = info.u_name
+          obj['下单人手机号'] = info.u_mobile
+          obj['收件人'] = info.username
+          obj['电话'] = info.mobile
+          obj['收件人省'] = info.province
+          obj['收件人市'] = info.city
+          obj['收件人区'] = info.town
+          obj['收件人街道地址'] = info.address
+          obj['备注'] = info.remark
+          obj['所属'] = info.belong
+          obj['订单状态'] = info.status
+          obj['支付状态'] = info.pay_status
+          obj['体验店或专车'] = info.store
+          obj['是否满箱'] = ''
+          obj['款式备注'] = '红色'
+          // obj['赠品'] = info.gift.map(item => `${item.name}${item.num}`).join(';')
+          let num_all = 0
+          for (let j = 0; j < item['红色混合'][g].length; j++) {
+            if (item['红色混合'][g][j].sec_attr === '男女款') {
+              const sex = item['红色混合'][g][j].size.split('-')[0]
+              let size = item['红色混合'][g][j].size.split('-')[1]
+              size = size === '3XL' ? 'XXXL' : size
+              if (sex === '男款') {
+                obj[size] += `${item['红色混合'][g][j].num}红`
+                num_all += item['红色混合'][g][j].num
+              } else {
+                obj['女' + size] += `${item['红色混合'][g][j].num}红`
+                num_all += item['红色混合'][g][j].num
+              }
+            } else {
+              if (item['红色混合'][g][j].size === '3XL') {
+                if (item['红色混合'][g][j].sec_attr === '男款') {
+                  obj['XXXL'] += `${item['红色混合'][g][j].num}红`
+                  num_all += item['红色混合'][g][j].num
+                }
+              } else {
+                if (item['红色混合'][g][j].sec_attr === '男款') {
+                  obj[item['红色混合'][g][j].size] += `${item['红色混合'][g][j].num}红`
+                  num_all += item['红色混合'][g][j].num
+                }
+                if (item['红色混合'][g][j].sec_attr === '女款') {
+                  obj['女' + item['红色混合'][g][j].size] += `${item['红色混合'][g][j].num}红`
+                  num_all += item['红色混合'][g][j].num
+                }
+              }
+            }
+          }
+          obj['数据求和'] = num_all
+          out.push(obj)
+          g++
+        }
         while (e < item.data.peijian.length) {
           const obj = Object.assign({}, moduleList)
           obj['订单编号'] = i

+ 10 - 1
src/vendor/Export2Excel.js

@@ -204,8 +204,17 @@ export function export_json_to_excel({
       }
     }
     ws['!cols'] = result;
+    //  /*以第一行为初始值*/
+    // let result = colWidth[0];
+    // for (let i = 1; i < colWidth.length; i++) {
+    //   for (let j = 0; j < colWidth[i].length; j++) {
+    //     if (result[j] && colWidth[i][j] && result[j]['wch'] < colWidth[i][j]['wch']) {
+    //      result[j]['wch'] = colWidth[i][j]['wch'];
+    //     }
+    //   }
+    // }
+    // ws['!cols'] = result;
   }
-
   /* add worksheet to workbook */
   wb.SheetNames.push(ws_name);
   wb.Sheets[ws_name] = ws;