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
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
<!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/systools/MBaseVue.js}"></script>
    <link rel="stylesheet" th:href="@{/plugin/element-ui/index.css}">
    <script type="text/javascript" th:src="@{/plugin/moment.min.js}"></script>
    <link th:href="@{/css/styleOne/style.min.css}" rel="stylesheet" type="text/css"/>
 
    <!-- 富文本编辑器 -->
    <script type="text/javascript" charset="utf-8"
            th:src="@{/plugin/beditor/ueditor.config.js}"></script>
    <script type="text/javascript" charset="utf-8"
            th:src="@{/plugin/beditor/ueditor.all.js}">
    </script>
    <script type="text/javascript" charset="utf-8"
            th:src="@{/plugin/beditor/lang/zh-cn/zh-cn.js}"></script>
 
 
    <style>
 
        .mform{
            display: flex;
            align-items: center;
            margin-top: 10px;
        }
 
 
        .mixSearchBox .searchResultTable {
            position: absolute;
            padding: 10px;
            border: 1px solid #e4e7ed;
            border-radius: 4px;
            background-color: #fff;
            box-shadow: 0 2px 12px 0 rgba(0, 0, 0, .1);
            box-sizing: border-box;
            margin: 10px 0;
            z-index: 99999999;
        }
        .el-icon-delete{
            cursor: pointer;
        }
        .el-icon-delete:hover{
            color: #F56C6C;
        }
        .tabs {
            margin-bottom: 80px;
        }
        .foot_bar2 {
            top: 98%;
            position: absolute;
            width: 98%;
            height: 80px;
            overflow: hidden;
            left: 0px;
            display: flex;
            align-items: center;
            z-index: 99;
            justify-content: center;
 
        }
        .max-height{
            height: 98%;
        }
        .orderBox{
            position: relative;
            border-left: 1px solid #EFEFEF;
            padding-left: 10px;
            margin-left:10px ;
        }
        .openOrClose {
            cursor:pointer
        }
    </style>
</head>
<body>
<div  class="ibox-content max-height" id="app" v-cloak>
 
    <el-row class="max-height">
        <el-col :span="16" >
            <el-tabs class="tabs" type="card" v-model="activeName" >
                <el-tab-pane label="项目" name="tab1">
 
                    <el-table
                            :data="projList"
                            style="width: 98%">
                        <el-table-column
                                prop="projName"
                                label="项目">
                        </el-table-column>
                        <el-table-column
                                prop="balance"
                                label="余额"
                                width="180">
                        </el-table-column>
                        <el-table-column
                                prop="surplusCount"
                                label="余次">
                        </el-table-column>
                        <el-table-column
                                prop="failTimeStr"
                                label="有效期">
                        </el-table-column>
                        <el-table-column
                                prop="source"
                                label="来源">
                        </el-table-column>
                        <el-table-column
                                prop="address"
                                label="操作">
                            <template slot-scope="scope">
                                <el-button v-if="scope.row.surplusCount>0"  type="primary"
                                           size="mini"
                                           @click="selected(scope.$index, scope.row)">添加
                                </el-button>
                            </template>
                        </el-table-column>
                    </el-table>
 
 
                </el-tab-pane>
                <el-tab-pane label="套餐" name="tab2">
                    <template v-for="(item,index) in taocanList">
                        <p class="el-big-title">
                            <span class="openOrClose" v-if="!item.openOrClose" @click="openOrCloseTc(item, index, 1)"><i class="el-icon-arrow-down"></i></span>
                            <span class="openOrClose" v-if="item.openOrClose" @click="openOrCloseTc(item, index, 2)"><i class="el-icon-arrow-up"></i></span>
                            【{{item.isCourse=='N'?'固定套餐':'任选套餐'}}】{{item.projName}}
                            <span style="float: right" v-if="item.failTime != null">有效期:{{item.failTime}}</span>
                            <code v-if="item.isCourse=='Y'" > 剩余次数:<span v-if="item.isInfinite == 'Y'">无限次</span><span v-else>{{item.surplusCount}}</span> </code>
                        </p>
                        <el-table
                                :data="item.taocanProjUse"
                                style="width: 98%" v-show="item.openOrClose">
                            <el-table-column
                                    prop="projName"
                                    label="项目">
                            </el-table-column>
                            <el-table-column
                                    prop="balance"
                                    label="余额"
                                    width="180">
                            </el-table-column>
                            <el-table-column
                                    prop="surplusCount"
                                    label="余次">
                            </el-table-column>
<!--                            <el-table-column-->
<!--                                    prop="failTimeStr"-->
<!--                                    label="有效期">-->
<!--                            </el-table-column>-->
                            <el-table-column
                                    prop="source"
                                    label="来源">
                            </el-table-column>
                            <el-table-column
                                    prop="address"
                                    label="操作">
                                <template slot-scope="scope">
                                    <el-button v-if="scope.row.surplusCount>0"  type="primary"
                                               size="mini"
                                               @click="selected(scope.$index, scope.row)">添加
                                    </el-button>
                                </template>
                            </el-table-column>
                        </el-table>
                    </template>
<!--                    <el-row style="text-align: center; margin-top: 5px;">-->
<!--                        <el-link type="primary" v-if="!tcIsOpen && taocanList.length > 0" @click="tcIsOpen = true">点击展开</el-link>-->
<!--                        <el-link type="primary" v-if="tcIsOpen" @click="tcIsOpen = false">点击隐藏</el-link>-->
<!--                    </el-row>-->
                </el-tab-pane>
 
            </el-tabs>
        </el-col>
        <el-col :span="7" class="orderBox max-height"  >
            <p class="el-big-title">服务开单</p>
            <el-row class="mform" >
                <el-col :span="6" >预约时间</el-col>
                <el-col :span="18" >
                    <el-date-picker
                            v-model="yyTime"
                            type="date"
                            value-format="yyyy-MM-dd HH:mm"
                            placeholder="选择预约时间">
                    </el-date-picker>
 
                </el-col>
            </el-row>
            <el-row class="mform"  v-for="(item,index) in orderItemList" >
                <el-col :span="16" >{{item.projUse.projName}}</el-col>
                <el-col :span="6" >
                    <el-input @blur="checkCount(item)"  type="number"  v-model="item.count">
                    </el-input>
                </el-col>
                <el-col :offset="1" :span="1" >
                    <i @click="remove(index)" class="el-icon-delete "></i>
                </el-col>
            </el-row>
            <el-row class="foot_bar2">
                <el-button :loading="submiting" type="primary" @click="submitForm('form')" >创建订单</el-button>
                <el-button @click="closeFram()">取消</el-button>
            </el-row>
        </el-col>
    </el-row>
 
 
 
</div>
</body>
<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="@{/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  th:src="@{/plugin/vue-treeselect/vue-treeselect.umd.min.js}"></script>
<link rel="stylesheet"  th:href="@{/plugin/vue-treeselect/vue-treeselect.min.css}">
 
 
<script>
    var id = $.query.get("id");
    //校验方法
    var ValidatorFactory = {
        validateUseCount: function (rule, value, callback) {
            if ((true)) {
                return callback;
            } else {
                return callback(new Error('请输入套餐最大使用次数'));
            }
        }
    };
 
    Vue.component('ValidatorFactory', ValidatorFactory);
    Vue.component('treeselect', VueTreeselect.Treeselect)
 
    var app = new Vue({
        el: '#app',
        data: {
            submiting:false,
            activeName:"tab1",
            orderItemList:[],
            projList:[],
            taocanList:[],
            tcIsOpen : false,
            yyTime:new Date(),
 
 
        },
 
        /**
         * 初始化数据表
         */
        created: function () {
            this.loadinfo();
        },
 
        methods: {
            /**
             * 提交表单
             * */
            submitForm(formName) {
                let _this=this;
                _this.submiting = true;
                if(_this.orderItemList.length<1){
                    _this.$message.error('请选择下单项目');
                    return false;
                }
                 let formData={
                     vipId:id,
                     yyTime:_this.yyTime,
                     serviceItems:[],
                 }
 
                 for(let i=0; i<_this.orderItemList.length; i++){
                     formData.serviceItems.push({
                         puseId:_this.orderItemList[i].projUse.id,
                         count:_this.orderItemList[i].count,
                     });
                 }
 
 
 
                AjaxProxy.requst({
                    app: _this,
                    data: formData,
                    url: basePath + "/admin/projService/addService",
                    callback: function (data) {
                        //提示是否进入排班
                        _this.open(data);
 
                    },
                    fail: function () {
                        _this.submiting = false;
                    }
                });
 
 
            },
            open(data) {
                let _this=this;
                this.$confirm('服务创建成功是否马上排班?', '确认信息', {
                    distinguishCancelAndClose: true,
                    confirmButtonText: '马上排班',
                    cancelButtonText: '暂不排班'
                }).then(() => {
                            window.location.href=basePath+"/admin/projService/yypb?pageFlae=1&id="+data.rows[0].id;
                        })
                        .catch(action => {
                             if(action === 'cancel'){
                                 _this.submiting = false;
                                 _this.closeFram();
                             }
                        });
            },
 
            remove(index){
                this.orderItemList.splice(index, 1);
            },
            checkCount(item){
                if(item.count>item.projUse.surplusCount){
                    item.count=item.projUse.surplusCount;
                    this.$message.error('下单次数不能大于余次');
                }else if(item.count<0){
                    item.count=1;
                    this.$message.error('下单次数不能小于0');
                }
            },
            /**
             * 选择产品
             * */
            selected(index, row) {
 
                    //是否已经被选择了
                    let selected = false;
                    this.orderItemList.forEach(item => {
                        if (item.projUse.id == row.id) {
                            selected = true;
                            //叠加次数
                            if(item.count<item.projUse.surplusCount){
                                item.count=item.count+1;
                            }else{
                                this.$message.error('下单次数不能大于余次');
                            }
 
                            return;
                        }
                    });
                    if (!selected) {
                        if(row.surplusCount>0){
                            this.orderItemList.push({
                                projUse: row,
                                count: 1,
                            });
                        }
 
                    }
 
            },
            loadinfo(){
                let _this=this;
                AjaxProxy.requst({
                    app: _this,
                    url: basePath + "/admin/projService/getUserProjInfo?vipId="+id,
                    callback: function (data) {
                        _this.projList = data.mapInfo.projList;
                        _this.taocanList = data.mapInfo.taoCanList;
                    }
                });
            },
            closeFram: function () {
                parent.layer.close(parent.layer.getFrameIndex(window.name));
            },
            openOrCloseTc : function (item, index, value) {
                if (value == 1) {
                    item.openOrClose = true;
                } else {
                    item.openOrClose = false;
                }
                Vue.set(this.taocanList, index, item);
            }
 
        }
 
    })
</script>
 
</body>
</html>