开发完成admin的组织信息

This commit is contained in:
wuxw 2025-06-04 11:42:03 +08:00
parent ebc1053d54
commit aaa767a4a4
5 changed files with 311 additions and 0 deletions

View File

@ -0,0 +1,55 @@
import request from '@/utils/request'
// 获取员工列表
export function getStaffInfos(params) {
return request({
url: '/query.staff.infos',
method: 'get',
params
})
}
// 获取员工关联的小区列表
export function listAStaffCommunity(params) {
return request({
url: '/role.listAStaffCommunity',
method: 'get',
params
})
}
// 获取待关联的小区列表
export function listWaitAStaffCommunity(params) {
return request({
url: '/role.listWaitAStaffCommunity',
method: 'get',
params
})
}
// 保存员工小区关联
export function saveStaffCommunity(data) {
return request({
url: '/role.saveStaffCommunity',
method: 'post',
data
})
}
// 删除员工小区关联
export function deleteStaffCommunity(data) {
return request({
url: '/role.deleteStaffCommunity',
method: 'post',
data
})
}
// 获取组织树
export function listOrgTree(params) {
return request({
url: '/org.listOrgTree',
method: 'get',
params
})
}

View File

@ -114,6 +114,7 @@ import { messages as supplierCouponMessages } from '../views/scm/supplierCouponL
import { messages as supplierCouponBuyMessages } from '../views/scm/supplierCouponBuyLang'
import { messages as aStaffMessages } from '../views/staff/aStaffLang'
import { messages as aStaffDetailMessages } from '../views/staff/aStaffDetailLang'
import { messages as aStaffCommunityMessages } from '../views/staff/aStaffCommunityLang'
Vue.use(VueI18n)
@ -232,6 +233,7 @@ const messages = {
...supplierCouponBuyMessages.en,
...aStaffMessages.en,
...aStaffDetailMessages.en,
...aStaffCommunityMessages.en,
},
zh: {
...loginMessages.zh,
@ -346,6 +348,7 @@ const messages = {
...supplierCouponBuyMessages.zh,
...aStaffMessages.zh,
...aStaffDetailMessages.zh,
...aStaffCommunityMessages.zh,
}
}

View File

@ -556,6 +556,11 @@ const routes = [
name: '/views/staff/aStaffDetail',
component: () => import('@/views/staff/aStaffDetailList.vue')
},
{
path:'/pages/staff/aStaffCommunity',
name:'/pages/staff/aStaffCommunity',
component: () => import('@/views/staff/aStaffCommunityList.vue')
},
// 其他子路由可以在这里添加
]
},

View File

@ -0,0 +1,26 @@
export const messages = {
en: {
aStaffCommunity: {
orgPlaceholder: 'Select organization',
staffPlaceholder: 'Enter staff name',
linkCommunity: 'Link Community',
staffName: 'Staff Name',
staffId: 'Staff ID',
communityId: 'Community ID',
communityName: 'Community Name',
selectStaffFirst: 'Please select a staff first'
}
},
zh: {
aStaffCommunity: {
orgPlaceholder: '选择组织',
staffPlaceholder: '填写员工名称',
linkCommunity: '关联小区',
staffName: '员工名称',
staffId: '员工编号',
communityId: '小区编号',
communityName: '小区名称',
selectStaffFirst: '请先选择员工'
}
}
}

View File

@ -0,0 +1,222 @@
<template>
<div>
<el-row :gutter="20">
<el-col :span="4">
<el-card class="box-card">
<div class="margin-bottom">
<el-input v-model="aStaffCommunityInfo.orgName" readonly @focus="openChooseOrgTree"
:placeholder="$t('aStaffCommunity.orgPlaceholder')" />
</div>
<div class="margin-bottom">
<el-input v-model="aStaffCommunityInfo.staffNameLike" :placeholder="$t('aStaffCommunity.staffPlaceholder')"
@keyup.enter.native="loadStaffs" />
</div>
<div class="text-right">
<el-button type="primary" @click="loadStaffs">{{ $t('common.search') }}</el-button>
</div>
<div class="treeview attendance-staff">
<ul class="list-group">
<li v-for="(item, index) in aStaffCommunityInfo.staffs" :key="index" @click="swatchStaff(item)"
:class="{ 'vc-node-selected': aStaffCommunityInfo.curStaffId == item.userId }" class="list-group-item">
{{ item.name }}
</li>
</ul>
</div>
</el-card>
</el-col>
<el-col :span="20">
<el-card class="box-card">
<div class="text-right margin-bottom" v-if="aStaffCommunityInfo.curStaffId">
<el-button type="primary" size="small" @click="openAddModal">
{{ $t('aStaffCommunity.linkCommunity') }}
</el-button>
</div>
<el-table :data="aStaffCommunityInfo.communitys" style="width: 100%">
<el-table-column prop="staffName" :label="$t('aStaffCommunity.staffName')" align="center" />
<el-table-column prop="staffId" :label="$t('aStaffCommunity.staffId')" align="center" />
<el-table-column prop="communityId" :label="$t('aStaffCommunity.communityId')" align="center" />
<el-table-column prop="communityName" :label="$t('aStaffCommunity.communityName')" align="center" />
<el-table-column :label="$t('common.operation')" align="center">
<template slot-scope="scope">
<el-button type="danger" size="mini" @click="openDeleteModal(scope.row)">
{{ $t('common.delete') }}
</el-button>
</template>
</el-table-column>
</el-table>
<el-pagination class="pagination" :current-page.sync="pagination.current" :page-sizes="[10, 20, 30, 50]"
:page-size="pagination.size" layout="total, sizes, prev, pager, next" :total="pagination.total"
@size-change="handleSizeChange" @current-change="handlePageChange" />
</el-card>
</el-col>
</el-row>
<choose-org-tree ref="chooseOrgTree" @switch-org="handleSwitchOrg" />
<add-a-staff-community ref="addModal" @success="loadAStaffCommunitys" />
<delete-a-staff-community ref="deleteModal" @success="loadAStaffCommunitys" />
</div>
</template>
<script>
import { getStaffInfos, listAStaffCommunity } from '@/api/staff/aStaffCommunityApi'
import ChooseOrgTree from '@/components/org/ChooseOrgTree'
import AddAStaffCommunity from '@/components/staff/addAStaffCommunity'
import DeleteAStaffCommunity from '@/components/staff/deleteAStaffCommunity'
export default {
name: 'AStaffCommunityList',
components: {
ChooseOrgTree,
AddAStaffCommunity,
DeleteAStaffCommunity
},
data() {
return {
aStaffCommunityInfo: {
staffs: [],
communitys: [],
orgId: '',
orgName: '',
curStaffId: '',
staffNameLike: ''
},
pagination: {
current: 1,
size: 10,
total: 0
}
}
},
created() {
this.loadStaffs()
},
methods: {
async loadStaffs() {
try {
const params = {
orgId: this.aStaffCommunityInfo.orgId,
staffName: this.aStaffCommunityInfo.staffNameLike,
page: 1,
row: 100
}
const {data} = await getStaffInfos(params)
this.aStaffCommunityInfo.staffs = data.staffs || []
if (this.aStaffCommunityInfo.staffs.length > 0) {
this.aStaffCommunityInfo.curStaffId = this.aStaffCommunityInfo.staffs[0].userId
this.loadAStaffCommunitys()
}
} catch (error) {
console.error('加载员工列表失败:', error)
}
},
async loadAStaffCommunitys() {
if (!this.aStaffCommunityInfo.curStaffId) return
try {
const params = {
staffId: this.aStaffCommunityInfo.curStaffId,
page: this.pagination.current,
row: this.pagination.size
}
const {data} = await listAStaffCommunity(params)
this.aStaffCommunityInfo.communitys = data.data || []
this.pagination.total = data.total || 0
} catch (error) {
console.error('加载小区列表失败:', error)
}
},
openChooseOrgTree() {
this.$refs.chooseOrgTree.open()
},
handleSwitchOrg(org) {
this.aStaffCommunityInfo.orgId = org.orgId
this.aStaffCommunityInfo.orgName = org.allOrgName
this.loadStaffs()
},
swatchStaff(staff) {
this.aStaffCommunityInfo.curStaffId = staff.userId
this.loadAStaffCommunitys()
},
openAddModal() {
if (!this.aStaffCommunityInfo.curStaffId) {
this.$message.warning(this.$t('aStaffCommunity.selectStaffFirst'))
return
}
const staffInfo = this.aStaffCommunityInfo.staffs.find(
s => s.userId === this.aStaffCommunityInfo.curStaffId
)
this.$refs.addModal.open({
staffId: this.aStaffCommunityInfo.curStaffId,
staffName: staffInfo ? staffInfo.name : ''
})
},
openDeleteModal(row) {
this.$refs.deleteModal.open(row)
},
handleSizeChange(size) {
this.pagination.size = size
this.loadAStaffCommunitys()
},
handlePageChange(current) {
this.pagination.current = current
this.loadAStaffCommunitys()
}
}
}
</script>
<style scoped>
.margin-bottom {
margin-bottom: 15px;
}
.text-right {
text-align: right;
}
.list-group {
list-style: none;
padding: 0;
margin-top: 15px;
}
.list-group-item {
padding: 10px 15px;
border: 1px solid #ebeef5;
cursor: pointer;
margin-bottom: 5px;
border-radius: 4px;
}
.list-group-item:hover {
background-color: #f5f7fa;
}
.vc-node-selected {
background-color: #ecf5ff;
color: #409eff;
border-color: #d9ecff;
}
.pagination {
margin-top: 20px;
text-align: right;
}
</style>