feige
2024-01-23 d0136913a2c74a44f5bb30327ebbb3fd85e24fce
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
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
<template>
  <div class="app-container" style="background-color: #FEF7FC;">
    <el-row :gutter="20">
      <el-col :span="8" :xs="24" >
        <el-card class="box-card" style="background-color: #EBF4FE;">
          <div slot="header" class="clearfix">
            <span>个人信息</span>
          </div>
          <div>
            <div class="text-center">
              <userAvatar :user="user" />
            </div >
            <ul class="list-group list-group-striped">
              <li class="list-group-item">
                用户名称
                <div class="pull-right">{{ user.nickName }}</div>
              </li>
              <li class="list-group-item">
                手机号码
                <div class="pull-right">{{ user.phoneNumber }}</div>
              </li>
              <li class="list-group-item">
                用户邮箱
                <div class="pull-right">{{ user.email }}</div>
              </li>
              <li class="list-group-item">
                所属家庭
                <div class="pull-right"  >{{ user.familyName }} </div>
              </li>
              <li class="list-group-item">
                所属角色
                <div class="pull-right">{{ user.roleName }}</div>
              </li>
              <li class="list-group-item">
                创建日期
                <div class="pull-right">{{ user.createTime }}</div>
              </li>
            </ul>
          </div>
        </el-card>
      </el-col>
      <el-col :span="16" :xs="24" >
        <el-card style="background-color: #FFF5F7;">
          <div slot="header" class="clearfix">
            <span>基本资料</span>
          </div>
          <el-tabs v-model="activeTab" >
            <el-tab-pane label="基本资料" name="userinfo">
              <userInfo :user="user" />
            </el-tab-pane>
            <el-tab-pane label="修改密码" name="resetPwd">
              <resetPwd />
            </el-tab-pane>
          </el-tabs>
        </el-card>
      </el-col>
    </el-row>
    <div style="padding-top: 20px; background-color: #F4FFF8;">
 
      <el-divider></el-divider>
      <div >
          <el-form ref="form" :model="form" :rules="rules" label-width="100px">
       <el-row>
       <el-col :span="10" :xs="24">
        <el-form-item label="菜单权限">
       <el-tree
            class="tree-border"
            :data="menuOptions"
            show-checkbox
            ref="authr"
            node-key="id"
:default-expand-all="true"
 
            empty-text="加载中,请稍候"
            :props="defaultProps"
          ></el-tree>     </el-form-item>
          </el-col>
          <el-col :span="4" :xs="24" type="flex" align="middle">可以授权相关人员</el-col>
          <el-col  :span="10" :xs="24">
          <el-tree
               class="tree-border"
               :data="menuOptions1"
               show-checkbox
               ref="peoInfo"
               node-key="id"
 
               empty-text="加载中,请稍候"
               :props="defaultProps"
             ></el-tree>
             </el-col>
</el-row>
<el-button type="primary" @click="upAuthority">授权</el-button>
        </el-form>
      </div>
      <el-divider></el-divider>
      <div>
        <el-form>
        <el-row>
          <el-col :span="10" :xs="24">
           <el-form-item label="收回权限">
              <el-select v-model="st" placeholder="请选择菜单" @change="handleChange">
                   <el-option v-for="mo in menuOptions2" :label="mo.label" :value="mo.id" :key="mo.id"></el-option>
                 </el-select>
 
 
              </el-form-item>
              </el-col>
              <el-col :span="4" :xs="24" class="centered">已经授权相关人员</el-col>
             <el-col :span="10" :xs="24">
                     <el-form-item label="已经授权相关成员">
                    <el-tree
                         class="tree-border"
                         :data="menuOptionsp"
                         show-checkbox
                         ref="spp"
                         node-key="id"
             :default-expand-all="true"
 
                         empty-text="加载中,请稍候"
                         :props="defaultProps"
                       ></el-tree>     </el-form-item>
                       </el-col>
              </el-row>
              <el-button type="primary" @click="deleteAuthority">收回授权</el-button>
              </el-form>
      </div>
    </div>
 
 
  </div>
 
</template>
 
<script>
import userAvatar from "./userAvatar";
import userInfo from "./userInfo";
import resetPwd from "./resetPwd";
import { getAllInfo,getUserProfile ,getSelfPermission,getFamilyids,setAuority
,getUserByFidAid,deleteUserByFidAid} from "@/api/system/user";
import { getIndividualList } from "@/api/self";
import {updateFamilyevent} from "@/api/bignote";
 
export default {
  name: "Profile",
  components: { userAvatar, userInfo, resetPwd },
  data() {
    return {
      formDat: {
        familyName: undefined,
        modelName: undefined,
      },
      fid: undefined,
      st: undefined,
      menuOptionsp:[
        {
          id: 1,
          label: '家庭成员',
          children:[]
        }
      ],
      menuOptions2:[
        {
          id: 2000,
          label: '家庭资产管理',
 
        },
        {
          id: 2012,
          label: '家大事记',
        },
        { id:2016,
          label: '家庭设备',
          },
          {
          id: 2004,
          label: '收藏和荣誉',
 
        },
        {
          id: 2029,
          label: '家庭小医生',
        },
        { id:2024,
          label: '保洁收纳',
          },
        {
          id: 2021,
          label: '通讯录',
        },
        { id:2033,
          label: '魅宠',
          },
          {id:2008,
            label: '家庭收支台账',
            }
      ],
      menuOptions1:[
        {
          id: 1,
          label: '家庭成员',
          children:[]
        }
      ],
      menuOptions:[
          {
            id: 1,
            label: '家庭模块',
            children: [
              {
                id: 2000,
                label: '家庭资产管理',
 
              },
              {
                id: 2012,
                label: '家大事记',
              },
              { id:2016,
                label: '家庭设备',
                },
                {
                id: 2004,
                label: '收藏和荣誉',
 
              },
              {
                id: 2029,
                label: '家庭小医生',
              },
              { id:2024,
                label: '保洁收纳',
                },
              {
                id: 2021,
                label: '通讯录',
              },
              { id:2033,
                label: '魅宠',
                },
                {id:2008,
                  label: '家庭收支台账',
                  }
            ],
          },
      ],
      FaimlyList:undefined,
      FaimlyList1:undefined,
      selectedFamily: "一号家庭",
      id:'',
      command1:undefined,
      selectedTab:"家根网",// 初始化选中的家庭为空字符串
      selectedTab1:"家根网",// 初始化选中的家庭为空字符串
      SelfPermission:undefined,
      SelfPermissionList:{
        insert:undefined,
        delete:undefined,
        search:undefined,
        update:undefined,
      },
      user: {},
      roleGroup: {},
      postGroup: {},
      activeTab: "userinfo",
      activeTab1:"家根网"
    };
  },
 
  created() {
    this.getUser();
    this.getList();
  },
  methods: {
    deleteAuthority(){
    //  alert(this.st)
      let uidKeys = this.$refs.spp.getCheckedKeys();
      let auIds = []
      auIds.push(this.st)
      let data = {
        uids:  uidKeys,
        fid: this.fid,
        authoritys: auIds
      }
      let _this = this
      if(this.st!=undefined&&uidKeys.length!=0){
        deleteUserByFidAid(data).then(response=>{
             this.$modal.msgSuccess(response.msg)
             let data = {
               "fid": _this.fid,
               "authority": _this.st
             }
           //  alert(data.authority)
            // let _this = this
             getUserByFidAid(data).then(response=>{
               console.log(response)
               let fams = response.data;
               for(let i = 0 ; i < fams.length; i++)
                 _this.menuOptionsp[0]['children'].push({id:fams[i].userId,label:fams[i].nickName })
 
             })
        })
        }
      else{
           this.$modal.msgSuccess("权限或被授权人不能为空!")
      }
    },
    getDeptAllCheckedKeys() {
      // 目前被选中的部门节点
      let checkedKeys = this.$refs.authr.getCheckedKeys();
     // console.log(checkedKeys)
      },
    upAuthority(){
      let checkedKeys = this.$refs.authr.getCheckedKeys();
      let peoKeys = this.$refs.peoInfo.getCheckedKeys();
     // console.log(peoKeys)
     // alert(checkedKeys.length)
     // this.getDeptAllCheckedKeys()
     if(checkedKeys.length!=0&&peoKeys.length!=0)
     {
       let data = {
         uids:  peoKeys,
         fid: this.fid,
         authoritys: checkedKeys
       }
     //  console.log(data)
      //  alert(123)
        setAuority(data).then(response=>{
       //   console.log(response)
           this.$modal.msgSuccess(response.msg)
        //  alert(response.data)
        })
      }
      else{
        this.$modal.msgSuccess("权限或被授权人不能为空!");
  }
    },
    handleChange(value){
 
      let data = {
        "fid": this.fid,
        "authority": value
      }
      alert(data.authority)
      let _this = this
      getUserByFidAid(data).then(response=>{
        console.log(response)
        let fams = response.data;
        for(let i = 0 ; i < fams.length; i++)
          _this.menuOptionsp[0]['children'].push({id:fams[i].userId,label:fams[i].nickName })
 
      })
    },
    handleTabClick(tab) {
      this.selectedTab = tab.label;
      if (this.selectedFamily && this.selectedTab) {
        this.getList();
      }
    },
    handleTabClick1(tab) {
      this.selectedTab1 = tab.label;
    },
    handleDropdownCommand(command) {
      // this.selectedFamily = command; // 更新选中的家庭
      // console.log(this.selectedFamily)
      // // 检查下拉菜单和切片页面是否都被选中
      // if (this.selectedFamily && this.selectedTab) {
      //   this.getList();
      // }
    },
    handleDropdownCommand1(command1) {
      // this.command1= command1;
      // console.log(command1)
      // let id = null;
      // if (command1 == '一号家庭') {
      //   id = 1;
      // } else if (command1 == '二号家庭') {
      //   id = 2;
      // } else if (command1 == '三号家庭') {
      //   id = 3;
      // } else if (command1 == '四号家庭') {
      //   id = 4;
      // }
      // if (id) {
      //   this.getUser(parseInt(id)); // 将id转换为数字类型
      // }
    },
 
 
    getUser(id) {
 
      // getUserProfile().then(response => {
      //   this.user = response.data;
      //   this.roleGroup = response.roleGroup;
      //   this.postGroup = response.postGroup;
      // });
 
     //  getFamilyids(id).then(response => {
     //    console.log(id)
     // //   this.FaimlyList = response.data;
     //    console.log("打印家庭成员序列"+id)
     //    console.log(this.FaimlyList)
     //  });
      getIndividualList().then(response => {
        this.user = response.data;
       // alert(890)
        this.fid = response.data.familyId
    //    alert(this.fid)
        this.roleGroup = response.roleGroup;
        this.postGroup = response.postGroup;
      });
      // if (this.user.familyName='一号家庭'){
      //   id=1;
      //   getFamilyids(id).then(response => {
      //     console.log(id)
      //     this.FaimlyList1 = response.data;
      //     console.log("打印家庭成员序列"+id)
      //     console.log(this.FaimlyList)
      //   });
      // }
 
 
 
    },
    getList() {
 
    let _this = this
 
    getAllInfo().then(response=>{
      let fams = response.data
      for(let i = 0; i < fams.length; i++)
        _this.menuOptions1[0]['children'].push({id:fams[i].userId,label:fams[i].nickName })
    })
//       var formData ={
//     "familyName": this.selectedFamily,
//     "modelName":this.selectedTab,
// }
 
//       var jsonString = JSON.stringify(formData);
//     //  console.log(jsonString);
 
//       getSelfPermission(jsonString).then(response => {
//         this.SelfPermissionList = response.data;
//         console.log(this.SelfPermissionList)
//       });
 
    }
  }
 
};
</script>
<style>
.container {
  display: flex;
}
.centered {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
}
.el-icon-arrow-down {
  font-size: 12px;
}
</style>