Helius
2020-12-23 e3b4931158274097a8389b4fbec05e44ac0bb2d2
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
 
 
 
 
<!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/plugin/jquery-2.1.4.min.js}"></script>
<script type="text/javascript"
    th:src="@{/js/systools/MBase.js}"></script>
 
<title></title>
 
 
</head>
 
<div class="panel-body">
    <div class="form-group">
        <label class="col-sm-2 control-label">订单号</label>
        <div class="col-sm-4">
            <span class="form-control-static" th:text="${order.orderNo}"></span>
        </div>
        <label class="col-sm-2 control-label">订单总价</label>
        <div class="col-sm-4">
            <span class="form-control-static" id="total" th:text="${order.total}"></span>
        </div>
    </div>
    <br>
    <div class="form-group">
        <label class="col-sm-2 control-label">客户编号</label>
        <div class="col-sm-4">
            <span class="form-control-static" th:text="${order.vipNo}"></span>
        </div>
        <label class="col-sm-2 control-label">客户姓名</label>
        <div class="col-sm-4">
            <span class="form-control-static" th:text="${order.vipName}"></span>
        </div>
    </div>
    <br>
    <div class="form-group">
        <label class="col-sm-2 control-label">折后价</label>
        <div class="col-sm-4">
            <span class="form-control-static" id="zkTotal" th:text="${order.zkTotal}"></span>
        </div>
        <label class="col-sm-2 control-label">欠款</label>
        <div class="col-sm-4">
            <span class="form-control-static" id="zkTotal" th:text="${order.arrears}"></span>
        </div>
    </div>
    <br>
    <div class="form-group">
        <label class="col-sm-2 control-label">卡付金额</label>
        <div class="col-sm-4">
            <span class="form-control-static" id="zkTotal" th:text="${order.cardPay}"></span>
        </div>
        <label class="col-sm-2 control-label">现金付款</label>
        <div class="col-sm-4">
            <span class="form-control-static" id="zkTotal" th:text="${order.cashPay}"></span>
        </div>
    </div>
    <br>
    <div class="form-group">
        <label class="col-sm-2 control-label">顾问姓名</label>
        <div class="col-sm-4">
            <span class="form-control-static" th:text="${order.staffName}"></span>
        </div>
    </div>
</div>
 
 
 
 
<div class="row ">
    <div class="col-sm-10 pd-20 col-sm-offset-1">
        <form class="form-horizontal" id="dataform"
            onsubmit="javascripr:return false;">
            <div class="tabs-container ">
                <ul class="nav nav-tabs">
                    <li class="active"><a data-toggle="tab" href="#tab-1"
                        aria-expanded="true">收款</a></li>
                    <li class=""><a data-toggle="tab" href="#tab-2"
                        aria-expanded="false">业绩</a></li>
                </ul>
                <div class="tab-content">
                    <div id="tab-1" class="tab-pane active">
                        <div class="panel-body">
                            <div class="col-sm-12 form-group">
                                <!-- 改变折扣后的总价 -->
                                <input autocomplete="off"   type="hidden" name="zkTotal" th:value="${order.zkTotal}"
                                    id="zkTotalInput">
                                <div class="panel-body">
                                    <table class="table table-striped table-condensed  table-hover">
                                        <thead>
                                            <tr>
                                                <th>序号</th>
                                                <th>商品名称</th>
                                                <th>单价</th>
                                                <th>购买数量</th>
                                                <th>折扣单价</th>
                                                <th>支付方式</th>
                                                <th>支付金额</th>
                                            </tr>
                                        </thead>
                                        <tbody id="tbody">
                                        <tr th:each="item,count:${order.items }">
                                            <td th:text="${count.index}+1"></td>
                                            <td>
                                                <span th:text=" ${item.shoppingGoods.name }"></span>
 
                                                <span th:if="${item.isFree eq '是' }" th:text="赠"></span>
                                            </td>
                                                    <td th:text="${item.price }"></td>
                                                    <td th:text="${item.count}"></td>
                                                    <td th:text="${item.zkPrice}"></td>
 
                                                    <td><input autocomplete="off"   type="hidden"
                                                        th:name="'items['+${count.index}+'].id'"
                                                               th:value="${item.id }">
 
 
                                                        <input autocomplete="off"   type="hidden" th:name="'items['+${count.index}+'].goodsId'"
                                                               th:value="${item.goodsId }">
                                                        <input autocomplete="off"   type="hidden"  th:name="'items['+${count.index}+'].count'"  th:value="${item.count}">
 
                                                        <select class="form-control"
                                                        th:name="'items['+${count.index}+'].payMethod'">
                                                                    <option th:if="${item.type eq '充值卡'}" value="现金">现金</option>
                                                                    <option value="现金">现金</option>
                                                            <th:block th:if="${item.type ne '充值卡'}">
                                                                    <th:block th:each="cardItem:${cards }" >
                                                                        <option th:value="${cardItem.id }" th:text="${cardItem.cardName }+'-余:'+${cardItem.realMoney+cardItem.giftMoney}"></option>
                                                                    </th:block>
                                                            </th:block>
 
                                                    </select></td>
                                                    <td><input autocomplete="off"   type="text" class="form-control"
                                                               th:onchange="'changePayMoney(\'p'+${item.id}+'\',this)'"
 
                                                        onchange="reckonTotal()" dataType="price" nullmsg="请填写金额"
                                                        errormsg="金额可为两位小数的正数" th:value="${item.arrears}"
                                                               th:name="'items['+${count.index}+'].payMoney'" >
                                                        <div class="Validform_checktip"></div></td>
                                                </tr>
                                            </th>
                                        </tbody>
                                    </table>
                                </div>
                            </div>
 
 
 
                            <div class="col-sm-12 form-group">
                                <div class="form-group">
                                    <div class="form-group">
                                        <label class="col-sm-2 control-label">实收金额</label>
                                        <div class="col-sm-4">
                                            <input autocomplete="off"   type="text" class="form-control" name="actualPay"
                                                id="money" readonly="readonly" th:value="${order.arrears}"
                                                datatype="/^(([0-9]\d{0,9})|0)(\.\d{1,2})?$/"
                                                ignore="ignore">
                                            <div class="Validform_checktip"></div>
                                        </div>
 
                                        <label class="col-sm-2 control-label">备注</label>
                                        <div class="col-sm-4">
                                            <input autocomplete="off"   type="text" class="form-control" name="remark"
                                                th:value="${order.remark}" datatype="*0-200" ignore="ignore">
                                            <div class="Validform_checktip"></div>
                                        </div>
                                    </div>
                                </div>
                                <input autocomplete="off"   type="hidden" id="id" name="id" th:value="${order.id}" />
                            </div>
                        </div>
                    </div>
                    <div id="tab-2" class="tab-pane">
                            <div class="panel-body">
                                <table class="table   table-condensed   ">
                                    <thead>
                                        <tr>
                                            <th>序号</th>
                                            <th>商品名称</th>
                                            <th>分配金额</th>
                                            <th>美疗师业绩</th>
                                            <th>操作</th>
                                        </tr>
                                    </thead>
                                    <tbody id="tbody2">
                                        <th:block th:each="item,count:${order.items }"  >
                                            <tr th:id="'p'+${item.id}">
                                                <td th:text="${count.index}+1"></td>
                                                <td th:text="${item.shoppingGoods.name }">
                                                    <span th:if="${item.isFree eq '是' }" th:text="赠"></span>
                                                </td>
                                                <td th:text="${item.arrears }"></td>
                                                <td>
                                                    <table class="table   table-condensed   ">
                                                            <tr th:each="achaeve,count2:${item.achaeveList }">
                                                                <td><select class="autoFull select2 input-sm"
 
                                                                    data-value="suId"
                                                                            data-filed="suName"
                                                                    th:data-def="${achaeve.staffId }"
                                                                    th:name="'items['+${count.index}+'].achaeveList['+${count2.index}'].beaultId'"
                                                                    th:data-url="@{/admin/getShopStaffByRoleName?roleName=美疗师}"
                                                                >
                                                                </select></td>
                                                                <td><input autocomplete="off"   type="text"
                                                                    class="form-control input-sm" style="width: 80px"
                                                                           th:name="'items['+${count.index}+'].achaeveList['+${count2.index}'].t1"></td>
                                                                <td><button class="btn btn-danger btn-sm"
                                                                        onclick="deleteBeaute(this)">删除</button></td>
                                                            </tr>
                                                    </table>
                                                </td>
                                                <td><a class="btn btn-default btn-sm"
                                                    th:onclick="'addBeaute(\'p'+${item.id}+'\','+${count.index}+')'">添加</a></td>
                                            </tr>
 
                                    </tbody>
                                </table>
                            </div>
                        </div>
                    </div>
                    <div class="form-group mt-20 ">
                        <div class="col-sm-12 text-center">
                            &nbsp;&nbsp;&nbsp;&nbsp; <a href="javascript:;"
                                onclick="myForm.submit()" class="btn btn-success radius">确认</a>
                            &nbsp;&nbsp;&nbsp;&nbsp;
                            <button onclick="MTools.closeForm()"
                                class="btn btn-danger radius" type="button">取消</button>
                        </div>
                    </div>
            </div>
        </form>
    </div>
</div>
 
 
<script type="text/javascript" th:src="@{/js/systools/MJsBase.js}"></script><script type="text/javascript">
    var myForm = MForm.initForm({
        invokeUrl : basePath+"/admin/moneyCardUse/bj",
        beforeSubmit : function() {
 
            //校验业绩
            var ifAchieveOk=true;
            $("#tbody2").children("tr").each(function(){
                var tr=$(this);
                var pay=parseFloat(tr.find("td").eq(2).html());
                var achieveSum=0;
                tr.find("td").eq(3).find("table").find("tr").each(function(){
                    var achieve= parseFloat($(this).find("td").eq(1).find("input").val());
                    achieveSum+=achieve;
                });
                if(achieveSum>pay){
                    ifAchieveOk=false;
                }
            });
            if(!ifAchieveOk){
                layer.msg("业绩金额不能大于支付金额",{icon:2})
                return false;
            }
 
 
            var money = parseFloat($("#money").val());
            var total = parseFloat($("#zkTotal").html());
        },
        afterSubmit : function() {
            if(parent.myGrid) {
                parent.myGrid.serchData();
            }
 
            if (parent.app) {
                parent.app.orderQuery();
            }
        },
    });
 
    //添加一个美疗师
    function addBeaute(trId,itemIndex){
        if(!itemIndex){
            itemIndex=0;
        }
         var id=MTools.randomStr();
 
         var table=$("#"+trId).find("td").eq(3).find("table")
 
         var achieveIndex=$("#"+trId).find("td").eq(3).find("table").find("tr").length;
        var html= '<tr> <td><select class="autoFull select2 input-sm" id="'+id+'"  name="items['+itemIndex+'].achaeveList['+achieveIndex+'].beaultId" '
                +'data-url="'+basePath+'/admin/getShopStaffByRoleName?roleName=美疗师" data-value="suId" data-filed="suName" data-def=""'
            +'name="beatuyId"> </select></td> <td><input autocomplete="off"   type="text" class="form-control input-sm"  style="width: 80px"  name="items['+itemIndex+'].achaeveList['+achieveIndex+'].t1" '
            +'name="items['+itemIndex+'].zkPrice" ></td> <td><button class="btn btn-danger btn-sm"  onclick="deleteBeaute(this)" >删除</button></td> </tr>';
        $("#"+trId).find("td").eq(3).find("table").append(html);
        $('#'+id).select2({'width':'80px'});
        MTools.autoFullSelect({selecteder:'#'+id});    
    };
    //删除一个美疗师
    function deleteBeaute(node){
        $(node).closest("tr").remove();
    }
    
    //修改收款金额
    function changePayMoney(trId,node){
        console.log(trId,node);
        $("#"+trId).find("td").eq(2).html($(node).val());
    };
 
    
    //改变折扣单价
    function changeZkprice() {
        var sum = 0;
        $("#tbody").find("tr").each(function() {
            var $tds = $(this).find("td");
            var count = $tds.eq(3).html();
            var zkprice = $tds.eq(4).find("input").eq(0).val();
            totalMoney = parseFloat(count) * parseFloat(zkprice);
            $tds.eq(6).find("input").eq(0).val(totalMoney);
            sum += totalMoney;
        });
        $("#money").val(sum);
        $("#zkTotal").html(sum);
        $("#zkTotalInput").val(sum);
    }
 
    //计算实收
    function reckonTotal() {
        var sum = 0;
        $("#tbody").find("tr").each(function() {
            var $tds = $(this).find("td");
            var count = $tds.eq(6).find("input").eq(0).val();
            sum += parseFloat(count)
        });
        $("#money").val(sum);
 
    }
</script>
</body>
</html>