完成医生模块功能

This commit is contained in:
lxd 2024-07-23 14:58:38 +08:00
parent ce4976b062
commit 6f9d054cec
4 changed files with 487 additions and 0 deletions

View File

@ -0,0 +1,61 @@
import request from '@/config/axios'
// 医生管理 VO
export interface VO {
doctorID: string // 主键
doctorName: string // 医生姓名
gender: string // 性别
birthday: Date // 出生日期
departmentName: string // 科室名称
doctorTel: string // 医生联系电话
remark: string // 备注
eSignatureUrl: string // 医生电子签名URL
doctorLevel: string // 医生级别:执业医师,主治医师,副主任医师,主任医师
orgId: string // 机构ID
departmentCode: string // 科室代码
}
// 上传图片
export interface baseFile {
doctorID: string // 主键
base: string // 图片base64
imagefilename:string//名称
}
// 医生管理 API
export const Api = {
// 查询医生管理分页
getPage: async (params: any) => {
return await request.get({ url: `/doctor/page`, params })
},
// 查询医生管理详情
get: async (id: number) => {
return await request.get({ url: `/doctor/get?id=` + id })
},
// 新增医生管理
create: async (data: VO) => {
return await request.post({ url: `/doctor/create`, data })
},
// 修改医生管理
update: async (data: VO) => {
return await request.put({ url: `/doctor/update`, data })
},
// 删除医生管理
delete: async (id: number,name:string) => {
return await request.delete({ url: `/doctor/delete?id=${id}&&username=${name}` })
},
// 导出医生管理 Excel
export: async (params) => {
return await request.download({ url: `/doctor/export-excel`, params })
},
// 上传图片
upload: async (data:baseFile) => {
return await request.post({ url: `/doctor/upload`, data})
},
}

View File

@ -0,0 +1,221 @@
<template>
<Dialog :title="dialogTitle" v-model="dialogVisible">
<el-form
ref="formRef"
:model="formData"
:rules="formRules"
label-width="100px"
v-loading="formLoading"
>
<el-form-item label="医生编号" prop="doctorID">
<el-input v-model="formData.doctorID" placeholder="请输入医生编号" />
</el-form-item>
<el-form-item label="医生姓名" prop="doctorName">
<el-input v-model="formData.doctorName" placeholder="请输入医生姓名" />
</el-form-item>
<el-form-item label="性别" prop="gender">
<el-radio-group v-model="formData.gender" size="small">
<el-radio-button label="男" value="男" />
<el-radio-button label="女" value="女" />
</el-radio-group>
</el-form-item>
<el-form-item label="出生日期" prop="birthday">
<el-date-picker
v-model="formData.birthday"
type="date"
value-format="x"
placeholder="选择出生日期"
/>
</el-form-item>
<el-form-item label="所属科室" prop="departmentName">
<el-select v-model="formData.departmentName" placeholder="请选择科室">
<el-option label="影像科" value="影像科" />
</el-select>
</el-form-item>
<el-form-item label="医生联系电话" prop="doctorTel">
<el-input v-model="formData.doctorTel" placeholder="请输入医生联系电话" />
</el-form-item>
<el-form-item label="备注" prop="remark">
<el-input v-model="formData.remark" placeholder="请输入备注" />
</el-form-item>
<el-form-item label="医生电子签名" prop="eSignatureUrl">
<el-image
v-model="formData.eSignatureUrl"
style="width: 160px; height: 120px"
:src="formData.eSignatureUrl"
fit="fill"
/>
<div style="margin-left: 20px">
<!-- <el-input type="file" v-model="imagefilename" @change="handleImageChange"/> -->
<el-upload
class="upload-demo"
action=""
:auto-upload="false"
:limit="1"
:accept="'.png'"
@change="handleChange"
>
<el-button type="primary">选择签名图片</el-button>
</el-upload>
</div>
</el-form-item>
<el-form-item label="医生级别" prop="doctorLevel">
<el-select v-model="formData.doctorLevel" placeholder="请选择医生级别">
<el-option label="执业医师" value="执业医师" />
<el-option label="主治医师" value="主治医师" />
<el-option label="副主任医师" value="副主任医师" />
<el-option label="主任医师" value="主任医师" />
</el-select>
</el-form-item>
<el-form-item label="机构编号" prop="orgId">
<el-input v-model="formData.orgId" placeholder="请输入机构ID" />
</el-form-item>
</el-form>
<template #footer>
<el-button @click="submitForm" type="primary" :disabled="formLoading"> </el-button>
<el-button @click="dialogVisible = false"> </el-button>
</template>
</Dialog>
</template>
<script setup lang="ts">
import { Api, VO, baseFile } from '@/api/system/doctor'
import { error } from 'console'
import type { UploadProps, UploadUserFile } from 'element-plus'
//base64
const imageBase64 = ref()
//
const imagefilename = ref()
/** 医生管理 表单 */
defineOptions({ name: 'Form' })
const { t } = useI18n() //
const message = useMessage() //
const dialogVisible = ref(false) //
const dialogTitle = ref('') //
const formLoading = ref(false) // 12
const formType = ref('') // create - update -
const formData = ref({
doctorID: undefined,
doctorName: undefined,
gender: undefined,
birthday: undefined,
departmentName: undefined,
doctorTel: undefined,
remark: undefined,
eSignatureUrl: undefined,
doctorLevel: undefined,
orgId: undefined,
departmentCode: undefined
})
const formRules = reactive({
doctorID: [
{ required: true, message: '请输入医生编号', trigger: 'blur' }
// { pattern: /^[0-9]*$/, message: '', trigger: 'blur' }
],
orgId: [{ required: true, message: '请输入机构编号', trigger: 'blur' }],
doctorLevel: [{ required: true, message: '请输入医生级别', trigger: 'blur' }],
departmentName: [{ required: true, message: '请选择所属科室', trigger: 'blur' }]
})
const formRef = ref() // Ref
/** 打开弹窗 */
const open = async (type: string, id?: number) => {
dialogVisible.value = true
dialogTitle.value = t('action.' + type)
formType.value = type
resetForm()
//
if (id) {
formLoading.value = true
try {
formData.value = await Api.get(id)
} finally {
formLoading.value = false
}
}
}
defineExpose({ open }) // open
/** 提交表单 */
const emit = defineEmits(['success']) // success
const submitForm = async () => {
//
await formRef.value.validate()
//
formLoading.value = true
try {
const data = formData.value as unknown as VO
if (formType.value === 'create') {
await Api.create(data)
message.success(t('common.createSuccess'))
} else {
await Api.update(data)
message.success(t('common.updateSuccess'))
}
//
if (formData.value.doctorID != undefined && imageBase64.value) {
await Api.upload({
doctorID: formData.value.doctorID,
base: imageBase64.value,
imagefilename: imagefilename.value
})
}
dialogVisible.value = false
//
emit('success')
} finally {
formLoading.value = false
}
}
/** 重置表单 */
const resetForm = () => {
formData.value = {
doctorID: undefined,
doctorName: undefined,
gender: undefined,
birthday: undefined,
departmentName: undefined,
doctorTel: undefined,
remark: undefined,
eSignatureUrl: undefined,
doctorLevel: undefined,
orgId: undefined,
departmentCode: undefined
}
imagefilename.value = ''
imageBase64.value = ''
formRef.value?.resetFields()
}
//
const handleExceed: UploadProps['onExceed'] = (files, uploadFiles) => {
message.warning(`只能上传1个`)
}
const handleChange = (file, fileList) => {
const fileType = file.raw.type.split('/')[0]
if (file.raw.type === 'image/png') {
} else {
message.error('请上传png格式')
return false
}
const isLt2M = file.size / 1024 / 1024
if (fileType != 'image' || isLt2M > 2) {
message.error('请上传2M以内的图片文件!')
return false
}
const reader = new FileReader()
reader.readAsDataURL(file.raw)
reader.onload = (event) => {
imageBase64.value = event.target.result
// Base64
//console.log(base64Data)
}
imagefilename.value = file.name
}
</script>

View File

@ -0,0 +1,204 @@
<template>
<ContentWrap>
<!-- 搜索工作栏 -->
<el-form
class="-mb-15px"
:model="queryParams"
ref="queryFormRef"
:inline="true"
label-width="68px"
>
<el-form-item label="医生姓名" prop="doctorName">
<el-input
v-model="queryParams.doctorName"
placeholder="请输入医生姓名"
clearable
@keyup.enter="handleQuery"
class="!w-240px"
/>
</el-form-item>
<el-form-item label="科室名称" prop="departmentName">
<el-input
v-model="queryParams.departmentName"
placeholder="请输入科室名称"
clearable
@keyup.enter="handleQuery"
class="!w-240px"
/>
</el-form-item>
<el-form-item>
<el-button @click="handleQuery"><Icon icon="ep:search" class="mr-5px" /> 搜索</el-button>
<el-button @click="resetQuery"><Icon icon="ep:refresh" class="mr-5px" /> 重置</el-button>
<el-button
type="primary"
plain
@click="openForm('create')"
v-hasPermi="['doctor::create']"
>
<Icon icon="ep:plus" class="mr-5px" /> 新增
</el-button>
<el-button
type="success"
plain
@click="handleExport"
:loading="exportLoading"
v-hasPermi="['doctor::export']"
>
<Icon icon="ep:download" class="mr-5px" /> 导出
</el-button>
</el-form-item>
</el-form>
</ContentWrap>
<!-- 列表 -->
<ContentWrap>
<el-table v-loading="loading" :data="list" :stripe="true" :show-overflow-tooltip="true">
<el-table-column label="主键" align="center" prop="doctorID" v-if="false"/>
<el-table-column label="医生姓名" align="center" prop="doctorName" />
<el-table-column label="性别" align="center" prop="gender" />
<el-table-column
label="出生日期"
align="center"
prop="birthday"
:formatter="dateFormatter2"
width="180px"
/>
<el-table-column label="科室名称" align="center" prop="departmentName" />
<el-table-column label="医生联系电话" align="center" prop="doctorTel" />
<el-table-column label="备注" align="center" prop="remark" />
<el-table-column label="医生电子签名URL" align="center" prop="eSignatureUrl" v-if="false"/>
<el-table-column label="医生级别" align="center" prop="doctorLevel" />
<el-table-column label="机构ID" align="center" prop="orgId" v-if="false" />
<el-table-column label="科室代码" align="center" prop="departmentCode" v-if="false" />
<el-table-column label="操作" align="center">
<template #default="scope">
<el-button
link
type="primary"
@click="openForm('update', scope.row.doctorID)"
v-hasPermi="['doctor::update']"
>
编辑
</el-button>
<el-button
link
type="danger"
@click="handleDelete(scope.row.doctorID,Profilevo.username)"
v-hasPermi="['doctor::delete']"
>
删除
</el-button>
</template>
</el-table-column>
</el-table>
<!-- 分页 -->
<Pagination
:total="total"
v-model:page="queryParams.pageNo"
v-model:limit="queryParams.pageSize"
@pagination="getList"
/>
</ContentWrap>
<!-- 表单弹窗添加/修改 -->
<Form ref="formRef" @success="getList" />
</template>
<script setup lang="ts">
import { dateFormatter,dateFormatter2 } from '@/utils/formatTime'
import download from '@/utils/download'
import { Api, VO } from '@/api/system/doctor'
import Form from './Form.vue'
import { getUserProfile, ProfileVO } from '@/api/system/user/profile'
/** 医生管理 列表 */
defineOptions({ name: 'Doctor' })
//
const Profilevo = ref<ProfileVO>({} as ProfileVO)
const message = useMessage() //
const { t } = useI18n() //
const loading = ref(true) //
const list = ref<VO[]>([]) //
const total = ref(0) //
const queryParams = reactive({
pageNo: 1,
pageSize: 10,
doctorName: undefined,
departmentName: undefined,
})
const queryFormRef = ref() //
const exportLoading = ref(false) //
/** 查询列表 */
const getList = async () => {
loading.value = true
try {
const data = await Api.getPage(queryParams)
list.value = data.list
total.value = data.total
} finally {
loading.value = false
}
}
/** 搜索按钮操作 */
const handleQuery = () => {
queryParams.pageNo = 1
getList()
}
/** 重置按钮操作 */
const resetQuery = () => {
queryFormRef.value.resetFields()
handleQuery()
}
/** 添加/修改操作 */
const formRef = ref()
const openForm = (type: string, id?: number) => {
formRef.value.open(type, id)
}
/** 删除按钮操作 */
const handleDelete = async (id: number,name:string) => {
try {
//
await message.delConfirm()
//
await Api.delete(id,name)
message.success(t('common.delSuccess'))
//
await getList()
} catch {}
}
/** 导出按钮操作 */
const handleExport = async () => {
try {
//
await message.exportConfirm()
//
exportLoading.value = true
const data = await Api.export(queryParams)
download.excel(data, '医生管理.xls')
} catch {
} finally {
exportLoading.value = false
}
}
//
const getlogininfo = async () => {
Profilevo.value = await getUserProfile()
}
/** 初始化 **/
onMounted(() => {
getList()
})
</script>

View File

@ -756,6 +756,7 @@ const getlogininfo = async () => {
/** 重置表单 */ /** 重置表单 */
const resetForm = () => { const resetForm = () => {
applyFormVO.value={} as PatientexamlistVO
pid='' pid=''
strzdjl= '' strzdjl= ''
strsj = '' strsj = ''