Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions web/src/modules/base/api/department.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,37 @@
* @Link https://github.com/mineadmin
*/
import type { PageList, ResponseStruct } from '#/global'
import type { LeaderVo } from '~/base/api/leader.ts'
import type { PositionVo } from '~/base/api/position.ts'

export interface DepartmentUserPivotVo {
dept_id?: number
user_id?: number
}

export interface DepartmentUserVo {
id?: number
username?: string
nickname?: string
avatar?: string
phone?: string
email?: string
pivot?: DepartmentUserPivotVo
[key: string]: any
}

export interface DepartmentVo {
id?: number
name?: string
parent_id?: number | null
created_at?: string | null
updated_at?: string | null
deleted_at?: string | null
children?: DepartmentVo[]
leader?: LeaderVo[]
positions?: PositionVo[]
department_users?: DepartmentUserVo[]
[key: string]: any
}

export interface DepartmentSearchVo {
Expand Down
49 changes: 35 additions & 14 deletions web/src/modules/base/views/permission/department/viewUser.vue
Original file line number Diff line number Diff line change
Expand Up @@ -9,28 +9,24 @@
-->

<script setup lang="tsx">
import type { DepartmentVo } from '~/base/api/department.ts'
import type { MaTableColumns, MaTableOptions } from '@mineadmin/table'
import type { DepartmentUserVo, DepartmentVo } from '~/base/api/department.ts'
import type { MaTableColumns, MaTableExpose } from '@mineadmin/table'
import type { TransType } from '@/hooks/auto-imports/useTrans.ts'
import useTable from '@/hooks/useTable.ts'

const { data = null } = defineProps<{
data?: DepartmentVo | null
}>()

const dictStore = useDictStore()
const i18n = useTrans() as TransType
const t = i18n.globalTrans
const tableRef = ref<MaTableExpose>()

// 参数配置
const options = ref<MaTableOptions>({
data: data?.department_users ?? [],
adaption: false,
height: 400,
rowKey: 'id',
const tableData = computed<DepartmentUserVo[]>(() => {
return Array.isArray(data?.department_users) ? data.department_users : []
})

// 架构配置
const tableColumns = ref<MaTableColumns[]>([
const tableColumns: MaTableColumns[] = [
{
label: () => t('baseUserManage.username'),
prop: 'username',
Expand All @@ -48,18 +44,43 @@ const tableColumns = ref<MaTableColumns[]>([
label: () => t('baseUserManage.email'),
prop: 'email',
},
])
]

function setTableData(rows: DepartmentUserVo[]) {
tableRef.value?.setData(rows)
}

watch(tableData, (rows) => {
setTableData(rows)
}, { immediate: true })

useTable('tableRef')
.then((table: MaTableExpose) => {
tableRef.value = table
table.setOptions({
adaption: false,
height: 400,
rowKey: 'id',
})
table.setColumns(tableColumns)
setTableData(tableData.value)
})
.catch((err) => {
console.error('init user table failed:', err)
})
</script>

<template>
<ma-table :options="options" :columns="tableColumns" />
<ma-table ref="tableRef" />
</template>

<style scoped lang="scss">
:deep(.mineadmin-pro-table-search) {
margin: 0; padding: 0;
margin: 0;
padding: 0;
@apply pt-3;
}

:deep(.mine-card) {
margin: 0;
}
Expand Down
Loading