qinxianzhangyao
2023-12-12 f4c300867675f292e882d5125238bb970bc19bdf
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
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
<template>
    <div class="app-container">
 
        <el-form :inline="true" ref="form" :model="queryParams" class="demo-form-inline" label-width="80px">
            <el-row>
                <el-col :span="7">
                    <el-form-item label="姓名" prop="name" style="display: flex;">
                        <el-input v-model="queryParams.name" placeholder="请输入姓名" />
                    </el-form-item>
                </el-col>
                <el-col :span="12">
                    <el-form-item label="联系电话" prop="phone" style="display: flex;">
                        <el-input v-model="queryParams.phone" placeholder="请输入联系电话" />
                    </el-form-item>
                </el-col>
                <el-col :span="3">
                    <el-form-item>
                        <el-button type="primary" icon="el-icon-search" size="mini" @click="handleUpdate">查询</el-button>
                    </el-form-item>
                </el-col>
            </el-row>
        </el-form>
 
        <div style="margin-bottom: 10px;">
            <el-radio-group v-model="type" @input="handleUpdate">
                <el-radio-button label="1">收费记录</el-radio-button>
                <el-radio-button label="2">退费记录</el-radio-button>
            </el-radio-group>
        </div>
 
        <template>
            <el-table v-loading="loading" :data="tableList" @selection-change="handleSelect" border max-height="720px"
                :row-style="changRed">
                <el-table-column type="selection" width="55" align="center" />
                <el-table-column label="姓名" align="center" prop="customer.cusName" width="90px" />
                <el-table-column label="手机号" align="center" prop="customer.cusPhone" width="110px"
                    :show-overflow-tooltip="true"></el-table-column>
                <el-table-column label="订单流水号" align="center" prop="waterId" width="194px" />
                <el-table-column label="体检项目" align="center" prop="tjProName" width="120px" :show-overflow-tooltip="true" />
                <el-table-column label="应收金额" align="center" prop="copeWith" width="90px" />
                <el-table-column label="实收金额" align="center" prop="paidIn" width="80px" />
                <el-table-column label="付款类型" align="center" prop="payType" width="80px">
                    <template slot-scope="scope">
                        <dict-tag :options="dict.type.dict_pay_type" :value="scope.row.payType" />
                    </template>
                </el-table-column>
                <el-table-column label="收费员" align="center" prop="updateBy" width="100px" />
                <el-table-column label="收退时间" align="center" prop="updateTime" width="160px" />
                <el-table-column fixed="right" label="操作" align="center" class-name="small-padding " width="100px"
                    v-if="queryParams.type == '4'">
                    <template slot-scope="scope">
                        <el-button size="mini" type="text" @click="handlerefund(scope.row)"
                            v-if="scope.row.remarks != '已退费'">退费</el-button>
                        <el-button size="mini" type="text" v-if="scope.row.remarks == '已退费'">{{ scope.row.remarks
                        }}</el-button>
                        <el-button size="mini" type="text" v-if="scope.row.remarks != '已退费'"
                            @click="receipt(scope.row)">补打</el-button>
                    </template>
                </el-table-column>
            </el-table>
        </template>
        <div style="
              position: absolute;
              bottom: 100px;
              width: 360px;
              display: none;
            ">
            <div id="printBill" style="width: 280px;font-size: 1px;" ref="printContent">
                <div style="font-size: 1px;">
                    <div style="text-align: center;">
                        <h3>{{ hospName }}小票</h3>
                    </div>
 
                    <div style="margin-top: 4px;">
                        <div>
                            姓名:{{ formIn.name }}
                        </div>
                        <div>
                            电话:{{ formIn.phone }}
                        </div>
                        <div>
                            体检项目:{{ formIn.tjPro }}
                        </div>
                        <div>
                            折扣:{{ formIn.zk + "%" }}
                        </div>
                        <div>
                            实收金额:{{ formIn.ss }}元
                        </div>
                        <div>
                            收费时间:{{ currentDate + " " + currentTime }}
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</template>
    
<script>
import { getTjPrice, addOrderAndDetail, tjRefund, getFlowingWaterList, getPrintSetUp } from "@/api/system/examcharge";
import { getInfo } from "@/api/login";
import { projectGetList } from "@/api/system/tijian";
import printJS from "print-js";
export default {
    dicts: ["dict_pay_type"],
    name: "Examcharge",
 
    data() {
        let checkPhoneNum = (rule, value, callback) => {
         console.log( value)
      let patter = new RegExp(/^1\s*[3456789]\s*(\d\s*){9}$/);
      if (value == "" && value == undefined && !value) {
        return callback('');
      }  else if(value != undefined && value != ""){
        return callback();
      }else if (!patter.test(value)) {
        return callback('');
      }
    };
        return {
            tjNumbers: "",
            // 遮罩层
            loading: false,
            Projectopen1: false,
            // 弹出层标题
            title: "",
            disabled: "",
            iconData: "el-icon-arrow-down",
            DataList: [],
            tableList: [],
            list: [],
            Treedata: [],
            defaultProps: {
                children: "tjProjectList",
                label: "proName",
                disabled: function (data, node) {
                    if (data.tjProjectList && data.tjProjectList.length > 0) {
 
                        return false
                    }
                    else {
                        return true
                    }
                }
 
            },
            // 选中数组
            ids: [],
            getInfodis: "",
            waterId: "",
            type: "1",
            toggleSearchStatus: "0",
            queryParams: {
                name: null,
                phone: null,
                type: null
            },
            formIn: {
                name: null,
                tjPro: null,
                phone: null,
                number: 1,
                ys: "0",
                ss: "0",
                type: "0",
                zk: 10,
 
            },
            hospName: "",
            currentDate: "",
            currentTime: "",
            // 表单参数
            form: {
                name: null,
                tjPro: null,
                tjProName: "体检费",
                phone: null,
                number: 1,
                ys: 0,
                ss: 0,
                type: "0",
                zk: 10,
 
            },
            // 表单校验
            rules: {
                name: [{ required: true, validator: checkPhoneNum,  trigger: "change" }],
                tjPro: [
                    { required: true, validator: checkPhoneNum,  trigger: "change" },
                ],
                type: [
                    { required: true, validator: checkPhoneNum,  trigger: "blur" },
                ],
            },
        };
    },
    created() {
        this.getList();
        this.handleUpdate();
        this.getCurrentDateTime()
 
        this.startTimer()
    },
    methods: {
        getCurrentDateTime() {
 
            const currentDate = new Date()
 
            // 格式化日期:YYYY-MM-DD
 
            const year = currentDate.getFullYear()
 
            const month = String(currentDate.getMonth() + 1).padStart(2, '0')
 
            const day = String(currentDate.getDate()).padStart(2, '0')
 
            this.currentDate = `${year}-${month}-${day}`
 
            // 格式化时间:HH:mm:ss
 
            const hours = String(currentDate.getHours()).padStart(2, '0')
 
            const minutes = String(currentDate.getMinutes()).padStart(2, '0')
 
            const seconds = String(currentDate.getSeconds()).padStart(2, '0')
 
            this.currentTime = `${hours}:${minutes}:${seconds}`
 
        },
 
        startTimer() {
 
            this.timer = setInterval(() => {
 
                this.getCurrentDateTime()
 
            }, 1000) //每秒钟更新一次
 
        },
 
        beforeDestroy() {
 
            clearInterval(this.timer)
 
        },//清除定时器,以避免内存泄露。
 
        getList() {
            getTjPrice().then(res => {
                if (res.data) {
                    const r = /^\+?[0-9][0-9]*$/; //正整数(可以0打头)
                    if (r.test(res.data)) {
                        this.form.ys = res.data + ".00";
                    } else {
                        this.form.ys = res.data
                    }
 
                    this.form.ss = this.form.ys
                }
            })
            getInfo(this.queryParams).then((response) => {
                this.hospName = response.hospName;
            });
 
        },
        changRed({ row }) {
            if (row.remarks == '已退费') { // 变颜色的条件
                return {
                    backgroundColor: "#9cdcfe"  // 这个return的就是样式 可以是color 也可以是backgroundColor
                }
            }
        },
        handleToggleSearch() {
            if (this.toggleSearchStatus == "0") {
                this.toggleSearchStatus = "1"
                this.iconData = "el-icon-arrow-up"
            } else {
                this.toggleSearchStatus = "0"
                this.iconData = "el-icon-arrow-down"
            }
 
        },
        //重置按钮
        resetQuery() {
            this.form = {
                name: null,
                tjPro: null,
                phone: null,
                tjProName: "体检费",
                number: 1,
                ys: 0.00,
                ss: 0.00,
                type: "0",
                zk: 10,
            };
            this.resetForm("form");
        },
 
        // 表格单选
        handleSelect(selection, val) {
            this.DataList = this.$refs.multipleTable.selection;
        },
        handleUpdate() {
            if (this.type == 1) {
                this.queryParams.type = 4
                getFlowingWaterList(this.queryParams).then(res => {
                    this.tableList = res.data
 
                })
            } else {
                this.queryParams.type = this.type
                getFlowingWaterList(this.queryParams).then(res => {
                    this.tableList = res.data
 
                })
            }
 
        },
        hadeltjpro() {
 
            /** 查询部门下拉树结构 */
            projectGetList().then((response) => {
                this.Treedata = response.data.list;
 
            });
            this.Projectopen1 = true;
            this.title = "项目列表";
        },
        // 点击获取每个树节点
        handleCurrentChecked(data, checked, checkedNodes) {
            console.log(data, checked)
            // this.form.tjPro = "",
            //     this.form.ys = 0
            if (checked) {
                // this.menuOptions.id = data.id
                this.$refs.tree.setCheckedKeys([data.proId], true)
            } else {
                // this.menuOptions.id = null
            }
            if (checked == true) {
                this.form.tjPro = data.proId
                this.form.tjProName = data.proName
                const r = /^\+?[0-9][0-9]*$/; //正整数(可以0打头)
                if (r.test(data.proPrice)) {
                    this.form.ys = data.proPrice + ".00";
                } else {
                    this.form.ys = data.proPrice
                }
            }
 
            this.Projectopen1 = false;
        },
 
        // 折扣
        numberChange() {
            let price = (this.form.ss / this.form.ys) * 10
            this.form.zk = price.toFixed(2)
        },
        receipt(row) {
            getPrintSetUp().then(res => {
                if (res.msg == "0") {
                    this.formIn = {
                        name: row.customer.cusName,
                        tjPro: row.tjProName,
                        phone: row.customer.cusPhone,
                        ys: row.copeWith,
                        ss: row.paidIn,
                        zk: row.discount,
                    }
                    this.$nextTick(() => {
                        const style =
                            "@media print { @page{margin:0 10mm,size:4mm 6mm;}};"; //打印时去掉眉页眉尾
                        printJS({
                            printable: "printBill", // 标签元素id
                            noPrint: ".noPrint",
                            type: 'html',
                            header: "",
                            targetStyles: ["*"],
                            maxWidth: "800",
                            scanStyles: true, //打印必须加上,不然页面上的css样式无效
                            style,
                        });
                    });
                } else {
                    const tjnumber = row.tjNumber;
                    const viewNum = "809623418249637888";
                    const params = { viewNum, tjnumber };
                    this.$tab.openPage("个人发票", "/report/charge", params);
                }
                this.resetQuery()
                this.handleUpdate()
                this.getList()
            })
 
        },
 
        // 收费
        SubmitEvent() {
            if (this.form.name) {
                this.formIn = this.form
                addOrderAndDetail(this.form).then(res => {
                    if (res.code == 200) {
                        this.tjNumbers = res.msg
                        this.$modal.msgSuccess("收费成功");
                        getPrintSetUp().then(res => {
                            if (res.msg == "0") {
                                this.$nextTick(() => {
                                    const style =
                                        "@media print { @page{margin:0 10mm,size:4mm 6mm;}};"; //打印时去掉眉页眉尾
                                    printJS({
                                        printable: "printBill", // 标签元素id
                                        noPrint: ".noPrint",
                                        type: 'html',
                                        header: "",
                                        targetStyles: ["*"],
                                        maxWidth: "800",
                                        scanStyles: true, //打印必须加上,不然页面上的css样式无效
                                        style,
                                    });
                                });
 
                            } else {
                                const tjnumber = this.tjNumbers;
                                const viewNum = "809623418249637888";
                                const params = { viewNum, tjnumber };
                                this.$tab.openPage("个人发票", "/report/charge", params);
                            }
                            this.resetQuery()
                            this.handleUpdate()
                            this.getList()
                        })
 
                    }
                })
            } else {
                this.$modal.msgError("请填写姓名");
            }
 
        },
        handlerefund(row) {
            this.$confirm('您确定要退费吗?', '提示', {
                confirmButtonText: '确定',
                cancelButtonText: '取消',
                type: 'warning'
            }).then(() => {
                let data = {
                    waterId: row.waterId
                }
                tjRefund(data).then(res => {
                    if (res.code == 200) {
                        this.$modal.msgSuccess("退费成功");
                        this.handleUpdate()
                    }
 
                })
            }).catch(() => {
                this.$message({
                    type: 'info',
                    message: '已取消退费'
                });
            });
 
 
        }
    },
};
</script>
  
<style>
#sig .el-table__header-wrapper .el-checkbox {
    display: none;
}
</style>