提交 d46b853a authored 作者: leon's avatar leon

schema医院id属性抽出

上级 47bfb141
...@@ -3,6 +3,7 @@ ...@@ -3,6 +3,7 @@
*/ */
import * as DistributorApi from '/@/api/system/distributorApi'; import * as DistributorApi from '/@/api/system/distributorApi';
import get from 'lodash.get'; import get from 'lodash.get';
import * as HospitalApi from '/@/api/system/hospitalApi';
const getDistributorId = ({ colProps }) => { const getDistributorId = ({ colProps }) => {
return { return {
...@@ -30,4 +31,30 @@ const getDistributorId = ({ colProps }) => { ...@@ -30,4 +31,30 @@ const getDistributorId = ({ colProps }) => {
}; };
}; };
export { getDistributorId }; const getHospitalId = ({ colProps }) => {
return {
field: 'hospitalId',
label: '医院',
defaultValue: undefined,
form: {
componentProps: {
labelInValue: true,
api: HospitalApi.all,
params: {},
resultField: 'records',
labelField: 'name',
valueField: 'id',
allowClear: false,
placeholder: '医院',
},
colProps,
component: 'ApiSelect',
rules: [{ required: true, type: 'object', message: '请输入医院!' }],
},
table: {
customRender: ({ text, record }) => get(record, 'hospital.name') || text,
},
};
};
export { getDistributorId, getHospitalId };
...@@ -8,8 +8,7 @@ ...@@ -8,8 +8,7 @@
import { BasicColumn } from '/@/components/Table'; import { BasicColumn } from '/@/components/Table';
import { FormSchema } from '/@/components/Table'; import { FormSchema } from '/@/components/Table';
import get from 'lodash.get'; import { getHospitalId } from '/@/commonSchemaProperty';
import * as HospitalApi from '/@/api/system/hospitalApi';
export enum YesNoEnum { export enum YesNoEnum {
YES = '是', YES = '是',
...@@ -56,8 +55,7 @@ export const schema = { ...@@ -56,8 +55,7 @@ export const schema = {
component: 'InputNumber', component: 'InputNumber',
rules: [{ required: true, message: '请输入ID系统自动生成!' }], rules: [{ required: true, message: '请输入ID系统自动生成!' }],
}, },
table: { table: {},
},
}, },
{ {
field: 'distributorId', field: 'distributorId',
...@@ -72,8 +70,7 @@ export const schema = { ...@@ -72,8 +70,7 @@ export const schema = {
component: 'InputNumber', component: 'InputNumber',
rules: [{ required: true, message: '请输入经销商id!' }], rules: [{ required: true, message: '请输入经销商id!' }],
}, },
table: { table: {},
},
}, },
{ {
field: 'orderSn', field: 'orderSn',
...@@ -88,8 +85,7 @@ export const schema = { ...@@ -88,8 +85,7 @@ export const schema = {
component: 'Input', component: 'Input',
rules: [{ required: true, message: '请输入订单编号!' }], rules: [{ required: true, message: '请输入订单编号!' }],
}, },
table: { table: {},
},
}, },
{ {
field: 'productLineName', field: 'productLineName',
...@@ -103,31 +99,9 @@ export const schema = { ...@@ -103,31 +99,9 @@ export const schema = {
colProps, colProps,
component: 'Input', component: 'Input',
}, },
table: { table: {},
},
},
{
field: 'hospitalId',
label: '医院id',
defaultValue: undefined,
form: {
componentProps: {
labelInValue: true,
api: HospitalApi.all,
params: {},
resultField: 'records',
labelField: 'id',
valueField: 'id',
allowClear: true,
placeholder: '医院id',
},
colProps,
component: 'ApiSelect',
},
table: {
customRender: ({ text, record }) => get(record, 'hospital.name') || text,
},
}, },
getHospitalId({ colProps }),
{ {
field: 'saleUserId', field: 'saleUserId',
label: '业务员id', label: '业务员id',
...@@ -140,8 +114,7 @@ export const schema = { ...@@ -140,8 +114,7 @@ export const schema = {
colProps, colProps,
component: 'InputNumber', component: 'InputNumber',
}, },
table: { table: {},
},
}, },
{ {
field: 'saleUserName', field: 'saleUserName',
...@@ -155,8 +128,7 @@ export const schema = { ...@@ -155,8 +128,7 @@ export const schema = {
colProps, colProps,
component: 'Input', component: 'Input',
}, },
table: { table: {},
},
}, },
{ {
field: 'doctorId', field: 'doctorId',
...@@ -170,8 +142,7 @@ export const schema = { ...@@ -170,8 +142,7 @@ export const schema = {
colProps, colProps,
component: 'InputNumber', component: 'InputNumber',
}, },
table: { table: {},
},
}, },
{ {
field: 'doctorName', field: 'doctorName',
...@@ -185,8 +156,7 @@ export const schema = { ...@@ -185,8 +156,7 @@ export const schema = {
colProps, colProps,
component: 'Input', component: 'Input',
}, },
table: { table: {},
},
}, },
{ {
field: 'surgicalName', field: 'surgicalName',
...@@ -200,8 +170,7 @@ export const schema = { ...@@ -200,8 +170,7 @@ export const schema = {
colProps, colProps,
component: 'Input', component: 'Input',
}, },
table: { table: {},
},
}, },
{ {
field: 'surgicalTime', field: 'surgicalTime',
...@@ -217,8 +186,7 @@ export const schema = { ...@@ -217,8 +186,7 @@ export const schema = {
showTime: true, showTime: true,
}, },
}, },
table: { table: {},
},
}, },
{ {
field: 'deliveryTime', field: 'deliveryTime',
...@@ -234,8 +202,7 @@ export const schema = { ...@@ -234,8 +202,7 @@ export const schema = {
showTime: true, showTime: true,
}, },
}, },
table: { table: {},
},
}, },
{ {
field: 'needTool', field: 'needTool',
...@@ -252,7 +219,7 @@ export const schema = { ...@@ -252,7 +219,7 @@ export const schema = {
}, },
table: { table: {
customRender: ({ text }) => { customRender: ({ text }) => {
const option = YesNoEnumOptions.find((item) => item.value === text) const option = YesNoEnumOptions.find((item) => item.value === text);
return option ? option.label : text; return option ? option.label : text;
}, },
}, },
...@@ -269,8 +236,7 @@ export const schema = { ...@@ -269,8 +236,7 @@ export const schema = {
colProps, colProps,
component: 'Input', component: 'Input',
}, },
table: { table: {},
},
}, },
{ {
field: 'receiveName', field: 'receiveName',
...@@ -284,8 +250,7 @@ export const schema = { ...@@ -284,8 +250,7 @@ export const schema = {
colProps, colProps,
component: 'Input', component: 'Input',
}, },
table: { table: {},
},
}, },
{ {
field: 'receivePhone', field: 'receivePhone',
...@@ -299,8 +264,7 @@ export const schema = { ...@@ -299,8 +264,7 @@ export const schema = {
colProps, colProps,
component: 'Input', component: 'Input',
}, },
table: { table: {},
},
}, },
{ {
field: 'address', field: 'address',
...@@ -314,8 +278,7 @@ export const schema = { ...@@ -314,8 +278,7 @@ export const schema = {
component: 'InputTextArea', component: 'InputTextArea',
colProps: { span: 24 }, colProps: { span: 24 },
}, },
table: { table: {},
},
}, },
{ {
field: 'status', field: 'status',
...@@ -333,7 +296,7 @@ export const schema = { ...@@ -333,7 +296,7 @@ export const schema = {
}, },
table: { table: {
customRender: ({ text }) => { customRender: ({ text }) => {
const option = StatusEnumOptions.find((item) => item.value === text) const option = StatusEnumOptions.find((item) => item.value === text);
return option ? option.label : text; return option ? option.label : text;
}, },
}, },
...@@ -354,7 +317,7 @@ export const schema = { ...@@ -354,7 +317,7 @@ export const schema = {
}, },
table: { table: {
customRender: ({ text }) => { customRender: ({ text }) => {
const option = YesNoEnumOptions.find((item) => item.value === text) const option = YesNoEnumOptions.find((item) => item.value === text);
return option ? option.label : text; return option ? option.label : text;
}, },
}, },
...@@ -371,8 +334,7 @@ export const schema = { ...@@ -371,8 +334,7 @@ export const schema = {
colProps, colProps,
component: 'Input', component: 'Input',
}, },
table: { table: {},
},
}, },
{ {
field: 'deleteStatus', field: 'deleteStatus',
...@@ -389,7 +351,7 @@ export const schema = { ...@@ -389,7 +351,7 @@ export const schema = {
}, },
table: { table: {
customRender: ({ text }) => { customRender: ({ text }) => {
const option = YesNoEnumOptions.find((item) => item.value === text) const option = YesNoEnumOptions.find((item) => item.value === text);
return option ? option.label : text; return option ? option.label : text;
}, },
}, },
...@@ -407,8 +369,7 @@ export const schema = { ...@@ -407,8 +369,7 @@ export const schema = {
component: 'InputNumber', component: 'InputNumber',
rules: [{ required: true, message: '请输入操作人ID!' }], rules: [{ required: true, message: '请输入操作人ID!' }],
}, },
table: { table: {},
},
}, },
{ {
field: 'editorName', field: 'editorName',
...@@ -423,8 +384,7 @@ export const schema = { ...@@ -423,8 +384,7 @@ export const schema = {
component: 'Input', component: 'Input',
rules: [{ required: true, message: '请输入操作人!' }], rules: [{ required: true, message: '请输入操作人!' }],
}, },
table: { table: {},
},
}, },
{ {
field: 'createTime', field: 'createTime',
...@@ -441,8 +401,7 @@ export const schema = { ...@@ -441,8 +401,7 @@ export const schema = {
component: 'RangePicker', component: 'RangePicker',
rules: [{ required: true, message: '请输入CreateTime!' }], rules: [{ required: true, message: '请输入CreateTime!' }],
}, },
table: { table: {},
},
}, },
{ {
field: 'updateTime', field: 'updateTime',
...@@ -459,18 +418,116 @@ export const schema = { ...@@ -459,18 +418,116 @@ export const schema = {
component: 'RangePicker', component: 'RangePicker',
rules: [{ required: true, message: '请输入UpdateTime!' }], rules: [{ required: true, message: '请输入UpdateTime!' }],
}, },
table: { table: {},
},
}, },
], ],
}; };
const queryFields = ['id','distributorId','orderSn','productLineName','hospitalId','saleUserId','saleUserName','doctorId','doctorName','surgicalName','surgicalTime','deliveryTime','needTool','logisticsMode','receiveName','receivePhone','status','type','remark','deleteStatus','editorId','editorName','createTime','updateTime']; const queryFields = [
const editFields = ['distributorId','orderSn','productLineName','hospitalId','saleUserId','saleUserName','doctorId','doctorName','surgicalName','surgicalTime','deliveryTime','needTool','logisticsMode','receiveName','receivePhone','address','status','type','remark','deleteStatus']; 'id',
const tableFields = ['id','distributorId','orderSn','productLineName','hospitalId','saleUserId','saleUserName','doctorId','doctorName','surgicalName','surgicalTime','deliveryTime','needTool','logisticsMode','receiveName','receivePhone','address','status','type','remark','deleteStatus','editorId','editorName','createTime','updateTime']; 'distributorId',
const descriptionFields = ['id','distributorId','orderSn','productLineName','hospitalId','saleUserId','saleUserName','doctorId','doctorName','surgicalName','surgicalTime','deliveryTime','needTool','logisticsMode','receiveName','receivePhone','address','status','type','remark','deleteStatus','editorId','editorName','createTime','updateTime']; 'orderSn',
'productLineName',
'hospitalId',
'saleUserId',
'saleUserName',
'doctorId',
'doctorName',
'surgicalName',
'surgicalTime',
'deliveryTime',
'needTool',
'logisticsMode',
'receiveName',
'receivePhone',
'status',
'type',
'remark',
'deleteStatus',
'editorId',
'editorName',
'createTime',
'updateTime',
];
const editFields = [
'distributorId',
'orderSn',
'productLineName',
'hospitalId',
'saleUserId',
'saleUserName',
'doctorId',
'doctorName',
'surgicalName',
'surgicalTime',
'deliveryTime',
'needTool',
'logisticsMode',
'receiveName',
'receivePhone',
'address',
'status',
'type',
'remark',
'deleteStatus',
];
const tableFields = [
'id',
'distributorId',
'orderSn',
'productLineName',
'hospitalId',
'saleUserId',
'saleUserName',
'doctorId',
'doctorName',
'surgicalName',
'surgicalTime',
'deliveryTime',
'needTool',
'logisticsMode',
'receiveName',
'receivePhone',
'address',
'status',
'type',
'remark',
'deleteStatus',
'editorId',
'editorName',
'createTime',
'updateTime',
];
const descriptionFields = [
'id',
'distributorId',
'orderSn',
'productLineName',
'hospitalId',
'saleUserId',
'saleUserName',
'doctorId',
'doctorName',
'surgicalName',
'surgicalTime',
'deliveryTime',
'needTool',
'logisticsMode',
'receiveName',
'receivePhone',
'address',
'status',
'type',
'remark',
'deleteStatus',
'editorId',
'editorName',
'createTime',
'updateTime',
];
export const searchFormSchema: FormSchema[] = schema.properties.filter(item => queryFields.includes(item.field)) export const searchFormSchema: FormSchema[] = schema.properties
.filter((item) => queryFields.includes(item.field))
.map( .map(
({ field, label, form: { rules = [], ...formProps } }) => ({ field, label, form: { rules = [], ...formProps } }) =>
({ ({
...@@ -482,7 +539,8 @@ export const searchFormSchema: FormSchema[] = schema.properties.filter(item => q ...@@ -482,7 +539,8 @@ export const searchFormSchema: FormSchema[] = schema.properties.filter(item => q
} as FormSchema), } as FormSchema),
); );
export const formSchema: FormSchema[] = schema.properties.filter(item => editFields.includes(item.field)) export const formSchema: FormSchema[] = schema.properties
.filter((item) => editFields.includes(item.field))
.map( .map(
({ field, label, defaultValue, form }) => ({ field, label, defaultValue, form }) =>
({ ({
...@@ -494,17 +552,19 @@ export const formSchema: FormSchema[] = schema.properties.filter(item => editFie ...@@ -494,17 +552,19 @@ export const formSchema: FormSchema[] = schema.properties.filter(item => editFie
} as FormSchema), } as FormSchema),
); );
export const columns: BasicColumn[] = schema.properties.filter(item => tableFields.includes(item.field)) export const columns: BasicColumn[] = schema.properties
.filter((item) => tableFields.includes(item.field))
.map( .map(
({ field, label, table }) => ({ field, label, table }) =>
({ ({
dataIndex: field, dataIndex: field,
title: label, title: label,
...table, ...table,
} as BasicColumn) } as BasicColumn),
); );
export const descriptionColumns: BasicColumn[] = schema.properties.filter(item => descriptionFields.includes(item.field)) export const descriptionColumns: BasicColumn[] = schema.properties
.filter((item) => descriptionFields.includes(item.field))
.map( .map(
({ field, label, table }) => ({ field, label, table }) =>
({ ({
......
...@@ -8,9 +8,7 @@ ...@@ -8,9 +8,7 @@
import { BasicColumn } from '/@/components/Table'; import { BasicColumn } from '/@/components/Table';
import { FormSchema } from '/@/components/Table'; import { FormSchema } from '/@/components/Table';
import get from 'lodash.get'; import { getDistributorId, getHospitalId } from '/@/commonSchemaProperty';
import * as HospitalApi from '/@/api/system/hospitalApi';
import { getDistributorId } from '/@/commonSchemaProperty';
export enum SexEnum { export enum SexEnum {
MALE = '男', MALE = '男',
...@@ -60,29 +58,7 @@ export const schema = { ...@@ -60,29 +58,7 @@ export const schema = {
table: {}, table: {},
}, },
getDistributorId({ colProps }), getDistributorId({ colProps }),
{ getHospitalId({ colProps }),
field: 'hospitalId',
label: '医院id',
defaultValue: undefined,
form: {
componentProps: {
labelInValue: true,
api: HospitalApi.all,
params: {},
resultField: 'records',
labelField: 'name',
valueField: 'id',
allowClear: false,
placeholder: '医院id',
},
colProps,
component: 'ApiSelect',
rules: [{ required: true, type: 'object', message: '请输入医院id!' }],
},
table: {
customRender: ({ text, record }) => get(record, 'hospital.name') || text,
},
},
{ {
field: 'name', field: 'name',
label: '医生名称', label: '医生名称',
......
...@@ -303,7 +303,7 @@ export const schema = { ...@@ -303,7 +303,7 @@ export const schema = {
}; };
const queryFields = [ const queryFields = [
'distributorId', // 'distributorId',
'name', 'name',
'abbreviationName', 'abbreviationName',
'code', 'code',
...@@ -335,7 +335,7 @@ const editFields = [ ...@@ -335,7 +335,7 @@ const editFields = [
'status', 'status',
]; ];
const tableFields = [ const tableFields = [
'distributorId', // 'distributorId',
'name', 'name',
'abbreviationName', 'abbreviationName',
'code', 'code',
...@@ -355,7 +355,7 @@ const tableFields = [ ...@@ -355,7 +355,7 @@ const tableFields = [
]; ];
const descriptionFields = [ const descriptionFields = [
'id', 'id',
'distributorId', // 'distributorId',
'name', 'name',
'abbreviationName', 'abbreviationName',
'code', 'code',
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论