| | |
| | | <el-table-column type="index" show-overflow-tooltip width="64" label="序号" /> |
| | | <el-table-column prop="deptName" show-overflow-tooltip label="部门名称" /> |
| | | <el-table-column prop="fullName" show-overflow-tooltip label="部门全称" /> |
| | | <el-table-column prop="deptCategory" show-overflow-tooltip width="120" label="部门类型"> |
| | | <el-table-column prop="deptCategory" show-overflow-tooltip label="部门类型"> |
| | | <template v-slot="{ row }"> |
| | | {{ getDictLabel(row.deptCategory, dictObj.org_category) }} |
| | | </template> |
| | | </el-table-column> |
| | | <el-table-column prop="deptNature" show-overflow-tooltip width="120" label="部门性质"> |
| | | <el-table-column prop="deptNature" show-overflow-tooltip label="部门性质"> |
| | | <template v-slot="{ row }"> |
| | | {{ getDictLabel(row.deptNature, dictObj.org_nature) }} |
| | | </template> |
| | | </el-table-column> |
| | | <el-table-column prop="sort" show-overflow-tooltip width="80" label="排序" /> |
| | | <el-table-column prop="bingId" show-overflow-tooltip width="100" label="组织id" /> |
| | | <el-table-column prop="areaName" show-overflow-tooltip width="180" label="行政区划" /> |
| | | <el-table-column prop="deploymentMode" show-overflow-tooltip width="120" label="部署模式"> |
| | | <template v-slot="{ row }"> |
| | | {{ deploymentModeLabel(row.deploymentMode) }} |
| | | </template> |
| | | </el-table-column> |
| | | <el-table-column label="操作" class-name="operation-btns" width="220"> |
| | | <el-table-column prop="bingId" show-overflow-tooltip width="80" label="组织id" /> |
| | | <el-table-column prop="areaName" show-overflow-tooltip label="行政区划" /> |
| | | |
| | | <el-table-column label="操作" class-name="operation-btns"> |
| | | <template v-slot="{ row }"> |
| | | <el-link @click="handleView(row)">查看</el-link> |
| | | <el-link @click="handleEdit(row)">编辑</el-link> |
| | | <el-link @click="handleAddChild(row)">新增子项</el-link> |
| | | <el-link type="danger" @click="handleDelete(row)">删除</el-link> |
| | | <el-link type="danger" @click="handleShare(row)" v-if="hasSharing">共享</el-link> |
| | | </template> |
| | | </el-table-column> |
| | | </el-table> |
| | |
| | | </div> |
| | | </div> |
| | | |
| | | <FormDiaLog ref="dialogRef" @success="getList" /> |
| | | <FormDiaLog ref="dialogRef" @success="handleFormSuccess" v-model="visible" v-if="visible" /> |
| | | <ShareDiaLog ref="shareDialogRef" @success="getList" v-model="shareVisible" v-if="shareVisible" /> |
| | | </basic-container> |
| | | </template> |
| | | |
| | | <script setup> |
| | | import { Delete, Plus, RefreshRight, Search } from '@element-plus/icons-vue' |
| | | import { onMounted, provide, ref } from 'vue' |
| | | import { nextTick, onMounted, provide, ref } from 'vue' |
| | | import { ElMessage, ElMessageBox } from 'element-plus' |
| | | import { getDictionary } from '@/api/system/dict' |
| | | import { getChildLazyTree, getDeptTree, getLazyList, remove } from '@/api/system/dept' |
| | | import { getDictLabel } from '@ztzf/utils' |
| | | import FormDiaLog from './FormDiaLog.vue' |
| | | import ShareDiaLog from './ShareDiaLog.vue' |
| | | import { saveOperationLog } from '@ztzf/apis' |
| | | import { useRoute } from 'vue-router' |
| | | import { useStore } from 'vuex' |
| | | |
| | | const store = useStore() |
| | | const permission = computed(() => store.state.user.permission) |
| | | const ancestors = computed(() => store.state.user.userInfo?.detail?.ancestors) |
| | | // 市级部门并且有权限才能看到共享按钮 |
| | | const hasSharing = computed(() => permission.value.department_share && ancestors.value.split(',')?.length === 2) |
| | | const initSearchParams = () => ({ |
| | | deptName: '', |
| | | fullName: '', |
| | |
| | | |
| | | const searchParams = ref(initSearchParams()) |
| | | const loading = ref(true) |
| | | const visible = ref(false) |
| | | const list = ref([]) |
| | | const total = ref(0) |
| | | const selectedIds = ref([]) |
| | | const selectedRows = ref([]) |
| | | const lastActionParentRow = ref(null) |
| | | const queryParamsRef = ref(null) |
| | | const dialogRef = ref(null) |
| | | const shareDialogRef = ref(null) |
| | | const shareVisible = ref(false) |
| | | const dictObj = ref({ |
| | | org_category: [], |
| | | org_nature: [], |
| | | }) |
| | | const deptTree = ref([]) |
| | | const route = useRoute() |
| | | const treeResolveMap = new Map() |
| | | |
| | | provide('dictObj', dictObj) |
| | | provide('deptTree', deptTree) |
| | | |
| | | function deploymentModeLabel(value) { |
| | | if (value === 1) return '独立部署' |
| | | if (value === 0) return '统一部署' |
| | | return value ?? '-' |
| | | } |
| | | |
| | | async function getList() { |
| | | loading.value = true |
| | |
| | | } |
| | | |
| | | function handleAdd() { |
| | | dialogRef.value?.open({ mode: 'add' }) |
| | | visible.value = true |
| | | nextTick(() => { |
| | | dialogRef.value?.open({ mode: 'add' }) |
| | | }) |
| | | } |
| | | |
| | | function handleAddChild(row) { |
| | | dialogRef.value?.open({ mode: 'add', parent: row }) |
| | | lastActionParentRow.value = row |
| | | visible.value = true |
| | | nextTick(() => { |
| | | dialogRef.value?.open({ mode: 'add', parent: row }) |
| | | }) |
| | | } |
| | | |
| | | function handleView(row) { |
| | | dialogRef.value?.open({ mode: 'view', row: { ...row } }) |
| | | visible.value = true |
| | | nextTick(() => { |
| | | dialogRef.value?.open({ mode: 'view', row: { ...row } }) |
| | | }) |
| | | } |
| | | |
| | | function handleEdit(row) { |
| | | dialogRef.value?.open({ mode: 'edit', row: { ...row } }) |
| | | visible.value = true |
| | | nextTick(() => { |
| | | dialogRef.value?.open({ mode: 'edit', row: { ...row } }) |
| | | }) |
| | | } |
| | | |
| | | function handleShare(row) { |
| | | shareVisible.value = true |
| | | nextTick(() => { |
| | | shareDialogRef.value?.open({ row }) |
| | | }) |
| | | } |
| | | |
| | | async function handleDelete(row) { |
| | |
| | | cancelButtonClass: 'command-message-box-cancel', |
| | | }) |
| | | const ids = row ? row.id : selectedIds.value.join(',') |
| | | const rows = row ? [row] : selectedRows.value |
| | | await remove(ids) |
| | | saveOperationLog({ |
| | | requestUri: route.path, |
| | | title: `${route.name || '部门管理'}-删除`, |
| | | type: 1, |
| | | }) |
| | | ElMessage.success('删除成功') |
| | | selectedIds.value = [] |
| | | getList() |
| | | selectedRows.value = [] |
| | | const parentIds = Array.from(new Set(rows.map(item => item.parentId).filter(Boolean))) |
| | | const hasRoot = rows.some(item => !item.parentId) |
| | | if (hasRoot) { |
| | | getList() |
| | | } |
| | | parentIds.forEach(parentId => refreshChildNodes(parentId)) |
| | | } |
| | | |
| | | function handleSelectionChange(rows) { |
| | | selectedIds.value = rows.map(item => item.id) |
| | | selectedRows.value = rows |
| | | } |
| | | |
| | | function getDictList() { |
| | |
| | | } |
| | | |
| | | function loadChildren(row, treeNode, resolve) { |
| | | treeResolveMap.set(row.id, { resolve, row }) |
| | | getChildLazyTree({ parentId: row.id }) |
| | | .then(res => { |
| | | resolve(res?.data?.data ?? []) |
| | | const children = res?.data?.data ?? [] |
| | | row.hasChildren = children.length > 0 |
| | | resolve(children) |
| | | }) |
| | | .catch(() => resolve([])) |
| | | .catch(() => { |
| | | row.hasChildren = false |
| | | resolve([]) |
| | | }) |
| | | } |
| | | |
| | | function refreshChildNodes(parentId) { |
| | | const cache = treeResolveMap.get(parentId) |
| | | if (!cache?.resolve) return |
| | | getChildLazyTree({ parentId }) |
| | | .then(res => { |
| | | const children = res?.data?.data ?? [] |
| | | if (cache.row) { |
| | | cache.row.hasChildren = children.length > 0 |
| | | } |
| | | cache.resolve(children) |
| | | }) |
| | | .catch(() => { |
| | | if (cache.row) { |
| | | cache.row.hasChildren = false |
| | | } |
| | | cache.resolve([]) |
| | | }) |
| | | } |
| | | |
| | | function handleFormSuccess(payload = {}) { |
| | | if (payload?.parentId) { |
| | | refreshChildNodes(payload.parentId) |
| | | if (payload.isAddChild && lastActionParentRow.value?.id === payload.parentId) { |
| | | lastActionParentRow.value.hasChildren = true |
| | | } |
| | | lastActionParentRow.value = null |
| | | return |
| | | } |
| | | lastActionParentRow.value = null |
| | | getList() |
| | | } |
| | | |
| | | onMounted(() => { |