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