forked from kidgrow-microservices-platform

luliqiang
2021-02-19 1df2ad6224fa4bd1ca38d235d5e4b917262added
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
<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" style="margin-bottom: -25px;">
                    <select id="enabled" lay-filter="role_clients">
                        <option value="">医院状态</option>
                        <option value="1">启用</option>
                        <option value="0">停用</option>
                    </select>
                    <select id="isScreeningPush" lay-filter="role_clients">
                        <option value="">推送状态</option>
                        <option value="1">是</option>
                        <option value="0">否</option>
                    </select>
                    <input name="hospitalName" id="hospitalName-seach" placeholder="按医院名称" 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>
                <button id="screeningHospital-btn-add" class="layui-btn icon-btn"><i class="layui-icon">&#xe654;</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="edit">修改
    </button>
    <button class="layui-btn layui-btn-xs" lay-event="downLoad">
        下载二维码
    </button>
    <button class="layui-btn layui-btn-xs" lay-event="export">
        导出
    </button>
</script>
 
<script type="text/html" id="hospital-push-state">
    <input type="checkbox" lay-filter="hospital-push-state" value="{{d.id}}"
           lay-skin="switch" lay-text="是|否" {{d.isScreeningPush==1?'checked':''}}/>
</script>
 
<script type="text/html" id="hospital-state">
    <input type="checkbox" lay-filter="hospital-state" value="{{d.id}}"
           lay-skin="switch" lay-text="正常|停用" {{d.enabled==1?'checked':''}}/>
</script>
 
<script>
    layui.use(['form', 'table', 'laydate', 'util', 'config', 'upload', 'admin', 'autocomplete', 'formSelects'],
        function () {
            var form = layui.form;
            var table = layui.table;
            var config = layui.config;
            var layer = layui.layer;
            var util = layui.util;
            var admin = layui.admin;
            var autocomplete = layui.autocomplete;
            var formSelects = layui.formSelects;
            var $ = layui.jquery;
 
            //自动完成-医院名称
            autocomplete.render({
                elem: $('#hospitalName-seach')[0],
                keywordsName: 'hospitalName', //查询关键字名称
                url: config.base_server + 'api-opration/hospitalscreening/findByName',
                template_val: '{{d.hospitalName}}', //选择后文本框显示的数据字段
                template_txt: "<div class='layui-table-cell'>{{d.hospitalName}}</div>", //下拉列表模板
                onselect: function (resp) {
                    $("#hospitalId").val(resp.id);
                }
            });
 
            // 渲染表格
            table.render({
                elem: '#app-table',
                url: config.base_server + 'api-opration/hospitalscreening',
                method: 'GET',
                headers: {
                    'Authorization': 'Bearer ' + config.getToken().access_token
                },
                page: true,
                cols: [
                    [{
                        field: 'id',
                        width: "200",
                        title: '筛查医院ID',
                        fixed: 'left'
                    }, {
                        field: 'hospitalName',
                        width: "200",
                        title: '医院名称',
                        fixed: 'left'
                    }, {
                        field: 'departmentName',
                        width: "120",
                        title: '科室',
                        align: 'center',
                        fixed: 'left'
                    },
                        {
                            field: 'isScreeningPush',
                            width: "100",
                            title: '推送状态',
                            align: 'center',
                            fixed: 'left',
                            templet: '#hospital-push-state'
                        },
                        {
                            field: 'enabled',
                            width: "100",
                            title: '状态',
                            align: 'center',
                            fixed: 'left',
                            templet: '#hospital-state'
                        },
                        {
                            field: 'createTime',
                            width: "150",
                            sort: true,
                            align: 'center',
                            title: '创建时间',
                            templet: "<div>{{layui.util.toDateString(d.createTime, 'yyyy/MM/dd HH:mm')}}</div>"
                        },
                        {
                            width: "300",
                            align: 'center',
                            toolbar: '#doctor-table-bar',
                            title: '操作',
                            fixed: 'right'
                        }
                    ]
                ],
                done: function (res, curr, count) {
                    permissionsInput(res, config);
                }
            });
 
            // 修改状态
            form.on('switch(hospital-push-state)', function (obj) {
                layer.load(2);
                admin.req('api-opration/hospitalscreening/updateEnabled', {
                    objId: obj.elem.value,
                    objVal: obj.elem.checked ? 1 : 0,
                    type: 0
                }, function (data) {
                    layer.closeAll('loading');
                    if (data.code == 0) {
                        layer.msg(data.msg, {
                            icon: 1,
                            time: 2000
                        });
                    } else {
                        layer.msg(data.msg, {
                            icon: 2,
                            time: 2000
                        });
                        $(obj.elem).prop('checked', !obj.elem.checked);
                        form.render('checkbox');
                    }
                }, 'GET');
            });
 
            // 修改状态
            form.on('switch(hospital-state)', function (obj) {
                layer.load(2);
                admin.req('api-opration/hospitalscreening/updateEnabled', {
                    objId: obj.elem.value,
                    objVal: obj.elem.checked ? 1 : 0,
                    type: 1
                }, function (data) {
                    layer.closeAll('loading');
                    if (data.code == 0) {
                        layer.msg(data.msg, {
                            icon: 1,
                            time: 2000
                        });
                    } else {
                        layer.msg(data.msg, {
                            icon: 2,
                            time: 2000
                        });
                        $(obj.elem).prop('checked', !obj.elem.checked);
                        form.render('checkbox');
                    }
                }, 'GET');
            });
 
            // 搜索按钮点击事件
            $('#app-btn-search').click(function () {
                var enabled = $('#enabled').val();
                var isScreeningPush = $("#isScreeningPush").val();
                var hospitalName = $('#hospitalName-seach').val();
                table.reload('app-table', {
                    where: {
                        enabled: enabled,
                        hospitalName: hospitalName,
                        isScreeningPush: isScreeningPush,
                    }
                });
            });
 
            // 添加按钮点击事件
            $('#screeningHospital-btn-add').click(function () {
                showEditModel_add("添加");
            });
 
            var showEditModel_add = function (title, data) {
                admin.putTempData('t_screeningHospital', data);
                admin.popupCenter({
                    title: title,
                    path: 'pages/keaigao/screeningHospital_form.html',
                    area: '600px',
                    offset: '0px',
                    finish: function () {
                    }
                });
            };
 
            // 工具条点击事件
            table.on('tool(app-table)', function (obj) {
                var data = obj.data;
                var layEvent = obj.event;
                if (layEvent === 'downLoad') {
                    // 下载二维码
                    downLoad(data.hospitalQrImage);
                } else if (layEvent === 'edit') {
                    showEditModel_add("编辑", data);
                }else if(layEvent === 'export'){
                    showEditModel_import("导出",data);
                }
            });
 
            function downLoad(url) {
                window.open(url);
            }
 
            var showEditModel_import = function (title, data) {
                admin.putTempData('t_hospital', data);
                admin.popupCenter({
                    title: title,
                    path: 'pages/keaigao/exportScreeningHospital.html',
                    area: '500px',
                    offset: '0px',
                    finish: function () {
                    }
                });
            };
 
        });
</script>