From 9f346a575fcb46537190b746a894c1a3167f0848 Mon Sep 17 00:00:00 2001 From: Flow <958079825@qq.com> Date: Thu, 12 Jun 2025 14:08:52 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BA=BA=E5=91=98=E6=A1=A3=E6=A1=88=E4=BF=AE?= =?UTF-8?q?=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/api/personarchive/index.ts | 14 +- src/views/devices/DevFrom.vue | 4 +- src/views/person/index.vue | 10 -- src/views/personarchive/PersonArchiveForm.vue | 78 +++------ src/views/personarchive/index.vue | 148 +++++++++++------- 5 files changed, 127 insertions(+), 127 deletions(-) diff --git a/src/api/personarchive/index.ts b/src/api/personarchive/index.ts index 16b2d6bb..118a1512 100644 --- a/src/api/personarchive/index.ts +++ b/src/api/personarchive/index.ts @@ -33,8 +33,8 @@ export interface PersonArchiveVO { surgeryhistorydesc: string // 手术史描述 traumahistorydesc: string // 外伤史描述 transfusionhistorydesc: string // 输血史描述 - createtime: Date // 创建时间 - updatetime: Date // 更新时间 + createtime: string // 创建时间 + updatetime: string // 更新时间 createby: string // 创建人 updateby: string // 更新人 } @@ -51,6 +51,11 @@ export const PersonArchiveApi = { return await request.get({ url: `/system/person-archive/get?id=` + id }) }, + // 根据人员列表id查询人员档案 + getPersonArchiveByUserid: async (userid: number) => { + return await request.get({ url: `/system/person-archive/getByUserid?userid=` + userid }) + }, + // 新增人员档案 createPersonArchive: async (data: PersonArchiveVO) => { return await request.post({ url: `/system/person-archive/create`, data }) @@ -66,6 +71,11 @@ export const PersonArchiveApi = { return await request.delete({ url: `/system/person-archive/delete?id=` + id }) }, + // 根据人员列表id删除人员档案 + deletePersonArchiveByUserid: async (userid: number) => { + return await request.delete({ url: `/system/person-archive/deleteByUserid?userid=` + userid }) + }, + // 导出人员档案 Excel exportPersonArchive: async (params) => { return await request.download({ url: `/system/person-archive/export-excel`, params }) diff --git a/src/views/devices/DevFrom.vue b/src/views/devices/DevFrom.vue index 12c117a5..689669fe 100644 --- a/src/views/devices/DevFrom.vue +++ b/src/views/devices/DevFrom.vue @@ -115,7 +115,7 @@ const userProfile = ref() const formRef = ref() // 表单 Ref /** 打开弹窗 */ -const open = async (type: string, id?: number) => { +const open = async (type: string) => { dialogVisible.value = true dialogTitle.value = t('action.' + type) formType.value = type @@ -123,7 +123,6 @@ const open = async (type: string, id?: number) => { resetForm() // 首先获取用户信息 userProfile.value = await getUserProfile() - console.log(userProfile.value.dept.name) } defineExpose({ open }) // 提供 open 方法,用于打开弹窗 @@ -150,7 +149,6 @@ const submitForm = async () => { } as DeviceVO if (formType.value === 'create') { - console.log(data) await DeviceApi.createDevice(data) message.success(t('common.createSuccess')) } else { diff --git a/src/views/person/index.vue b/src/views/person/index.vue index a9372850..ddbaee88 100644 --- a/src/views/person/index.vue +++ b/src/views/person/index.vue @@ -37,16 +37,6 @@ class="!w-200px" /> - - - 搜索 重置 diff --git a/src/views/personarchive/PersonArchiveForm.vue b/src/views/personarchive/PersonArchiveForm.vue index 70db452e..6d3ae9ee 100644 --- a/src/views/personarchive/PersonArchiveForm.vue +++ b/src/views/personarchive/PersonArchiveForm.vue @@ -9,15 +9,6 @@ > - - - - - - - - - @@ -33,6 +24,9 @@ + + + - - - @@ -62,13 +53,6 @@ - - - - - - - @@ -76,8 +60,17 @@ + + + + + + + + + @@ -107,7 +100,6 @@ - @@ -147,32 +139,6 @@ - - - - - - - - - - - - - - - - @@ -199,6 +165,7 @@ interface CascaderOption { label: string children?: CascaderOption[] } +import dayjs from 'dayjs' /** 人员档案 表单 */ defineOptions({ name: 'PersonArchiveForm' }) @@ -284,16 +251,16 @@ const formData = ref<{ updateby: undefined, }) const formRules = reactive({ - userid: [{ required: true, message: '人员表ID不能为空', trigger: 'blur' }], - orgid: [{ required: true, message: '机构ID不能为空', trigger: 'blur' }], - orgname: [{ required: true, message: '机构名称不能为空', trigger: 'blur' }], name: [{ required: true, message: '姓名不能为空', trigger: 'blur' }], + gender: [{ required: true, message: '性别不能为空', trigger: 'blur' }], + idcard: [{ required: true, message: '身份证号不能为空', trigger: 'blur' }], + phone: [{ required: true, message: '联系电话不能为空', trigger: 'blur' }], }) const formRef = ref() // 表单 Ref const selectedOptions = ref([]) // 添加级联选择器的值 const options = ref(regionData as unknown as CascaderOption[]) - +const userData = ref() /** 处理地址变化 */ const handleAddressChange = (value: any) => { if (value && value.length === 3) { @@ -311,7 +278,8 @@ watch(() => formData.value.address, (newValue) => { }) /** 打开弹窗 */ -const open = async (type: string, id?: number) => { +const open = async (type: string, id?: number, userProfile?: any) => { + userData.value = userProfile dialogVisible.value = true dialogTitle.value = t('action.' + type) formType.value = type @@ -320,7 +288,7 @@ const open = async (type: string, id?: number) => { if (id) { formLoading.value = true try { - formData.value = await PersonArchiveApi.getPersonArchive(id) + formData.value = await PersonArchiveApi.getPersonArchiveByUserid(id) // 处理地址数据 if (formData.value.address) { const addressParts = formData.value.address.split('/') @@ -354,9 +322,15 @@ const submitForm = async () => { try { const data = formData.value as unknown as PersonArchiveVO if (formType.value === 'create') { + data.orgid = userData.value.dept.id + data.orgname = userData.value.nickname + data.createtime = dayjs().format('YYYY-MM-DD HH:mm:ss') await PersonArchiveApi.createPersonArchive(data) message.success(t('common.createSuccess')) } else { + data.orgid = userData.value.dept.id + data.orgname = userData.value.nickname + data.updatetime = dayjs().format('YYYY-MM-DD HH:mm:ss') await PersonArchiveApi.updatePersonArchive(data) message.success(t('common.updateSuccess')) } diff --git a/src/views/personarchive/index.vue b/src/views/personarchive/index.vue index 204e86cb..3772b9e3 100644 --- a/src/views/personarchive/index.vue +++ b/src/views/personarchive/index.vue @@ -1,40 +1,25 @@ - + +v-model="queryParams.name" placeholder="请输入姓名" clearable @keyup.enter="handleQuery" + class="!w-240px" /> +v-model="queryParams.idcard" placeholder="请输入身份证号" clearable @keyup.enter="handleQuery" + class="!w-240px" /> - 搜索 - 重置 - + + 搜索 + + + 重置 + + 导出 @@ -43,52 +28,58 @@ - + + - + 男 女 - - + A B AB - O + O + 其他 - - + + - - 详情 - - - 删除 - + + + 详情 + + handleCommand(command, scope.row)"> + + 更多 + + + + + 创建档案 + + + + 删除 + + + + + + +:total="total" v-model:page="queryParams.pageNo" v-model:limit="queryParams.pageSize" + @pagination="getList" /> @@ -101,6 +92,7 @@ import download from '@/utils/download' import { PersonArchiveApi, PersonArchiveVO } from '@/api/personarchive' import PersonArchiveForm from './PersonArchiveForm.vue' import { getUserProfile } from '@/api/system/user/profile' +import { PersonApi, PersonVO } from '@/api/person' /** 人员档案 列表 */ defineOptions({ name: 'PersonArchive' }) @@ -157,9 +149,9 @@ const getList = async () => { loading.value = true try { //首先获取用户信息 - const userProfile = await getUserProfile() - queryParams.orgid = userProfile.dept.id - const data = await PersonArchiveApi.getPersonArchivePage(queryParams) + userProfile.value = await getUserProfile() + queryParams.orgid = userProfile.value.dept.id + const data = await PersonApi.getPersonPage(queryParams) list.value = data.list total.value = data.total } finally { @@ -181,8 +173,19 @@ const resetQuery = () => { /** 添加/修改操作 */ const formRef = ref() -const openForm = (type: string, id?: number) => { - formRef.value.open(type, id) +const openForm = async (type: string, id?: number) => { + if (type == 'update') { + const res = await PersonArchiveApi.getPersonArchiveByUserid(id) + if (!res) { + message.error('该人员没有档案') + return + } + else{ + formRef.value.open(type, id, userProfile.value) + } + } else { + formRef.value.open(type, id, userProfile.value) + } } /** 删除按钮操作 */ @@ -191,11 +194,11 @@ const handleDelete = async (id: number) => { // 删除的二次确认 await message.delConfirm() // 发起删除 - await PersonArchiveApi.deletePersonArchive(id) + await PersonArchiveApi.deletePersonArchiveByUserid(id) message.success(t('common.delSuccess')) // 刷新列表 await getList() - } catch {} + } catch { } } /** 导出按钮操作 */ @@ -213,6 +216,31 @@ const handleExport = async () => { } } +/** 操作分发 */ +const handleCommand = async (command: string, row: PersonArchiveVO) => { + switch (command) { + case 'handleCreate': + if(row.id){ + const res = await PersonArchiveApi.getPersonArchiveByUserid(row.id) + if(res){ + message.error('该人员档案已存在') + return + } + else{ + openForm('create') + } + }else{ + openForm('create') + } + break + case 'handleDelete': + handleDelete(row.id) + break + default: + break + } +} + /** 初始化 **/ onMounted(() => { getList()