Blame view

src/views/staff/staffDetailList.vue 7.91 KB
a42b3256   wuxw   HC小区管理系统前段vue版正在开发中
1
2
3
4
5
6
7
8
9
10
11
12
13
14
  <template>
    <div class="staff-detail-container">
      <el-row :gutter="20">
        <el-col :span="18">
          <el-card class="box-card">
            <div slot="header" class="clearfix flex justify-between">
              <span>{{ $t('staffDetailInfo.title') }}</span>
              <el-button style="padding: 3px 0" type="text" @click="goBack">
                {{ $t('common.back') }}
              </el-button>
            </div>
            <div class="staff-info">
              <el-row :gutter="20">
                <el-col :span="4">
69e18472   wuxw   v1.9 员工头像不对问题
15
                  <el-image style="width: 120px; height: 140px; border-radius: 4px;" :src="staffDetailInfo.photoUrl"
27dcfde5   wuxw   系统全面测试完成
16
                    fit="cover" @error="errorLoadImg">
a42b3256   wuxw   HC小区管理系统前段vue版正在开发中
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
                  </el-image>
                </el-col>
                <el-col :span="20">
                  <el-row :gutter="20">
                    <el-col :span="8">
                      <div class="info-item">
                        <label>{{ $t('staffDetailInfo.staffId') }}</label>
                        <div>{{ staffDetailInfo.staffId }}</div>
                      </div>
                    </el-col>
                    <el-col :span="8">
                      <div class="info-item">
                        <label>{{ $t('staffDetailInfo.userName') }}</label>
                        <div>{{ staffDetailInfo.userName }}</div>
                      </div>
                    </el-col>
                    <el-col :span="8">
                      <div class="info-item ">
                        <label>{{ $t('staffDetailInfo.email') }}</label>
                        <div>{{ staffDetailInfo.email }}</div>
                      </div>
                    </el-col>
                  </el-row>
                  <el-row :gutter="20">
                    <el-col :span="8">
                      <div class="info-item">
                        <label>{{ $t('staffDetailInfo.tel') }}</label>
                        <div>{{ staffDetailInfo.tel }}</div>
                      </div>
                    </el-col>
                    <el-col :span="8">
                      <div class="info-item">
                        <label>{{ $t('staffDetailInfo.sex') }}</label>
27dcfde5   wuxw   系统全面测试完成
50
51
                        <div>{{ staffDetailInfo.sex == '0' ? $t('staffDetailInfo.male') : $t('staffDetailInfo.female') }}
                        </div>
a42b3256   wuxw   HC小区管理系统前段vue版正在开发中
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
                      </div>
                    </el-col>
                    <el-col :span="8">
                      <div class="info-item">
                        <label>{{ $t('staffDetailInfo.address') }}</label>
                        <div>{{ staffDetailInfo.address }}</div>
                      </div>
                    </el-col>
                  </el-row>
                </el-col>
              </el-row>
            </div>
          </el-card>
  
          <el-card class="box-card margin-top text-left">
            <div slot="header" class="clearfix ">
              <span>{{ $t('staffDetailInfo.relatedOrg') }}</span>
            </div>
27dcfde5   wuxw   系统全面测试完成
70
            <div v-for="(item, index) in staffDetailInfo.orgs" :key="index">
a42b3256   wuxw   HC小区管理系统前段vue版正在开发中
71
72
73
74
75
76
77
78
              <div class="org-item">{{ $t('staffDetailInfo.org') }}: {{ item.orgName }}</div>
            </div>
          </el-card>
  
          <el-card class="box-card margin-top text-left">
            <div slot="header" class="clearfix">
              <span>{{ $t('staffDetailInfo.relatedRoleCommunity') }}</span>
            </div>
27dcfde5   wuxw   系统全面测试完成
79
            <div v-for="(item, index) in staffDetailInfo.roles" :key="index">
6b909af0   wuxw   v1.9 优化员工详情页面
80
81
              <div class="flex justify-start">
               <div> {{ item.roleName }} </div> <div v-if="item.roleCommunityDtoList.length > 0">(
27dcfde5   wuxw   系统全面测试完成
82
                <span v-for="(item1, index1) in item.roleCommunityDtoList" :key="index1">
a42b3256   wuxw   HC小区管理系统前段vue版正在开发中
83
                  {{ item1.communityName }}
27dcfde5   wuxw   系统全面测试完成
84
                  {{ index1 === item.roleCommunityDtoList.length - 1 ? " " : " 、 " }}
a42b3256   wuxw   HC小区管理系统前段vue版正在开发中
85
                </span> )
6b909af0   wuxw   v1.9 优化员工详情页面
86
                </div>
a42b3256   wuxw   HC小区管理系统前段vue版正在开发中
87
88
89
90
91
92
93
94
95
96
97
98
              </div>
            </div>
          </el-card>
  
          <!-- <staff-map-pos :staff-id="staffDetailInfo.staffId" class="margin-top"></staff-map-pos> -->
        </el-col>
  
        <el-col :span="6">
          <el-card class="box-card text-left">
            <div slot="header" class="clearfix">
              <span>{{ $t('staffDetailInfo.staffPrivilege') }}</span>
            </div>
27dcfde5   wuxw   系统全面测试完成
99
            <el-tree :data="privilegeTreeData" node-key="id" default-expand-all :props="defaultProps">
a42b3256   wuxw   HC小区管理系统前段vue版正在开发中
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
            </el-tree>
          </el-card>
        </el-col>
      </el-row>
    </div>
  </template>
  
  <script>
  import { getStaffDetail, getStaffOrgs, getStaffRoles, getStaffPrivileges } from '@/api/staff/staffDetailApi'
  
  export default {
    name: 'StaffDetailList',
    components: {
    },
    data() {
      return {
        staffDetailInfo: {
          staffId: '',
          userName: '',
          email: '',
          tel: '',
          sex: '',
          address: '',
          photo: '',
          orgs: [],
          roles: []
        },
        privilegeTreeData: [],
        defaultProps: {
          children: 'children',
          label: 'text'
        }
      }
    },
    created() {
      this.staffDetailInfo.staffId = this.$route.query.staffId
      this.loadStaffDetail()
      this.loadStaffOrgs()
      this.loadStaffRoles()
      this.loadStaffPrivileges()
    },
    methods: {
      goBack() {
        this.$router.go(-1)
      },
      errorLoadImg() {
69e18472   wuxw   v1.9 员工头像不对问题
146
        this.staffDetailInfo.photoUrl = "/img/noPhoto.jpg"
a42b3256   wuxw   HC小区管理系统前段vue版正在开发中
147
148
149
150
151
152
153
154
155
      },
      async loadStaffDetail() {
        try {
          const params = {
            page: 1,
            row: 1,
            staffId: this.staffDetailInfo.staffId
          }
          const res = await getStaffDetail(params)
6b909af0   wuxw   v1.9 优化员工详情页面
156
157
          if ( res.staffs.length > 0) {
            Object.assign(this.staffDetailInfo, res.staffs[0])
69e18472   wuxw   v1.9 员工头像不对问题
158
            this.staffDetailInfo.photoUrl = res.staffs[0].photoUrl
a42b3256   wuxw   HC小区管理系统前段vue版正在开发中
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
          }
        } catch (error) {
          this.$message.error(this.$t('staffDetailInfo.fetchError'))
        }
      },
      async loadStaffOrgs() {
        try {
          const params = {
            page: 1,
            row: 1,
            staffId: this.staffDetailInfo.staffId
          }
          const res = await getStaffOrgs(params)
          if (res.code === 0) {
            this.staffDetailInfo.orgs = res.data
          }
        } catch (error) {
          this.$message.error(this.$t('staffDetailInfo.fetchOrgError'))
        }
      },
      async loadStaffRoles() {
        try {
          const params = {
            page: 1,
            row: 9999,
            staffId: this.staffDetailInfo.staffId
          }
          const res = await getStaffRoles(params)
6b909af0   wuxw   v1.9 优化员工详情页面
187
          if (res.code == 0) {
a42b3256   wuxw   HC小区管理系统前段vue版正在开发中
188
189
190
191
192
193
194
195
196
197
198
199
            this.staffDetailInfo.roles = res.data
          }
        } catch (error) {
          this.$message.error(this.$t('staffDetailInfo.fetchRoleError'))
        }
      },
      async loadStaffPrivileges() {
        try {
          const params = {
            staffId: this.staffDetailInfo.staffId
          }
          const res = await getStaffPrivileges(params)
6b909af0   wuxw   v1.9 优化员工详情页面
200
201
          if (res.datas && res.datas.length > 0) {
            this.privilegeTreeData = this.buildTreeData(res.datas)
a42b3256   wuxw   HC小区管理系统前段vue版正在开发中
202
203
204
205
206
207
208
          }
        } catch (error) {
          this.$message.error(this.$t('staffDetailInfo.fetchPrivilegeError'))
        }
      },
      buildTreeData(privileges) {
        const groupMap = {}
27dcfde5   wuxw   系统全面测试完成
209
  
a42b3256   wuxw   HC小区管理系统前段vue版正在开发中
210
211
212
213
214
215
216
217
218
        privileges.forEach(item => {
          if (!groupMap[item.gId]) {
            groupMap[item.gId] = {
              id: `g_${item.gId}`,
              gId: item.gId,
              text: item.gName,
              children: []
            }
          }
27dcfde5   wuxw   系统全面测试完成
219
  
a42b3256   wuxw   HC小区管理系统前段vue版正在开发中
220
221
          const group = groupMap[item.gId]
          const menuExists = group.children.some(menu => menu.mId === item.mId)
27dcfde5   wuxw   系统全面测试完成
222
  
a42b3256   wuxw   HC小区管理系统前段vue版正在开发中
223
224
225
226
227
228
229
230
          if (!menuExists) {
            group.children.push({
              id: `m_${item.mId}`,
              mId: item.mId,
              text: item.mName,
              children: []
            })
          }
27dcfde5   wuxw   系统全面测试完成
231
  
a42b3256   wuxw   HC小区管理系统前段vue版正在开发中
232
233
234
235
236
237
238
          const menu = group.children.find(menu => menu.mId === item.mId)
          menu.children.push({
            id: `p_${item.pId}`,
            pId: item.pId,
            text: item.pName
          })
        })
27dcfde5   wuxw   系统全面测试完成
239
  
a42b3256   wuxw   HC小区管理系统前段vue版正在开发中
240
241
242
243
244
245
246
247
248
        return Object.values(groupMap)
      }
    }
  }
  </script>
  
  <style lang="scss" scoped>
  .staff-detail-container {
    padding: 20px;
27dcfde5   wuxw   系统全面测试完成
249
  
a42b3256   wuxw   HC小区管理系统前段vue版正在开发中
250
251
252
    .margin-top {
      margin-top: 20px;
    }
27dcfde5   wuxw   系统全面测试完成
253
  
a42b3256   wuxw   HC小区管理系统前段vue版正在开发中
254
255
256
    .info-item {
      margin-bottom: 15px;
  
27dcfde5   wuxw   系统全面测试完成
257
  
a42b3256   wuxw   HC小区管理系统前段vue版正在开发中
258
259
260
261
262
263
      label {
        display: block;
        color: #909399;
        margin-bottom: 5px;
      }
    }
27dcfde5   wuxw   系统全面测试完成
264
  
a42b3256   wuxw   HC小区管理系统前段vue版正在开发中
265
266
267
268
269
    .org-item {
      padding: 5px 0;
    }
  }
  </style>