16 changed files with 798 additions and 452 deletions
@ -1,30 +1,50 @@ |
|||||||
import {OfficeParams,OfficeItem,OfficeItemListResult} from '/@/api/platform/system/entity/officeModel'; |
import {OfficeParams,OfficeItem,OfficeItemListResult} from '/@/api/platform/system/entity/officeModel'; |
||||||
import { defHttp } from '/@/utils/http/axios'; |
import { defHttp } from '/@/utils/http/axios'; |
||||||
import {isDef} from '/@/utils/is'; |
import {isDef} from '/@/utils/is'; |
||||||
|
import {HospitalItemListResult, HospitalParams} from "/@/api/platform/system/entity/hospitalModel"; |
||||||
|
|
||||||
|
|
||||||
const prefix = '/system_proxy/system'; |
|
||||||
|
|
||||||
enum Api { |
enum Api { |
||||||
QueryById = '/office/getById', |
QueryById = '/system_proxy/system/office/getById', |
||||||
List = '/office/list', |
list = '/system_proxy/system/office/list', |
||||||
Add = '/office/add', |
add = '/system_proxy/system/office/add', |
||||||
Update = '/office/update', |
edit = '/system_proxy/system/office/update', |
||||||
Remove = '/office/remove' |
del = '/system_proxy/system/office/remove', |
||||||
|
get = '/system_proxy/system/office' |
||||||
} |
} |
||||||
|
//
|
||||||
|
// export const queryById = (params: { id: String }) =>
|
||||||
|
// defHttp.get<OfficeItem>({url:Api.QueryById, params});
|
||||||
|
//
|
||||||
|
// export const list = (params: OfficeParams) =>
|
||||||
|
// defHttp.get<OfficeItemListResult>({url: Api.List, params});
|
||||||
|
//
|
||||||
|
// export const set = (params: OfficeItem) => {
|
||||||
|
// if (isDef(params.id)){
|
||||||
|
// defHttp.put<OfficeItem>({url:Api.Update, params});
|
||||||
|
// }else {
|
||||||
|
// defHttp.post<OfficeItem>({url: Api.Add, params});
|
||||||
|
// }
|
||||||
|
// };
|
||||||
|
//
|
||||||
|
// export const remove = (params: {ids: String}) =>
|
||||||
|
// defHttp.delete<boolean>({url:Api.Remove + `/${params.ids}`});
|
||||||
export const queryById = (params: { id: String }) => |
export const queryById = (params: { id: String }) => |
||||||
defHttp.get<OfficeItem>({url: prefix + Api.QueryById, params}); |
defHttp.get<OfficeItem>({url: Api.QueryById + `/${params.id}`}); |
||||||
|
|
||||||
|
/** 查询科室列表 */ |
||||||
|
// export const listOffice = (params?: Partial<OfficeItem>) => defHttp.get<OfficeItemListResult>({ url: Api.list, params }, { isReturnResultResponse: true });
|
||||||
|
export const listOffice = (params: OfficeItem) => |
||||||
|
defHttp.get<OfficeItemListResult>({url: Api.list, params}); |
||||||
|
/** 新增科室*/ |
||||||
|
export const addOffice = (params: Partial<OfficeParams>) => defHttp.post({ url: Api.add, data: params }); |
||||||
|
|
||||||
export const list = (params: OfficeParams) => |
/** 修改科室 */ |
||||||
defHttp.get<OfficeItemListResult>({url: prefix + Api.List, params}); |
export const editOffice = (params: Partial<OfficeParams>) => defHttp.put({ url: Api.edit, data: params }); |
||||||
|
|
||||||
export const set = (params: OfficeItem) => { |
/** 查询科室详细 */ |
||||||
if (isDef(params.id)){ |
export const getOffice = (id: string) => defHttp.get<OfficeItem>({ url: `${Api.get}/${id}` }); |
||||||
defHttp.put<OfficeItem>({url: prefix + Api.Update, params}); |
|
||||||
}else { |
|
||||||
defHttp.post<OfficeItem>({url: prefix + Api.Add, params}); |
|
||||||
} |
|
||||||
}; |
|
||||||
|
|
||||||
export const remove = (params: {ids: String}) => |
/** 删除科室 */ |
||||||
defHttp.delete<boolean>({url: prefix + Api.Remove + `/${params.ids}`}); |
export const delOffice = (id: string) => defHttp.delete({ url: `${Api.del}/${id}` }); |
@ -1,65 +1,79 @@ |
|||||||
<template> |
<template> |
||||||
<BasicModal v-bind="$attrs" |
<BasicModal v-bind="$attrs" |
||||||
:title="getTitle" |
width="720px" |
||||||
@register="registerModal" |
@register="registerModal" |
||||||
@ok="handleSubmit" |
@ok="handleSubmit" |
||||||
> |
> |
||||||
<BasicForm @register="registerForm"/> |
<BasicForm @register="registerForm"/> |
||||||
</BasicModal> |
</BasicModal> |
||||||
</template> |
</template> |
||||||
|
|
||||||
<script lang="ts" setup> |
<script lang="ts" setup> |
||||||
import {ref, computed, unref, toRaw} from 'vue'; |
|
||||||
import {BasicModal, useModalInner} from '/@/components/Modal'; |
|
||||||
import {hospitalFormSchema} from './hospital.data'; |
|
||||||
import {BasicForm, useForm} from '/@/components/Form'; |
|
||||||
import {set} from '/@/api/platform/system/controller/hospital'; |
|
||||||
import {HospitalItem} from '/@/api/platform/system/entity/hospitalModel'; |
|
||||||
const isUpdate = ref(true); |
|
||||||
// 定义emit |
|
||||||
const emit = defineEmits(['success', 'register']); |
|
||||||
/** |
/** |
||||||
* 表单 |
* 提供模板规范代码参考,请尽量保证编写代码风格跟模板规范代码一致 |
||||||
|
* 采用vben-动态表格表单封装组件编写,采用 setup 写法 |
||||||
|
* Copyright © 2020-2022 <a href="http://www.entfrm.com/">entfrm</a> All rights reserved. |
||||||
|
* author entfrm开发团队-王翔 |
||||||
*/ |
*/ |
||||||
const [registerForm, {resetFields, setFieldsValue, validate}] = useForm({ |
import { ref, unref } from 'vue'; |
||||||
labelWidth: 120, |
import { BasicForm, useForm } from '/@/components/Form/index'; |
||||||
|
import { hospitalFormSchema } from './hospital.data'; |
||||||
|
import {addHospital, delHospital,getHospital,editHospital} from '/@/api/platform/system/controller/hospital'; |
||||||
|
import { BasicModal, ModalProps, useModalInner } from '/@/components/Modal'; |
||||||
|
import { isEmpty } from '/@/utils/is'; |
||||||
|
|
||||||
|
/** 通用变量统一声明区域 */ |
||||||
|
const tag = ref<Nullable<string>>(''); |
||||||
|
/** https://v3.cn.vuejs.org/api/options-data.html#emits */ |
||||||
|
const emit = defineEmits(['success', 'register']); |
||||||
|
const [registerForm, { resetFields, setFieldsValue, validate, clearValidate, updateSchema }] = useForm({ |
||||||
|
labelWidth: 100, |
||||||
schemas: hospitalFormSchema, |
schemas: hospitalFormSchema, |
||||||
showActionButtonGroup: false, |
showActionButtonGroup: false, |
||||||
actionColOptions: { |
baseColProps: { span: 24 } |
||||||
span: 23, |
|
||||||
}, |
|
||||||
}); |
}); |
||||||
/** |
const [registerModal, { setModalProps, closeModal }] = useModalInner(async (data: WindowInnerData = { _tag: '' }) => { |
||||||
* 表单参数 |
// 处理清除脏数据 |
||||||
*/ |
await resetFields(); |
||||||
const [registerModal, {setModalProps, closeModal}] = useModalInner( (data) => { |
await clearValidate(); |
||||||
resetFields(); |
// 处理设置数据 |
||||||
setModalProps({confirmLoading: false}); |
tag.value = data._tag; |
||||||
isUpdate.value = !!data?.isUpdate; |
const id = data.record?.id; |
||||||
if (unref(isUpdate)) { |
const props: Partial<ModalProps> = { confirmLoading: false }; |
||||||
if(typeof data.record.addressIds == 'string'){ |
// 采用tag标签区分操作 |
||||||
let addressIdsStr: string = data.record.addressIds; |
switch (unref(tag)) { |
||||||
const addressIds:String[] = addressIdsStr.split(','); |
case 'add': |
||||||
data.record.addressIds = addressIds; |
props.title = '新增医院'; |
||||||
} |
break; |
||||||
setFieldsValue({ |
case 'edit': |
||||||
...data.record, |
props.title = '编辑医院'; |
||||||
}); |
await setFieldsValue(await getHospital(id)); |
||||||
|
break; |
||||||
} |
} |
||||||
|
// 尾部:设置处理后的最终配置数据 |
||||||
|
setModalProps(props); |
||||||
}); |
}); |
||||||
//表单标题 |
|
||||||
const getTitle = computed(() => (!unref(isUpdate) ? '新增医院' : '编辑医院')); |
/** 处理弹出框提交 */ |
||||||
async function handleSubmit() { |
async function handleSubmit() { |
||||||
try { |
try { |
||||||
const values = await validate(); |
// 提取验证数据 |
||||||
setModalProps({confirmLoading: true}); |
const formData = await validate(); |
||||||
let val = toRaw<HospitalItem>(values); |
// 处理提交之前逻辑 |
||||||
values.addressIds = toRaw(val.addressIds); |
setModalProps({ confirmLoading: true }); |
||||||
await set(values); |
// 采用tag标签区分操作 |
||||||
|
switch (unref(tag)) { |
||||||
|
case 'add': |
||||||
|
await addHospital(formData); |
||||||
|
break; |
||||||
|
case 'edit': |
||||||
|
await editHospital(formData); |
||||||
|
break; |
||||||
|
} |
||||||
|
// 处理提交完成之后逻辑 |
||||||
closeModal(); |
closeModal(); |
||||||
emit('success'); |
emit('success'); |
||||||
} finally { |
} finally { |
||||||
setModalProps({confirmLoading: false}); |
setModalProps({ confirmLoading: false }); |
||||||
} |
} |
||||||
} |
} |
||||||
</script> |
</script> |
||||||
|
@ -1,94 +1,136 @@ |
|||||||
<template> |
<template> |
||||||
<div> |
<div> |
||||||
<BasicTable @register="registerTable"> |
<BasicTable @register="registerTable" |
||||||
|
@selection-change="handleSelectionChange" |
||||||
|
> |
||||||
<template #toolbar> |
<template #toolbar> |
||||||
<a-button type="primary" @click="handleCreate">新增医院</a-button> |
<a-button |
||||||
|
type="primary" |
||||||
|
@click="handleAdd()" |
||||||
|
>新增医院</a-button> |
||||||
|
<a-button type="primary" |
||||||
|
:disabled="state.single" |
||||||
|
@click="handleEdit()" |
||||||
|
>修改医院</a-button> |
||||||
|
<a-button type="primary" |
||||||
|
:disabled="state.multiple" |
||||||
|
@click="handleDel()" |
||||||
|
>删除医院</a-button> |
||||||
</template> |
</template> |
||||||
<template #action="{ record }"> |
<template #action="{ record }"> |
||||||
<TableAction |
<TableAction :actions="[ |
||||||
:actions="[ |
{ |
||||||
{ |
label: '编辑', |
||||||
icon: 'clarity:note-edit-line', |
icon: 'fa6-regular:pen-to-square', |
||||||
onClick: handleEdit.bind(null, record), |
onClick: handleEdit.bind(null, record) |
||||||
}, |
}, |
||||||
{ |
{ |
||||||
icon: 'ant-design:delete-outlined', |
label: '删除', |
||||||
color: 'error', |
icon: 'ant-design:delete-outlined', |
||||||
popConfirm: { |
color: 'error', |
||||||
title: '是否确认删除', |
onClick: handleDel.bind(null, record) |
||||||
confirm: handleDelete.bind(null, record), |
}]" |
||||||
}, |
|
||||||
}, |
|
||||||
]" |
|
||||||
/> |
/> |
||||||
</template> |
</template> |
||||||
</BasicTable> |
</BasicTable> |
||||||
|
<!--弹出窗体区域--> |
||||||
<HospitalModal @register="registerModal" @success="handleSuccess"/> |
<HospitalModal @register="registerModal" @success="handleRefreshTable"/> |
||||||
</div> |
</div> |
||||||
</template> |
</template> |
||||||
|
|
||||||
<script lang="ts" setup> |
<script lang="ts" setup> |
||||||
import {BasicTable, useTable, TableAction} from '/@/components/Table'; |
/** |
||||||
import {useModal} from '/@/components/Modal'; |
* 提供模板规范代码参考,请尽量保证编写代码风格跟模板规范代码一致 |
||||||
|
* 采用vben-动态表格表单封装组件编写,采用 setup 写法 |
||||||
|
* Copyright © 2020-2022 <a href="http://www.entfrm.com/">entfrm</a> All rights reserved. |
||||||
|
* author entfrm开发团队-王翔 |
||||||
|
*/ |
||||||
|
import { reactive, toRaw } from 'vue'; |
||||||
|
import { BasicTable, useTable, TableAction } from '/@/components/Table'; |
||||||
|
import {list, delHospital} from '/@/api/platform/system/controller/hospital'; |
||||||
|
import { useModal } from '/@/components/Modal'; |
||||||
|
import { columns, searchFormSchema } from './hospital.data'; |
||||||
|
import { useMessage } from '/@/hooks/web/useMessage'; |
||||||
import HospitalModal from './HospitalModal.vue'; |
import HospitalModal from './HospitalModal.vue'; |
||||||
import {columns, searchFormSchema} from './hospital.data'; |
|
||||||
import {useMessage} from '/@/hooks/web/useMessage'; |
/** 类型规范统一声明定义区域 */ |
||||||
import {list, remove} from '/@/api/platform/system/controller/hospital'; |
interface TableState { |
||||||
const {createMessage} = useMessage(); |
single: boolean; |
||||||
const [registerModal, {openModal}] = useModal(); |
multiple: boolean; |
||||||
const [registerTable, {reload}] = useTable({ |
} |
||||||
title: '医院列表', |
|
||||||
|
/** 通用变量统一声明区域 */ |
||||||
|
const state = reactive<TableState>({ |
||||||
|
// 非单个禁用 |
||||||
|
single: true, |
||||||
|
// 非多个禁用 |
||||||
|
multiple: true |
||||||
|
}); |
||||||
|
const { createConfirm, createMessage } = useMessage(); |
||||||
|
const [registerModal, { openModal }] = useModal(); |
||||||
|
const [registerTable, { reload, clearSelectedRowKeys, getSelectRowKeys }] = useTable({ |
||||||
|
title: '医院', |
||||||
api: list, |
api: list, |
||||||
|
rowKey: 'id', |
||||||
columns, |
columns, |
||||||
formConfig: { |
formConfig: { |
||||||
labelWidth: 120, |
labelWidth: 120, |
||||||
schemas: searchFormSchema, |
schemas: searchFormSchema, |
||||||
|
autoSubmitOnEnter: true, |
||||||
|
fieldMapToTime: [['dateRange', ['beginTime', 'endTime'], 'YYYY-MM-DD']] |
||||||
}, |
}, |
||||||
pagination: true, |
rowSelection: { type: 'checkbox' }, |
||||||
striped: true, |
|
||||||
useSearchForm: true, |
useSearchForm: true, |
||||||
showTableSetting: true, |
showTableSetting: true, |
||||||
bordered: true, |
bordered: true, |
||||||
showIndexColumn: true, |
clickToRowSelect: false, |
||||||
canResize: false, |
showIndexColumn: false, |
||||||
actionColumn: { |
actionColumn: { |
||||||
width: 80, |
width: 220, |
||||||
title: '操作', |
title: '操作', |
||||||
dataIndex: 'action', |
dataIndex: 'action', |
||||||
slots: {customRender: 'action'}, |
slots: { customRender: 'action' }, |
||||||
fixed: undefined, |
fixed: false |
||||||
}, |
}, |
||||||
|
handleSearchInfoFn: () => clearSelectedRowKeys() |
||||||
}); |
}); |
||||||
/** |
|
||||||
* 创建菜单 |
/** 处理多选框选中数据 */ |
||||||
*/ |
function handleSelectionChange(selection?: Recordable) { |
||||||
function handleCreate() { |
const rowSelection = toRaw(selection?.keys) || []; |
||||||
openModal(true, { |
state.single = rowSelection.length != 1; |
||||||
isUpdate: false, |
state.multiple = !rowSelection.length; |
||||||
}); |
|
||||||
} |
} |
||||||
/** |
|
||||||
* 编辑菜单 |
/** 新增按钮操作,行内新增与工具栏局域新增通用 */ |
||||||
*/ |
function handleAdd() { |
||||||
function handleEdit(record: Recordable) { |
openModal(true,{ _tag: 'add' }); |
||||||
openModal(true, { |
|
||||||
record, |
|
||||||
isUpdate: true, |
|
||||||
}); |
|
||||||
} |
} |
||||||
/** |
|
||||||
* 删除菜单 |
/** 编辑按钮操作,行内编辑 */ |
||||||
*/ |
function handleEdit(record?: Recordable) { |
||||||
async function handleDelete(record: Recordable) { |
record = record || { id: getSelectRowKeys() }; |
||||||
await remove({ids: record.id}); |
openModal(true, { _tag: 'edit', record }); |
||||||
createMessage.success('删除成功!'); |
|
||||||
handleSuccess(); |
|
||||||
} |
} |
||||||
/** |
|
||||||
* 成功后重载表格 |
/** 删除按钮操作,行内删除 */ |
||||||
*/ |
async function handleDel(record?: Recordable) { |
||||||
function handleSuccess() { |
const id = record?.id || getSelectRowKeys(); |
||||||
|
createConfirm({ |
||||||
|
iconType: 'warning', |
||||||
|
title: '警告', |
||||||
|
content: `是否确认删除医院编号为${id}医院吗?`, |
||||||
|
onOk: async () => { |
||||||
|
await delHospital(id); |
||||||
|
createMessage.success('删除成功!'); |
||||||
|
handleRefreshTable(); |
||||||
|
} |
||||||
|
}); |
||||||
|
} |
||||||
|
|
||||||
|
/** 处理表格刷新 */ |
||||||
|
function handleRefreshTable() { |
||||||
|
clearSelectedRowKeys(); |
||||||
reload(); |
reload(); |
||||||
} |
} |
||||||
</script> |
</script> |
||||||
|
@ -1,57 +1,79 @@ |
|||||||
<template> |
<template> |
||||||
<BasicModal v-bind="$attrs" |
<BasicModal v-bind="$attrs" |
||||||
:title="getTitle" |
width="720px" |
||||||
@register="registerModal" |
@register="registerModal" |
||||||
@ok="handleSubmit" |
@ok="handleSubmit" |
||||||
> |
> |
||||||
<BasicForm @register="registerForm"/> |
<BasicForm @register="registerForm"/> |
||||||
</BasicModal> |
</BasicModal> |
||||||
</template> |
</template> |
||||||
|
|
||||||
<script lang="ts" setup> |
<script lang="ts" setup> |
||||||
import {ref, computed, unref} from 'vue'; |
|
||||||
import {BasicModal, useModalInner} from '/@/components/Modal'; |
|
||||||
import {institutionFormSchema} from './institution.data'; |
|
||||||
import {BasicForm, useForm} from '/@/components/Form'; |
|
||||||
import {set} from '/@/api/platform/system/controller/institution'; |
|
||||||
const isUpdate = ref(true); |
|
||||||
// 定义emit |
|
||||||
const emit = defineEmits(['success', 'register']); |
|
||||||
/** |
/** |
||||||
* 表单 |
* 提供模板规范代码参考,请尽量保证编写代码风格跟模板规范代码一致 |
||||||
|
* 采用vben-动态表格表单封装组件编写,采用 setup 写法 |
||||||
|
* Copyright © 2020-2022 <a href="http://www.entfrm.com/">entfrm</a> All rights reserved. |
||||||
|
* author entfrm开发团队-王翔 |
||||||
*/ |
*/ |
||||||
const [registerForm, {resetFields, setFieldsValue, validate}] = useForm({ |
import { ref, unref } from 'vue'; |
||||||
|
import { BasicForm, useForm } from '/@/components/Form/index'; |
||||||
|
import { institutionFormSchema } from './institution.data'; |
||||||
|
import {addInstitution, delInstitution,getInstitution,editInstitution} from '/@/api/platform/system/controller/institution'; |
||||||
|
import { BasicModal, ModalProps, useModalInner } from '/@/components/Modal'; |
||||||
|
import { isEmpty } from '/@/utils/is'; |
||||||
|
|
||||||
|
/** 通用变量统一声明区域 */ |
||||||
|
const tag = ref<Nullable<string>>(''); |
||||||
|
/** https://v3.cn.vuejs.org/api/options-data.html#emits */ |
||||||
|
const emit = defineEmits(['success', 'register']); |
||||||
|
const [registerForm, { resetFields, setFieldsValue, validate, clearValidate, updateSchema }] = useForm({ |
||||||
labelWidth: 100, |
labelWidth: 100, |
||||||
schemas: institutionFormSchema, |
schemas: institutionFormSchema, |
||||||
showActionButtonGroup: false, |
showActionButtonGroup: false, |
||||||
actionColOptions: { |
baseColProps: { span: 24 } |
||||||
span: 23, |
|
||||||
}, |
|
||||||
}); |
}); |
||||||
/** |
const [registerModal, { setModalProps, closeModal }] = useModalInner(async (data: WindowInnerData = { _tag: '' }) => { |
||||||
* 表单参数 |
// 处理清除脏数据 |
||||||
*/ |
await resetFields(); |
||||||
const [registerModal, {setModalProps, closeModal}] = useModalInner(async (data) => { |
await clearValidate(); |
||||||
resetFields(); |
// 处理设置数据 |
||||||
setModalProps({confirmLoading: false}); |
tag.value = data._tag; |
||||||
isUpdate.value = !!data?.isUpdate; |
const id = data.record?.id; |
||||||
if (unref(isUpdate)) { |
const props: Partial<ModalProps> = { confirmLoading: false }; |
||||||
setFieldsValue({ |
// 采用tag标签区分操作 |
||||||
...data.record, |
switch (unref(tag)) { |
||||||
}); |
case 'add': |
||||||
|
props.title = '新增机构'; |
||||||
|
break; |
||||||
|
case 'edit': |
||||||
|
props.title = '编辑机构'; |
||||||
|
await setFieldsValue(await getInstitution(id)); |
||||||
|
break; |
||||||
} |
} |
||||||
|
// 尾部:设置处理后的最终配置数据 |
||||||
|
setModalProps(props); |
||||||
}); |
}); |
||||||
//表单标题 |
|
||||||
const getTitle = computed(() => (!unref(isUpdate) ? '新增机构' : '编辑机构')); |
/** 处理弹出框提交 */ |
||||||
async function handleSubmit() { |
async function handleSubmit() { |
||||||
try { |
try { |
||||||
const values = await validate(); |
// 提取验证数据 |
||||||
setModalProps({confirmLoading: true}); |
const formData = await validate(); |
||||||
await set(values); |
// 处理提交之前逻辑 |
||||||
|
setModalProps({ confirmLoading: true }); |
||||||
|
// 采用tag标签区分操作 |
||||||
|
switch (unref(tag)) { |
||||||
|
case 'add': |
||||||
|
await addInstitution(formData); |
||||||
|
break; |
||||||
|
case 'edit': |
||||||
|
await editInstitution(formData); |
||||||
|
break; |
||||||
|
} |
||||||
|
// 处理提交完成之后逻辑 |
||||||
closeModal(); |
closeModal(); |
||||||
emit('success'); |
emit('success'); |
||||||
} finally { |
} finally { |
||||||
setModalProps({confirmLoading: false}); |
setModalProps({ confirmLoading: false }); |
||||||
} |
} |
||||||
} |
} |
||||||
</script> |
</script> |
||||||
|
@ -1,94 +1,136 @@ |
|||||||
<template> |
<template> |
||||||
<div> |
<div> |
||||||
<BasicTable @register="registerTable"> |
<BasicTable @register="registerTable" |
||||||
|
@selection-change="handleSelectionChange" |
||||||
|
> |
||||||
<template #toolbar> |
<template #toolbar> |
||||||
<a-button type="primary" @click="handleCreate">新增医检机构</a-button> |
<a-button |
||||||
|
type="primary" |
||||||
|
@click="handleAdd()" |
||||||
|
>新增机构</a-button> |
||||||
|
<a-button type="primary" |
||||||
|
:disabled="state.single" |
||||||
|
@click="handleEdit()" |
||||||
|
>修改机构</a-button> |
||||||
|
<a-button type="primary" |
||||||
|
:disabled="state.multiple" |
||||||
|
@click="handleDel()" |
||||||
|
>删除机构</a-button> |
||||||
</template> |
</template> |
||||||
<template #action="{ record }"> |
<template #action="{ record }"> |
||||||
<TableAction |
<TableAction :actions="[ |
||||||
:actions="[ |
{ |
||||||
{ |
label: '编辑', |
||||||
icon: 'clarity:note-edit-line', |
icon: 'fa6-regular:pen-to-square', |
||||||
onClick: handleEdit.bind(null, record), |
onClick: handleEdit.bind(null, record) |
||||||
}, |
}, |
||||||
{ |
{ |
||||||
icon: 'ant-design:delete-outlined', |
label: '删除', |
||||||
color: 'error', |
icon: 'ant-design:delete-outlined', |
||||||
popConfirm: { |
color: 'error', |
||||||
title: '是否确认删除', |
onClick: handleDel.bind(null, record) |
||||||
confirm: handleDelete.bind(null, record), |
}]" |
||||||
}, |
|
||||||
}, |
|
||||||
]" |
|
||||||
/> |
/> |
||||||
</template> |
</template> |
||||||
</BasicTable> |
</BasicTable> |
||||||
|
<!--弹出窗体区域--> |
||||||
<BoxCardModal @register="registerModal" @success="handleSuccess"/> |
<InstitutionModal @register="registerModal" @success="handleRefreshTable"/> |
||||||
</div> |
</div> |
||||||
</template> |
</template> |
||||||
|
|
||||||
<script lang="ts" setup> |
<script lang="ts" setup> |
||||||
import {BasicTable, useTable, TableAction} from '/@/components/Table'; |
/** |
||||||
import {useModal} from '/@/components/Modal'; |
* 提供模板规范代码参考,请尽量保证编写代码风格跟模板规范代码一致 |
||||||
import BoxCardModal from './InstitutionModal.vue'; |
* 采用vben-动态表格表单封装组件编写,采用 setup 写法 |
||||||
import {columns, searchFormSchema} from './institution.data'; |
* Copyright © 2020-2022 <a href="http://www.entfrm.com/">entfrm</a> All rights reserved. |
||||||
import {useMessage} from '/@/hooks/web/useMessage'; |
* author entfrm开发团队-王翔 |
||||||
import {list, remove} from '/@/api/platform/system/controller/institution'; |
*/ |
||||||
const {createMessage} = useMessage(); |
import { reactive, toRaw } from 'vue'; |
||||||
const [registerModal, {openModal}] = useModal(); |
import { BasicTable, useTable, TableAction } from '/@/components/Table'; |
||||||
const [registerTable, {reload}] = useTable({ |
import {list, delInstitution} from '/@/api/platform/system/controller/institution'; |
||||||
title: '医检列表', |
import { useModal } from '/@/components/Modal'; |
||||||
|
import { columns, searchFormSchema } from './institution.data'; |
||||||
|
import { useMessage } from '/@/hooks/web/useMessage'; |
||||||
|
import InstitutionModal from './InstitutionModal.vue'; |
||||||
|
|
||||||
|
/** 类型规范统一声明定义区域 */ |
||||||
|
interface TableState { |
||||||
|
single: boolean; |
||||||
|
multiple: boolean; |
||||||
|
} |
||||||
|
|
||||||
|
/** 通用变量统一声明区域 */ |
||||||
|
const state = reactive<TableState>({ |
||||||
|
// 非单个禁用 |
||||||
|
single: true, |
||||||
|
// 非多个禁用 |
||||||
|
multiple: true |
||||||
|
}); |
||||||
|
const { createConfirm, createMessage } = useMessage(); |
||||||
|
const [registerModal, { openModal }] = useModal(); |
||||||
|
const [registerTable, { reload, clearSelectedRowKeys, getSelectRowKeys }] = useTable({ |
||||||
|
title: '医生列表', |
||||||
api: list, |
api: list, |
||||||
|
rowKey: 'id', |
||||||
columns, |
columns, |
||||||
formConfig: { |
formConfig: { |
||||||
labelWidth: 120, |
labelWidth: 120, |
||||||
schemas: searchFormSchema, |
schemas: searchFormSchema, |
||||||
|
autoSubmitOnEnter: true, |
||||||
|
fieldMapToTime: [['dateRange', ['beginTime', 'endTime'], 'YYYY-MM-DD']] |
||||||
}, |
}, |
||||||
pagination: true, |
rowSelection: { type: 'checkbox' }, |
||||||
striped: true, |
|
||||||
useSearchForm: true, |
useSearchForm: true, |
||||||
showTableSetting: true, |
showTableSetting: true, |
||||||
bordered: true, |
bordered: true, |
||||||
showIndexColumn: true, |
clickToRowSelect: false, |
||||||
canResize: false, |
showIndexColumn: false, |
||||||
actionColumn: { |
actionColumn: { |
||||||
width: 80, |
width: 220, |
||||||
title: '操作', |
title: '操作', |
||||||
dataIndex: 'action', |
dataIndex: 'action', |
||||||
slots: {customRender: 'action'}, |
slots: { customRender: 'action' }, |
||||||
fixed: undefined, |
fixed: false |
||||||
}, |
}, |
||||||
|
handleSearchInfoFn: () => clearSelectedRowKeys() |
||||||
}); |
}); |
||||||
/** |
|
||||||
* 创建菜单 |
/** 处理多选框选中数据 */ |
||||||
*/ |
function handleSelectionChange(selection?: Recordable) { |
||||||
function handleCreate() { |
const rowSelection = toRaw(selection?.keys) || []; |
||||||
openModal(true, { |
state.single = rowSelection.length != 1; |
||||||
isUpdate: false, |
state.multiple = !rowSelection.length; |
||||||
}); |
|
||||||
} |
} |
||||||
/** |
|
||||||
* 编辑菜单 |
/** 新增按钮操作,行内新增与工具栏局域新增通用 */ |
||||||
*/ |
function handleAdd() { |
||||||
function handleEdit(record: Recordable) { |
openModal(true,{ _tag: 'add' }); |
||||||
openModal(true, { |
|
||||||
record, |
|
||||||
isUpdate: true, |
|
||||||
}); |
|
||||||
} |
} |
||||||
/** |
|
||||||
* 删除菜单 |
/** 编辑按钮操作,行内编辑 */ |
||||||
*/ |
function handleEdit(record?: Recordable) { |
||||||
async function handleDelete(record: Recordable) { |
record = record || { id: getSelectRowKeys() }; |
||||||
await remove({ids: record.id}); |
openModal(true, { _tag: 'edit', record }); |
||||||
createMessage.success('删除成功!'); |
|
||||||
handleSuccess(); |
|
||||||
} |
} |
||||||
/** |
|
||||||
* 成功后重载表格 |
/** 删除按钮操作,行内删除 */ |
||||||
*/ |
async function handleDel(record?: Recordable) { |
||||||
function handleSuccess() { |
const id = record?.id || getSelectRowKeys(); |
||||||
|
createConfirm({ |
||||||
|
iconType: 'warning', |
||||||
|
title: '警告', |
||||||
|
content: `是否确认删除机构编号为${id}机构吗?`, |
||||||
|
onOk: async () => { |
||||||
|
await delInstitution(id); |
||||||
|
createMessage.success('删除成功!'); |
||||||
|
handleRefreshTable(); |
||||||
|
} |
||||||
|
}); |
||||||
|
} |
||||||
|
|
||||||
|
/** 处理表格刷新 */ |
||||||
|
function handleRefreshTable() { |
||||||
|
clearSelectedRowKeys(); |
||||||
reload(); |
reload(); |
||||||
} |
} |
||||||
</script> |
</script> |
||||||
|
@ -1,58 +1,79 @@ |
|||||||
<template> |
<template> |
||||||
<BasicModal v-bind="$attrs" |
<BasicModal v-bind="$attrs" |
||||||
:title="getTitle" |
width="720px" |
||||||
@register="registerModal" |
@register="registerModal" |
||||||
@ok="handleSubmit" |
@ok="handleSubmit" |
||||||
> |
> |
||||||
<BasicForm @register="registerForm"/> |
<BasicForm @register="registerForm"/> |
||||||
</BasicModal> |
</BasicModal> |
||||||
</template> |
</template> |
||||||
|
|
||||||
<script lang="ts" setup> |
<script lang="ts" setup> |
||||||
import {ref, computed, unref} from 'vue'; |
|
||||||
import {BasicModal, useModalInner} from '/@/components/Modal'; |
|
||||||
import {officeFormSchema} from './office.data'; |
|
||||||
import {BasicForm, useForm} from '/@/components/Form'; |
|
||||||
import {set} from '/@/api/platform/system/controller/office'; |
|
||||||
const isUpdate = ref(true); |
|
||||||
// 定义emit |
|
||||||
const emit = defineEmits(['success', 'register']); |
|
||||||
/** |
/** |
||||||
* 表单 |
* 提供模板规范代码参考,请尽量保证编写代码风格跟模板规范代码一致 |
||||||
|
* 采用vben-动态表格表单封装组件编写,采用 setup 写法 |
||||||
|
* Copyright © 2020-2022 <a href="http://www.entfrm.com/">entfrm</a> All rights reserved. |
||||||
|
* author entfrm开发团队-王翔 |
||||||
*/ |
*/ |
||||||
const [registerForm, {resetFields, setFieldsValue, validate}] = useForm({ |
import { ref, unref } from 'vue'; |
||||||
|
import { BasicForm, useForm } from '/@/components/Form/index'; |
||||||
|
import { officeFormSchema } from './office.data'; |
||||||
|
import {addOffice, delOffice,getOffice,editOffice} from '/@/api/platform/system/controller/office'; |
||||||
|
import { BasicModal, ModalProps, useModalInner } from '/@/components/Modal'; |
||||||
|
import { isEmpty } from '/@/utils/is'; |
||||||
|
|
||||||
|
/** 通用变量统一声明区域 */ |
||||||
|
const tag = ref<Nullable<string>>(''); |
||||||
|
/** https://v3.cn.vuejs.org/api/options-data.html#emits */ |
||||||
|
const emit = defineEmits(['success', 'register']); |
||||||
|
const [registerForm, { resetFields, setFieldsValue, validate, clearValidate, updateSchema }] = useForm({ |
||||||
labelWidth: 100, |
labelWidth: 100, |
||||||
schemas: officeFormSchema, |
schemas: officeFormSchema, |
||||||
showActionButtonGroup: false, |
showActionButtonGroup: false, |
||||||
actionColOptions: { |
baseColProps: { span: 24 } |
||||||
span: 23, |
|
||||||
}, |
|
||||||
}); |
}); |
||||||
/** |
const [registerModal, { setModalProps, closeModal }] = useModalInner(async (data: WindowInnerData = { _tag: '' }) => { |
||||||
* 表单参数 |
// 处理清除脏数据 |
||||||
*/ |
await resetFields(); |
||||||
const [registerModal, {setModalProps, closeModal}] = useModalInner(async (data) => { |
await clearValidate(); |
||||||
resetFields(); |
// 处理设置数据 |
||||||
setModalProps({confirmLoading: false}); |
tag.value = data._tag; |
||||||
isUpdate.value = !!data?.isUpdate; |
const id = data.record?.id; |
||||||
if (unref(isUpdate)) { |
const props: Partial<ModalProps> = { confirmLoading: false }; |
||||||
setFieldsValue({ |
// 采用tag标签区分操作 |
||||||
...data.record, |
switch (unref(tag)) { |
||||||
}); |
case 'add': |
||||||
|
props.title = '新增科室'; |
||||||
|
break; |
||||||
|
case 'edit': |
||||||
|
props.title = '编辑科室'; |
||||||
|
await setFieldsValue(await getOffice(id)); |
||||||
|
break; |
||||||
} |
} |
||||||
|
// 尾部:设置处理后的最终配置数据 |
||||||
|
setModalProps(props); |
||||||
}); |
}); |
||||||
//表单标题 |
|
||||||
const getTitle = computed(() => (!unref(isUpdate) ? '新增科室' : '编辑科室')); |
/** 处理弹出框提交 */ |
||||||
async function handleSubmit() { |
async function handleSubmit() { |
||||||
try { |
try { |
||||||
const values = await validate(); |
// 提取验证数据 |
||||||
|
const formData = await validate(); |
||||||
setModalProps({confirmLoading: true}); |
// 处理提交之前逻辑 |
||||||
await set(values); |
setModalProps({ confirmLoading: true }); |
||||||
|
// 采用tag标签区分操作 |
||||||
|
switch (unref(tag)) { |
||||||
|
case 'add': |
||||||
|
await addOffice(formData); |
||||||
|
break; |
||||||
|
case 'edit': |
||||||
|
await editOffice(formData); |
||||||
|
break; |
||||||
|
} |
||||||
|
// 处理提交完成之后逻辑 |
||||||
closeModal(); |
closeModal(); |
||||||
emit('success'); |
emit('success'); |
||||||
} finally { |
} finally { |
||||||
setModalProps({confirmLoading: false}); |
setModalProps({ confirmLoading: false }); |
||||||
} |
} |
||||||
} |
} |
||||||
</script> |
</script> |
||||||
|
@ -1,95 +1,136 @@ |
|||||||
<template> |
<template> |
||||||
<div> |
<div> |
||||||
<BasicTable @register="registerTable"> |
<BasicTable @register="registerTable" |
||||||
|
@selection-change="handleSelectionChange" |
||||||
|
> |
||||||
<template #toolbar> |
<template #toolbar> |
||||||
<a-button type="primary" @click="handleCreate">新增科室</a-button> |
<a-button |
||||||
|
type="primary" |
||||||
|
@click="handleAdd()" |
||||||
|
>新增科室</a-button> |
||||||
|
<a-button type="primary" |
||||||
|
:disabled="state.single" |
||||||
|
@click="handleEdit()" |
||||||
|
>修改科室</a-button> |
||||||
|
<a-button type="primary" |
||||||
|
:disabled="state.multiple" |
||||||
|
@click="handleDel()" |
||||||
|
>删除科室</a-button> |
||||||
</template> |
</template> |
||||||
<template #action="{ record }"> |
<template #action="{ record }"> |
||||||
<TableAction |
<TableAction :actions="[ |
||||||
:actions="[ |
{ |
||||||
{ |
label: '编辑', |
||||||
icon: 'clarity:note-edit-line', |
icon: 'fa6-regular:pen-to-square', |
||||||
onClick: handleEdit.bind(null, record), |
onClick: handleEdit.bind(null, record) |
||||||
}, |
}, |
||||||
{ |
{ |
||||||
icon: 'ant-design:delete-outlined', |
label: '删除', |
||||||
color: 'error', |
icon: 'ant-design:delete-outlined', |
||||||
popConfirm: { |
color: 'error', |
||||||
title: '是否确认删除', |
onClick: handleDel.bind(null, record) |
||||||
confirm: handleDelete.bind(null, record), |
}]" |
||||||
}, |
|
||||||
}, |
|
||||||
]" |
|
||||||
/> |
/> |
||||||
</template> |
</template> |
||||||
</BasicTable> |
</BasicTable> |
||||||
|
<!--弹出窗体区域--> |
||||||
<OfficeModal @register="registerModal" @success="handleSuccess"/> |
<OfficeModal @register="registerModal" @success="handleRefreshTable"/> |
||||||
</div> |
</div> |
||||||
</template> |
</template> |
||||||
|
|
||||||
<script lang="ts" setup> |
<script lang="ts" setup> |
||||||
import {BasicTable, useTable, TableAction} from '/@/components/Table'; |
/** |
||||||
import {useModal} from '/@/components/Modal'; |
* 提供模板规范代码参考,请尽量保证编写代码风格跟模板规范代码一致 |
||||||
|
* 采用vben-动态表格表单封装组件编写,采用 setup 写法 |
||||||
|
* Copyright © 2020-2022 <a href="http://www.entfrm.com/">entfrm</a> All rights reserved. |
||||||
|
* author entfrm开发团队-王翔 |
||||||
|
*/ |
||||||
|
import { reactive, toRaw } from 'vue'; |
||||||
|
import { BasicTable, useTable, TableAction } from '/@/components/Table'; |
||||||
|
import {listOffice, delOffice} from '/@/api/platform/system/controller/office'; |
||||||
|
import { useModal } from '/@/components/Modal'; |
||||||
|
import { columns, searchFormSchema } from './office.data'; |
||||||
|
import { useMessage } from '/@/hooks/web/useMessage'; |
||||||
import OfficeModal from './OfficeModal.vue'; |
import OfficeModal from './OfficeModal.vue'; |
||||||
import {columns, searchFormSchema} from './office.data'; |
|
||||||
import {useMessage} from '/@/hooks/web/useMessage'; |
/** 类型规范统一声明定义区域 */ |
||||||
import {list, remove} from '/@/api/platform/system/controller/office'; |
interface TableState { |
||||||
const {createMessage} = useMessage(); |
single: boolean; |
||||||
const [registerModal, {openModal}] = useModal(); |
multiple: boolean; |
||||||
const [registerTable, {reload}] = useTable({ |
} |
||||||
title: '科室列表', |
|
||||||
api: list, |
/** 通用变量统一声明区域 */ |
||||||
|
const state = reactive<TableState>({ |
||||||
|
// 非单个禁用 |
||||||
|
single: true, |
||||||
|
// 非多个禁用 |
||||||
|
multiple: true |
||||||
|
}); |
||||||
|
const { createConfirm, createMessage } = useMessage(); |
||||||
|
const [registerModal, { openModal }] = useModal(); |
||||||
|
const [registerTable, { reload, clearSelectedRowKeys, getSelectRowKeys }] = useTable({ |
||||||
|
title: '医生列表', |
||||||
|
api: listOffice, |
||||||
|
rowKey: 'id', |
||||||
columns, |
columns, |
||||||
formConfig: { |
formConfig: { |
||||||
labelWidth: 120, |
labelWidth: 120, |
||||||
schemas: searchFormSchema, |
schemas: searchFormSchema, |
||||||
|
autoSubmitOnEnter: true, |
||||||
|
fieldMapToTime: [['dateRange', ['beginTime', 'endTime'], 'YYYY-MM-DD']] |
||||||
}, |
}, |
||||||
pagination: true, |
rowSelection: { type: 'checkbox' }, |
||||||
striped: true, |
|
||||||
useSearchForm: true, |
useSearchForm: true, |
||||||
showTableSetting: true, |
showTableSetting: true, |
||||||
bordered: true, |
bordered: true, |
||||||
showIndexColumn: true, |
clickToRowSelect: false, |
||||||
canResize: false, |
showIndexColumn: false, |
||||||
actionColumn: { |
actionColumn: { |
||||||
width: 80, |
width: 220, |
||||||
title: '操作', |
title: '操作', |
||||||
dataIndex: 'action', |
dataIndex: 'action', |
||||||
slots: {customRender: 'action'}, |
slots: { customRender: 'action' }, |
||||||
fixed: undefined, |
fixed: false |
||||||
}, |
}, |
||||||
|
handleSearchInfoFn: () => clearSelectedRowKeys() |
||||||
}); |
}); |
||||||
/** |
|
||||||
* 创建菜单 |
/** 处理多选框选中数据 */ |
||||||
*/ |
function handleSelectionChange(selection?: Recordable) { |
||||||
function handleCreate() { |
const rowSelection = toRaw(selection?.keys) || []; |
||||||
debugger; |
state.single = rowSelection.length != 1; |
||||||
openModal(true, { |
state.multiple = !rowSelection.length; |
||||||
isUpdate: false, |
|
||||||
}); |
|
||||||
} |
} |
||||||
/** |
|
||||||
* 编辑菜单 |
/** 新增按钮操作,行内新增与工具栏局域新增通用 */ |
||||||
*/ |
function handleAdd() { |
||||||
function handleEdit(record: Recordable) { |
openModal(true,{ _tag: 'add' }); |
||||||
openModal(true, { |
|
||||||
record, |
|
||||||
isUpdate: true, |
|
||||||
}); |
|
||||||
} |
} |
||||||
/** |
|
||||||
* 删除菜单 |
/** 编辑按钮操作,行内编辑 */ |
||||||
*/ |
function handleEdit(record?: Recordable) { |
||||||
async function handleDelete(record: Recordable) { |
record = record || { id: getSelectRowKeys() }; |
||||||
await remove({ids: record.id}); |
openModal(true, { _tag: 'edit', record }); |
||||||
createMessage.success('删除成功!'); |
|
||||||
handleSuccess(); |
|
||||||
} |
} |
||||||
/** |
|
||||||
* 成功后重载表格 |
/** 删除按钮操作,行内删除 */ |
||||||
*/ |
async function handleDel(record?: Recordable) { |
||||||
function handleSuccess() { |
const id = record?.id || getSelectRowKeys(); |
||||||
|
createConfirm({ |
||||||
|
iconType: 'warning', |
||||||
|
title: '警告', |
||||||
|
content: `是否确认删除科室编号为${id}科室吗?`, |
||||||
|
onOk: async () => { |
||||||
|
await delOffice(id); |
||||||
|
createMessage.success('删除成功!'); |
||||||
|
handleRefreshTable(); |
||||||
|
} |
||||||
|
}); |
||||||
|
} |
||||||
|
|
||||||
|
/** 处理表格刷新 */ |
||||||
|
function handleRefreshTable() { |
||||||
|
clearSelectedRowKeys(); |
||||||
reload(); |
reload(); |
||||||
} |
} |
||||||
</script> |
</script> |
||||||
|
Loading…
Reference in new issue