wzy
2020-12-22 f06092fc373f4df414a0540578e15236d479e4c9
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
<!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 rel="stylesheet" th:href="@{/plugin/bootstrap-3.3.5/css/bootstrap.min.css}">
    <link th:href="@{/css/styleOne/style.min.css}" rel="stylesheet" type="text/css"/>
</head>
<body>
<div class="ibox-content" id="app" v-cloak>
    <form class="form-horizontal" id="dataform"
          onsubmit="javascripr:return false;">
 
        <div class="form-group">
            <label class="col-md-2 control-label">&nbsp;</label>
            <div class="col-md-12">
                <div class="panel panel-primary">
                    <div class="panel-heading">
                        <div class="row">
                            <div class="col-md-6">
                                <h2>客户:{{vipInfo.vipName}}</h2>
                            </div>
                        </div>
                    </div>
                    <div class="panel-body">
                        <div class="form-group">
                            <label class="col-md-1 control-label">退款时间:</label>
                            <div class="col-md-3">
                                <el-date-picker v-model="orderTime"
                                                type="date"
                                                placeholder="选择日期">
                                </el-date-picker>
                            </div>
 
                        </div>
                        <div class="form-group">
 
                            <label class="col-md-1 control-label">退款类型</label>
                            <div class="col-md-6">
                                <el-button-group>
                                    <el-button @click="openSelect(1)" type="primary" size="small">退产品</el-button>
                                    <el-button @click="openSelect(2)" type="primary" size="small">退项目套餐</el-button>
                                    <el-button @click="openSelect(3)" type="primary" size="small">退卡项</el-button>
                                </el-button-group>
                            </div>
                        </div>
 
 
                        <div class="form-group">
                            <label class="col-md-1 control-label">退款明细</label>
                            <div class="col-md-11">
                                <table class="table table-bordered">
                                    <tr>
                                        <th>序号</th>
                                        <th width="50px">产品名称</th>
                                        <th>原单价</th>
                                        <th>折扣单价</th>
                                        <th>退款数量</th>
                                        <th>卡项退款</th>
                                        <th>现金退款</th>
                                        <th>操作</th>
                                    </tr>
 
                                    <tr v-for="(item,index) in refundItems">
                                        <td>{{index+1}}</td>
                                        <td>{{item.goodsName}}</td>
                                        <td>{{item.price}}</td>
                                        <td>
                                            <el-input :readonly="item.refundType==3" :max="item.price"  v-model="item.zkPrice"></el-input>
                                        </td>
                                        <td>
                                            <el-input :readonly="item.refundType==3" :max="item.maxCount"  v-model="item.count"></el-input>
                                        </td>
                                        <td>
 
                                            <el-input v-if="item.cardName" v-model="item.cardPay"></el-input>
                                            <div>{{item.cardName}}</div>
                                        </td>
                                        <td>
                                            <el-input v-model="item.cashPay"  ></el-input>
                                        </td>
                                        <td>
                                            <el-button @click="remove(index)" size="small" type="danger"
                                                       icon="el-icon-delete"></el-button>
                                        </td>
                                    </tr>
 
                                </table>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-md-1 control-label">备  注:</label>
                            <div class="col-md-7">
                <textarea name="remark" type="text" id="remark"
                          class="form-control" rows="4"
                          v-model="remark"></textarea>
                            </div>
                        </div>
 
                        <div class="form-group ">
                            <div class="col-md-12 text-center">
                                <a href="javascript:;" @click="submit()"
                                   class="btn btn-success radius">保存</a>&nbsp;&nbsp;&nbsp;&nbsp;
                                <button @click="closeFram()" class="btn btn-danger radius" type="button">取消</button>
                            </div>
                        </div>
                    </div>
                </div>
 
            </div>
        </div>
 
    </form>
</div>
</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/bootstrap-3.3.5/js/bootstrap.min.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/layer/layer.js}"></script>
<script type="text/javascript" th:src="@{/plugin/element-ui/index.js}"></script>
<script type="text/javascript">
 
    var vipId = $.query.get("id");
    console.log(vipId);
    var app = new Vue({
        el: '#app',
        data: {
            refundItems: [],
            vipInfo: {},
            orderTime: new Date(),
            remark: "",
            vipId: vipId
        },
        created: function () {
            this.loadInfo();
        },
 
        mounted: function () {
 
        },
 
        methods: {
 
 
            loadInfo: function () {
 
                console.log('加载客户信息数据');
                var _this = this;
                AjaxProxy.requst({
                    app: _this,
                    async: false,
                    url: basePath + '/admin/vipInfo/findUserById?id=' + _this.vipId,
                    callback: function (data) {
                        _this.vipInfo = data.rows[0];
                    }
                });
 
 
            }
            ,
            remove: function (index) {
                this.refundItems.splice(index, 1);
            },
 
            closeFram: function () {
                parent.layer.close(parent.layer.getFrameIndex(window.name));
            },
 
            submit: function () {
                var _this = this;
                var params = {
                    vipId: _this.vipId,
                    items: _this.refundItems,
                    remark: _this.remark,
                }
                if (this.validate(this.refundItems)) {
                    AjaxProxy.requst({
                        app: _this,
                        data: params,
                        url: basePath + '/admin/refundOrder/refundOrder',
                        callback: function (data) {
                            _this.$message({
                                message: data.info,
                                type: 'success',
                                onClose: function () {
                                    _this.closeFram();
                                }
                            });
                        }
                    });
                }
            }
            ,
 
            openSelect: function (type) {
                var title = "";
                var url = "";
                if (type == 1) {
                    title = "选择退款订单";
                    url = basePath + '/admin/redirect/hive/beautySalon/refundSelectOrder-list?keyword=' + this.vipInfo.phone;
                } else if (type == 2) {
                    title = "选择退款项目";
                    url = basePath + '/admin/redirect/hive/beautySalon/refundSelectTaocan-list?vipId=' + this.vipInfo.id;
                } else if (type == 3) {
                    title = "选择退款卡项";
                    url = basePath + '/admin/redirect/hive/beautySalon/refundSelectCard-list?vipId=' + this.vipInfo.id;
                }
                layer.open({
                    type: 2,
                    title: title,
                    area: ["100%", "100%"],
                    content: [url]
                });
 
            },
 
            /**
             * 订单产品退款
             * @param orderId
             */
            selectOrder: function (orderId) {
                console.log('加载退款订单');
                this.createItem({refundType: 1, orderId: orderId})
            },
            /**
             * 项目套餐退款
             * @param orderId
             */
            selectTaocan: function (ids) {
                console.log('项目套餐');
                this.createItem({refundType: 2, ids: ids.join(",")})
            },
            selectCard: function (id) {
                console.log('充值卡');
                this.createItem({refundType: 3, ids: id})
            },
 
            createItem: function (data) {
                var _this = this;
                AjaxProxy.requst({
                    app: _this,
                    async: false,
                    data: data,
                    url: basePath + '/admin/refundOrder/createItem',
                    callback: function (data) {
                        _this.refundItems = data.rows;
                    }
                });
            },
 
 
            validate: function (params) {
                for (var i = 0; i < params.length; i++) {
                    var item = params[i];
                    if( parseFloat(item.zkPrice)> parseFloat(item.price)){
                        this.$message({
                            message: '退款单价不能大于购买单价',
                            type: 'error'
                        });
                        return false;
                    }
                    if( parseFloat(item.count)> parseFloat(item.maxCount)){
                        this.$message({
                            message: '退款数量不能大于购买数量',
                            type: 'error'
                        });
                        return false;
                    }
                    var tkje = parseFloat(item.cardPay) + parseFloat(item.cashPay);
                    var zfje = parseFloat(item.zkPrice) * parseFloat(item.count);
                    if (tkje > zfje) {
                        this.$message({
                            message: '退款金额不能大于购买金额',
                            type: 'error'
                        });
                        return false;
                    }
                }
 
                return true;
            }
            ,
 
 
        },
        filters:
            {
                format: function (value, patten) {
                    if (!value) return '';
                    return MTools.formatDate(value, patten)
                }
                ,
            }
        ,
 
    })
 
 
</script>
</body>
</html>