Browse Source

🧬更新菜单模块

master
wangxiang 3 years ago
parent
commit
9626187f12
  1. 7
      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. 18
      src/views/common/doctor/doctor.data.ts
  6. 3
      src/views/common/hospital/index.vue
  7. 27
      src/views/common/office/OfficeModal.vue
  8. 3
      src/views/common/office/index.vue
  9. 18
      src/views/common/office/office.data.ts
  10. 3
      src/views/common/org/OrgModal.vue
  11. 3
      src/views/common/org/index.vue
  12. 50
      src/views/common/org/org.data.ts

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

@ -22,6 +22,13 @@ export const listRegion = (params?: Partial<RegionParams>) => { @@ -22,6 +22,13 @@ export const listRegion = (params?: Partial<RegionParams>) => {
return defHttp.get({ url: url, 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 addRegion = (params:Partial<Region>) => defHttp.post({ url: Api.add,data:params });
export const editRegion = (params:Partial<Region>) => defHttp.put({ url: Api.edit,data:params });

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

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

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

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

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

@ -17,14 +17,16 @@ @@ -17,14 +17,16 @@
import { ref, unref } from 'vue';
import { BasicForm, useForm } from '/@/components/Form';
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 { listHospital } from '/@/api/platform/common/controller/hospital';
import { listOrg } from '/@/api/platform/common/controller/org';
/** 通用变量统一声明区域 */
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({
const [registerForm, { resetFields, setFieldsValue, validate, clearValidate, updateSchema, getFieldsValue }] = useForm({
labelWidth: 100,
schemas: formSchema,
showActionButtonGroup: false,
@ -48,6 +50,26 @@ @@ -48,6 +50,26 @@
await setFieldsValue(await getDoctor(id));
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);
});

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

@ -2,9 +2,6 @@ import { BasicColumn } from '/@/components/Table'; @@ -2,9 +2,6 @@ import { BasicColumn } from '/@/components/Table';
import { FormSchema } from '/@/components/Table';
import { h } from '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[] = [
{
@ -193,17 +190,12 @@ export const formSchema: FormSchema[] = [ @@ -193,17 +190,12 @@ export const formSchema: FormSchema[] = [
field: 'orgId',
label: '所属组织',
component: 'ApiSelect',
required: true,
renderComponentContent: ({ schema, values, model, field }) => {
const organType = model.orgType;
const dataApi = ~~organType === 1 ? listHospital : listOrg;
schema.componentProps = {
api: dataApi,
componentProps: {
resultField: 'data',
labelField: 'name',
valueField: 'id',
resultField: 'data'
};
}
valueField: 'id'
},
required: true
},
{
field: 'status',

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

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

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

@ -17,15 +17,16 @@ @@ -17,15 +17,16 @@
import { ref, unref } from 'vue';
import { BasicForm, useForm } from '/@/components/Form';
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 { 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>>('');
/** https://v3.cn.vuejs.org/api/options-data.html#emits */
const emit = defineEmits(['success', 'register']);
const [registerForm, { resetFields, setFieldsValue, validate, clearValidate, updateSchema }] = useForm({
const [registerForm, { resetFields, setFieldsValue, validate, clearValidate, updateSchema, getFieldsValue }] = useForm({
labelWidth: 100,
schemas: formSchema,
showActionButtonGroup: false,
@ -49,6 +50,26 @@ const [registerModal, { setModalProps, closeModal }] = useModalInner(async (data @@ -49,6 +50,26 @@ const [registerModal, { setModalProps, closeModal }] = useModalInner(async (data
await setFieldsValue(await getOffice(id));
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);
});

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

@ -4,8 +4,7 @@ @@ -4,8 +4,7 @@
@selection-change="handleSelectionChange"
>
<template #toolbar>
<a-button
type="primary"
<a-button type="primary"
@click="handleAdd()"
>新增科室</a-button>
<a-button type="primary"

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

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

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

@ -17,9 +17,8 @@ @@ -17,9 +17,8 @@
import { ref, unref } from 'vue';
import { BasicForm, useForm } from '/@/components/Form';
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 { isEmpty } from '/@/utils/is';
/** 通用变量统一声明区域 */
const tag = ref<Nullable<string>>('');

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

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

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

@ -2,7 +2,7 @@ import { BasicColumn } from '/@/components/Table'; @@ -2,7 +2,7 @@ import { BasicColumn } from '/@/components/Table';
import { FormSchema } from '/@/components/Table';
import { h } from 'vue';
import { Tag } from 'ant-design-vue';
import { listRegionCascade } from '/@/api/platform/system/controller/region';
export const columns: BasicColumn[] = [
{
@ -20,10 +20,8 @@ export const columns: BasicColumn[] = [ @@ -20,10 +20,8 @@ export const columns: BasicColumn[] = [
dataIndex: 'type',
width: 120,
customRender: ({ record }) =>{
console.log(record);
const type = record.type;
let text = '';
let color = '';
let text = '', color = '';
switch (type) {
case '1':
text = '医检机构';
@ -37,28 +35,23 @@ export const columns: BasicColumn[] = [ @@ -37,28 +35,23 @@ export const columns: BasicColumn[] = [
text = '其他机构';
color = 'gray';
break;
default:
text = '其他医院';
color = 'gray';
break;
}
return h(Tag, { color: color }, () => text);
}
},
{
title: '联系人',
dataIndex: 'contactsName',
dataIndex: 'contactName',
width: 120,
},
{
title: '联系人电话',
dataIndex: 'contactsTel',
dataIndex: 'contactPhone',
width: 120,
},
{
title: '联系人职称',
dataIndex: 'contactsTitle',
dataIndex: 'contactTitle',
width: 120,
},
{
@ -72,7 +65,7 @@ export const columns: BasicColumn[] = [ @@ -72,7 +65,7 @@ export const columns: BasicColumn[] = [
width: 100,
customRender: ({ record }) => {
const status = record.status;
const enable = status === '0';
const enable = ~~status === 0;
const color = enable ? 'green' : 'red';
const text = enable ? '启用' : '禁用';
return h(Tag, { color: color }, () => text);
@ -104,12 +97,12 @@ export const searchFormSchema: FormSchema[] = [ @@ -104,12 +97,12 @@ export const searchFormSchema: FormSchema[] = [
field: 'type',
label: '机构类型',
component: 'Select',
defaultValue: '1',
componentProps: {
options: [
{label: '医检机构',value: '1'},
{label: '三甲机构',value: '2'},
{label: '其他机构',value: '0'},
{label: '其他机构',value: '0'}
]
},
colProps: {span: 5}
@ -152,19 +145,18 @@ export const institutionFormSchema: FormSchema[] = [ @@ -152,19 +145,18 @@ export const institutionFormSchema: FormSchema[] = [
{ label: '其他机构', value: '0' },
]
},
required: true,
required: true
},
{
field: 'contactsName',
field: 'contactName',
label: '联系人名称',
component: 'Input',
required: true
},
{
field: 'contactsTel',
field: 'contactPhone',
label: '联系人电话',
component: 'Input',
rules: [
{
pattern: new RegExp('^1[3|4|5|6|7|8|9][0-9]\\d{8}$'),
@ -173,23 +165,27 @@ export const institutionFormSchema: FormSchema[] = [ @@ -173,23 +165,27 @@ export const institutionFormSchema: FormSchema[] = [
required: true
}
],
},
{
field: 'contactsTitle',
field: 'contactTitle',
label: '联系人职称',
component: 'Input',
required: true
},
/* {
{
field: 'addressIds',
label: '地址',
component: 'ApiAddressCascader',
label: '城市地址',
component: 'ApiCascader',
componentProps: {
api: addressList
api: listRegionCascade,
asyncFetchParamKey: 'parentId',
labelField: 'name',
valueField: 'id',
initFetchParams: {
parentId: '0'
}
}
},*/
},
{
field: 'detailAddress',
label: '详细地址',

Loading…
Cancel
Save