forked from kidgrow-microservices-platform

dougang
2021-04-19 ea5b87e2ac4747ca8a47f00dffac5b2c1668948b
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
<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="2">电话</option>
                        <option value="3">图文/电话</option>
                    </select>
                </div>
                <div class="layui-inline" style="margin-bottom: -19px">
                    <input name="hospitalName" id="hospitalName-seach" placeholder="按筛查医院名称" type="text"
                           class="layui-input search-input" maxlength="50" autocomplete="off"/>&emsp;
                </div>
                <div class="layui-inline">
                    <input name="doctorName" id="doctorName-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="doctor-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="delete">
        删除
    </button>
</script>
<script>
    layui.use(['form', 'table', 'laydate', 'util', 'config', 'upload', 'admin', 'autocomplete', 'formSelects','area'],
        function () {
            var form = layui.form;
            var table = layui.table;
            var config = layui.config;
            var admin = layui.admin;
            var $ = layui.jquery;
            var autocomplete = layui.autocomplete;
 
            //自动完成-医院名称
            autocomplete.render({
                elem: $('#hospitalName-seach')[0],
                keywordsName: 'hospitalName', //查询关键字名称
                url: config.base_server + 'api-user/syshospital/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/advisorydoctor',
                method: 'GET',
                headers: {
                    'Authorization': 'Bearer ' + config.getToken().access_token
                },
                page: true,
                cols: [
                    [{
                        field: 'id',
                        width: "200",
                        title: 'ID',
                        align: 'center',
                        fixed: 'left',
                    },{
                        field: 'createTime',
                        width: "200",
                        title: '创建时间',
                        align: 'center',
                        fixed: 'left',
                    },{
                        field: 'doctorName',
                        width: "150",
                        title: '医生姓名',
                        fixed: 'left',
                    },{
                        field: 'hospitalName',
                        width: "200",
                        title: '医院名称',
                        align: 'center',
                        fixed: 'left',
                    },{
                        field: 'deptName',
                        width: "200",
                        title: '部门名称',
                        align: 'center',
                        fixed: 'left',
                    },{
                        field: 'service',
                        width: "100",
                        align: 'center',
                        title: '服务类型',
                        fixed: 'left',
                         templet: function (d) {
                            if(d.service == 1){
                                return "图文"
                            }else if(d.service == 2){
                                return "电话"
                            }else{
                                return "图文/电话"
                            }
                        }
                    },{
                        field: 'bindPhone',
                        width: "150",
                        title: '绑定用户手机号',
                        align: 'center',
                        fixed: 'left',
                    },
                    {
                        width: "200",
                        align: 'center',
                        toolbar: '#doctor-table-bar',
                        title: '操作',
                        fixed: 'right'
                    }
                    ]
                ],
                done: function (res, curr, count) {
                    permissionsInput(res, config);
                }
            });
 
 
            // 搜索按钮点击事件
            $('#app-btn-search').click(function () {
                var service = $('#type').val();
                var hospitalName = $("#hospitalName-seach").val();
                var doctorName = $('#doctorName-seach').val();
                table.reload('app-table', {
                    where: {
                        service: service,
                        hospitalName: hospitalName,
                        doctorName: doctorName
                    }
                });
            });
 
            // 添加按钮点击事件
            $('#doctor-btn-add').click(function () {
                showEditModel_add("添加");
            });
 
            var showEditModel_add = function (title, data) {
                admin.putTempData('t_adisoryDoctor', data);
                admin.popupCenter({
                    title: title,
                    path: 'pages/keaigao/AdvisoryDoctor_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 === 'edit') {
                    showEditModel_add("编辑", data);
                }else if(layEvent === 'delete'){
                     doDelete(data);
                 }
            });
 
            // 删除
            var doDelete = function (obj) {
                layer.confirm('确定删除此医生吗?', function (i) {
                    layer.close(i);
                    layer.load(2);
                    admin.req('api-opration/advisorydoctor/delete/' + obj.id, {}, 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 });
                        }
                    }, 'delete');
                });
            };
 
        });
</script>