@@ -360,6 +399,187 @@
+
+
+ 当前地区:{{ currentRegionName }}
+
+
+
+
+
+
+
+
+
+
+ {{ row.deptName }}
+ —
+
+
+
+
+ 负责人
+ 否
+
+
+
+
+
+ {{ row.isLeader ? '取消负责人' : '设为负责人' }}
+
+ 移除
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 取消
+
+
+
+ 确定
+
+
+
+
+
+
+ 关闭
+
+
+
+
0 ? row.hospitalNames.join('、') : '无'
+ const staffs =
+ row.staffNames && row.staffNames.length > 0 ? row.staffNames.join('、') : '无'
+ const leaders =
+ row.leaderNames && row.leaderNames.length > 0 ? row.leaderNames.join('、') : '未设置'
return [
{
title: '基本信息',
@@ -441,6 +670,13 @@
{ label: '地区名称', value: row.regionName },
{ label: '创建时间', value: row.createTime },
{ label: '关联医院', value: hospitals, span: true },
+ { label: '工作人员', value: staffs, span: true },
+ {
+ label: '负责人',
+ value: row.leaderNames?.length ? leaders : '未设置',
+ tagType: row.leaderNames?.length ? 'success' : 'info',
+ span: true
+ },
{ label: '备注', value: row.remark, span: true }
]
}
@@ -674,6 +910,156 @@
await loadHospitals()
}, fullscreenLoadingText.batchDelete)
}
+
+ const staffDialogVisible = ref(false)
+ const staffDialogTitle = ref('地区人员配置')
+ const staffTable = ref([])
+ const staffSelected = ref([])
+ const staffLoading = ref(false)
+ const staffPagination = reactive({ page: 1, pageSize: 10, total: 0 })
+ const staffAddVisible = ref(false)
+ const staffAddLoading = ref(false)
+ const staffAddForm = reactive<{ userId: string; isLeader: boolean }>({
+ userId: '',
+ isLeader: false
+ })
+ const staffUserOptions = ref([])
+ const staffUserLoading = ref(false)
+ const boundStaffUserIds = ref>(new Set())
+
+ function onStaffSelectionChange(rows: Api.BizCollectionRegionStaff.StaffItem[]) {
+ staffSelected.value = rows
+ }
+
+ function openStaffDialog(row: Api.BizCollectionRegion.RegionItem) {
+ currentRegionId.value = row.id
+ currentRegionName.value = row.regionName || ''
+ staffDialogTitle.value = '地区人员配置'
+ staffPagination.page = 1
+ staffSelected.value = []
+ staffDialogVisible.value = true
+ loadStaff()
+ }
+
+ async function refreshBoundStaffUserIds() {
+ if (!currentRegionId.value) {
+ boundStaffUserIds.value = new Set()
+ return
+ }
+ try {
+ const res = await fetchRegionStaffList(currentRegionId.value, {
+ page: 1,
+ pageSize: 500
+ })
+ boundStaffUserIds.value = new Set((res.list || []).map((s) => s.userId))
+ } catch {
+ boundStaffUserIds.value = new Set(staffTable.value.map((s) => s.userId))
+ }
+ }
+
+ async function loadStaff() {
+ if (!currentRegionId.value) return
+ staffLoading.value = true
+ try {
+ const res = await fetchRegionStaffList(currentRegionId.value, {
+ page: staffPagination.page,
+ pageSize: staffPagination.pageSize
+ })
+ staffTable.value = res.list || []
+ staffPagination.total = res.total ?? 0
+ await refreshBoundStaffUserIds()
+ } finally {
+ staffLoading.value = false
+ }
+ }
+
+ function onStaffDialogClosed() {
+ staffTable.value = []
+ staffSelected.value = []
+ boundStaffUserIds.value = new Set()
+ loadData()
+ }
+
+ function handleAddStaff() {
+ staffAddForm.userId = ''
+ staffAddForm.isLeader = false
+ staffUserOptions.value = []
+ staffAddVisible.value = true
+ remoteSearchUsers('')
+ }
+
+ async function remoteSearchUsers(query: string) {
+ staffUserLoading.value = true
+ try {
+ const res = await fetchUserList({
+ page: 1,
+ pageSize: 20,
+ keyword: query || undefined,
+ status: '1'
+ })
+ const bound = boundStaffUserIds.value
+ staffUserOptions.value = (res.list || []).filter((u) => !bound.has(u.id))
+ } finally {
+ staffUserLoading.value = false
+ }
+ }
+
+ async function submitAddStaff() {
+ if (!staffAddForm.userId) {
+ ElMessage.warning('请选择系统人员')
+ return
+ }
+ staffAddLoading.value = true
+ try {
+ await fetchCreateRegionStaff(currentRegionId.value, {
+ userId: staffAddForm.userId,
+ isLeader: staffAddForm.isLeader
+ })
+ ElMessage.success('添加成功')
+ staffAddVisible.value = false
+ staffAddForm.userId = ''
+ staffAddForm.isLeader = false
+ await loadStaff()
+ await loadData()
+ } catch {
+ /* */
+ } finally {
+ staffAddLoading.value = false
+ }
+ }
+
+ async function toggleStaffLeader(row: Api.BizCollectionRegionStaff.StaffItem) {
+ await fetchUpdateRegionStaff(currentRegionId.value, row.id, { isLeader: !row.isLeader })
+ ElMessage.success('已更新')
+ await loadStaff()
+ await loadData()
+ }
+
+ async function handleDeleteStaff(row: Api.BizCollectionRegionStaff.StaffItem) {
+ await ElMessageBox.confirm(`确定移除「${row.userName}」吗?`, '提示', { type: 'warning' })
+ await fetchDeleteRegionStaff(currentRegionId.value, row.id)
+ ElMessage.success('已移除')
+ await loadStaff()
+ await loadData()
+ }
+
+ async function handleBatchDeleteStaff() {
+ if (!staffSelected.value.length) return
+ await ElMessageBox.confirm(`确定移除选中的 ${staffSelected.value.length} 人吗?`, '提示', {
+ type: 'warning'
+ })
+ const rid = currentRegionId.value
+ await withFullscreenLoading(async () => {
+ for (const row of staffSelected.value) {
+ await fetchDeleteRegionStaff(rid, row.id)
+ }
+ ElMessage.success('已移除')
+ staffSelected.value = []
+ await loadStaff()
+ await loadData()
+ }, fullscreenLoadingText.batchDelete)
+ }
+
// 输入检索条件时自动搜索(防抖 300ms)
watchDebounced(
searchForm,