zhangyanpeng
2020-05-07 dca74c76b85c5ece7b87beae9d9f921883b55564
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
<template>
    <div style="100%;height: 100%;margin: 0;">
        <el-container style="height: 100vh; box-sizing: border-box;">
          <el-aside width="200px" style="background-color: rgb(238, 241, 246); ">
                <div style="width: 100%;height: 60px;"></div>
                <el-menu
                    class="el-menu-vertical-demo"
                    :unique-opened="true"
                        :default-active="defaultActive"
                    @select ="menuSelect"
                    @open ="menuSelect"
                    @close ="menuSelect"
                    active-text-color="#409EFF"
                    >
                  <navigationItem v-for="menu in navList" :key="menu.path" :item="menu" />
                </el-menu>
                
            <!-- <el-menu default-active="1"  @select="handleSelect">
                    <el-menu-item index="0">
                        <i class="el-icon-menu"></i>
                        <span slot="title">首页</span>
                    </el-menu-item>
                        <el-submenu index="1">
                            <template slot="title">
                                <i class="el-icon-menu"></i>
                                <span>项目管理</span>
                            </template>
                            <el-menu-item-group>
                                <el-menu-item index="1-1">信息广场</el-menu-item>
                                <el-menu-item index="1-2">项目总览</el-menu-item>
                                <el-menu-item index="1-3">项目分析</el-menu-item>
                                <el-menu-item index="1-4">归档报告</el-menu-item>
                            </el-menu-item-group>
                        </el-submenu>
                    <el-menu-item index="2">
                        <i class="el-icon-menu"></i>
                        <span slot="title">任务管理</span>
                    </el-menu-item>
            </el-menu> -->
          </el-aside>
          
          <el-container>
            <el-header style="text-align: right; font-size: 15px;padding-right: 40px;">
                    <i class="el-icon-user-solid"></i>
                    <span>{{userName}}</span>
                    <el-button size="small" type="primary" @click="upPassword">修改密码</el-button>
                    <el-button size="small" type="primary" @click="Cancel">退 出</el-button>
            </el-header>
            
            <el-main style="background-color: #f7f8f9;">
                    <router-view name="home"></router-view>
            </el-main>
          </el-container>
        </el-container>
        
        <el-dialog custom-class="z_master_dialog" v-if="dialog_2_2" title="新增兼职成员" :visible.sync="dialog_2_2" width="400px">
          <el-form ref="ruleForm" label-position="left" :model="ruleForm" status-icon :rules="rules" label-width="90px" class="demo-ruleForm">
                <el-form-item label="原密码" prop="pass_obj">
                  <el-input type="password" size="small" v-model="ruleForm.pass_obj"></el-input>
                </el-form-item>
                <el-form-item label="新密码" prop="pass">
              <el-input type="password" size="small" v-model="ruleForm.pass" autocomplete="off"></el-input>
            </el-form-item>
            <el-form-item label="确认密码" prop="checkPass">
              <el-input type="password" size="small" v-model="ruleForm.checkPass" autocomplete="off"></el-input>
            </el-form-item>
          </el-form>
            
            <div slot="footer" class="dialog-footer" style="text-align: right;">
            <el-button type="" size="small" @click="dialog_2_2 = false">取 消</el-button>
            <el-button type="primary" size="small" @click="savePassword">保存并重新登录</el-button>
          </div>
        </el-dialog>
        
    </div>
</template>
 
<script>
import navigationItem from '../components/menu/navigationItem.vue'
export default {
    components: {
      navigationItem
    },
  data() {
        var validatePass = (rule, value, callback) => {
            if (value === '' || !(/^[A-Za-z0-9]{6,10}$/).test(value) || value.length<6 || value.length>10) {
                callback(new Error('请输入密码,由字母和数字组成且长度在6~10之间'));
            } else {
                if (this.ruleForm.checkPass !== '') {
                    this.$refs.ruleForm.validateField('checkPass');
                }
                callback();
            }
        };
        var validatePass2 = (rule, value, callback) => {
            if (value === '') {
                callback(new Error('请再次输入密码'));
            } else if (value !== this.ruleForm.pass) {
                callback(new Error('两次输入密码不一致!'));
            } else {
                callback();
            }
        };
        return {
            breadcrumbItems:[],
            defaultActive: "",
            navList:[],
            
            dialog_2_2: false,
            ruleForm: {},
            rules: {
                pass_obj: [
                    {required: true, message: '请输入原密码', trigger: ['blur', 'change']}
                ],
                pass: [
                    {required: true, validator: validatePass, trigger: ['blur', 'change']}
                ],
                checkPass: [
                    {required: true, validator: validatePass2, trigger: ['blur', 'change']}
                ]
            },
        }
  },
    created() {
        //let userId_ = localStorage.getItem('userId');
        let userId_ = this.$cookies.get('userId');
        this.userName = this.$cookies.get('userName');
        let departId = this.$cookies.get('departId');
        //this.userName = localStorage.getItem('userName');
        //let departId = localStorage.getItem('departId');
        if (!userId_ || !departId) {
            this.$router.push('/login').catch(err => {err});
        }
        else {
            this.defaultActive = "mine";
            this.$router.push('/mine').catch(err => {err});
            let type;
            if(departId == "100" || departId == "500") {
                type = departId;
                this.$cookies.set('assign', false);
                // localStorage.setItem('assign', false);
            }else {
                type = "all";
                this.$cookies.set('assign', true);
                //localStorage.setItem('assign', true);
            }
            
            this.getMenu(type);
        }
    },
    
  methods: {
        getMenu(userType) {
            let DayDatas = {
                 all: [
                    {'id': "110", 'title': "首页", 'path': "mine"}, //返回的数组字段
                    {'id': "111", 'title': "项目管理", 'path': "0_111"}, //返回的数组字段
                    {'id': "112", 'title': "任务管理", 'path': "0_112"},
                    {'id': "113", 'title': "财务管理", 'path': "0_113"},
                    {'id': "111_1", 'title': "信息广场", 'path': 'square', 'parentId': "111"}, //
                    {'id': "111_2", 'title': "项目总览", 'path': 'list', 'parentId': "111"}, //
                    {'id': "111_3", 'title': "项目分析", 'path': 'Overview', 'parentId': "111"}, //
                    // {'id': "111_4", 'title': "归档报告", 'path': 'project4', 'parentId': "111"}, //
                    {'id': "112_1", 'title': "任务列表", 'path': 'calendarTask', 'parentId': "112"}, //
                    
                    {'id': "113_1", 'title': "实际支付费用", 'path': 'actualPayment', 'parentId': "113"}, //
                    {'id': "113_2", 'title': "合同完成统计", 'path': 'completeStatistics', 'parentId': "113"}, //
                    {'id': "113_3", 'title': "兼职支付确认", 'path': 'partTimeExpenses', 'parentId': "113"}, //
                //    {'id': "113_4", 'title': "成本核算", 'path': 'costAccounting', 'parentId': "113"}, //
                    {'id': "113_5", 'title': "已回款统计", 'path': 'collectionStatistics', 'parentId': "113"}, //
                ],
                100: [
                        {'id': "110", 'title': "首页", 'path': "mine"}, //返回的数组字段
                        {'id': "112", 'title': "任务管理", 'path': "0_112"},
                        {'id': "112_1", 'title': "任务列表", 'path': 'calendarTask', 'parentId': "112"}, //
                    ],
                500: [
                    {'id': "110", 'title': "首页", 'path': "mine"}, //返回的数组字段
                    {'id': "112", 'title': "任务管理", 'path': "0_112"},
                    {'id': "112_1", 'title': "任务列表", 'path': 'calendarTask', 'parentId': "112"}, //
                ],
            };
            
            let list = [];
            if (!userType || userType=='undefined') {
                list = DayDatas['all'];
            }
            else {
                list = DayDatas[userType];
            }
            
            let parId = "";
            let obj = {};
            let result = [];
                        
            list.map(el => {
                obj[el.id] = el;
            })
            for(let i=0, len = list.length; i < len; i++) {
                let id = list[i].parentId;
                //设置显示字段
                list[i].title = list[i].title;
                if(id == parId || !id) {
                    if(!obj[list[i].id].children) {
                      obj[list[i].id].children = [];
                    }
                    result.push(list[i]);
                    continue;
                }
                if(obj[id].children) {
                    obj[id].children.push(list[i]);
                } else {
                    obj[id].children = [list[i]];
                }
            }
            this.navList = result;
        },
        
        upPassword() {
            this.ruleForm = {};
            this.dialog_2_2 = true;
        },
        
        savePassword() {
            let me = this;
            let is_null1 = true;
            this.$refs.ruleForm.validate((valid) => {
                if (!valid) {
                    is_null1 = false;
                }
            });
            
            if (is_null1) {
                let url_ = "/api/user/changePass/" + this.$cookies.get('userId');
                let params_ = {
                    prePass: this.ruleForm.pass_obj,
                    newPass: this.ruleForm.checkPass,
                };
                this.$axios.get(url_,{
                  params: params_
                }).then(data_ => {
                    window.console.log(data_);
                    if (data_.data.status == "1009") {
                        me.$message.error("保存失败!" + data_.data.message);
                    }
                    else {
                        me.$router.push('/login').catch(err => {err});
                    }
                    //me.$cookies.set('userId', null);
                }).catch(error =>{
                    
                })
            }
        },
        
        Cancel() {
            //localStorage.setItem('userId', null);
            this.$cookies.set('userId', null);
            this.$router.push('/login').catch(err => {err});
        },
        menuSelect(index, a){
         let isPage = index.substring(0,2);
         if (isPage != "0_") {
            this.$router.push('/'+ index).catch(err => {err});
         }
        },
        
      /* handleSelect(key, keyPath){
            switch(key){
                case '0':
                    this.$router.push('/mine');
                    this.breadcrumbItems = ["首页"];
                    break;
                case '2':
                    this.$router.push('/project')
                    this.breadcrumbItems = ["首页"];
                    break;
                case '3':
                    this.$router.push('/Page3')
                    break;
            }
        }, */
 
  }
};
</script>
 
<style>
  .el-header {
    background-color: #409EFF;
    color: #333;
    line-height: 60px;
  }
  
  .el-aside {
    color: #333;
  }
</style>