Helius
2020-12-23 c554c7ad5405bafa149dbb6429e8245f78b33ffc
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
<!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"/>
    <!-- 本框架基本脚本和样式 -->
    <script type="text/javascript"
            th:src="@{/js/plugin/jquery-2.1.4.min.js}"></script>
    <script type="text/javascript" th:src="@{/js/systools/MBase.js}"></script>
 
</head>
<body class=" container-fluid">
<div class="pd-10">
    <!-- 搜索框部分start -->
    <div class="row form-head">
        <form class="form-inline" id="serchform">
            <!-- 用于套餐的查询 -->
            <input autocomplete="off"   type="hidden" name="vipId" value="" id="vipId">
 
            <div class="form-group mr-20 mt-10">
                <label>充值卡名称</label> <input autocomplete="off"   name="cardName" type="text"
                                            class="form-control">
            </div>
 
            <div class="form-group mr-20 mt-10">
                <label for="status">状态</label> <select name="status"
                                                       class="form-control">
                <option value="">--请选择状态--</option>
                <option value="有效">有效</option>
                <option value="无效">无效</option>
                <option value="转让">转让</option>
                <option value="冻结">冻结</option>
                <option value="退款">退款</option>
            </select>
            </div>
 
            <div class="form-group mr-20 mt-10">
                <label >来源</label> <select name="source"
                                                       class="form-control">
                <option value="">--请选择来源--</option>
                <option value="购买">购买</option>
                <option value="赠送">赠送</option>
                <option value="转让">转让</option>
                <option value="数据迁移">数据迁移</option>
            </select>
            </div>
            <div class="form-group">
                <button onclick="myGrid.serchData(1)" type="button"
                        class="btn btn-sm btn-info">
                    <i class="fa fa-search "></i> 搜索
                </button>
                <button type="reset" class="btn btn-sm btn-info ">
                    <i class="fa fa-refresh "></i> 重置
                </button>
 
            </div>
        </form>
    </div>
    <div class="row mt-10">
<!--        <div id="option-bar">-->
<!--            &lt;!&ndash; 功能按钮部分 &ndash;&gt;-->
<!--                <button matrix:btn="vipInfo-youxiao"  class="btn btn-info btn-sm " onClick="openActive()">-->
<!--                    <i class="fa fa-hand-o-up"></i> 有效-->
<!--                </button>-->
<!--                <button matrix:btn="vipInfo-wuxiao"  class="btn btn-info btn-sm " onClick="openInvalid()">-->
<!--                    <i class="fa fa-hand-o-down"></i> 无效-->
<!--                </button>-->
 
<!--                <button matrix:btn="vipInfo-tuikuan"  class="btn btn-info btn-sm " onClick="returnMoney()">-->
<!--                    <i class="fa  fa-step-backward"></i> 退款-->
<!--                </button>-->
<!--                <button matrix:btn="vipInfo-dongjie"  class="btn btn-info btn-sm " onClick="freezeTc()">-->
<!--                    <i class="fa fa-stop"></i> 冻结-->
<!--                </button>-->
<!--                <button matrix:btn="vipInfo-cardEdit"  class="btn btn-info btn-sm " onClick="openEditPro()">-->
<!--                    <i class="fa fa-edit"></i> 编辑-->
<!--                </button>-->
 
<!--        </div>-->
        <!-- 数据表格部分 -->
        <table id="mgrid">
            <thead>
            <tr>
                <th data-checkbox="true"></th>
                <th data-formatter="MGrid.indexfn" data-align="center"
                    data-width="30px">序号</th>
                <th data-field="vipInfo.vipName">所属客户</th>
                <th data-field="cardName" data-sortable="true">充值卡名称</th>
                <th data-field="useTotal">总次数</th>
                <th data-field="lastCount">剩余次数</th>
                <th data-field="realMoney">本金</th>
                <th data-field="giftMoney">赠送金额</th>
                <th data-field="source">来源</th>
                <th data-field="status">状态</th>
                <th data-field="isVipCar" data-formatter="getYesOrNo">是否是会籍卡</th>
                <th data-field="isOver" data-formatter="getYesOrNo">是否使用完成</th>
                <th data-field="failTime" data-formatter="MGrid.getTimeDD">到期时间</th>
                <th data-field="remark" >备注</th>
 
            </tr>
            </thead>
        </table>
        <!-- 数据表格部分end -->
        <div class="form-group ">
            <div class="col-sm-12 text-center fixed-button">
                <a class="btn btn-danger radius" href="javascript:;"
                   onclick="MTools.closeForm()"><i class="fa fa-close"></i> 关闭</a>
            </div>
        </div>
    </div>
</div>
<div id="tuikuandan" style="display: none">
    <div class="col-sm-12">
        <div class=" form-group mr-20">
            <label>店铺</label> <select class="form-control autoFull"
                                      th:data-url="@{/hiveErp/shopInfo/findShopByRole}" data-value="id"
                                      data-filed="shopName" name="shopId" id="shopId">
            <option value="">--请选择门店--</option>
        </select>
        </div>
    </div>
    <div class="col-sm-12">
        <div class=" form-group mr-20">
            <label>备注</label> <input autocomplete="off"   id="remark" type="text"
                                     class="form-control">
        </div>
    </div>
    <div class="form-group ">
        <div class="col-sm-12 text-center">
            <a href="javascript:;" onclick="xjtk()"
               class="btn btn-success radius">确认</a>&nbsp;&nbsp;&nbsp;&nbsp;
        </div>
    </div>
 
</div>
<script type="text/javascript" th:src="@{/js/systools/MJsBase.js}"></script>
<script type="text/javascript">
    $(".select2").select2();
    MTools.autoFullSelect();
    //记录一下客户id和退款
    var p_vipId = 0, p_value = 0, layerIndex, p_money, p_name, p_hjkId;
    //初始化表格
    $("#vipId").val($.query.get("vipId"));
    var myGrid;
    myGrid = MGrid.initGrid({
        url : basePath
            +"/admin/moneyCardUse/showVipMoneyCardList",
    });
 
    //设置有效
    function openActive() {
        var id = myGrid.getSelectItemId();
        $
            .AjaxProxy({
                p : {
                    id : id
                }
            })
            .invoke(
                basePath
                +"/admin/moneyCardUse/active",
                function(loj) {
                    var rs = loj.attr("result");
                    console.log(loj);
                    if (rs.info == '已过期') {
                        layer
                            .open({
                                type : 2,
                                title : "设置过期日期",
                                area : [ "420px", '300px' ],
                                content : [ basePath+'/admin/redirect/vip/select-date-card?id='
                                + id ]
                            });
                    } else {
                        layer.alert(loj.getValue("info"), {
                            icon : 1
                        });
                        myGrid.serchData();
                    }
                });
    }
    //设置无效
    function openInvalid() {
        var id = myGrid.getSelectItemId();
        $.AjaxProxy({
            p : {
                id : id
            }
        }).invoke(basePath
            +"/admin/moneyCardUse/invalid", function(loj) {
            layer.alert(loj.getValue("info"), {
                icon : 1
            });
            myGrid.serchData();
        });
    }
 
 
 
    //退款
    function returnMoney() {
        var row = myGrid.getSelectItem();
        var vipId = row.vipId;
        var value = row.id;
        var goodsName = row.cardName;
        //判断是否有会籍卡
        $.AjaxProxy({
            p : {
                vipId : vipId,
                id : value
            }
        }).invoke(
            basePath
            +"/admin/moneyCardUse/getEffectCard",
            function(loj) {
                console.log(loj);
                var rs = loj.attr("result");
                var info = rs.info;
                var name = loj.getString("0", "moneyCard").name;
                var hjkId = loj.getString("0", "id");
                var money = loj.getString("0", "realMoney");
                if (info == '有有效会籍卡') {
                    layer.confirm('本金' + money + '元将会存储到名称为【' + name
                        + '】的会籍卡中,请确认', {
                        btn : [ '确认', '取消' ]
                        //按钮
                    }, function() {
                        p_vipId = vipId;
                        p_value = value;
                        p_money = money;
                        p_name = goodsName;
                        p_hjkId = hjkId;
 
                        //弹出门店选择框,备注输入框
                        layerIndex = layer.open({
                            type : 1,
                            shade : false,
                            title : "请填写退款信息", //不显示标题
                            area : [ '520px', '240px' ], //宽高
                            content : $('#tuikuandan'), //捕获的元素,注意:最好该指定的元素要存放在body最外层,否则可能被其它的相对元素所影响
                        });
 
                    }, function() {
                        //取消的操作
                    });
                } else {
 
                    layer.prompt({
                        title : '会籍卡余额' + money + '元,请输入退款金额,并确认',
                        formType : 0
                    }, function(text, index) {
                        // layer.close(index);
                        var reg = /^(([0-9]+)|([0-9]+\.[0-9]{1,2}))$/;
                        var isMoneyFormatRight = reg.test(text);
                        if (isMoneyFormatRight) {
                            if (text > money) {
                                layer.msg("退款金额不能大于会籍卡余额!");
                                return false;
                            } else {
 
                                p_vipId = vipId;
                                p_value = value;
                                p_money = text;
                                p_name = goodsName;
                                p_hjkId = hjkId;
 
                                //弹出门店选择框,备注输入框
                                layerIndex = layer.open({
                                    type : 1,
                                    shade : false,
                                    title : "请填写退款信息", //不显示标题
                                    area : [ '520px', '240px' ], //宽高
                                    content : $('#tuikuandan'), //捕获的元素,注意:最好该指定的元素要存放在body最外层,否则可能被其它的相对元素所影响
                                });
 
                            }
                        } else {
                            layer.msg("请输入最多两位小数的数字!");
                            return false;
                        }
 
                        /* layer.prompt({title: '随便写点啥,并确认', formType: 2}, function(text, index){
                          layer.close(index);
                          layer.msg('演示完毕!您的口令:'+ pass +'<br>您最后写下了:'+text);
                        }); */
                    });
 
                    /* layer.confirm(info+',是否要退现金'+money+'元,请确认', {
                      btn: ['确认','取消'] //按钮
                    }, function(){
                          //退现金
                         $.AjaxProxy({
                             p:{vipId:vipId,id:value,returnMonery:money}
                            }).invoke(basePath
                            +"/admin/moneyCardUse/returnMoney",function(loj){
                                     layer.alert(loj.getValue("info"), {
                                          icon : 1
                                        });
                                     myGrid.serchData();
                             }
                         );
 
                    }, function(){
                        //取消的操作
                    }); */
 
                }
            });
 
    }
 
    //退现金
    function xjtk() {
        $.AjaxProxy({
            p : {
                vipId : p_vipId,
                id : p_value,
                returnMonery : p_money,
                money : p_money,
                tcRemark : $("#remark").val(),
                shopId : $("#shopId").val(),
                tcName : p_name,
                hjkId : p_hjkId
            }
        }).invoke(basePath
            +"/admin/moneyCardUse/returnMoney", function(loj) {
            layer.alert(loj.getValue("info"), {
                icon : 1
            });
            myGrid.serchData();
            layer.closeAll();
        });
    }
 
    //冻结
    function freezeTc() {
        var id = myGrid.getSelectItemId();
        $.AjaxProxy({
            p : {
                id : id
            }
        }).invoke(basePath
            +"/admin/moneyCardUse/freeze", function(loj) {
            layer.alert(loj.getValue("info"), {
                icon : 1
            });
            myGrid.serchData();
        });
    }
 
    function getYesOrNo(value, row, index) {
        switch (value) {
            case 'Y':
                return "是";
            case 'N':
                return "否";
            default:
                return value;
        }
    }
 
    //修改
    function openEditPro() {
        var id = myGrid.getSelectItemId();
        console.log("id = " + id);
        //弹出修改框
        layer.open({
            type : 2,
            title : "编辑",
            area : MUI.SIZE_M,
            maxmin : true,
            content : [ basePath+'/admin/moneyCardUse/editForm?id=' + id ]
        });
    }
</script>
 
</body>
</html>