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. 18
      src/views/common/doctor/doctor.data.ts
  6. 3
      src/views/common/hospital/index.vue
  7. 57
      src/views/common/office/OfficeModal.vue
  8. 69
      src/views/common/office/index.vue
  9. 18
      src/views/common/office/office.data.ts
  10. 35
      src/views/common/org/OrgModal.vue
  11. 3
      src/views/common/org/index.vue
  12. 60
      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>) => { @@ -22,9 +22,16 @@ export const listRegion = (params?: Partial<RegionParams>) => {
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}` });

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"

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

@ -8,30 +8,31 @@ @@ -8,30 +8,31 @@
</BasicModal>
</template>
<script lang="ts" setup>
/**
/**
* 提供模板规范代码参考,请尽量保证编写代码风格跟模板规范代码一致
* 采用vben-动态表格表单封装组件编写,采用 setup 写法
* Copyright © 2020-2022 <a href="http://www.entfrm.com/">entfrm</a> All rights reserved.
* author entfrm开发团队-王翔
*/
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 { BasicModal, ModalProps, useModalInner } from '/@/components/Modal';
import { isEmpty } from '/@/utils/is';
import { ref, unref } from 'vue';
import { BasicForm, useForm } from '/@/components/Form';
import { formSchema } from './office.data';
import { addOffice, editOffice, getOffice } from '/@/api/platform/common/controller/office';
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 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, getFieldsValue }] = useForm({
labelWidth: 100,
schemas: formSchema,
showActionButtonGroup: false,
baseColProps: { span: 24 }
});
const [registerModal, { setModalProps, closeModal }] = useModalInner(async (data: WindowInnerData = { _tag: '' }) => {
});
const [registerModal, { setModalProps, closeModal }] = useModalInner(async (data: WindowInnerData = { _tag: '' }) => {
//
await resetFields();
await clearValidate();
@ -49,12 +50,32 @@ const [registerModal, { setModalProps, closeModal }] = useModalInner(async (data @@ -49,12 +50,32 @@ 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);
});
});
/** 处理弹出框提交 */
async function handleSubmit() {
/** 处理弹出框提交 */
async function handleSubmit() {
try {
//
const formData = await validate();
@ -75,5 +96,5 @@ async function handleSubmit() { @@ -75,5 +96,5 @@ async function handleSubmit() {
} finally {
setModalProps({ confirmLoading: false });
}
}
}
</script>

69
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"
@ -39,36 +38,36 @@ @@ -39,36 +38,36 @@
</template>
<script lang="ts" setup>
/**
/**
* 提供模板规范代码参考,请尽量保证编写代码风格跟模板规范代码一致
* 采用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/common/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 { reactive, toRaw } from 'vue';
import { BasicTable, useTable, TableAction } from '/@/components/Table';
import {listOffice, delOffice} from '/@/api/platform/common/controller/office';
import { useModal } from '/@/components/Modal';
import { columns, searchFormSchema } from './office.data';
import { useMessage } from '/@/hooks/web/useMessage';
import OfficeModal from './OfficeModal.vue';
/** 类型规范统一声明定义区域 */
interface TableState {
/** 类型规范统一声明定义区域 */
interface TableState {
single: boolean;
multiple: boolean;
}
}
/** 通用变量统一声明区域 */
const state = reactive<TableState>({
/** 通用变量统一声明区域 */
const state = reactive<TableState>({
//
single: true,
//
multiple: true
});
const { createConfirm, createMessage } = useMessage();
const [registerModal, { openModal }] = useModal();
const [registerTable, { reload, clearSelectedRowKeys, getSelectRowKeys }] = useTable({
});
const { createConfirm, createMessage } = useMessage();
const [registerModal, { openModal }] = useModal();
const [registerTable, { reload, clearSelectedRowKeys, getSelectRowKeys }] = useTable({
title: '医生列表',
api: listOffice,
rowKey: 'id',
@ -93,28 +92,28 @@ const [registerTable, { reload, clearSelectedRowKeys, getSelectRowKeys }] = useT @@ -93,28 +92,28 @@ const [registerTable, { reload, clearSelectedRowKeys, getSelectRowKeys }] = useT
fixed: false
},
handleSearchInfoFn: () => clearSelectedRowKeys()
});
});
/** 处理多选框选中数据 */
function handleSelectionChange(selection?: Recordable) {
/** 处理多选框选中数据 */
function handleSelectionChange(selection?: Recordable) {
const rowSelection = toRaw(selection?.keys) || [];
state.single = rowSelection.length != 1;
state.multiple = !rowSelection.length;
}
}
/** 新增按钮操作,行内新增与工具栏局域新增通用 */
function handleAdd() {
/** 新增按钮操作,行内新增与工具栏局域新增通用 */
function handleAdd() {
openModal(true,{ _tag: 'add' });
}
}
/** 编辑按钮操作,行内编辑 */
function handleEdit(record?: Recordable) {
/** 编辑按钮操作,行内编辑 */
function handleEdit(record?: Recordable) {
record = record || { id: getSelectRowKeys() };
openModal(true, { _tag: 'edit', record });
}
}
/** 删除按钮操作,行内删除 */
async function handleDel(record?: Recordable) {
/** 删除按钮操作,行内删除 */
async function handleDel(record?: Recordable) {
const id = record?.id || getSelectRowKeys();
createConfirm({
iconType: 'warning',
@ -126,11 +125,11 @@ async function handleDel(record?: Recordable) { @@ -126,11 +125,11 @@ async function handleDel(record?: Recordable) {
handleRefreshTable();
}
});
}
}
/** 处理表格刷新 */
function handleRefreshTable() {
/** 处理表格刷新 */
function handleRefreshTable() {
clearSelectedRowKeys();
reload();
}
}
</script>

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',

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

@ -8,30 +8,29 @@ @@ -8,30 +8,29 @@
</BasicModal>
</template>
<script lang="ts" setup>
/**
/**
* 提供模板规范代码参考,请尽量保证编写代码风格跟模板规范代码一致
* 采用vben-动态表格表单封装组件编写,采用 setup 写法
* Copyright © 2020-2022 <a href="http://www.entfrm.com/">entfrm</a> All rights reserved.
* author entfrm开发团队-王翔
*/
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 { BasicModal, ModalProps, useModalInner } from '/@/components/Modal';
import { isEmpty } from '/@/utils/is';
import { ref, unref } from 'vue';
import { BasicForm, useForm } from '/@/components/Form';
import { institutionFormSchema } from './org.data';
import { addOrg, getOrg, editOrg } from '/@/api/platform/common/controller/org';
import { BasicModal, ModalProps, useModalInner } from '/@/components/Modal';
/** 通用变量统一声明区域 */
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 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,
baseColProps: { span: 24 }
});
const [registerModal, { setModalProps, closeModal }] = useModalInner(async (data: WindowInnerData = { _tag: '' }) => {
});
const [registerModal, { setModalProps, closeModal }] = useModalInner(async (data: WindowInnerData = { _tag: '' }) => {
//
await resetFields();
await clearValidate();
@ -51,10 +50,10 @@ const [registerModal, { setModalProps, closeModal }] = useModalInner(async (data @@ -51,10 +50,10 @@ const [registerModal, { setModalProps, closeModal }] = useModalInner(async (data
}
// :
setModalProps(props);
});
});
/** 处理弹出框提交 */
async function handleSubmit() {
/** 处理弹出框提交 */
async function handleSubmit() {
try {
//
const formData = await validate();
@ -75,5 +74,5 @@ async function handleSubmit() { @@ -75,5 +74,5 @@ async function handleSubmit() {
} finally {
setModalProps({ confirmLoading: false });
}
}
}
</script>

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"

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

@ -1,8 +1,8 @@ @@ -1,8 +1,8 @@
import { BasicColumn } from '/@/components/Table';
import { FormSchema } from '/@/components/Table';
import {h} from 'vue';
import {Tag} from 'ant-design-vue';
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}
@ -147,24 +140,23 @@ export const institutionFormSchema: FormSchema[] = [ @@ -147,24 +140,23 @@ export const institutionFormSchema: FormSchema[] = [
defaultValue: '0',
componentProps: {
options: [
{label: '医检机构',value: '1'},
{label: '三甲机构',value: '2'},
{label: '其他机构',value: '0'},
{ label: '医检机构', value: '1' },
{ label: '三甲机构', value: '2' },
{ 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