Commit aaa767a4a4259ce13712183412bd4af5a30eb9ef
1 parent
ebc1053d
开发完成admin的组织信息
Showing
5 changed files
with
311 additions
and
0 deletions
src/api/staff/aStaffCommunityApi.js
0 → 100644
| 1 | +import request from '@/utils/request' | |
| 2 | + | |
| 3 | +// 获取员工列表 | |
| 4 | +export function getStaffInfos(params) { | |
| 5 | + return request({ | |
| 6 | + url: '/query.staff.infos', | |
| 7 | + method: 'get', | |
| 8 | + params | |
| 9 | + }) | |
| 10 | +} | |
| 11 | + | |
| 12 | +// 获取员工关联的小区列表 | |
| 13 | +export function listAStaffCommunity(params) { | |
| 14 | + return request({ | |
| 15 | + url: '/role.listAStaffCommunity', | |
| 16 | + method: 'get', | |
| 17 | + params | |
| 18 | + }) | |
| 19 | +} | |
| 20 | + | |
| 21 | +// 获取待关联的小区列表 | |
| 22 | +export function listWaitAStaffCommunity(params) { | |
| 23 | + return request({ | |
| 24 | + url: '/role.listWaitAStaffCommunity', | |
| 25 | + method: 'get', | |
| 26 | + params | |
| 27 | + }) | |
| 28 | +} | |
| 29 | + | |
| 30 | +// 保存员工小区关联 | |
| 31 | +export function saveStaffCommunity(data) { | |
| 32 | + return request({ | |
| 33 | + url: '/role.saveStaffCommunity', | |
| 34 | + method: 'post', | |
| 35 | + data | |
| 36 | + }) | |
| 37 | +} | |
| 38 | + | |
| 39 | +// 删除员工小区关联 | |
| 40 | +export function deleteStaffCommunity(data) { | |
| 41 | + return request({ | |
| 42 | + url: '/role.deleteStaffCommunity', | |
| 43 | + method: 'post', | |
| 44 | + data | |
| 45 | + }) | |
| 46 | +} | |
| 47 | + | |
| 48 | +// 获取组织树 | |
| 49 | +export function listOrgTree(params) { | |
| 50 | + return request({ | |
| 51 | + url: '/org.listOrgTree', | |
| 52 | + method: 'get', | |
| 53 | + params | |
| 54 | + }) | |
| 55 | +} | |
| 0 | 56 | \ No newline at end of file | ... | ... |
src/i18n/index.js
| ... | ... | @@ -114,6 +114,7 @@ import { messages as supplierCouponMessages } from '../views/scm/supplierCouponL |
| 114 | 114 | import { messages as supplierCouponBuyMessages } from '../views/scm/supplierCouponBuyLang' |
| 115 | 115 | import { messages as aStaffMessages } from '../views/staff/aStaffLang' |
| 116 | 116 | import { messages as aStaffDetailMessages } from '../views/staff/aStaffDetailLang' |
| 117 | +import { messages as aStaffCommunityMessages } from '../views/staff/aStaffCommunityLang' | |
| 117 | 118 | |
| 118 | 119 | Vue.use(VueI18n) |
| 119 | 120 | |
| ... | ... | @@ -232,6 +233,7 @@ const messages = { |
| 232 | 233 | ...supplierCouponBuyMessages.en, |
| 233 | 234 | ...aStaffMessages.en, |
| 234 | 235 | ...aStaffDetailMessages.en, |
| 236 | + ...aStaffCommunityMessages.en, | |
| 235 | 237 | }, |
| 236 | 238 | zh: { |
| 237 | 239 | ...loginMessages.zh, |
| ... | ... | @@ -346,6 +348,7 @@ const messages = { |
| 346 | 348 | ...supplierCouponBuyMessages.zh, |
| 347 | 349 | ...aStaffMessages.zh, |
| 348 | 350 | ...aStaffDetailMessages.zh, |
| 351 | + ...aStaffCommunityMessages.zh, | |
| 349 | 352 | } |
| 350 | 353 | } |
| 351 | 354 | ... | ... |
src/router/index.js
| ... | ... | @@ -556,6 +556,11 @@ const routes = [ |
| 556 | 556 | name: '/views/staff/aStaffDetail', |
| 557 | 557 | component: () => import('@/views/staff/aStaffDetailList.vue') |
| 558 | 558 | }, |
| 559 | + { | |
| 560 | + path:'/pages/staff/aStaffCommunity', | |
| 561 | + name:'/pages/staff/aStaffCommunity', | |
| 562 | + component: () => import('@/views/staff/aStaffCommunityList.vue') | |
| 563 | + }, | |
| 559 | 564 | // 其他子路由可以在这里添加 |
| 560 | 565 | ] |
| 561 | 566 | }, | ... | ... |
src/views/staff/aStaffCommunityLang.js
0 → 100644
| 1 | +export const messages = { | |
| 2 | + en: { | |
| 3 | + aStaffCommunity: { | |
| 4 | + orgPlaceholder: 'Select organization', | |
| 5 | + staffPlaceholder: 'Enter staff name', | |
| 6 | + linkCommunity: 'Link Community', | |
| 7 | + staffName: 'Staff Name', | |
| 8 | + staffId: 'Staff ID', | |
| 9 | + communityId: 'Community ID', | |
| 10 | + communityName: 'Community Name', | |
| 11 | + selectStaffFirst: 'Please select a staff first' | |
| 12 | + } | |
| 13 | + }, | |
| 14 | + zh: { | |
| 15 | + aStaffCommunity: { | |
| 16 | + orgPlaceholder: '选择组织', | |
| 17 | + staffPlaceholder: '填写员工名称', | |
| 18 | + linkCommunity: '关联小区', | |
| 19 | + staffName: '员工名称', | |
| 20 | + staffId: '员工编号', | |
| 21 | + communityId: '小区编号', | |
| 22 | + communityName: '小区名称', | |
| 23 | + selectStaffFirst: '请先选择员工' | |
| 24 | + } | |
| 25 | + } | |
| 26 | +} | |
| 0 | 27 | \ No newline at end of file | ... | ... |
src/views/staff/aStaffCommunityList.vue
0 → 100644
| 1 | +<template> | |
| 2 | + <div> | |
| 3 | + <el-row :gutter="20"> | |
| 4 | + <el-col :span="4"> | |
| 5 | + <el-card class="box-card"> | |
| 6 | + <div class="margin-bottom"> | |
| 7 | + <el-input v-model="aStaffCommunityInfo.orgName" readonly @focus="openChooseOrgTree" | |
| 8 | + :placeholder="$t('aStaffCommunity.orgPlaceholder')" /> | |
| 9 | + </div> | |
| 10 | + <div class="margin-bottom"> | |
| 11 | + <el-input v-model="aStaffCommunityInfo.staffNameLike" :placeholder="$t('aStaffCommunity.staffPlaceholder')" | |
| 12 | + @keyup.enter.native="loadStaffs" /> | |
| 13 | + </div> | |
| 14 | + <div class="text-right"> | |
| 15 | + <el-button type="primary" @click="loadStaffs">{{ $t('common.search') }}</el-button> | |
| 16 | + </div> | |
| 17 | + | |
| 18 | + <div class="treeview attendance-staff"> | |
| 19 | + <ul class="list-group"> | |
| 20 | + <li v-for="(item, index) in aStaffCommunityInfo.staffs" :key="index" @click="swatchStaff(item)" | |
| 21 | + :class="{ 'vc-node-selected': aStaffCommunityInfo.curStaffId == item.userId }" class="list-group-item"> | |
| 22 | + {{ item.name }} | |
| 23 | + </li> | |
| 24 | + </ul> | |
| 25 | + </div> | |
| 26 | + </el-card> | |
| 27 | + </el-col> | |
| 28 | + | |
| 29 | + <el-col :span="20"> | |
| 30 | + <el-card class="box-card"> | |
| 31 | + <div class="text-right margin-bottom" v-if="aStaffCommunityInfo.curStaffId"> | |
| 32 | + <el-button type="primary" size="small" @click="openAddModal"> | |
| 33 | + {{ $t('aStaffCommunity.linkCommunity') }} | |
| 34 | + </el-button> | |
| 35 | + </div> | |
| 36 | + | |
| 37 | + <el-table :data="aStaffCommunityInfo.communitys" style="width: 100%"> | |
| 38 | + <el-table-column prop="staffName" :label="$t('aStaffCommunity.staffName')" align="center" /> | |
| 39 | + <el-table-column prop="staffId" :label="$t('aStaffCommunity.staffId')" align="center" /> | |
| 40 | + <el-table-column prop="communityId" :label="$t('aStaffCommunity.communityId')" align="center" /> | |
| 41 | + <el-table-column prop="communityName" :label="$t('aStaffCommunity.communityName')" align="center" /> | |
| 42 | + <el-table-column :label="$t('common.operation')" align="center"> | |
| 43 | + <template slot-scope="scope"> | |
| 44 | + <el-button type="danger" size="mini" @click="openDeleteModal(scope.row)"> | |
| 45 | + {{ $t('common.delete') }} | |
| 46 | + </el-button> | |
| 47 | + </template> | |
| 48 | + </el-table-column> | |
| 49 | + </el-table> | |
| 50 | + | |
| 51 | + <el-pagination class="pagination" :current-page.sync="pagination.current" :page-sizes="[10, 20, 30, 50]" | |
| 52 | + :page-size="pagination.size" layout="total, sizes, prev, pager, next" :total="pagination.total" | |
| 53 | + @size-change="handleSizeChange" @current-change="handlePageChange" /> | |
| 54 | + </el-card> | |
| 55 | + </el-col> | |
| 56 | + </el-row> | |
| 57 | + | |
| 58 | + <choose-org-tree ref="chooseOrgTree" @switch-org="handleSwitchOrg" /> | |
| 59 | + <add-a-staff-community ref="addModal" @success="loadAStaffCommunitys" /> | |
| 60 | + <delete-a-staff-community ref="deleteModal" @success="loadAStaffCommunitys" /> | |
| 61 | + </div> | |
| 62 | +</template> | |
| 63 | + | |
| 64 | +<script> | |
| 65 | +import { getStaffInfos, listAStaffCommunity } from '@/api/staff/aStaffCommunityApi' | |
| 66 | +import ChooseOrgTree from '@/components/org/ChooseOrgTree' | |
| 67 | +import AddAStaffCommunity from '@/components/staff/addAStaffCommunity' | |
| 68 | +import DeleteAStaffCommunity from '@/components/staff/deleteAStaffCommunity' | |
| 69 | + | |
| 70 | +export default { | |
| 71 | + name: 'AStaffCommunityList', | |
| 72 | + components: { | |
| 73 | + ChooseOrgTree, | |
| 74 | + AddAStaffCommunity, | |
| 75 | + DeleteAStaffCommunity | |
| 76 | + }, | |
| 77 | + data() { | |
| 78 | + return { | |
| 79 | + aStaffCommunityInfo: { | |
| 80 | + staffs: [], | |
| 81 | + communitys: [], | |
| 82 | + orgId: '', | |
| 83 | + orgName: '', | |
| 84 | + curStaffId: '', | |
| 85 | + staffNameLike: '' | |
| 86 | + }, | |
| 87 | + pagination: { | |
| 88 | + current: 1, | |
| 89 | + size: 10, | |
| 90 | + total: 0 | |
| 91 | + } | |
| 92 | + } | |
| 93 | + }, | |
| 94 | + created() { | |
| 95 | + this.loadStaffs() | |
| 96 | + }, | |
| 97 | + methods: { | |
| 98 | + async loadStaffs() { | |
| 99 | + try { | |
| 100 | + const params = { | |
| 101 | + orgId: this.aStaffCommunityInfo.orgId, | |
| 102 | + staffName: this.aStaffCommunityInfo.staffNameLike, | |
| 103 | + page: 1, | |
| 104 | + row: 100 | |
| 105 | + } | |
| 106 | + | |
| 107 | + const {data} = await getStaffInfos(params) | |
| 108 | + this.aStaffCommunityInfo.staffs = data.staffs || [] | |
| 109 | + | |
| 110 | + if (this.aStaffCommunityInfo.staffs.length > 0) { | |
| 111 | + this.aStaffCommunityInfo.curStaffId = this.aStaffCommunityInfo.staffs[0].userId | |
| 112 | + this.loadAStaffCommunitys() | |
| 113 | + } | |
| 114 | + } catch (error) { | |
| 115 | + console.error('加载员工列表失败:', error) | |
| 116 | + } | |
| 117 | + }, | |
| 118 | + | |
| 119 | + async loadAStaffCommunitys() { | |
| 120 | + if (!this.aStaffCommunityInfo.curStaffId) return | |
| 121 | + | |
| 122 | + try { | |
| 123 | + const params = { | |
| 124 | + staffId: this.aStaffCommunityInfo.curStaffId, | |
| 125 | + page: this.pagination.current, | |
| 126 | + row: this.pagination.size | |
| 127 | + } | |
| 128 | + | |
| 129 | + const {data} = await listAStaffCommunity(params) | |
| 130 | + this.aStaffCommunityInfo.communitys = data.data || [] | |
| 131 | + this.pagination.total = data.total || 0 | |
| 132 | + } catch (error) { | |
| 133 | + console.error('加载小区列表失败:', error) | |
| 134 | + } | |
| 135 | + }, | |
| 136 | + | |
| 137 | + openChooseOrgTree() { | |
| 138 | + this.$refs.chooseOrgTree.open() | |
| 139 | + }, | |
| 140 | + | |
| 141 | + handleSwitchOrg(org) { | |
| 142 | + this.aStaffCommunityInfo.orgId = org.orgId | |
| 143 | + this.aStaffCommunityInfo.orgName = org.allOrgName | |
| 144 | + this.loadStaffs() | |
| 145 | + }, | |
| 146 | + | |
| 147 | + swatchStaff(staff) { | |
| 148 | + this.aStaffCommunityInfo.curStaffId = staff.userId | |
| 149 | + this.loadAStaffCommunitys() | |
| 150 | + }, | |
| 151 | + | |
| 152 | + openAddModal() { | |
| 153 | + if (!this.aStaffCommunityInfo.curStaffId) { | |
| 154 | + this.$message.warning(this.$t('aStaffCommunity.selectStaffFirst')) | |
| 155 | + return | |
| 156 | + } | |
| 157 | + | |
| 158 | + const staffInfo = this.aStaffCommunityInfo.staffs.find( | |
| 159 | + s => s.userId === this.aStaffCommunityInfo.curStaffId | |
| 160 | + ) | |
| 161 | + | |
| 162 | + this.$refs.addModal.open({ | |
| 163 | + staffId: this.aStaffCommunityInfo.curStaffId, | |
| 164 | + staffName: staffInfo ? staffInfo.name : '' | |
| 165 | + }) | |
| 166 | + }, | |
| 167 | + | |
| 168 | + openDeleteModal(row) { | |
| 169 | + this.$refs.deleteModal.open(row) | |
| 170 | + }, | |
| 171 | + | |
| 172 | + handleSizeChange(size) { | |
| 173 | + this.pagination.size = size | |
| 174 | + this.loadAStaffCommunitys() | |
| 175 | + }, | |
| 176 | + | |
| 177 | + handlePageChange(current) { | |
| 178 | + this.pagination.current = current | |
| 179 | + this.loadAStaffCommunitys() | |
| 180 | + } | |
| 181 | + } | |
| 182 | +} | |
| 183 | +</script> | |
| 184 | + | |
| 185 | +<style scoped> | |
| 186 | +.margin-bottom { | |
| 187 | + margin-bottom: 15px; | |
| 188 | +} | |
| 189 | + | |
| 190 | +.text-right { | |
| 191 | + text-align: right; | |
| 192 | +} | |
| 193 | + | |
| 194 | +.list-group { | |
| 195 | + list-style: none; | |
| 196 | + padding: 0; | |
| 197 | + margin-top: 15px; | |
| 198 | +} | |
| 199 | + | |
| 200 | +.list-group-item { | |
| 201 | + padding: 10px 15px; | |
| 202 | + border: 1px solid #ebeef5; | |
| 203 | + cursor: pointer; | |
| 204 | + margin-bottom: 5px; | |
| 205 | + border-radius: 4px; | |
| 206 | +} | |
| 207 | + | |
| 208 | +.list-group-item:hover { | |
| 209 | + background-color: #f5f7fa; | |
| 210 | +} | |
| 211 | + | |
| 212 | +.vc-node-selected { | |
| 213 | + background-color: #ecf5ff; | |
| 214 | + color: #409eff; | |
| 215 | + border-color: #d9ecff; | |
| 216 | +} | |
| 217 | + | |
| 218 | +.pagination { | |
| 219 | + margin-top: 20px; | |
| 220 | + text-align: right; | |
| 221 | +} | |
| 222 | +</style> | |
| 0 | 223 | \ No newline at end of file | ... | ... |