fix: 医生管理

This commit is contained in:
2025-03-24 18:15:28 +08:00
parent b51462237b
commit 6eed8c41b0
8 changed files with 608 additions and 8 deletions

View File

@@ -214,6 +214,7 @@ const decrypt = (str: string) => str; // 简单base64解码示例
<div class="price-info"></div>
<div class="price-info">总价: {{ item.total_pay_price }}</div>
<div class="validity">处方有效期: {{ item.valid_hours }}小时</div>
<div class="validity">处方有效期2: {{ item.auto_expire_time }}小时</div>
</div>
</div>
</Page>

View File

@@ -427,14 +427,14 @@ const sendPrescription = () => {
}).then(() => {
message.success('处方已发送');
// 清空当前数据
currentDrugs.value = [];
diagnosis.value = '';
medicalAdvice.value = '';
packageMethodId.value = 2;
processRulePrice.value = '';
dosage.value = 1;
dayDosage.value = 1;
updateLocalStorage();
// currentDrugs.value = [];
// diagnosis.value = '';
// medicalAdvice.value = '';
// packageMethodId.value = 2;
// processRulePrice.value = '';
// dosage.value = 1;
// dayDosage.value = 1;
// updateLocalStorage();
});
};
@@ -770,6 +770,9 @@ function addProducts(data) {
<div class="container-box">
<!-- 左侧患者列表 -->
<div class="patient-panel">
<Select class="w-full">
<SelectOption :value="1">测试诊所</SelectOption>
</Select>
<RadioGroup v-model:value="listType" @change="updatePatientList" class="w-full" style="text-align: center">
<RadioButton class="w-1/2" :value="1">当前</RadioButton>
<RadioButton class="w-1/2" :value="2">历史</RadioButton>

View File

@@ -0,0 +1,82 @@
import { requestClient } from '#/api/request';
const prefix = 'doctor/';
/**
* 分页查询用户列表
* @param data
*/
export async function getDoctorList(data: any) {
return requestClient.get<any>(`${prefix}list`, { params: data });
}
/**
* 分页查询用户列表
* @param data
*/
export async function getDoctorAccountBalance(data: any = {}) {
return requestClient.get<any>(`${prefix}my-balance`, { params: data });
}
/**
* 获取医生详情
* @param id
*/
export async function getDoctorInfo(id: number) {
return requestClient.get<any>(`${prefix}detail`, { params: { id } });
}
/**
* 新增医生
* @param data
*/
export async function createDoctor(data: Record<string, any>) {
return requestClient.post<any>(`${prefix}create`, data);
}
/**
* 编辑医生
* @param data
*/
export async function updateDoctor(data: Record<string, any>) {
return requestClient.post<any>(`${prefix}update`, data);
}
/**
* 删除医生
* @param data
*/
export async function deleteDoctor(data: Record<string, any>) {
return requestClient.post<any>(`${prefix}delete`, data);
}
/**
* 修改密码
* @param data
*/
export async function updatePassword(data: Record<string, any>) {
return requestClient.post<any>(`${prefix}update-password`, data);
}
/**
* 删除医生
* @param id
*/
export async function openPcWindowsApi(id: number) {
return requestClient.post<any>(`${prefix}open-pc-windows`, {
id,
});
}
/**
* 获取我绑定的银行卡
*/
export async function getMyCard() {
return requestClient.get<any>(`${prefix}my-card`);
}
/**
* 编辑账户绑定银行卡
* @param data
*/
export async function saveCard(data: Record<string, any>) {
return requestClient.post<any>(`${prefix}save-card`, data);
}

View File

@@ -0,0 +1,65 @@
<script lang="ts" setup>
import { ref } from 'vue';
import { useVbenModal } from '@vben/common-ui';
import { message } from 'ant-design-vue';
import { useVbenForm } from '#/adapter/form';
import { createDoctor, updateDoctor } from '../api';
import { modalFormProps } from '../config/form';
defineOptions({
name: 'FormModelDemo',
});
const isUpdate = ref(false);
const gridApi = ref();
const [Form, formApi] = useVbenForm(modalFormProps);
const [Modal, modalApi] = useVbenModal({
fullscreenButton: false,
draggable: true,
onCancel() {
modalApi.close();
},
onConfirm: async () => {
formApi.validate().then(async (e: any) => {
if (e.valid) {
const values = await formApi.getValues();
modalApi.setState({ loading: true, confirmLoading: true });
const submitApi = isUpdate.value ? updateDoctor : createDoctor;
submitApi(values)
.then(() => {
message.success('保存成功');
gridApi.value?.reload();
modalApi.close();
})
.finally(() => {
modalApi.setState({ loading: false, confirmLoading: false });
});
}
});
await formApi.validateAndSubmitForm();
},
onOpenChange(isOpen: boolean) {
gridApi.value = isOpen ? modalApi.getData()?.gridApi : null;
if (isOpen) {
const { values, update } = modalApi.getData<Record<string, any>>();
if (values) {
isUpdate.value = update;
formApi.setValues(values);
}
}
},
});
</script>
<template>
<Modal
:title="`${isUpdate === true ? '编辑' : '新增'}医生`"
class="w-[60%]"
>
<Form />
</Modal>
</template>

View File

@@ -0,0 +1,172 @@
import type { VbenFormProps } from '#/adapter/form';
import { z } from '#/adapter/form';
import { getRoleOption } from '#/views/system/role/api';
import { getSupplierOption } from '#/views/system/supplier/api';
const defaultPassword = 'Xk123456@';
const supplierId = 7;
export const modalFormProps: VbenFormProps = {
wrapperClass: 'grid-cols-12', // 24栅格,
commonConfig: {
formItemClass: 'col-span-12',
// 所有表单项
componentProps: {
class: 'w-full',
},
},
// handleSubmit: onSubmit,
layout: 'horizontal',
schema: [
{
component: 'VbenInput',
fieldName: 'id',
label: 'ID',
formItemClass: 'col-span-6',
dependencies: {
show: false,
triggerFields: ['id'],
},
},
{
component: 'VbenInput',
componentProps: {
placeholder: '请输入医生昵称',
},
fieldName: 'nick_name',
label: '昵称',
rules: 'required',
formItemClass: 'col-span-6',
},
{
component: 'Avatar',
fieldName: 'avatar',
label: '头像',
rules: 'required',
formItemClass: 'col-span-6',
},
{
component: 'VbenInput',
componentProps: {
placeholder: '请输入医生手机号码',
},
fieldName: 'phone',
label: '手机号',
rules: 'required',
formItemClass: 'col-span-6',
},
{
component: 'ApiSelect',
componentProps: {
allowClear: true,
filterOption: (input: string, option: any) => {
// 自定义过滤逻辑,确保可以根据 name 进行搜索
return option?.label.toLowerCase().indexOf(input.toLowerCase()) >= 0;
},
showSearch: true,
// 菜单接口转options格式
afterFetch: (data: { id: number; name: string }[]) => {
return data.map((item: any) => ({
label: item.name,
value: item.id,
}));
},
api: getRoleOption,
placeholder: '请选择',
},
fieldName: 'role_id',
formItemClass: 'col-span-6',
label: '角色',
rules: 'required',
},
{
component: 'ApiSelect',
componentProps: {
allowClear: true,
filterOption: true,
showSearch: true,
// 菜单接口转options格式
afterFetch: (data: { id: number; name: string }[]) => {
return data.map((item: any) => ({
label: item.name,
value: item.id,
}));
},
api: getSupplierOption,
placeholder: '请选择',
},
dependencies: {
show: (values) => {
return values.role_id === supplierId;
},
triggerFields: ['role_id'],
},
fieldName: 'supplier_id',
formItemClass: 'col-span-6',
label: '所属供应商',
rules: 'required',
},
{
fieldName: 'password',
label: '密码',
component: 'InputPassword',
help: '5-18位数字、字母、特殊字符组成。',
componentProps: {
placeholder: '请输入密码',
allowClear: true,
},
defaultValue: defaultPassword,
rules: z
.string()
.regex(
/^(?=.*[A-Z0-9])(?=.*[!@#$%^&*])[A-Z0-9!@#$%^&*]{5,18}$/i,
'密码由5-18位数字、字母、特殊字符组成。',
),
dependencies: {
if({ id }) {
return !id;
},
triggerFields: ['id'],
},
formItemClass: 'col-span-6',
},
{
fieldName: 'confirmPassword',
label: '确认密码',
component: 'InputPassword',
componentProps: {
placeholder: '请输入确认密码',
allowClear: true,
},
defaultValue: defaultPassword,
rules: z
.string()
.regex(/[\w!@#$%^&*]{5,18}/, '密码由5-18位数字、字母、特殊字符组成。'),
dependencies: {
if({ id }) {
return !id;
},
triggerFields: ['id', 'confirmPassword'],
rules: (values) => {
return z
.string()
.regex(
/[\w!@#$%^&*]{5,18}/,
'密码由5-18位数字、字母、特殊字符组成。',
)
.refine(
(confirmPassword) => {
return confirmPassword === values.password;
},
{
message: '确认密码必须与密码一致',
},
);
},
},
formItemClass: 'col-span-6',
},
],
showDefaultActions: false,
};

View File

@@ -0,0 +1,56 @@
import type { VbenFormProps } from '#/adapter/form';
import { getRoleOption } from '#/views/system/role/api';
export const formOptions: VbenFormProps = {
// 默认展开
collapsed: false,
schema: [
{
component: 'VbenInput',
componentProps: {
placeholder: '输入名称',
},
defaultValue: '',
fieldName: 'name',
label: '医生名称',
},
// {
// component: 'VbenInput',
// componentProps: {
// placeholder: '输入手机号码',
// },
// defaultValue: '',
// fieldName: 'phone',
// label: '手机号码',
// },
// {
// component: 'ApiSelect',
// componentProps: {
// allowClear: true,
// filterOption: true,
// showSearch: true,
// // 菜单接口转options格式
// afterFetch: (data: { id: number; name: string }[]) => {
// return data.map((item: any) => ({
// label: item.name,
// value: item.id,
// }));
// },
// api: getRoleOption,
// placeholder: '请选择',
// },
// fieldName: 'role_id',
// label: '角色',
// },
],
// 控制表单是否显示折叠按钮
showCollapseButton: true,
submitButtonOptions: {
content: '查询',
},
// 是否在字段值改变时提交表单
submitOnChange: true,
// 按下回车时是否提交表单
submitOnEnter: false,
};

View File

@@ -0,0 +1,81 @@
import type { VxeGridProps } from '#/adapter/vxe-table';
import { getDoctorList } from '../api';
interface RowType {
id: string;
nick_name: string;
email: string;
avatar: string;
roles: { name: string }[];
open_id: string;
code: string;
platform_id: string;
phone: string;
desc: string;
created_at: string;
}
export const gridOptions: VxeGridProps<RowType> = {
checkboxConfig: {
highlight: true,
labelField: '',
},
columnConfig: {
useKey: true,
},
rowConfig: {
useKey: true,
},
columns: [
{ type: 'checkbox', width: 60 },
{ field: 'id', align: 'left', title: 'ID', width: 100 },
{ field: 'name', align: 'left', title: '名称' },
{ field: 'mobile', align: 'left', title: '手机号' },
{
field: 'avatar',
align: 'left',
title: '头像',
slots: { default: 'avatar' },
width: 130,
},
{ field: 'su_id', title: 'wxID' },
{ field: 'stores', title: '所属诊所', slots: { default: 'stores' } },
{ field: 'created_at', title: '注册时间' },
{ type: 'html', title: '操作', width: 200, slots: { default: 'action' } },
],
keepSource: true,
pagerConfig: {},
proxyConfig: {
ajax: {
// 请求后端接口方法
query: async ({ page }, formValues) => {
return await getDoctorList({
page: page.currentPage,
pageSize: page.pageSize,
...formValues,
});
},
},
},
height: 'auto',
border: false,
toolbarConfig: {
// 是否显示搜索表单控制按钮
// @ts-ignore 正式环境时有完整的类型声明
search: true,
refresh: true, // 刷新
print: false, // 打印
export: false, // 导出
// custom: true, // 自定义列
zoom: true, // 最大化最小化
slots: {
buttons: 'toolbar-buttons',
},
custom: {
// 自定义列-图标
icon: 'vxe-icon-menu',
},
},
showOverflow: false,
};

View File

@@ -0,0 +1,140 @@
<script lang="ts" setup>
import type { VxeGridListeners } from '#/adapter/vxe-table';
import { ref } from 'vue';
import { Page, useVbenModal } from '@vben/common-ui';
import { Button, Image, message } from 'ant-design-vue';
import { useVbenVxeGrid } from '#/adapter/vxe-table';
import { TableAction } from '#/components/table-action';
import {openPcWindowsApi} from './api';
import FormModalDemo from './components/modal.vue';
import { formOptions } from './config/search';
import { gridOptions } from './config/table';
const hasTopTableDropDownActions = ref(false);
const gridEvents: VxeGridListeners<any> = {
checkboxChange() {
// eslint-disable-next-line no-use-before-define
const records = gridApi.grid.getCheckboxRecords();
hasTopTableDropDownActions.value = records.length > 0;
},
checkboxAll() {
// eslint-disable-next-line no-use-before-define
const records = gridApi.grid.getCheckboxRecords();
hasTopTableDropDownActions.value = records.length > 0;
},
};
const [Grid, gridApi] = useVbenVxeGrid({
formOptions,
gridOptions,
gridEvents,
});
const [FormModal, formModalApi] = useVbenModal({
connectedComponent: FormModalDemo,
});
const showModal = (data = {}, isUpdate = false) => {
formModalApi.setData({
// 表单值
values: data,
update: isUpdate,
gridApi,
});
formModalApi.open();
};
const openPcWindows = (id: number) => {
openPcWindowsApi(id).then(() => {
message.success('开通成功!');
gridApi.reload();
});
};
</script>
<template>
<Page auto-content-height title="医生管理">
<FormModal />
<Grid>
<template #toolbar-buttons>
<TableAction
:actions="[
// {
// label: '新增',
// type: 'primary',
// icon: 'ant-design:plus-outlined',
// // auth: ['超级医生', 'sys:user:save'],
// onClick: showModal.bind(null),
// },
]"
:drop-down-actions="[
// {
// label: '删除',
// icon: 'ant-design:delete-outlined',
// ifShow: hasTopTableDropDownActions,
// // auth: ['超级医生', 'sys:user:save'],
// popConfirm: {
// title: '确定删除吗',
// confirm: deleteApi.bind(null, false),
// },
// },
]"
>
<template #more>
<Button style="margin-left: 16px">
批量操作
<Icon icon="ant-design:down-outlined" />
</Button>
</template>
</TableAction>
</template>
<template #avatar="{ row }">
<Image :src="row.avatar" height="30" width="30" />
</template>
<template #stores="{ row }">
<p v-for="item in row.stores" :key="item.store_id">{{ item?.store?.name }}</p>
</template>
<template #toolbar-tools></template>
<template #action="{ row }">
<TableAction
:actions="[
{
label: '绑定诊所',
type: 'link',
icon: 'uil:edit',
size: 'small',
// auth: ['doctor', 'sys:role:detail'],
onClick: showModal.bind(null, row, true),
},
{
label: '开通PC端',
type: 'link',
icon: 'uil:edit',
size: 'small',
// auth: ['doctor', 'sys:role:detail'],
onClick: openPcWindows.bind(null, row.id),
},
]"
:drop-down-actions="[
// {
// label: '重置密码',
// type: 'link',
// icon: 'bitcoin-icons:refresh-filled',
// size: 'small',
// popConfirm: {
// title: '确定重置密码吗',
// confirm: openPcWindows.bind(null, row.id),
// },
// },
]"
/>
</template>
</Grid>
</Page>
</template>