zhanghua
2025-03-25 cbcfcdcb943df7ab8979917972b44edd567b1151
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
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
<template>
    <div class="app-container">
        <div style="display: flex; justify-content: space-between">
            <div style="width: 300px">
                <el-input
                    placeholder="按姓名、课程、电话搜索"
                    v-model="data.keyword"
                    class="input-with-select"
                    size="small"
                >
                    <el-button
                        slot="append"
                        icon="el-icon-search"
                        @click="handleClick"
                    ></el-button>
                </el-input>
            </div>
        </div>
        <div style="height: calc(100vh - 158px)">
            <el-table
                v-loading="listLoading"
                :data="list"
                element-loading-text="Loading"
                fit
                height="100%"
            >
                <el-table-column label="订单号" width="200" prop="number">
                </el-table-column>
                <el-table-column label="学员" prop="playerBaseInfo.name">
                </el-table-column>
                <el-table-column label="电话" prop="mobile"> </el-table-column>
                <el-table-column label="购买方式" prop="payType">
                    <template slot-scope="scope">
                        {{
                            scope.row.payType == 'DIRECT'
                                ? '收费录入'
                                : '商城购入'
                        }}
                    </template>
                </el-table-column>
                <el-table-column label="总价" width="80" prop="originAmt">
                </el-table-column>
                <el-table-column label="折扣" width="80" prop="discount">
                </el-table-column>
                <el-table-column label="实际缴费" width="80" prop="amt">
                </el-table-column>
                <el-table-column label="订单时间" width="180" prop="createTime">
                </el-table-column>
                <el-table-column label="操作" width="120">
                    <template slot-scope="scope">
                        <el-link
                            @click="handlePrint(scope.row)"
                            type="primary"
                            :underline="false"
                            >打印收据</el-link
                        >
                    </template>
                </el-table-column>
            </el-table>
        </div>
        <div>
            <el-pagination
                @size-change="handleSizeChange"
                @current-change="handleCurrentChange"
                :current-page="data.pageIn.index + 1"
                :page-sizes="[10, 20, 30, 40]"
                :page-size="data.pageIn.size"
                layout="total, sizes, prev, pager, next, jumper"
                :total="total"
            >
            </el-pagination>
        </div>
    </div>
</template>
 
<script>
import { getData, findPlayerAccByOrderId } from "@/api/order";
import { printHtml } from "@/utils/print";
import { convertCurrency } from "@/utils/ruoyi";
 
export default {
    filters: {
        statusFilter(status) {
            const statusMap = {
                published: "success",
                draft: "gray",
                deleted: "danger",
            };
            return statusMap[status];
        },
    },
    data() {
        return {
            dateRange: [],
            list: null,
            listLoading: true,
            total: 0,
            data: {
                staffId: JSON.parse(localStorage.getItem("selectStaff")).id,
                keyword: "",
                pageIn: {
                    //可选,如果是分页查询,需要加上。
                    index: 0, //必选
                    size: 10, //每页的大小。默认20
                    sorts: {
                        name: "createTime", //排序字段名称
                        direction: "DESC", //排序方向
                    },
                },
            },
            dialogVisible: false,
        };
    },
    created() {
        this.fetchData();
    },
    methods: {
        reloadData() {
            this.dialogVisible = false;
            this.fetchData();
        },
        fetchData() {
            this.listLoading = true;
            getData(this.data).then((response) => {
                this.list = response.data.findOrderVoByOrgId.ls;
                this.total = response.data.findOrderVoByOrgId.pageOut.total;
                this.listLoading = false;
            });
        },
        handleClick() {
            this.fetchData();
        },
        handleSizeChange(val) {
            this.data.pageIn.size = val;
            this.fetchData();
        },
        handleCurrentChange(val) {
            this.data.pageIn.index = val - 1;
            this.fetchData();
        },
        handlePrint(row) {
 
            if (row.payType == "DIRECT") {
                findPlayerAccByOrderId({ 'orderId': row.id }).then(res => {
                    if (res.data.findPlayerAccByOrderId.length > 0) {
                        row.staffName = res.data.findPlayerAccByOrderId[0].staffName
                        row.message = res.data.findPlayerAccByOrderId[0].description
                    }
                    this.doPrint(row)
                })
            }
            else {
                this.doPrint(row)
            }
 
        },
        doPrint(row) {
            const orgName = JSON.parse(localStorage.getItem("selectStaff")).org.name;
            let detail = "";
            row.details.forEach((o) => {
                detail += `<tr>
                <td> ${o.voucherName || o.goodsName}</td>
                <td>${o.qty} </td>
                <td> ${o.giftQty || 0}</td>
                <td>${o.amt}</td>
                <td>${row.saleStaff ? row.saleStaff.name : ''} </td>
            </tr>`;
            });
 
            let printData = `<div style="display: flex; justify-content: center;">
    <div style="margin-top: 50px; width: 600px;line-height: 2;">
        <h2 style="text-align: center;">${orgName}缴费收据 </h2>
        <div> 订单号:${row.number}</div>
        <div class="div-2-column">
            <div> 学员姓名:<u>${row.playerBaseInfo ? (row.playerBaseInfo.name||'') : ""
                }</u> </div>
            <div>联系电话:<u>${row.mobile || "未录入"} </u></div>
        </div>
        <div> 订单类型:${row.payType == "DIRECT" ? "收费录入" : "商城购入"
                } </div>
 
        <div class="m-h2"> 课程信息</div>
        <table class="txt-center" width="100%" border="1" cellpadding="2" cellspacing="0">
            <tr>
                <th width="140px" nowradiv>科目</th>
                <th width="80px" nowradiv>数量</th>
                <th width="80px" nowradiv>赠送</th>
                <th width="100px" nowradiv>金额</th>
                <th>课程顾问</th>
            </tr>
            ${detail}
        </table>
 
        <div class="m-h2"> 缴费记录</div>
        <table width="100%" border="1" cellpadding="2" cellspacing="0">
            <tr>
                <td>&nbsp;应缴费金额:${row.originAmt}</td>
            </tr>
            <tr>
                <td>&nbsp;折扣/赠送金额:${row.discount}</td>
            </tr>
            <tr>
                <td>&nbsp;实缴金额:${convertCurrency(row.amt)}(¥${row.amt
                })</td>
            </tr>
        </table>
        <div>&nbsp;校区地址:${row.org.address||row.org.addressDetail}</div>
        <div>&nbsp;备注:${row.message || ""} </div>
        <br>
        <br>
        <div class="div-2-column">
            <div> 经办人:${row.staffName || ''}  </div>
            <div>经办日期:${row.createTime} </div>
        </div>
    </div>
</div>`;
            printHtml(printData);
        },
        showCreate() {
            this.$refs.studentCreate.showDialog();
        },
    },
};
</script>
 
<style>
#print-container {
    display: none;
}
@media print {
    body > :not(.print-container) {
        display: none;
    }
    html,
    body {
        display: block !important;
    }
    #print-container {
        display: block;
    }
}
@page {
    margin-top: 0;
    margin-bottom: 0;
}
.div-2-column {
    display: flex;
    flex-direction: row;
    justify-content: space-between;
}
.m-h2 {
    text-align: center;
    font-size: 1.17em;
    margin-top: 50px;
    font-weight: bold;
}
#tr {
    height: 30px;
}
.txt-center {
    text-align: center;
}
</style>