333
schangxiang@126.com
2025-09-19 18966e02fb573c7e2bb0c6426ed792b38b910940
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
<template>
  <div class="print-container">
    <el-card v-for="(item, index) in groupList" :key="index" class="box-card page-after">
      <h2 class="head">交货清单</h2>
      <div>
        <h4>打印统计</h4>
        <table cellspacing="0" cellpadding="0">
          <tr class="stat-tr">
            <td class="bottom-line">货主</td>
            <td class="bottom-line">快递公司</td>
            <td class="bottom-line">日期</td>
            <td class="bottom-line">操作人</td>
            <td class="bottom-line">订单数</td>
          </tr>
          <tr class="stat-tr">
            <td>{{ item.consignorName }}</td>
            <td>{{ item.expressCorpName }}</td>
            <td>{{ newDate }}</td>
            <td>{{ item.creator }}</td>
            <td>{{ getTotal(item) }}</td>
          </tr>
        </table>
      </div>
      <div>
        <h4>打印明细</h4>
        <el-table :data="getCurrentDetails(item)" style="width: 100%">
          <el-table-column prop="orderCode" label="订单号" width="135">
          </el-table-column>
          <el-table-column prop="expressCode" label="快递单号" width="130">
          </el-table-column>
          <el-table-column prop="storeOrderCode" label="店铺订单号" width="150">
          </el-table-column>
          <el-table-column prop="clientShortName" label="客户" width="80">
          </el-table-column>
          <el-table-column prop="shippingName" label="联系人" width="80">
          </el-table-column>
          <el-table-column prop="telephone" label="手机号" width="130">
          </el-table-column>
          <el-table-column prop="materialCount" label="数量" width="60">
          </el-table-column>
          <el-table-column prop="weight" label="重量" width="60">
          </el-table-column>
          <el-table-column prop="shippingAddress" label="地址">
          </el-table-column>
        </el-table>
      </div>
      <el-row class="row margin-top-20">
        <el-col :span="6">发货人:{{ item.clientShortName }}</el-col>
        <el-col :span="6">取货人:{{ item.shippingName }}</el-col>
        <el-col :span="12">打印时间:{{ newDate }}</el-col>
      </el-row>
    </el-card>
    <el-form class="form padding-20 no-print">
      <el-form-item>
        <el-button type="primary" @click="printBill">打印</el-button>
      </el-form-item>
    </el-form>
  </div>
</template>
 
<script>
var moment = require("moment");
 
export default {
  data() {
    return {
      // 分组数据
      groupList: [],
      // 打印数据
      tableData: [],
      newDate: new Date(), // 当前打印时间
      materialCount: 0 // 统计数量
    };
  },
  computed: {
    // 获得当前明细集合
    getCurrentDetails: function() {
      return item => {
        return this.tableData.filter(
          row => row.expressCorpName === item.expressCorpName && row.consignor_Id === item.consignor_Id
        );
      };
    },
    // 获得合计数据
    getTotal: function() {
      return item => {
        const filterList = this.tableData.filter(
          row => row.expressCorpName === item.expressCorpName && row.consignor_Id === item.consignor_Id
        );
        // const total = filterList.reduce(
        //   (totalItem, currItem) => {
        //     totalItem.materialCount += currItem.materialCount;
        //     return totalItem;
        //   },
        //   { materialCount: 0 }
        // );
 
        return filterList.length;
      };
    }
  },
 
  mounted() {
    var data = sessionStorage["print-send-list"];
    this.tableData = JSON.parse(data);
    const groupList = this.tableData.reduce(
      (all, next) =>
        all.some(item => item.expressCorpName === next.expressCorpName && item.consignor_Id === next.consignor_Id)
          ? all
          : [...all, next],
      []
    );
    this.groupList = groupList;
    this.getTime();
  },
  methods: {
    // 获取当前打印时间
    getTime() {
      this.newDate = moment(this.newDate).format("YYYY-MM-DD HH:mm:ss");
    },
    // 打印单据
    printBill() {
      window.print();
    }
  }
};
</script>
 
<style lang="scss" scoped>
.print-container {
  margin-top: 20px;
  margin-left: 20px;
  .box-card {
    margin-bottom: 20px;
    max-width: 1366px;
  }
  .head {
    text-align: center;
  }
  .stat-tr {
    td {
      padding: 10px;
    }
    .bottom-line {
      border-bottom: 2px solid gray;
    }
  }
}
</style>