david-PC\david
2018-06-12 f240ac3ccd37c541cab2c21cfc433d3510999a3c
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
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>组织架构</title>
<meta name="renderer" content="webkit">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
<link href="../../css/common.css" type='text/css' rel='stylesheet'>
<link href="../../css/validform.css" type="text/css" rel='stylesheet'/>
<link href="../../css/card.css" type='text/css' rel='stylesheet'>
<link href="../../css/tree.css" type='text/css' rel='stylesheet'>
<link href="../../css/control.css" rel="stylesheet" />
 
<script src="../../js/jquery-1.7.2.min.js"></script>
<script src="../../js/foundation-2.0.js"></script>
<script src="../../js/control.js"></script>
<script src="../../js/Validform_v5.3.2.js"></script>
<script src="../../js/card.js"></script>
<script src="../../js/tree.js"></script>
 
<style type="text/css">
body {
    text-align: left;
}
 
.btn2 {
    width: 50px;
    height: 23px;
    line-height: 22px;
    border: 1px solid #42b2f3;
    color: #42b2f3;
    font-family: 微软雅黑;
    font-size: 15px;
    cursor: pointer;
    margin-left: -4px;
    text-align: center;
    display: inline-block;
}
 
.btn-green2 {
    background-color: #fff;
}
 
.btn-green2:hover {
    background-color: #42b2f3;
    color: #fff;
}
</style>
 
<script type="text/javascript">
    var tree, card;    
    var rMenu;
    var nodeRecord;
    
    var departmentdatas = [
        {code: "PMO", name: "PMO"},
        {code: "OPC", name: "OPC"},
        {code: "ASD", name: "ASD"},
        {code: "other", name: "其他"}
    ];
    var captiondatas = [
        {code: "部门领导", name: "部门领导"},
        {code: "普通用户", name: "普通用户"},
        {code: "系统管理员", name: "系统管理员"},
        {code: "other", name: "其他"}
    ];    
    var activedatas = [
        {code: "T", name: "激活"},
        {code: "F", name: "冻结"},
    ];    
    var positiondatas = [
        {code: "VGM", name: "VGM"},
        {code: "GM", name: "GM"},
        {code: "admin", name: "系统管理员"},
        {code: "ASD", name: "客户服务事业部"},
        {code: "PMD1", name: "项目管理一部"},
        {code: "PMD2", name: "项目管理二部"},
        {code: "PMD3", name: "项目管理三部"},
        {code: "PMD4", name: "项目管理四部"},
        {code: "PMD5", name: "项目管理五部"},
        {code: "PMD6", name: "项目管理六部"},
        {code: "PMO1", name: "项目管理办公一室"},
        {code: "PMO2", name: "项目管理办公一室"},
        {code: "PMO", name: "项目管理办公室"},
        {code: "other", name: "其他"}
    ];
    function saveData() {
        var data = card.getData().record;
        
        var operation = "addEmployee";
        if (document.getElementById("isuser").checked) {
            if (!$("#username").val()) {
                Dialog.alert("请填写用户账号");
                return;
            }
            if (!$("#password").val()) {
                Dialog.alert("请填写用户密码");
                return;
            }
            
            data.username = $("#username").val();
            data.password = $("#password").val();
            operation = "upUser";
        }
        
        var validformError = card.getValidformMsg();
        var blanks = card.inspectMandatoryField();
        if (validformError) {
            Dialog.alert(validformError);
        }
        else if (blanks) {
            Dialog.alert("填写“" + blanks + "”数据");
        }
        else {
            Server.call("root/fine/" + operation, data, function(result) {
                if (!result.success) {
                    alert(result.error);
                }
                else {
                    Dialog.alert("修改成功");
                    refreshTreeDetail();
                }
            });
        }
    }
    
    function showEdit(code) {
        if ("new" == code) {
            Server.newObject("root/data/employee", function(result) {
                var line = result.line;
                Win.popup({
                    url: "../fine/popup/userLine.html",
                    top: "10%",
                    width: 850,
                    height: 250,
                    data: {type: "user", operator: code, record: {id: line.id}},
                    callback: refreshTreeDetail
                });    
            });        
        }
        else {
            var line = nodeRecord;
            if (!line) {
                Dialog.alert("请选择要修改的员工");
                return;
            }
            if ("updata" == code) {
                Win.popup({
                    url: "../fine/popup/userLine.html",
                    top: "10%",
                    width: 850,
                    height: 250,
                    data: {type: "user", operator: code, record: line},
                    callback: refreshTreeDetail
                });    
            }
            else if("remove" == code) {
                Server.call("root/fine/removeUser?id=" + line.id, function(result) {
                    if (!result.success) {
                        alert(result.error);
                    }
                    else {
                        refreshTreeDetail();
                    }
                });
            }
        }
    }
    
    function refreshTreeDetail() {
        var param = "";
        
        Server.getData("root/data/procedure/getOrganization/EntitySet", param, function(result) {
            $("#tree").html("");
            tree = new Tree({
                element: "tree",
                autoExpended: true,
                renderNodeText: function(element, record) {
                    element.html(record.position + "--" + record.name);
                },
                onNodeSelect: function(node) {
                    $("#current_data").html(node.record.position + "——" + node.record.name);
                    card.setData(node.record);
                    nodeRecord = node.record;
                }
            });
            tree.loadData(result);
        });
    }
    
    function Changedepartment(element, value) {
        if ("pmo" == value) {
            value = "PMO";
        }
        else if ("opc" == value) {
            value = "OPC";
        }
        else if ("asd" == value) {
            value = "ASD";
        }
        else if ("other" == value) {
            value = "其他";
        }
        element.html(value);
        
    }
    
    
    function isActive(element, value) {
        if ("T" == value) {
            value = "激活";
        }
        else if ("F" == value) {
            value = "冻结";
        }
        element.html(value);
    }
    
    function newPerson(type) {
        var datas = card.getData().record;
    
        if(!datas) {
            alert("请选择新岗位所在的位置");
            return;
        }
        if((datas.position == "KA" || datas.position == "PM") && "subordinate" == type) {
            alert("一级岗位不能添加下属");
            return;
        }
        datas.type = type;
        
        Win.popup({
            width: 800,
            height: 500,
            data: datas,
            url: "root/page/manager/newperson.html",
            callback: saveLine
        });
    }
    
    function removePerison() {
        var datas = card.getData().record;
    
        if(!datas) {
            alert("请选择要岗位位置");
            return;
        }
        Server.call("root/data/usr/delUsr", datas, function (success){
            if(success) {
                alert("删除成功");
                window.top.location.href = "manager_index.html?" + new Date().getTime();
            }
        });
    }
    
    function saveLine(datas)  {
        if(!datas) {
            datas = card.getData().record;
        }
        if("close" == datas.close) {
            return;
        }
        Server.call("root/data/usr/saveUser",datas,function(result){
            if(result){
                window.top.location.href = "manager_index.html?" + new Date().getTime();
            }
        });
    }
    
    function changeActive() {
        var line = card.getData()? card.getData().record : null;
        
        if (!line) {
            Dialog.alert("请选择一条记录");
            return;
        }
        if (!line.id){
            Dialog.alert("未有相关记录");
            return;
        }
        
        var params = "table=usr&field=active&filter=id='" + line.userid + "'";
        if(line.active == "T") {
            params += "&active=F"
        }
        else if(line.active == "F") {
            params += "&active=T"
        }
        Server.call("root/data/procedure/updatetableactive/changecount", params, function(result){
            if(result.success) {
                if(result.integer == 1) {
                    window.top.location.href = "manager_index.html?" + new Date().getTime();
                }
            }
        });
    }
    
    function mappingcompany() {
        var line = card.getData()? card.getData().record : null;
        if(!line) {
            alert("请选择一个用户");
        }
        Win.popup({
            width: 800,
            height: 500,
            data: line.userid,
            url: "root/page/manager/companyList.html"
        });
    }
    
    function changeData() {
        Server.call("root/fine/changeData", function(result) {
            Dialog.alert("格式化组织架构完成");
        });
    }
    
    $(document).ready(function() {
        rMenu = $("#rMenu");
 
          card = new Card({
            element: "card",
            columns: [
                {field: "name", caption: "姓名", type: "text", datatype: "*"},
                {field: "email", caption: "邮箱", type: "e"},
                {field: "phone", caption: "移动电话", type: "text"},
                {field: "password", caption: "密码", type: "text", datatype: "*"},
                {field: "department",caption: "部门:",datas: departmentdatas,type: "select"},
                {field: "position",caption: "角色:",getdata: "getposition",type: "select"},
                {field: "reporterdept",caption: "直报部门:",type: "select", datas: positiondatas},
                {field: "reporterid",caption: "直报:",type: "select",getdata:"getreporter"},
                {field: "active", caption: "冻结/激活",datas: activedatas,type: "select"}
            ]
        }); 
        refreshTreeDetail();
        
        var dept = card.getEditByField("reporterdept").onChangefunc(function(){
            var val = card.getEditByField("reporterdept").getValue();
            card.getEditByField("reporterid").setURL("root/data/procedure/getreporter/dataset?filter=position='" + val + "'");
        });
    });
</script>
 
</head>
<body>
    <div style="position:absolute; top: 10px; left: 2%; bottom: 10px; border: 0px solid #ddd; width: 25%;">
        <div  id="tree" style="border: 1px solid #ddd; width: 100%; height: 80%"></div>
        
        <div align="center" style="height: 30px; line-height: 30px; margin-top: 5%; text-align: center;">
            <div class="btn btn-green" onclick="newPerson('new')">新增</div>
            <div class="btn btn-green" onclick="newPerson('subordinate');">新增下属</div>
            <div class="btn btn-green" onclick="removePerison()">删除</div>
        </div>
    </div>
    <div style="position:absolute; top: 10px; left: 29%; right:4%; bottom: 10px;">
        <div style="position:absolute; border: 1px solid #ddd; width: 100%; height: 10%">
            <img src="root/image/user/user.jpg" style="float: left; height: 80%; border-radius: 50%; vertical-align: middle; margin: 10px 30px 0px 20px">
            <div id="current_data" style="float: left; height: 45%; font-size: 20px; margin-top: 15px">
                当前岗位——人名
            </div>
            <!-- <div style="position:absolute; height: 30px; right: 30px; width: 70%; bottom: 10px; text-align: right">
                <div class="btn2 btn-green2" onclick="saveData();">保存</div>
            </div>     -->        
        </div>
        
        <div style="position:absolute; width: 100%; height: 90%; top: 10%; border: 1px solid #ddd; padding: 10px 10px">
            <div id="card" style="text-align: left;"></div>
        </div>
    </div>
    <div style="position: absolute; left: 40%; bottom: 30%; height: 30px; line-height: 30px; margin-top: 15px;" align="center" >
        <div id="readonly" class="btn btn-green" onclick="saveLine()" style="margin-left: 30px;">保存</div>
        <div id="readonly" class="btn btn-green" onclick="mappingcompany()" style="margin-left: 30px;">配置公司</div>
        <div id="process" class="btn btn-green" onclick="changeActive();">冻结/激活</div>
        <!-- <div id="process" class="btn btn-green" onclick="changeData();">生成架构</div> -->
    </div>    
</body>
</html>