Helius
2022-05-27 4351e71d782741143a98f86f6648acd16689165f
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
<!DOCTYPE HTML>
<html xmlns:th="http://www.thymeleaf.org" xmlns:matrix="http://www.w3.org/1999/xhtml">
<head>
<meta charset="utf-8">
<META HTTP-EQUIV="Pragma" CONTENT="no-cache">
<meta name="renderer" content="webkit|ie-comp|ie-stand">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport"
    content="width=device-width,initial-scale=1,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no" />
<meta http-equiv="Cache-Control" content="no-siteapp" />
<LINK rel="Bookmark" href="../images/favicon.ico">
    <!-- 本框架基本脚本和样式 -->
    <script type="text/javascript" th:src="@{/js/systools/MBaseVue.js}"></script>
    <link rel="stylesheet" th:href="@{/plugin/element-ui/index.css}">
    <link th:href="@{/css/styleOne/style.min.css}" rel="stylesheet" type="text/css"/>
<title></title>
    <style>
        .paymethod ul {
            padding: 0;
            margin: 0;
            height: 50px;
        }
        .paymethod ul li {
            padding: 10px;
            margin: 5px;
            list-style:none;
            float: left;
            display: block;
            cursor: pointer;
            position: relative;
            border: white 1px solid;
        }
        .paymethod ul li:hover {
            border: #409EFF 1px solid;
        }
        .paymethod .active {
            border: #409EFF 1px solid;
        }
        .paymethod .active::after {
            content: '';
            display: block;
            height: 0px;
            width: 0px;
            position: absolute;
            bottom: 0;
            right: 0;
            color:#fff;
            /**对号大小*/
            font-size: 10px;
            line-height: 8px;
            border: 3px solid;
            border-color: transparent #4884ff #4884ff transparent;
        }
 
        .el-dialog__body {
            padding-top: 10px !important;
        }
    </style>
</head>
<div class="panel-body" id="app">
    <el-dialog title="还款" :visible.sync="dialogSettleVisible" :show-close="false" :close-on-click-modal="false" :close-on-press-escape="false">
        <el-row type="flex" align="middle" style="padding: 0 0 10px 0;">
            <el-col :span="5" style="text-align: center;">还款金额</el-col>
            <el-col :span="10" style="text-align: center; line-height: 50px;"><span style="color: red; font-size: 20px;">¥ {{order.arrears}}</span></el-col>
        </el-row>
 
        <el-row type="flex" align="middle" style="padding: 10px 0;">
            <el-col :span="5" style="text-align: center;">收款方式</el-col>
            <el-col class="paymethod" :span="15">
                <el-row>
                    <ul>
                        <span v-for="(item, index) in payMethods">
                            <el-popover
                                    :disabled="item.type != '储值卡'"
                                    placement="bottom"
                                    trigger="hover"
                                    @hide="popoverHide(item)">
                                <el-row style="text-align: center;"><span style="padding: 0 0 10px 0; display: block; font-size: 12px;">选择储值卡支付方式</span></el-row>
                                <el-tree :data="moneyCards"
                                         show-checkbox
                                         default-expand-all
                                         node-key="id"
                                         ref="tree"
                                         check-strictly
                                         highlight-current
                                         @check="(click, checked,$item)=>{handleCheckChange(click, checked,$item)}"
                                         :props="defaultProps">
                                </el-tree>
                                <li :class="{active : item.isActive}" slot="reference" @click="payMethodSelect(item, index)"><div style=" height:30px; line-height: 30px; display: flex; align-items: center"><img style="width: 25px; height: 25px; align-items: center;" :src="item.img"><span style="margin-left: 5px;">{{item.value}}</span></div></li>
                            </el-popover>
                        </span>
                    </ul>
                </el-row>
            </el-col>
        </el-row>
 
        <el-row type="flex" align="middle" style="padding: 10px 0 50px 0;">
            <el-col :span="5" style="text-align: center;">支付金额</el-col>
            <el-col :span="15">
                <el-row style="line-height: 50px;" v-for="(item, index) in payMoneys">
                    <el-col :span="6" style="text-align: right; padding-right: 10px; font-size: 12px;">{{item.value}}</el-col>
                    <el-col :span="8"><el-input v-model="item.money"></el-input></el-col>
                    <el-col :span="6" style="margin-left: 10px;" v-if="item.type == '储值卡'">{{item.isGift == 1 ? '赠送余额' : '余额' }}:<span class="arrears">¥ {{item.balance}}</span></el-col>
                </el-row>
            </el-col>
        </el-row>
 
        <el-row style="text-align: center; margin: 20px 0 10px 0">
            <el-checkbox v-model="printPaper">打印小票</el-checkbox>
        </el-row>
 
        <el-row style="text-align: center; margin: 10px 0 0 0">
            <el-button type="primary" @click="submitBj">确认收款</el-button>
            <el-button type="danger" @click="cancelSubmit">取消</el-button>
        </el-row>
    </el-dialog>
</div>
 
<script type="text/javascript" th:src="@{/js/plugin/jquery-2.1.4.min.js}"></script>
<script type="text/javascript" th:src="@{/js/plugin/jquery.query.js}"></script>
<script type="text/javascript" th:src="@{/plugin/layer/layer.js}"></script>
<script type="text/javascript" th:src="@{/js/systools/AjaxProxyVue.js}"></script>
<script type="text/javascript" th:src="@{/js/plugin/vue.js}"></script>
<script type="text/javascript" th:src="@{/plugin/element-ui/index.js}"></script>
<script type="text/javascript"  th:inline="javascript">
    //<![CDATA[
    var vue = new Vue({
        el: '#app',
        data : {
            order : "",
            payMethods: [{
                value: '现金支付',
                img: '/images/pay/cash.png',
                isActive: false,
                type: '现金支付'
            }, {
                value: '微信',
                img: '/images/pay/wechat.png',
                isActive: false,
                type: '微信'
            }, {
                value: '支付宝',
                img: '/images/pay/zhifubao.png',
                isActive: false,
                type: '支付宝'
            }, {
                value: '银行卡',
                img: '/images/pay/yinlian.png',
                isActive: false,
                type: '银行卡'
            }, {
                value: '团购',
                img: '/images/pay/tuan.png',
                isActive: false,
                type: '团购'
            }, {
                value: '储值卡',
                img: '/images/pay/card.png',
                isActive: false,
                type: '储值卡'
            },],
            moneyCards : [],
            dialogSettleVisible : true,
            defaultProps: {
                children: 'children',
                label: 'showLable'
            },
            treeSelect : [],
            payMoneys : [],
            printPaper : false,
        },
        created : function() {
            this.order = /*[[${order}]]*/
            this.getVipMoneyCards();
        },
        methods : {
            submitBj() {
                let _this = this;
                if (_this.payMoneys.length > 0) {
                    let flows = []
                    var total = 0;
                    _this.payMoneys.forEach(item => {
                        let flow = {};
                        flow.payMethod = item.type;
                        if (!item.money) {
                            this.$message.warning("请输入" + item.type + "的付款金额");
                            return false;
                        }
                        flow.amount = item.money;
                        if (item.type == '储值卡'){
                            flow.isGift = item.isGift;
                            flow.cardId = item.id;
                        }
                        total += item.money;
                        flows.push(flow)
                    })
                    if (total > _this.order.arrears) {
                        this.$message.warning("输入付款总金额大于应还金额");
                        return false;
                    }
                    _this.order.flows = flows;
                } else {
                    this.$message.warning("请选择支付方式");
                    return false;
                }
 
                let url = basePath + "/admin/moneyCardUse/bj";
 
                AjaxProxy.requst({
                    app: _this,
                    data: _this.order,
                    url: url,
                    callback: function (data) {
                        if (_this.printPaper) {
                            _this.print();
                        }
 
                        if(parent.myGrid) {
                            parent.myGrid.serchData();
                        }
 
                        if (parent.app) {
                            parent.app.orderQuery();
                        }
 
                        _this.closeFrame();
                    }
                });
            },
            cancelSubmit() {
                this.closeFrame();
            },
            print() {
                let _this = this;
                if (_this.order.id) {
                    layer.open({
                        type: 2,
                        title: "打印订单",
                        area: ['250px', '550px'],
                        maxmin: true,
                        content: [basePath + '/admin/order/printOrder?id=' + this.order.id],
                        cancel: function (index, layero) {
                            _this.closeFram();
                        }
                    });
                } else {
                    this.$message.warning("请先挂单在打印");
                }
 
 
            },
            getVipMoneyCards() {
                let _this = this;
                if (_this.order.vipId) {
                    AjaxProxy.requst({
                        app: _this,
                        data: {vipId: _this.order.vipId},
                        contentType: 'application/x-www-form-urlencoded',
                        url: basePath + '/admin/moneyCardUse/getUseMoneyCard',
                        callback: function (data) {
                            if (data.rows.length > 0) {
                                data.rows.forEach(function (item, index, input) {
                                    item.showLable = item.cardName + "-余额:" + (item.realMoney)
                                    item.uuid = MTools.uuid();
                                    if (item.giftMoney != 0) {
                                        var children = [];
                                        var gift = {};
                                        gift.id = item.id;
                                        gift.giftMoney = item.giftMoney;
                                        gift.showLable = item.cardName + '-赠送金额' + item.giftMoney;
                                        gift.cardName = item.cardName;
                                        gift.isGift = 1;
                                        gift.uuid = MTools.uuid();
                                        children.push(gift);
                                        item.children = children;
                                    }
                                });
                                _this.moneyCards = data.rows;
                            }
 
                        }
                    });
                }
            },
            payMethodSelect(item, index) {
                let _this = this;
                let payMoneys = _this.payMoneys;
                if (item.type != '储值卡') {
                    this.$nextTick(function () {
                        if (item.isActive) {
                            Vue.set(item,'isActive',false);
                            var index = -1;
                            for (var i = 0; i < payMoneys.length; i++) {
                                let payMoney = payMoneys[i];
                                if (payMoney.value == item.value) {
                                    index = i;
                                    break;
                                }
                            }
 
                            if (index > -1) {
                                _this.payMoneys.splice(index, 1)
                            }
                        } else {
                            Vue.set(item,'isActive',true);
                            var hasAmount = 0;
                            for(var i = 0; i < payMoneys.length; i++) {
                                hasAmount += parseFloat(payMoneys[i].money);
                            }
                            if (_this.order.arrears - hasAmount > 0) {
                                Vue.set(item, 'money', _this.order.arrears - hasAmount);
                            }
                            _this.payMoneys.push(item);
                        }
                    });
                }
            },
            popoverHide(item) {
                if(this.treeSelect.length <= 0) {
                    Vue.set(item, 'isActive', false)
                } else {
                    Vue.set(item, 'isActive', true)
                }
            },
            handleCheckChange(clickNode, checked) {
                let _this = this;
 
                let nodes = checked.checkedNodes;
                _this.treeSelect = nodes;
                var index = -1;
                // 判断点击节点是否在已展示支付方式中
                for(var i = 0; i < _this.payMoneys.length; i++) {
                    let node = _this.payMoneys[i];
                    if (node.uuid === clickNode.uuid) {
                        index = i;
                        break;
                    }
                }
 
                // 若点击节点在选中节点中,且已展示支付方式不存在,则添加
                if (nodes.indexOf(clickNode) > -1 && index === -1) {
                    var node = clickNode;
                    var item = {};
                    if (node.isGift) {
                        item.value = node.cardName;
                        item.balance = node.giftMoney;
                        item.isGift = 'Y';
                    } else {
                        item.value = node.cardName;
                        item.balance = node.realMoney;
                        item.isGift = 'N';
                    }
                    item.type = '储值卡';
                    item.id = node.id;
                    item.uuid = clickNode.uuid;
                    _this.payMoneys.push(item);
                }
 
                // 若点击节点不存在选中节点中,且已展示支付方式中存在,则移除
                if (nodes.indexOf(clickNode) === -1 && index > -1) {
                    _this.payMoneys.splice(index, 1);
                }
            },
            closeFrame() {
                parent.layer.close(parent.layer.getFrameIndex(window.name));
            },
        }
    });
    //]]>
</script>
</body>
</html>