Browse Source

🧬更新菜单模块

master
wangxiang 3 years ago
parent
commit
9626187f12
  1. 11
      src/api/platform/system/controller/region.ts
  2. 7
      src/components/Form/src/BasicForm.vue
  3. 2
      src/components/Form/src/components/ApiCascader.vue
  4. 26
      src/views/common/doctor/DoctorModal.vue
  5. 20
      src/views/common/doctor/doctor.data.ts
  6. 5
      src/views/common/hospital/index.vue
  7. 139
      src/views/common/office/OfficeModal.vue
  8. 179
      src/views/common/office/index.vue
  9. 20
      src/views/common/office/office.data.ts
  10. 117
      src/views/common/org/OrgModal.vue
  11. 5
      src/views/common/org/index.vue
  12. 400
      src/views/common/org/org.data.ts

11
src/api/platform/system/controller/region.ts

@ -22,9 +22,16 @@ export const listRegion = (params?: Partial<RegionParams>) => {
return defHttp.get({ url: url, params }); return defHttp.get({ url: url, params });
}; };
export const addRegion =(params:Partial<Region>) => defHttp.post({ url: Api.add,data:params }); export const listRegionCascade = (params?: Partial<RegionParams>) => defHttp.get({ url: Api.lazyList, params }).then(res => {
return res.map(item => {
const { children, ...result } = item;
return { ...result, isLeaf: !!!children };
});
});
export const editRegion =(params:Partial<Region>) => defHttp.put({ url: Api.edit,data:params }); export const addRegion = (params:Partial<Region>) => defHttp.post({ url: Api.add,data:params });
export const editRegion = (params:Partial<Region>) => defHttp.put({ url: Api.edit,data:params });
export const getRegion = (id: string) => defHttp.get<ResultVo<Region>>({ url: `${Api.get}/${id}` }); export const getRegion = (id: string) => defHttp.get<ResultVo<Region>>({ url: `${Api.get}/${id}` });

7
src/components/Form/src/BasicForm.vue

@ -56,7 +56,6 @@
import { useDebounceFn } from '@vueuse/core'; import { useDebounceFn } from '@vueuse/core';
import { basicProps } from './props'; import { basicProps } from './props';
import { useDesign } from '/@/hooks/web/useDesign'; import { useDesign } from '/@/hooks/web/useDesign';
import { cloneDeep } from 'lodash-es';
export default defineComponent({ export default defineComponent({
name: 'BasicForm', name: 'BasicForm',
@ -127,11 +126,9 @@
} }
} }
if (unref(getProps).showAdvancedButton) { if (unref(getProps).showAdvancedButton) {
return cloneDeep( return schemas.filter((schema) => schema.component !== 'Divider') as FormSchema[];
schemas.filter((schema) => schema.component !== 'Divider') as FormSchema[],
);
} else { } else {
return cloneDeep(schemas as FormSchema[]); return schemas as FormSchema[];
} }
}); });

2
src/components/Form/src/components/ApiCascader.vue

@ -95,10 +95,10 @@
if (next) { if (next) {
const value = next[valueField]; const value = next[valueField];
const item = { const item = {
isLeaf: isLeaf && typeof isLeaf === 'function' ? isLeaf(next) : false,
...omit(next, [labelField, valueField]), ...omit(next, [labelField, valueField]),
label: next[labelField], label: next[labelField],
value: numberToString ? `${value}` : value, value: numberToString ? `${value}` : value,
isLeaf: isLeaf && typeof isLeaf === 'function' ? isLeaf(next) : false,
}; };
const children = Reflect.get(next, childrenField); const children = Reflect.get(next, childrenField);
if (children) { if (children) {

26
src/views/common/doctor/DoctorModal.vue

@ -17,14 +17,16 @@
import { ref, unref } from 'vue'; import { ref, unref } from 'vue';
import { BasicForm, useForm } from '/@/components/Form'; import { BasicForm, useForm } from '/@/components/Form';
import { formSchema } from './doctor.data'; import { formSchema } from './doctor.data';
import {addDoctor, delDoctor, getDoctor, editDoctor} from '/@/api/platform/common/controller/doctor'; import { addDoctor, getDoctor, editDoctor} from '/@/api/platform/common/controller/doctor';
import { BasicModal, ModalProps, useModalInner } from '/@/components/Modal'; import { BasicModal, ModalProps, useModalInner } from '/@/components/Modal';
import { listHospital } from '/@/api/platform/common/controller/hospital';
import { listOrg } from '/@/api/platform/common/controller/org';
/** 通用变量统一声明区域 */ /** 通用变量统一声明区域 */
const tag = ref<Nullable<string>>(''); const tag = ref<Nullable<string>>('');
/** https://v3.cn.vuejs.org/api/options-data.html#emits */ /** https://v3.cn.vuejs.org/api/options-data.html#emits */
const emit = defineEmits(['success', 'register']); const emit = defineEmits(['success', 'register']);
const [registerForm, { resetFields, setFieldsValue, validate, clearValidate, updateSchema }] = useForm({ const [registerForm, { resetFields, setFieldsValue, validate, clearValidate, updateSchema, getFieldsValue }] = useForm({
labelWidth: 100, labelWidth: 100,
schemas: formSchema, schemas: formSchema,
showActionButtonGroup: false, showActionButtonGroup: false,
@ -48,6 +50,26 @@
await setFieldsValue(await getDoctor(id)); await setFieldsValue(await getDoctor(id));
break; break;
} }
const model = getFieldsValue();
await updateSchema([{
field: 'orgType',
componentProps: {
onChange: (value: string) => {
setFieldsValue({ orgId: '' });
updateSchema({
field: 'orgId',
componentProps: {
api: ~~value == 1 ? listHospital : listOrg
}
});
}
},
}, {
field: 'orgId',
componentProps: {
api: ~~model?.orgType == 1 ? listHospital : listOrg
}
}]);
// : // :
setModalProps(props); setModalProps(props);
}); });

20
src/views/common/doctor/doctor.data.ts

@ -2,9 +2,6 @@ import { BasicColumn } from '/@/components/Table';
import { FormSchema } from '/@/components/Table'; import { FormSchema } from '/@/components/Table';
import { h } from 'vue'; import { h } from 'vue';
import { Tag } from 'ant-design-vue'; import { Tag } from 'ant-design-vue';
import { listHospital } from '/@/api/platform/common/controller/hospital';
import { listOrg } from '/@/api/platform/common/controller/org';
import { listOffice } from '/@/api/platform/common/controller/office';
export const columns: BasicColumn[] = [ export const columns: BasicColumn[] = [
{ {
@ -193,17 +190,12 @@ export const formSchema: FormSchema[] = [
field: 'orgId', field: 'orgId',
label: '所属组织', label: '所属组织',
component: 'ApiSelect', component: 'ApiSelect',
required: true, componentProps: {
renderComponentContent: ({ schema, values, model, field }) => { resultField: 'data',
const organType = model.orgType; labelField: 'name',
const dataApi = ~~organType === 1 ? listHospital : listOrg; valueField: 'id'
schema.componentProps = { },
api: dataApi, required: true
labelField: 'name',
valueField: 'id',
resultField: 'data'
};
}
}, },
{ {
field: 'status', field: 'status',

5
src/views/common/hospital/index.vue

@ -4,9 +4,8 @@
@selection-change="handleSelectionChange" @selection-change="handleSelectionChange"
> >
<template #toolbar> <template #toolbar>
<a-button <a-button type="primary"
type="primary" @click="handleAdd()"
@click="handleAdd()"
>新增医院</a-button> >新增医院</a-button>
<a-button type="primary" <a-button type="primary"
:disabled="state.single" :disabled="state.single"

139
src/views/common/office/OfficeModal.vue

@ -8,72 +8,93 @@
</BasicModal> </BasicModal>
</template> </template>
<script lang="ts" setup> <script lang="ts" setup>
/** /**
* 提供模板规范代码参考,请尽量保证编写代码风格跟模板规范代码一致 * 提供模板规范代码参考,请尽量保证编写代码风格跟模板规范代码一致
* 采用vben-动态表格表单封装组件编写,采用 setup 写法 * 采用vben-动态表格表单封装组件编写,采用 setup 写法
* Copyright © 2020-2022 <a href="http://www.entfrm.com/">entfrm</a> All rights reserved. * Copyright © 2020-2022 <a href="http://www.entfrm.com/">entfrm</a> All rights reserved.
* author entfrm开发团队-王翔 * author entfrm开发团队-王翔
*/ */
import { ref, unref } from 'vue'; import { ref, unref } from 'vue';
import { BasicForm, useForm } from '/@/components/Form'; import { BasicForm, useForm } from '/@/components/Form';
import { formSchema } from './office.data'; import { formSchema } from './office.data';
import {addOffice, delOffice,getOffice,editOffice} from '/@/api/platform/common/controller/office'; import { addOffice, editOffice, getOffice } from '/@/api/platform/common/controller/office';
import { BasicModal, ModalProps, useModalInner } from '/@/components/Modal'; import { BasicModal, ModalProps, useModalInner } from '/@/components/Modal';
import { isEmpty } from '/@/utils/is'; import { listHospital } from '/@/api/platform/common/controller/hospital';
import { listOrg } from '/@/api/platform/common/controller/org';
/** 通用变量统一声明区域 */ /** 通用变量统一声明区域 */
const tag = ref<Nullable<string>>(''); const tag = ref<Nullable<string>>('');
/** https://v3.cn.vuejs.org/api/options-data.html#emits */ /** https://v3.cn.vuejs.org/api/options-data.html#emits */
const emit = defineEmits(['success', 'register']); const emit = defineEmits(['success', 'register']);
const [registerForm, { resetFields, setFieldsValue, validate, clearValidate, updateSchema }] = useForm({ const [registerForm, { resetFields, setFieldsValue, validate, clearValidate, updateSchema, getFieldsValue }] = useForm({
labelWidth: 100, labelWidth: 100,
schemas: formSchema, schemas: formSchema,
showActionButtonGroup: false, showActionButtonGroup: false,
baseColProps: { span: 24 } baseColProps: { span: 24 }
}); });
const [registerModal, { setModalProps, closeModal }] = useModalInner(async (data: WindowInnerData = { _tag: '' }) => { const [registerModal, { setModalProps, closeModal }] = useModalInner(async (data: WindowInnerData = { _tag: '' }) => {
// //
await resetFields(); await resetFields();
await clearValidate(); await clearValidate();
// //
tag.value = data._tag; tag.value = data._tag;
const id = data.record?.id; const id = data.record?.id;
const props: Partial<ModalProps> = { confirmLoading: false }; 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);
});
/** 处理弹出框提交 */
async function handleSubmit() {
try {
//
const formData = await validate();
//
setModalProps({ confirmLoading: true });
// tag // tag
switch (unref(tag)) { switch (unref(tag)) {
case 'add': case 'add':
await addOffice(formData); props.title = '新增科室';
break; break;
case 'edit': case 'edit':
await editOffice(formData); props.title = '编辑科室';
await setFieldsValue(await getOffice(id));
break; break;
} }
// const model = getFieldsValue();
closeModal(); await updateSchema([{
emit('success'); field: 'orgType',
} finally { componentProps: {
setModalProps({ confirmLoading: false }); onChange: (value: string) => {
setFieldsValue({ orgId: '' });
updateSchema({
field: 'orgId',
componentProps: {
api: ~~value == 1 ? listHospital : listOrg
}
});
}
},
}, {
field: 'orgId',
componentProps: {
api: ~~model?.orgType == 1 ? listHospital : listOrg
}
}]);
// :
setModalProps(props);
});
/** 处理弹出框提交 */
async function handleSubmit() {
try {
//
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 });
}
} }
}
</script> </script>

179
src/views/common/office/index.vue

@ -4,9 +4,8 @@
@selection-change="handleSelectionChange" @selection-change="handleSelectionChange"
> >
<template #toolbar> <template #toolbar>
<a-button <a-button type="primary"
type="primary" @click="handleAdd()"
@click="handleAdd()"
>新增科室</a-button> >新增科室</a-button>
<a-button type="primary" <a-button type="primary"
:disabled="state.single" :disabled="state.single"
@ -39,98 +38,98 @@
</template> </template>
<script lang="ts" setup> <script lang="ts" setup>
/** /**
* 提供模板规范代码参考,请尽量保证编写代码风格跟模板规范代码一致 * 提供模板规范代码参考,请尽量保证编写代码风格跟模板规范代码一致
* 采用vben-动态表格表单封装组件编写,采用 setup 写法 * 采用vben-动态表格表单封装组件编写,采用 setup 写法
* Copyright © 2020-2022 <a href="http://www.entfrm.com/">entfrm</a> All rights reserved. * Copyright © 2020-2022 <a href="http://www.entfrm.com/">entfrm</a> All rights reserved.
* author entfrm开发团队-王翔 * author entfrm开发团队-王翔
*/ */
import { reactive, toRaw } from 'vue'; import { reactive, toRaw } from 'vue';
import { BasicTable, useTable, TableAction } from '/@/components/Table'; import { BasicTable, useTable, TableAction } from '/@/components/Table';
import {listOffice, delOffice} from '/@/api/platform/common/controller/office'; import {listOffice, delOffice} from '/@/api/platform/common/controller/office';
import { useModal } from '/@/components/Modal'; import { useModal } from '/@/components/Modal';
import { columns, searchFormSchema } from './office.data'; import { columns, searchFormSchema } from './office.data';
import { useMessage } from '/@/hooks/web/useMessage'; import { useMessage } from '/@/hooks/web/useMessage';
import OfficeModal from './OfficeModal.vue'; import OfficeModal from './OfficeModal.vue';
/** 类型规范统一声明定义区域 */ /** 类型规范统一声明定义区域 */
interface TableState { interface TableState {
single: boolean; single: boolean;
multiple: boolean; multiple: boolean;
} }
/** 通用变量统一声明区域 */ /** 通用变量统一声明区域 */
const state = reactive<TableState>({ const state = reactive<TableState>({
// //
single: true, single: true,
// //
multiple: true multiple: true
}); });
const { createConfirm, createMessage } = useMessage(); const { createConfirm, createMessage } = useMessage();
const [registerModal, { openModal }] = useModal(); const [registerModal, { openModal }] = useModal();
const [registerTable, { reload, clearSelectedRowKeys, getSelectRowKeys }] = useTable({ const [registerTable, { reload, clearSelectedRowKeys, getSelectRowKeys }] = useTable({
title: '医生列表', title: '医生列表',
api: listOffice, api: listOffice,
rowKey: 'id', rowKey: 'id',
columns, columns,
formConfig: { formConfig: {
labelWidth: 120, labelWidth: 120,
schemas: searchFormSchema, schemas: searchFormSchema,
autoSubmitOnEnter: true, autoSubmitOnEnter: true,
fieldMapToTime: [['dateRange', ['beginTime', 'endTime'], 'YYYY-MM-DD']] fieldMapToTime: [['dateRange', ['beginTime', 'endTime'], 'YYYY-MM-DD']]
}, },
rowSelection: { type: 'checkbox' }, rowSelection: { type: 'checkbox' },
useSearchForm: true, useSearchForm: true,
showTableSetting: true, showTableSetting: true,
bordered: true, bordered: true,
clickToRowSelect: false, clickToRowSelect: false,
showIndexColumn: false, showIndexColumn: false,
actionColumn: { actionColumn: {
width: 220, width: 220,
title: '操作', title: '操作',
dataIndex: 'action', dataIndex: 'action',
slots: { customRender: 'action' }, slots: { customRender: 'action' },
fixed: false fixed: false
}, },
handleSearchInfoFn: () => clearSelectedRowKeys() handleSearchInfoFn: () => clearSelectedRowKeys()
}); });
/** 处理多选框选中数据 */ /** 处理多选框选中数据 */
function handleSelectionChange(selection?: Recordable) { function handleSelectionChange(selection?: Recordable) {
const rowSelection = toRaw(selection?.keys) || []; const rowSelection = toRaw(selection?.keys) || [];
state.single = rowSelection.length != 1; state.single = rowSelection.length != 1;
state.multiple = !rowSelection.length; state.multiple = !rowSelection.length;
} }
/** 新增按钮操作,行内新增与工具栏局域新增通用 */ /** 新增按钮操作,行内新增与工具栏局域新增通用 */
function handleAdd() { function handleAdd() {
openModal(true,{ _tag: 'add' }); openModal(true,{ _tag: 'add' });
} }
/** 编辑按钮操作,行内编辑 */ /** 编辑按钮操作,行内编辑 */
function handleEdit(record?: Recordable) { function handleEdit(record?: Recordable) {
record = record || { id: getSelectRowKeys() }; record = record || { id: getSelectRowKeys() };
openModal(true, { _tag: 'edit', record }); openModal(true, { _tag: 'edit', record });
} }
/** 删除按钮操作,行内删除 */ /** 删除按钮操作,行内删除 */
async function handleDel(record?: Recordable) { async function handleDel(record?: Recordable) {
const id = record?.id || getSelectRowKeys(); const id = record?.id || getSelectRowKeys();
createConfirm({ createConfirm({
iconType: 'warning', iconType: 'warning',
title: '警告', title: '警告',
content: `是否确认删除科室编号为${id}科室吗?`, content: `是否确认删除科室编号为${id}科室吗?`,
onOk: async () => { onOk: async () => {
await delOffice(id); await delOffice(id);
createMessage.success('删除成功!'); createMessage.success('删除成功!');
handleRefreshTable(); handleRefreshTable();
} }
}); });
} }
/** 处理表格刷新 */ /** 处理表格刷新 */
function handleRefreshTable() { function handleRefreshTable() {
clearSelectedRowKeys(); clearSelectedRowKeys();
reload(); reload();
} }
</script> </script>

20
src/views/common/office/office.data.ts

@ -2,8 +2,6 @@ import { BasicColumn } from '/@/components/Table';
import { FormSchema } from '/@/components/Table'; import { FormSchema } from '/@/components/Table';
import { h } from 'vue'; import { h } from 'vue';
import { Tag } from 'ant-design-vue'; import { Tag } from 'ant-design-vue';
import { listHospital } from '/@/api/platform/common/controller/hospital';
import { listOrg } from '/@/api/platform/common/controller/org';
export const columns: BasicColumn[] = [ export const columns: BasicColumn[] = [
{ {
@ -127,6 +125,7 @@ export const formSchema: FormSchema[] = [
field: 'orgType', field: 'orgType',
label: '所属组织类型', label: '所属组织类型',
component: 'Select', component: 'Select',
defaultValue: '1',
componentProps: { componentProps: {
options: [ options: [
{ label: '医院', value: '1' }, { label: '医院', value: '1' },
@ -139,17 +138,12 @@ export const formSchema: FormSchema[] = [
field: 'orgId', field: 'orgId',
label: '所属组织', label: '所属组织',
component: 'ApiSelect', component: 'ApiSelect',
required: true, componentProps: {
renderComponentContent: ({ schema, values, model, field }) => { resultField: 'data',
const organType = model.orgType; labelField: 'name',
const dataApi = ~~organType === 1 ? listHospital : listOrg; valueField: 'id'
schema.componentProps = { },
api: dataApi, required: true
labelField: 'name',
valueField: 'id',
resultField: 'data'
};
}
}, },
{ {
field: 'manageName', field: 'manageName',

117
src/views/common/org/OrgModal.vue

@ -8,72 +8,71 @@
</BasicModal> </BasicModal>
</template> </template>
<script lang="ts" setup> <script lang="ts" setup>
/** /**
* 提供模板规范代码参考,请尽量保证编写代码风格跟模板规范代码一致 * 提供模板规范代码参考,请尽量保证编写代码风格跟模板规范代码一致
* 采用vben-动态表格表单封装组件编写,采用 setup 写法 * 采用vben-动态表格表单封装组件编写,采用 setup 写法
* Copyright © 2020-2022 <a href="http://www.entfrm.com/">entfrm</a> All rights reserved. * Copyright © 2020-2022 <a href="http://www.entfrm.com/">entfrm</a> All rights reserved.
* author entfrm开发团队-王翔 * author entfrm开发团队-王翔
*/ */
import { ref, unref } from 'vue'; import { ref, unref } from 'vue';
import { BasicForm, useForm } from '/@/components/Form'; import { BasicForm, useForm } from '/@/components/Form';
import { institutionFormSchema } from './org.data'; import { institutionFormSchema } from './org.data';
import {addOrg, delOrg,getOrg,editOrg} from '/@/api/platform/common/controller/org'; import { addOrg, getOrg, editOrg } from '/@/api/platform/common/controller/org';
import { BasicModal, ModalProps, useModalInner } from '/@/components/Modal'; import { BasicModal, ModalProps, useModalInner } from '/@/components/Modal';
import { isEmpty } from '/@/utils/is';
/** 通用变量统一声明区域 */ /** 通用变量统一声明区域 */
const tag = ref<Nullable<string>>(''); const tag = ref<Nullable<string>>('');
/** https://v3.cn.vuejs.org/api/options-data.html#emits */ /** https://v3.cn.vuejs.org/api/options-data.html#emits */
const emit = defineEmits(['success', 'register']); const emit = defineEmits(['success', 'register']);
const [registerForm, { resetFields, setFieldsValue, validate, clearValidate, updateSchema }] = useForm({ const [registerForm, { resetFields, setFieldsValue, validate, clearValidate, updateSchema }] = useForm({
labelWidth: 100, labelWidth: 100,
schemas: institutionFormSchema, schemas: institutionFormSchema,
showActionButtonGroup: false, showActionButtonGroup: false,
baseColProps: { span: 24 } baseColProps: { span: 24 }
}); });
const [registerModal, { setModalProps, closeModal }] = useModalInner(async (data: WindowInnerData = { _tag: '' }) => { const [registerModal, { setModalProps, closeModal }] = useModalInner(async (data: WindowInnerData = { _tag: '' }) => {
// //
await resetFields(); await resetFields();
await clearValidate(); await clearValidate();
// //
tag.value = data._tag; tag.value = data._tag;
const id = data.record?.id; const id = data.record?.id;
const props: Partial<ModalProps> = { confirmLoading: false }; const props: Partial<ModalProps> = { confirmLoading: false };
// tag
switch (unref(tag)) {
case 'add':
props.title = '新增机构';
break;
case 'edit':
props.title = '编辑机构';
await setFieldsValue(await getOrg(id));
break;
}
// :
setModalProps(props);
});
/** 处理弹出框提交 */
async function handleSubmit() {
try {
//
const formData = await validate();
//
setModalProps({ confirmLoading: true });
// tag // tag
switch (unref(tag)) { switch (unref(tag)) {
case 'add': case 'add':
await addOrg(formData); props.title = '新增机构';
break; break;
case 'edit': case 'edit':
await editOrg(formData); props.title = '编辑机构';
await setFieldsValue(await getOrg(id));
break; break;
} }
// // :
closeModal(); setModalProps(props);
emit('success'); });
} finally {
setModalProps({ confirmLoading: false }); /** 处理弹出框提交 */
async function handleSubmit() {
try {
//
const formData = await validate();
//
setModalProps({ confirmLoading: true });
// tag
switch (unref(tag)) {
case 'add':
await addOrg(formData);
break;
case 'edit':
await editOrg(formData);
break;
}
//
closeModal();
emit('success');
} finally {
setModalProps({ confirmLoading: false });
}
} }
}
</script> </script>

5
src/views/common/org/index.vue

@ -4,9 +4,8 @@
@selection-change="handleSelectionChange" @selection-change="handleSelectionChange"
> >
<template #toolbar> <template #toolbar>
<a-button <a-button type="primary"
type="primary" @click="handleAdd()"
@click="handleAdd()"
>新增机构</a-button> >新增机构</a-button>
<a-button type="primary" <a-button type="primary"
:disabled="state.single" :disabled="state.single"

400
src/views/common/org/org.data.ts

@ -1,216 +1,212 @@
import { BasicColumn } from '/@/components/Table'; import { BasicColumn } from '/@/components/Table';
import { FormSchema } from '/@/components/Table'; import { FormSchema } from '/@/components/Table';
import {h} from 'vue'; import { h } from 'vue';
import {Tag} from 'ant-design-vue'; import { Tag } from 'ant-design-vue';
import { listRegionCascade } from '/@/api/platform/system/controller/region';
export const columns: BasicColumn[] = [ export const columns: BasicColumn[] = [
{ {
title: 'ID', title: 'ID',
dataIndex: 'id', dataIndex: 'id',
width: 120, width: 120,
}, },
{ {
title: '机构名称', title: '机构名称',
dataIndex: 'name', dataIndex: 'name',
width: 120, width: 120,
}, },
{ {
title: '机构类型', title: '机构类型',
dataIndex: 'type', dataIndex: 'type',
width: 120, width: 120,
customRender: ({ record }) =>{ customRender: ({ record }) =>{
console.log(record); const type = record.type;
const type = record.type; let text = '', color = '';
let text = ''; switch (type) {
let color = ''; case '1':
switch (type) { text = '医检机构';
case '1': color = 'green';
text = '医检机构'; break;
color = 'green'; case '2':
break; text = '三甲机构';
case '2': color = 'blue';
text = '三甲机构'; break;
color = 'blue'; case '0':
break; text = '其他机构';
case '0': color = 'gray';
text = '其他机构'; break;
color = 'gray'; }
break; return h(Tag, { color: color }, () => text);
default:
text = '其他医院';
color = 'gray';
break;
}
return h(Tag, { color: color }, () => text);
}
},
{
title: '联系人',
dataIndex: 'contactsName',
width: 120,
},
{
title: '联系人电话',
dataIndex: 'contactsTel',
width: 120,
},
{
title: '联系人职称',
dataIndex: 'contactsTitle',
width: 120,
},
{
title: '详细地址',
dataIndex: 'detailAddress',
width: 180,
},
{
title: '状态',
dataIndex: 'status',
width: 100,
customRender: ({ record }) => {
const status = record.status;
const enable = status === '0';
const color = enable ? 'green' : 'red';
const text = enable ? '启用' : '禁用';
return h(Tag, { color: color }, () => text);
},
},
{
title: '创建人',
dataIndex: 'createByName',
width: 180,
},
{
title: '创建时间',
dataIndex: 'createTime',
width: 180,
} }
},
{
title: '联系人',
dataIndex: 'contactName',
width: 120,
},
{
title: '联系人电话',
dataIndex: 'contactPhone',
width: 120,
},
{
title: '联系人职称',
dataIndex: 'contactTitle',
width: 120,
},
{
title: '详细地址',
dataIndex: 'detailAddress',
width: 180,
},
{
title: '状态',
dataIndex: 'status',
width: 100,
customRender: ({ record }) => {
const status = record.status;
const enable = ~~status === 0;
const color = enable ? 'green' : 'red';
const text = enable ? '启用' : '禁用';
return h(Tag, { color: color }, () => text);
},
},
{
title: '创建人',
dataIndex: 'createByName',
width: 180,
},
{
title: '创建时间',
dataIndex: 'createTime',
width: 180,
}
]; ];
export const searchFormSchema: FormSchema[] = [ export const searchFormSchema: FormSchema[] = [
{ {
field: 'name', field: 'name',
label: '机构名称' , label: '机构名称' ,
component: 'Input', component: 'Input',
componentProps: { componentProps: {
placeholder: '请输入机构名称', placeholder: '请输入机构名称',
}, },
colProps: { span: 5 }, colProps: { span: 5 },
}, },
{ {
field: 'type', field: 'type',
label: '机构类型', label: '机构类型',
component: 'Select', component: 'Select',
defaultValue: '1',
componentProps: { componentProps: {
options: [ options: [
{label: '医检机构',value: '1'}, {label: '医检机构',value: '1'},
{label: '三甲机构',value: '2'}, {label: '三甲机构',value: '2'},
{label: '其他机构',value: '0'}, {label: '其他机构',value: '0'}
] ]
}, },
colProps: {span: 5} colProps: {span: 5}
}, },
{ {
field: 'dateRange', field: 'dateRange',
label: '创建时间', label: '创建时间',
component: 'RangePicker', component: 'RangePicker',
componentProps: { componentProps: {
style: { width:'100%' }, style: { width:'100%' },
valueFormat: 'YYYY-MM-DD', valueFormat: 'YYYY-MM-DD',
placeholder: ['开始日期','结束日期'] placeholder: ['开始日期','结束日期']
}, },
colProps: { span: 8 } colProps: { span: 8 }
} }
]; ];
export const institutionFormSchema: FormSchema[] = [ export const institutionFormSchema: FormSchema[] = [
{ {
field: 'id', field: 'id',
label: 'ID', label: 'ID',
component: 'Input', component: 'Input',
show: false, show: false,
}, },
{ {
field: 'name', field: 'name',
label: '机构名称', label: '机构名称',
component: 'Input', component: 'Input',
required: true required: true
}, },
{ {
field: 'type', field: 'type',
label: '机构类型', label: '机构类型',
component: 'Select', component: 'Select',
defaultValue: '0', defaultValue: '0',
componentProps: { componentProps: {
options: [ options: [
{label: '医检机构',value: '1'}, { label: '医检机构', value: '1' },
{label: '三甲机构',value: '2'}, { label: '三甲机构', value: '2' },
{label: '其他机构',value: '0'}, { label: '其他机构', value: '0' },
] ]
}, },
required: true, required: true
}, },
{ {
field: 'contactsName', field: 'contactName',
label: '联系人名称', label: '联系人名称',
component: 'Input', component: 'Input',
required: true required: true
}, },
{ {
field: 'contactsTel', field: 'contactPhone',
label: '联系人电话', label: '联系人电话',
component: 'Input', component: 'Input',
rules: [
rules: [ {
{ pattern: new RegExp('^1[3|4|5|6|7|8|9][0-9]\\d{8}$'),
pattern: new RegExp('^1[3|4|5|6|7|8|9][0-9]\\d{8}$'), message: '请输入正确的手机号',
message: '请输入正确的手机号', validateTrigger: 'change',
validateTrigger: 'change',
required: true
}
],
},
{
field: 'contactsTitle',
label: '联系人职称',
component: 'Input',
required: true required: true
}, }
/* { ],
field: 'addressIds', },
label: '地址', {
component: 'ApiAddressCascader', field: 'contactTitle',
componentProps: { label: '联系人职称',
api: addressList component: 'Input',
} required: true
},*/ },
{ {
field: 'detailAddress', field: 'addressIds',
label: '详细地址', label: '城市地址',
component: 'Input', component: 'ApiCascader',
required: true componentProps: {
}, api: listRegionCascade,
{ asyncFetchParamKey: 'parentId',
field: 'status', labelField: 'name',
label: '状态', valueField: 'id',
component: 'RadioButtonGroup', initFetchParams: {
defaultValue: '0', parentId: '0'
componentProps: { }
options: [
{ label: '启用', value: '0' },
{ label: '禁用', value: '1' },
],
},
},
{
label: '备注',
field: 'remarks',
component: 'InputTextArea',
} }
},
{
field: 'detailAddress',
label: '详细地址',
component: 'Input',
required: true
},
{
field: 'status',
label: '状态',
component: 'RadioButtonGroup',
defaultValue: '0',
componentProps: {
options: [
{ label: '启用', value: '0' },
{ label: '禁用', value: '1' },
],
},
},
{
label: '备注',
field: 'remarks',
component: 'InputTextArea',
}
]; ];
Loading…
Cancel
Save