puzhibing
2023-10-08 22199bbdda579861736420fe26c2873ab0f5d21c
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
/**
 * 美牙医生管理初始化
 */
var MyDoctor = {
    id: "MyDoctorTable",    //表格id
    seItem: null,        //选中的条目
    table: null,
    layerIndex: -1
};
 
/**
 * 初始化表格的列
 */
MyDoctor.initColumn = function () {
    return [
        {field: 'selectItem', checkbox: true},
        {title: '添加时间', field: 'createTime', visible: true, align: 'center', valign: 'middle'},
        {title: '医生头像', field: 'avatar', visible: true, align: 'center', valign: 'middle',
            formatter: function (value, row) {
                return Feng.getImageDom(value);
            }
        },
        {title: '医生名称', field: 'name', visible: true, align: 'center', valign: 'middle'},
        {title: '所在城市', field: 'cityName', visible: true, align: 'center', valign: 'middle'},
        {title: '所在门店', field: 'merchantName', visible: true, align: 'center', valign: 'middle'},
        {title: '入职时间', field: 'workTime', visible: true, align: 'center', valign: 'middle'},
        {title: '性别', field: 'sex', visible: true, align: 'center', valign: 'middle', formatter: function (value, row) {
                if(value == 0){
                    return "女";
                }
                return "男";
            }},
        {title: '联系电话', field: 'phone', visible: true, align: 'center', valign: 'middle'},
        {title: '职级', field: 'position', visible: true, align: 'center', valign: 'middle'},
        {title: '擅长领域', field: 'technique', visible: true, align: 'center', valign: 'middle'},
        {title: '个人介绍', field: 'remark', visible: true, align: 'center', valign: 'middle'},
        {title: '从业年限', field: 'workTimeNum', visible: true, align: 'center', valign: 'middle'},
    ];
};
 
/**
 * 检查是否选中
 */
MyDoctor.check = function () {
    var selected = $('#' + this.id).bootstrapTable('getSelections');
    if(selected.length == 0){
        Feng.info("请先选中表格中的某一记录!");
        return false;
    }else{
        MyDoctor.seItem = selected[0];
        return true;
    }
};
 
/**
 * 点击添加美牙医生
 */
MyDoctor.openMyDoctorAdd = function () {
    var index = layer.open({
        type: 2,
        title: '添加美牙医生',
        area: ['80%', '80%'], //宽高
        fix: false, //不固定
        maxmin: true,
        content: Feng.ctxPath + '/myDoctor/myDoctor_add'
    });
    this.layerIndex = index;
};
 
/**
 * 点击编辑美牙医生
 */
MyDoctor.openMyDoctorUpdate = function (id) {
    var ids = id;
    if(id == 0) {
        // 如果id为0,则为批量删除
        ids = Feng.checkBoxIds(MyDoctor.id);
    }
    if (ids.length != 0) {
        var index = layer.open({
            type: 2,
            title: '编辑美牙医生',
            area: ['80%', '80%'], //宽高
            fix: false, //不固定
            maxmin: true,
            content: Feng.ctxPath + '/myDoctor/myDoctor_update/' + ids
        });
        this.layerIndex = index;
    }
};
 
/**
 * 打开查看美牙医生详情
 */
MyDoctor.openMyDoctorDetail = function (id) {
    var ids = id;
    if(id == 0) {
        // 如果id为0,则为批量删除
        ids = Feng.checkBoxIds(MyDoctor.id);
    }
    if (ids.length != 0) {
        var index = layer.open({
            type: 2,
            title: '美牙医生详情',
            area: ['80%', '80%'], //宽高
            fix: false, //不固定
            maxmin: true,
            content: Feng.ctxPath + '/myDoctor/detail/' + ids
        });
        this.layerIndex = index;
    }
};
 
/**
 * 删除/批量删除美牙医生
 */
MyDoctor.delete = function(id){
    var ids = id;
    if(id == 0) {
      // 如果id为0,则为批量删除
      ids = Feng.checkBoxIds(MyDoctor.id);
    }
    if (ids.length != 0) {
        var operation = function() {
            // 加载动画层,0代表加载的风格,支持0-2
            var index = parent.layer.load(0, {shade: false});
            var ajax = new $ax(Feng.ctxPath + "/myDoctor/delete", function (data) {
                // 关闭加载动画层
                parent.layer.close(index);
                Feng.success("删除成功!");
                MyDoctor.table.refresh();
            }, function (data) {
                Feng.error("删除失败!" + data.responseJSON.message + "!");
            });
            ajax.set("ids", ids);
            ajax.start();
        };
        Feng.confirm("是否删除所选中的数据?", operation);
    }
};
 
/**
 * 编辑美牙医生状态
 */
MyDoctor.updateState = function (id, state) {
    var ajax = new $ax(Feng.ctxPath + "/myDoctor/updateState", function (data) {
        if(data.code == 200){
            Feng.success("操作成功!");
            MyDoctor.table.refresh();
        } else {
            Feng.error("操作失败!" + data.message);
        }
    }, function () {
        Feng.error("操作失败!");
    });
    ajax.set("myDoctorId", id);
    ajax.set("state", state);
    ajax.start();
};
 
/**
 * 查询美牙医生列表
 */
MyDoctor.search = function () {
    var queryData = {};
    queryData['beginTime'] = $("#beginTime").val();
    queryData['endTime'] = $("#endTime").val();
    queryData['condition'] = $("#condition").val();
    queryData['cityId'] = $("#cityId").val();
    queryData['sex'] = $("#sex").val();
    queryData['workTime'] = $("#workTime").val();
    MyDoctor.table.refresh({query: queryData});
};
/**
 * 重置查询条件
 */
MyDoctor.resetSearch = function () {
    $("#beginTime").val("");
    $("#endTime").val("");
    $("#condition").val("");
    $("#cityId").val("");
    $("#sex").val("");
    $("#workTime").val("");
    MyDoctor.search();
};
$(function () {
    var defaultColunms = MyDoctor.initColumn();
    var table = new BSTable(MyDoctor.id, "/myDoctor/list", defaultColunms);
    // 设置物理分页server(逻辑分页client)
    table.setPaginationType("server");
    // 表单提交参数
    var queryData = {};
    queryData['beginTime'] = $("#beginTime").val();
    queryData['endTime'] = $("#endTime").val();
    queryData['condition'] = $("#condition").val();
    queryData['cityId'] = $("#cityId").val();
    queryData['sex'] = $("#sex").val();
    queryData['workTime'] = $("#workTime").val();
    table.setQueryParams(queryData);
    MyDoctor.table = table.init();
 
    // 初始化开始时间、结束时间
    laydate.render({
        elem: '#beginTime'
    });
    laydate.render({
        elem: '#endTime'
    });
});
MyDoctor.export = function () {
    var queryData = {};
    queryData['beginTime'] = $("#beginTime").val();
    queryData['endTime'] = $("#endTime").val();
    queryData['condition'] = $("#condition").val();
    queryData['cityId'] = $("#cityId").val();
    queryData['sex'] = $("#sex").val();
    queryData['workTime'] = $("#workTime").val();
    Feng.down_export( "/myDoctor/export", queryData);
};