forked from kidgrow-microservices-platform

zhaoxiaohao
2021-04-26 9adebb75e04e8b0b369ebd318495cb683aa385b8
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
<div class="layui-card">
    <div class="layui-card-header">
        <h2 class="header-title">咨询管理</h2>
        <span class="layui-breadcrumb pull-right">
            <a href="#!home_console">首页</a>
            <a><cite>咨询管理</cite></a>
        </span>
    </div>
   <div class="layui-card-body">
        <div class="layui-form toolbar">
            <div class="layui-form-item">
                <div class="layui-inline">
                    <select id="type" lay-filter="role_clients">
                        <option value="">服务类型</option>
                        <option value="1">图文</option>
                        <option value="3">图文/电话</option>
                    </select>
                    <select id="status" lay-filter="role_clients">
                        <option value="">咨询状态</option>
                        <option value="1">待咨询</option>
                        <option value="2">咨询中</option>
                        <option value="3">待完成</option>
                        <option value="4">已完成</option>
                    </select>
                </div>
                <div class="layui-inline" >
                    <input name="keyword" id="keyword" placeholder="咨询ID/医生名/用户名称" type="text"
                           class="layui-input search-input" maxlength="50" autocomplete="off"/>&emsp;
                </div>
 
                <button id="app-btn-search" class="layui-btn icon-btn" layt="abc"><i class="layui-icon">&#xe615;</i>搜索
                </button>
                <table class="layui-table" id="app-table" lay-filter="app-table"></table>
            </div>
        </div>
    </div>
</div>
 
<input id="hospitalId" type="hidden"/>
<!-- 表格操作列 -->
<script type="text/html" id="doctor-table-bar">
    <button class="layui-btn layui-btn-primary layui-btn-xs" lay-event="show">查看
    </button>
    {{# if(d.type == 2 && d.payStatus == 1){ }}
    <button class="layui-btn layui-btn-xs" lay-event="refund">
        退款
    </button>
    {{# } }}
    {{# if(d.type == 1 && d.consultationStatus != 4 && d.consultationStatus != -1){ }}
    <button class="layui-btn layui-btn-primary layui-btn-xs" lay-event="complete">
        完成
    </button>
    {{# } }}
</script>
<script>
    layui.use(['form', 'table', 'laydate', 'util', 'config', 'upload', 'admin', 'formSelects','area'],
        function () {
            var form = layui.form;
            var table = layui.table;
            var config = layui.config;
            var admin = layui.admin;
            var $ = layui.jquery;
 
            // 渲染表格
            table.render({
                elem: '#app-table',
                url: config.base_server + 'api-opration/advisorydoctor/findAll',
                method: 'GET',
                headers: {
                    'Authorization': 'Bearer ' + config.getToken().access_token
                },
                page: true,
                cols: [
                    [{
                        field: 'advisoryId',
                        width: "300",
                        title: '咨询ID',
                        align: 'center',
                        fixed: 'left',
                    },{
                        field: 'type',
                        width: "90",
                        title: '服务类型',
                        fixed: 'left',
                        templet: function (d) {
                            if (d.type == 1) {
                                return "图文"
                            } else if (d.type == 2) {
                                return "电话"
                            } else {
                                return "图文/电话"
                            }
                        }
                    },{
                        field: 'createTime',
                        width: "160",
                        title: '创建时间',
                        align: 'center',
                        fixed: 'left',
                    },{
                        field: 'doctorName',
                        width: "150",
                        title: '咨询医生',
                        align: 'center',
                        fixed: 'left',
                    },{
                        field: 'userName',
                        width: "150",
                        align: 'center',
                        title: '用户名',
                        fixed: 'left',
                    },
                    {
                        field: 'appointmentTime',
                        width: "250",
                        align: 'center',
                        title: '预约时间',
                        fixed: 'left',
                    },
                    {
                        field: 'consultationStatus',
                        width: "90",
                        align: 'center',
                        title: '咨询状态',
                        fixed: 'left',
                        templet: function (d) {
                            if (d.consultationStatus == 1) {
                                return "待咨询"
                            } else if (d.consultationStatus == 2) {
                                return "咨询中"
                            } else if (d.consultationStatus == 3) {
                                return "待完成"
                            }else if (d.consultationStatus == 4) {
                                return "已完成"
                            }else{
                                return "已取消"
                            }
                        }
                    },
                    {
                        field: 'evaluationLevel',
                        width: "80",
                        align: 'center',
                        title: '评价',
                        fixed: 'left',
                        templet: function (d) {
                            return (d.evaluationLevel == null || d.evaluationLevel == 0) ? "" :  d.evaluationLevel + "星";
                        }
                    },
                    {
                        width: "200",
                        align: 'center',
                        title: '操作',
                        fixed: 'right',
                        templet: '#doctor-table-bar'
                    }
                    ]
                ],
                done: function (res, curr, count) {
                    permissionsInput(res, config);
                }
            });
 
 
            // 搜索按钮点击事件
            $('#app-btn-search').click(function () {
                var type = $('#type').val();
                var status = $("#status").val();
                var keyword = $('#keyword').val();
                table.reload('app-table', {
                    where: {
                        type: type,
                        status: status,
                        keyword: keyword
                    }
                });
            });
 
            var showEditModel_add = function (title, data) {
                admin.putTempData('t_adisory', data);
                admin.popupCenter({
                    title: title,
                    path: 'pages/keaigao/AdvisoryManager_form.html',
                    area: '610px',
                    offset: '0px',
                    finish: function () {
                    }
                });
            };
 
            // 工具条点击事件
            table.on('tool(app-table)', function (obj) {
                var data = obj.data;
                var layEvent = obj.event;
                 if (layEvent === 'show') {
                    showEditModel_add("查看", data);
                }else if(layEvent === 'complete'){
                     doComplete(data);
                 }else if(layEvent === 'refund'){
                     doRefund(data);
                 }
            });
 
            //标记完成
            var doComplete = function (obj) {
                var name = "确定要标记完成吗?";
                if(obj.payStatus !== 1 && obj.type == 2){
                    name = "该咨询支付异常,确定要标记完成吗?"
                }
                layer.confirm(name , function (i) {
                    layer.close(i);
                    layer.load(2);
                    admin.req('api-opration/advisorydoctor/update/' + obj.advisoryId, {}, function (data) {
                        layer.closeAll('loading');
                        if (data.code == 0) {
                            layer.msg(data.msg, { icon: 1, time: 2000 });
                            table.reload('app-table', {});
                        } else {
                            layer.msg(data.msg, { icon: 2, time: 2000 });
                        }
                    }, 'Get');
                });
            };
 
            //退款
            var doRefund = function (obj) {
                if(obj.payStatus == -1){
                    layer.msg("已退款,无需重复操作", { icon: 2, time: 2000 });
                    return;
                }
 
                var name = "确定要将"+(obj.payStatus == 1 ? "已支付" : "未支付")+"的订单进行退款吗?";
                layer.confirm(name , function (i) {
                    layer.close(i);
                    layer.load(2);
                    admin.req('api-opration/advisorydoctor/refund', JSON.stringify({'advisoryId':obj.advisoryId}), function (data) {
                        layer.closeAll('loading');
                        if (data.code == 0) {
                            layer.msg("申请成功,请等待微信退款!", { icon: 1, time: 2000 });
                            table.reload('app-table', {});
                        } else {
                            layer.msg("操作失败", { icon: 2, time: 2000 });
                        }
                    }, 'POST');
                });
            };
 
        });
</script>