update
init
This commit is contained in:
@@ -0,0 +1,120 @@
|
||||
import { defHttp } from '/@/utils/http/axios';
|
||||
import { useMessage } from '/@/hooks/web/useMessage';
|
||||
|
||||
const { createConfirm } = useMessage();
|
||||
|
||||
enum Api {
|
||||
list = '/sys/healthUserDoctorEx/list',
|
||||
save = '/sys/healthUserDoctorEx/add',
|
||||
edit = '/sys/healthUserDoctorEx/edit',
|
||||
deleteOne = '/sys/healthUserDoctorEx/delete',
|
||||
deleteBatch = '/sys/healthUserDoctorEx/deleteBatch',
|
||||
importExcel = '/sys/healthUserDoctorEx/importExcel',
|
||||
exportXls = '/sys/healthUserDoctorEx/exportXls',
|
||||
queryById = '/sys/healthUserDoctorEx/queryById',
|
||||
}
|
||||
|
||||
/**
|
||||
* 导出api
|
||||
* @param params
|
||||
*/
|
||||
export const getExportUrl = Api.exportXls;
|
||||
|
||||
/**
|
||||
* 编辑页面回显
|
||||
*/
|
||||
export const queryByIdUrl = Api.queryById;
|
||||
|
||||
/**
|
||||
* 导入api
|
||||
*/
|
||||
export const getImportUrl = Api.importExcel;
|
||||
|
||||
/**
|
||||
* 列表接口
|
||||
* @param params
|
||||
*/
|
||||
export const list = (params) => defHttp.get({ url: Api.list, params });
|
||||
|
||||
/**
|
||||
* 请求编辑数据
|
||||
*/
|
||||
export const resEditData = async (params, handleSuccess) => {
|
||||
return await defHttp.get({ url: Api.queryById, params });
|
||||
};
|
||||
|
||||
/**
|
||||
* 删除单个
|
||||
*/
|
||||
export const deleteOne = (params, handleSuccess) => {
|
||||
return defHttp.delete({ url: Api.deleteOne, params }, { joinParamsToUrl: true }).then(() => {
|
||||
handleSuccess();
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* 批量删除
|
||||
* @param params
|
||||
*/
|
||||
export const batchDelete = (params, handleSuccess) => {
|
||||
createConfirm({
|
||||
iconType: 'warning',
|
||||
title: '确认删除',
|
||||
content: '是否删除选中数据',
|
||||
okText: '确认',
|
||||
cancelText: '取消',
|
||||
onOk: () => {
|
||||
return defHttp.delete({ url: Api.deleteBatch, data: params }, { joinParamsToUrl: true }).then(() => {
|
||||
handleSuccess();
|
||||
});
|
||||
},
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* 保存或者更新
|
||||
* @param params
|
||||
*/
|
||||
export const saveOrUpdate = (params, isUpdate) => {
|
||||
const data = {
|
||||
healthUserDoctorEx: {
|
||||
doctorName: params.realname,
|
||||
doctorTitle: params.doctorTitle,
|
||||
doctorJob: params.doctorJob,
|
||||
hospitalId: params.hospitalId,
|
||||
hospitalName: params.hospitalName,
|
||||
officeId: params.officeName,
|
||||
doctorStatus: params.doctorStatus,
|
||||
type: params.type,
|
||||
isAccept: params.isAccept,
|
||||
goodAt: params.goodAt,
|
||||
goodAtSymptom: params.goodAtSymptom,
|
||||
goodAtSickness: params.goodAtSickness,
|
||||
experience: params.experience,
|
||||
nationality: params.nationality,
|
||||
nativePlace: params.nativePlace,
|
||||
address: params.address,
|
||||
joinWork: params.joinWork,
|
||||
healthStatus: params.healthStatus,
|
||||
eq: params.eq,
|
||||
school: params.school,
|
||||
outTime: params.outTime,
|
||||
contactAddress: params.contactAddress,
|
||||
memo: params.memo,
|
||||
onDutyTime: params.onDutyTime,
|
||||
award: params.award,
|
||||
},
|
||||
sysUserModel: {
|
||||
avatar: params.avatar,
|
||||
username: params.username,
|
||||
realname: params.realname,
|
||||
idCard: params.idCard,
|
||||
email: params.email,
|
||||
phone: params.phone,
|
||||
sex: params.sex,
|
||||
password: params.password,
|
||||
},
|
||||
},
|
||||
url = isUpdate ? Api.edit : Api.save;
|
||||
return defHttp.post({ url: url, params: data });
|
||||
};
|
||||
@@ -0,0 +1,396 @@
|
||||
import { BasicColumn, FormSchema } from '/@/components/Table';
|
||||
import { render } from '/@/utils/common/renderUtils';
|
||||
import { getHospitalsList, getOfficeList } from '../user.api';
|
||||
import { checkPassword } from '/@/hooks/checkPassword/checkPassword';
|
||||
//列表数据
|
||||
export const columns: BasicColumn[] = [
|
||||
{
|
||||
title: '专家名称',
|
||||
align: 'center',
|
||||
dataIndex: 'doctorName',
|
||||
},
|
||||
{
|
||||
title: '所属医院名称',
|
||||
align: 'center',
|
||||
dataIndex: 'hospitalName',
|
||||
},
|
||||
{
|
||||
title: '所属科室名称',
|
||||
align: 'center',
|
||||
dataIndex: 'officeName',
|
||||
},
|
||||
{
|
||||
title: '职务',
|
||||
align: 'center',
|
||||
dataIndex: 'doctorTitle',
|
||||
customRender: ({ text }) => {
|
||||
return render.renderDict(text, 'z_doct_lev');
|
||||
},
|
||||
},
|
||||
{
|
||||
title: '职称',
|
||||
align: 'center',
|
||||
dataIndex: 'doctorJob',
|
||||
customRender: ({ text }) => {
|
||||
return render.renderDict(text, 'z_doct_job');
|
||||
},
|
||||
},
|
||||
{
|
||||
title: '执业经历',
|
||||
align: 'center',
|
||||
dataIndex: 'experience',
|
||||
},
|
||||
{
|
||||
title: '医生状态',
|
||||
align: 'center',
|
||||
dataIndex: 'doctorStatus',
|
||||
customRender: ({ text }) => {
|
||||
return render.renderDict(text, 'doc_status');
|
||||
},
|
||||
},
|
||||
{
|
||||
title: '是否接受咨询',
|
||||
align: 'center',
|
||||
dataIndex: 'isAccept',
|
||||
customRender: ({ text }) => {
|
||||
return render.renderDict(text, 'doc_accept_flag');
|
||||
},
|
||||
},
|
||||
{
|
||||
title: '专家类型',
|
||||
align: 'center',
|
||||
dataIndex: 'type',
|
||||
customRender: ({ text }) => {
|
||||
return render.renderDict(text, 'z_doct_typ');
|
||||
},
|
||||
},
|
||||
// {
|
||||
// title: '状态',
|
||||
// align:"center",
|
||||
// dataIndex: 'status',
|
||||
// customRender: ({ text }) => {
|
||||
// // 1-正常,2-冻结
|
||||
// return text == '1' ? '正常' : '冻结' ;
|
||||
// },
|
||||
// },
|
||||
// {
|
||||
// title: '值班时间',
|
||||
// align:"center",
|
||||
// dataIndex: 'onDutyTime'
|
||||
// },
|
||||
];
|
||||
|
||||
//查询数据
|
||||
export const searchFormSchema: FormSchema[] = [
|
||||
{
|
||||
field: 'doctorJob',
|
||||
label: '职称',
|
||||
component: 'JDictSelectTag',
|
||||
componentProps: () => {
|
||||
return {
|
||||
dictCode: 'z_doct_job',
|
||||
};
|
||||
},
|
||||
},
|
||||
{
|
||||
field: 'doctorTitle',
|
||||
label: '职务',
|
||||
component: 'JDictSelectTag',
|
||||
componentProps: () => {
|
||||
return {
|
||||
dictCode: 'z_doct_lev',
|
||||
};
|
||||
},
|
||||
},
|
||||
{
|
||||
field: 'goodAtSymptom',
|
||||
label: '擅长症状',
|
||||
component: 'Input',
|
||||
colProps: { span: 8 },
|
||||
},
|
||||
];
|
||||
|
||||
//表单数据
|
||||
export const formSchema: FormSchema[] = [
|
||||
// 主键隐藏字段
|
||||
{
|
||||
label: '',
|
||||
field: 'id',
|
||||
component: 'Input',
|
||||
show: false,
|
||||
},
|
||||
{
|
||||
label: '职务',
|
||||
field: 'doctorTitle',
|
||||
component: 'JDictSelectTag',
|
||||
componentProps: {
|
||||
dictCode: 'z_doct_lev',
|
||||
},
|
||||
},
|
||||
{
|
||||
label: '职称',
|
||||
field: 'doctorJob',
|
||||
component: 'JDictSelectTag',
|
||||
componentProps: {
|
||||
dictCode: 'z_doct_job',
|
||||
},
|
||||
},
|
||||
{
|
||||
label: '医院名称',
|
||||
field: 'hospitalName',
|
||||
component: 'ApiSelect',
|
||||
componentProps: {
|
||||
api: getHospitalsList,
|
||||
resultField: 'list',
|
||||
labelField: 'name',
|
||||
valueField: 'id',
|
||||
immediate: false,
|
||||
// onChange: (e) => {
|
||||
// console.log('selected:', e);
|
||||
// },
|
||||
// // 请求后回调
|
||||
// onOptionsChange: (options) => {
|
||||
// console.log('get options', options.length, options);
|
||||
// },
|
||||
onOptionsChange: (options) => {
|
||||
// console.log("options",options)
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
label: '',
|
||||
field: 'hospitalId', // 医院名称选中的医院ID
|
||||
component: 'Input',
|
||||
show: false,
|
||||
},
|
||||
{
|
||||
label: '科室名称',
|
||||
field: 'officeName',
|
||||
component: 'ApiSelect',
|
||||
componentProps: {
|
||||
api: getOfficeList,
|
||||
resultField: 'list',
|
||||
labelField: 'name',
|
||||
valueField: 'id',
|
||||
immediate: false,
|
||||
onChange: (e) => {
|
||||
// console.log('selected:', e);
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
label: '医生状态',
|
||||
field: 'doctorStatus',
|
||||
component: 'JDictSelectTag',
|
||||
componentProps: {
|
||||
dictCode: 'doc_status',
|
||||
},
|
||||
},
|
||||
{
|
||||
label: '专家类型',
|
||||
field: 'type',
|
||||
component: 'JDictSelectTag',
|
||||
componentProps: {
|
||||
dictCode: 'z_doct_typ',
|
||||
},
|
||||
},
|
||||
{
|
||||
label: '是否接受咨询',
|
||||
field: 'isAccept',
|
||||
component: 'JDictSelectTag',
|
||||
componentProps: {
|
||||
dictCode: 'doc_accept_flag',
|
||||
},
|
||||
},
|
||||
{
|
||||
field: 'avatar',
|
||||
label: '头像',
|
||||
component: 'JImageUpload',
|
||||
componentProps: {
|
||||
maxCount: 1,
|
||||
},
|
||||
},
|
||||
{
|
||||
label: '用户账号',
|
||||
field: 'username',
|
||||
component: 'Input',
|
||||
required: true,
|
||||
},
|
||||
{
|
||||
label: '密码',
|
||||
field: 'password',
|
||||
component: 'StrengthMeter',
|
||||
componentProps: {
|
||||
autocomplete: 'new-password',
|
||||
readOnly: true,
|
||||
onfocus: (field) => {
|
||||
field.target.readOnly = false;
|
||||
},
|
||||
},
|
||||
dynamicRules: () => {
|
||||
return [
|
||||
{
|
||||
required: true,
|
||||
validator: (_, value) => {
|
||||
let { message } = checkPassword(value);
|
||||
if (message === 'ok') {
|
||||
return Promise.resolve();
|
||||
} else {
|
||||
return Promise.reject(message);
|
||||
}
|
||||
},
|
||||
trigger: 'blur',
|
||||
},
|
||||
];
|
||||
},
|
||||
},
|
||||
{
|
||||
label: '真实名字',
|
||||
field: 'realname',
|
||||
component: 'Input',
|
||||
},
|
||||
{
|
||||
label: '擅长',
|
||||
field: 'goodAt',
|
||||
component: 'Input',
|
||||
},
|
||||
{
|
||||
label: '擅长症状',
|
||||
field: 'goodAtSymptom',
|
||||
component: 'Input',
|
||||
},
|
||||
{
|
||||
label: '擅长疾病',
|
||||
field: 'goodAtSickness',
|
||||
component: 'Input',
|
||||
},
|
||||
{
|
||||
label: '职业经历',
|
||||
field: 'experience',
|
||||
component: 'InputTextArea',
|
||||
},
|
||||
{
|
||||
label: '民族',
|
||||
field: 'nationality',
|
||||
component: 'Input',
|
||||
},
|
||||
{
|
||||
label: '籍贯',
|
||||
field: 'nativePlace',
|
||||
component: 'Input',
|
||||
},
|
||||
{
|
||||
label: '住址',
|
||||
field: 'address',
|
||||
component: 'Input',
|
||||
},
|
||||
{
|
||||
field: 'joinWork',
|
||||
label: '参加工作时间',
|
||||
component: 'DatePicker',
|
||||
componentProps: {
|
||||
showTime: false,
|
||||
valueFormat: 'YYYY-MM-DD HH:mm:ss',
|
||||
},
|
||||
},
|
||||
{
|
||||
field: 'onDutyTime',
|
||||
label: '值班时间',
|
||||
component: 'CheckboxGroup',
|
||||
componentProps: {
|
||||
options: [
|
||||
{ label: '周一上午', value: '周一上午' },
|
||||
{ label: '周一下午', value: '周一下午' },
|
||||
{ label: '周二上午', value: '周二上午' },
|
||||
{ label: '周二下午', value: '周二下午' },
|
||||
{ label: '周三上午', value: '周三上午' },
|
||||
{ label: '周三下午', value: '周三下午' },
|
||||
{ label: '周四上午', value: '周四上午' },
|
||||
{ label: '周四下午', value: '周四下午' },
|
||||
{ label: '周五上午', value: '周五上午' },
|
||||
{ label: '周五下午', value: '周五下午' },
|
||||
{ label: '周六上午', value: '周六上午' },
|
||||
{ label: '周六下午', value: '周六下午' },
|
||||
{ label: '周日上午', value: '周日上午' },
|
||||
{ label: '周日下午', value: '周日下午' },
|
||||
],
|
||||
},
|
||||
},
|
||||
{
|
||||
label: '身份证号码',
|
||||
field: 'idCard',
|
||||
component: 'Input',
|
||||
},
|
||||
{
|
||||
label: '健康状况',
|
||||
field: 'healthStatus',
|
||||
component: 'Input',
|
||||
},
|
||||
{
|
||||
label: '学历',
|
||||
field: 'eq',
|
||||
component: 'Input',
|
||||
},
|
||||
{
|
||||
label: '毕业学校',
|
||||
field: 'school',
|
||||
component: 'Input',
|
||||
},
|
||||
{
|
||||
field: 'outTime',
|
||||
label: '毕业时间',
|
||||
component: 'DatePicker',
|
||||
componentProps: {
|
||||
showTime: false,
|
||||
valueFormat: 'YYYY-MM-DD HH:mm:ss',
|
||||
},
|
||||
},
|
||||
{
|
||||
label: '获奖或论文',
|
||||
field: 'award',
|
||||
component: 'InputTextArea',
|
||||
},
|
||||
{
|
||||
field: 'email',
|
||||
label: '邮箱',
|
||||
component: 'Input',
|
||||
rules: [{ type: 'email', message: '邮箱格式不正确', trigger: 'blur' }],
|
||||
componentProps: {
|
||||
placeholder: '请输入邮箱',
|
||||
},
|
||||
},
|
||||
{
|
||||
label: '手机号',
|
||||
field: 'phone',
|
||||
component: 'Input',
|
||||
rules: [{ required: false, pattern: /^1[3456789]\d{9}$/, message: '手机号码格式有误' }],
|
||||
},
|
||||
{
|
||||
field: 'sex',
|
||||
component: 'JDictSelectTag',
|
||||
label: '性别',
|
||||
componentProps: {
|
||||
dictCode: 'sex',
|
||||
type: 'radioButton',
|
||||
},
|
||||
},
|
||||
{
|
||||
label: '联系地址',
|
||||
field: 'contactAddress',
|
||||
component: 'Input',
|
||||
},
|
||||
{
|
||||
label: '备注',
|
||||
field: 'memo',
|
||||
component: 'Input',
|
||||
},
|
||||
];
|
||||
|
||||
/**
|
||||
* 流程表单调用这个方法获取formSchema
|
||||
* @param param
|
||||
*/
|
||||
export function getBpmFormSchema(_formData): FormSchema[] {
|
||||
// 默认和原始表单保持一致 如果流程中配置了权限数据,这里需要单独处理formSchema
|
||||
return formSchema;
|
||||
}
|
||||
@@ -0,0 +1,197 @@
|
||||
<template>
|
||||
<div>
|
||||
<!--引用表格-->
|
||||
<BasicTable :rowSelection="rowSelection" @register="registerTable">
|
||||
<!--插槽:table标题-->
|
||||
<template #tableTitle>
|
||||
<a-button v-auth="'system:health_user_doctor_ex:add'" preIcon="ant-design:plus-outlined" type="primary" @click="handleAdd">
|
||||
新增</a-button
|
||||
>
|
||||
<a-button v-auth="'system:health_user_doctor_ex:exportXls'" preIcon="ant-design:export-outlined" type="primary" @click="onExportXls">
|
||||
导出</a-button
|
||||
>
|
||||
<j-upload-button
|
||||
v-auth="'system:health_user_doctor_ex:importExcel'"
|
||||
preIcon="ant-design:import-outlined"
|
||||
type="primary"
|
||||
@click="onImportXls"
|
||||
>导入</j-upload-button
|
||||
>
|
||||
<a-dropdown v-if="selectedRowKeys.length > 0">
|
||||
<template #overlay>
|
||||
<a-menu>
|
||||
<a-menu-item key="1" @click="batchHandleDelete">
|
||||
<Icon icon="ant-design:delete-outlined" />
|
||||
删除
|
||||
</a-menu-item>
|
||||
</a-menu>
|
||||
</template>
|
||||
<a-button
|
||||
>批量操作
|
||||
<Icon icon="mdi:chevron-down" />
|
||||
</a-button>
|
||||
</a-dropdown>
|
||||
</template>
|
||||
<!--操作栏-->
|
||||
<template #action="{ record }">
|
||||
<TableAction :actions="getTableAction(record)" :dropDownActions="getDropDownAction(record)" />
|
||||
</template>
|
||||
<!--字段回显插槽-->
|
||||
<template #htmlSlot="{ text }">
|
||||
<div v-html="text"></div>
|
||||
</template>
|
||||
<!--省市区字段回显插槽-->
|
||||
<template #pcaSlot="{ text }">
|
||||
{{ getAreaTextByCode(text) }}
|
||||
</template>
|
||||
<template #fileSlot="{ text }">
|
||||
<span v-if="!text" style="font-size: 12px; font-style: italic">无文件</span>
|
||||
<a-button v-else :ghost="true" preIcon="ant-design:download-outlined" size="small" type="primary" @click="downloadFile(text)"
|
||||
>下载</a-button
|
||||
>
|
||||
</template>
|
||||
</BasicTable>
|
||||
<!-- 表单区域 -->
|
||||
<HealthUserDoctorExModal @register="registerModal" @success="handleSuccess" />
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script lang="ts" name="system-healthUserDoctorEx" setup>
|
||||
import { ref } from 'vue';
|
||||
import { BasicTable, TableAction } from '/@/components/Table';
|
||||
import { useModal } from '/@/components/Modal';
|
||||
import { useListPage } from '/@/hooks/system/useListPage';
|
||||
import HealthUserDoctorExModal from './components/HealthUserDoctorExModal.vue';
|
||||
import { columns, searchFormSchema } from './HealthUserDoctorEx.data';
|
||||
import { batchDelete, deleteOne, getExportUrl, getImportUrl, list, resEditData } from './HealthUserDoctorEx.api';
|
||||
import { downloadFile } from '/@/utils/common/renderUtils';
|
||||
|
||||
const checkedKeys = ref<Array<string | number>>([]);
|
||||
//注册model
|
||||
const [registerModal, { openModal }] = useModal();
|
||||
//注册table数据
|
||||
const { prefixCls, tableContext, onExportXls, onImportXls } = useListPage({
|
||||
tableProps: {
|
||||
title: 'health_user_doctor_ex',
|
||||
api: list,
|
||||
columns,
|
||||
canResize: false,
|
||||
formConfig: {
|
||||
//labelWidth: 120,
|
||||
schemas: searchFormSchema,
|
||||
autoSubmitOnEnter: true,
|
||||
showAdvancedButton: true,
|
||||
fieldMapToNumber: [],
|
||||
fieldMapToTime: [],
|
||||
},
|
||||
actionColumn: {
|
||||
width: 120,
|
||||
fixed: 'right',
|
||||
},
|
||||
},
|
||||
exportConfig: {
|
||||
name: 'health_user_doctor_ex',
|
||||
url: getExportUrl,
|
||||
},
|
||||
importConfig: {
|
||||
url: getImportUrl,
|
||||
success: handleSuccess,
|
||||
},
|
||||
});
|
||||
|
||||
const [registerTable, { reload }, { rowSelection, selectedRowKeys }] = tableContext;
|
||||
|
||||
/**
|
||||
* 新增事件
|
||||
*/
|
||||
function handleAdd() {
|
||||
openModal(true, {
|
||||
isUpdate: false,
|
||||
showFooter: true,
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 编辑事件
|
||||
*/
|
||||
function handleEdit(record: Recordable) {
|
||||
resEditData({ id: record.id }).then((res) => {
|
||||
let data = { ...res.userInfo, ...res.healthUserDoctorEx };
|
||||
openModal(true, {
|
||||
record: data,
|
||||
isUpdate: true,
|
||||
showFooter: true,
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 详情
|
||||
*/
|
||||
function handleDetail(record: Recordable) {
|
||||
resEditData({ id: record.id }).then((res) => {
|
||||
let data = { ...res.userInfo, ...res.healthUserDoctorEx };
|
||||
openModal(true, {
|
||||
record: data,
|
||||
isUpdate: true,
|
||||
showFooter: false,
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除事件
|
||||
*/
|
||||
async function handleDelete(record) {
|
||||
await deleteOne({ id: record.id }, handleSuccess);
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量删除事件
|
||||
*/
|
||||
async function batchHandleDelete() {
|
||||
await batchDelete({ ids: selectedRowKeys.value }, handleSuccess);
|
||||
}
|
||||
|
||||
/**
|
||||
* 成功回调
|
||||
*/
|
||||
function handleSuccess() {
|
||||
(selectedRowKeys.value = []) && reload();
|
||||
}
|
||||
|
||||
/**
|
||||
* 操作栏
|
||||
*/
|
||||
function getTableAction(record) {
|
||||
return [
|
||||
{
|
||||
label: '编辑',
|
||||
onClick: handleEdit.bind(null, record),
|
||||
auth: 'system:health_user_doctor_ex:edit',
|
||||
},
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* 下拉操作栏
|
||||
*/
|
||||
function getDropDownAction(record) {
|
||||
return [
|
||||
{
|
||||
label: '详情',
|
||||
onClick: handleDetail.bind(null, record),
|
||||
},
|
||||
{
|
||||
label: '删除',
|
||||
popConfirm: {
|
||||
title: '是否确认删除',
|
||||
confirm: handleDelete.bind(null, record),
|
||||
},
|
||||
auth: 'system:health_user_doctor_ex:delete',
|
||||
},
|
||||
];
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped></style>
|
||||
@@ -0,0 +1,68 @@
|
||||
<template>
|
||||
<div style="min-height: 400px">
|
||||
<BasicForm @register="registerForm" />
|
||||
<div v-if="!formDisabled" style="width: 100%; text-align: center">
|
||||
<a-button @click="submitForm" pre-icon="ant-design:check" type="primary">提 交</a-button>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script lang="ts">
|
||||
import { BasicForm, useForm } from '/@/components/Form';
|
||||
import { computed, defineComponent } from 'vue';
|
||||
import { defHttp } from '/@/utils/http/axios';
|
||||
import { propTypes } from '/@/utils/propTypes';
|
||||
import { getBpmFormSchema } from '../HealthUserDoctorEx.data';
|
||||
import { queryByIdUrl, saveOrUpdate } from '../HealthUserDoctorEx.api';
|
||||
|
||||
export default defineComponent({
|
||||
name: 'HealthUserDoctorExForm',
|
||||
components: {
|
||||
BasicForm,
|
||||
},
|
||||
props: {
|
||||
formData: propTypes.object.def({}),
|
||||
formBpm: propTypes.bool.def(true),
|
||||
},
|
||||
setup(props) {
|
||||
const [registerForm, { setFieldsValue, setProps, getFieldsValue }] = useForm({
|
||||
labelWidth: 150,
|
||||
schemas: getBpmFormSchema(props.formData),
|
||||
showActionButtonGroup: false,
|
||||
baseColProps: { span: 24 },
|
||||
});
|
||||
|
||||
const formDisabled = computed(() => {
|
||||
if (props.formData.disabled === false) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
});
|
||||
|
||||
let formData = {};
|
||||
async function initFormData() {
|
||||
let params = { id: props.formData.dataId };
|
||||
const data = await defHttp.get({ url: queryByIdUrl, params });
|
||||
formData = { ...data };
|
||||
//设置表单的值
|
||||
await setFieldsValue(formData);
|
||||
//默认是禁用
|
||||
await setProps({ disabled: formDisabled.value });
|
||||
}
|
||||
|
||||
async function submitForm() {
|
||||
let data = getFieldsValue();
|
||||
let params = Object.assign({}, formData, data);
|
||||
await saveOrUpdate(params, true);
|
||||
}
|
||||
|
||||
initFormData();
|
||||
|
||||
return {
|
||||
registerForm,
|
||||
formDisabled,
|
||||
submitForm,
|
||||
};
|
||||
},
|
||||
});
|
||||
</script>
|
||||
@@ -0,0 +1,77 @@
|
||||
<template>
|
||||
<BasicModal :title="title" :width="800" destroyOnClose v-bind="$attrs" @ok="handleSubmit" @register="registerModal">
|
||||
<BasicForm @register="registerForm" />
|
||||
</BasicModal>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import { computed, ref, unref } from 'vue';
|
||||
import { BasicModal, useModalInner } from '/@/components/Modal';
|
||||
import { BasicForm, useForm } from '/@/components/Form';
|
||||
import { formSchema } from '../HealthUserDoctorEx.data';
|
||||
import { saveOrUpdate } from '../HealthUserDoctorEx.api';
|
||||
// Emits声明
|
||||
const emit = defineEmits(['register', 'success']);
|
||||
const isUpdate = ref(true);
|
||||
formSchema[3].componentProps.onOptionsChange = (options) => {
|
||||
onSelectHospital(options);
|
||||
};
|
||||
//表单配置
|
||||
const [registerForm, { setProps, resetFields, setFieldsValue, validate }] = useForm({
|
||||
//labelWidth: 150,
|
||||
schemas: formSchema,
|
||||
showActionButtonGroup: false,
|
||||
baseColProps: { span: 24 },
|
||||
});
|
||||
//表单赋值
|
||||
const [registerModal, { setModalProps, closeModal }] = useModalInner(async (data) => {
|
||||
//重置表单
|
||||
await resetFields();
|
||||
setModalProps({ confirmLoading: false, showCancelBtn: !!data?.showFooter, showOkBtn: !!data?.showFooter });
|
||||
isUpdate.value = !!data?.isUpdate;
|
||||
if (unref(isUpdate)) {
|
||||
//表单赋值
|
||||
await setFieldsValue({
|
||||
...data.record,
|
||||
});
|
||||
}
|
||||
// 隐藏底部时禁用整个表单
|
||||
setProps({ disabled: !data?.showFooter });
|
||||
});
|
||||
//设置标题
|
||||
const title = computed(() => (!unref(isUpdate) ? '新增' : '编辑'));
|
||||
//表单提交事件
|
||||
async function handleSubmit(v) {
|
||||
try {
|
||||
let values = await validate();
|
||||
setModalProps({ confirmLoading: true });
|
||||
//提交表单
|
||||
await saveOrUpdate(values, isUpdate.value);
|
||||
//关闭弹窗
|
||||
closeModal();
|
||||
//刷新列表
|
||||
emit('success');
|
||||
} finally {
|
||||
setModalProps({ confirmLoading: false });
|
||||
}
|
||||
}
|
||||
|
||||
// 选择医院名称
|
||||
async function onSelectHospital(options) {
|
||||
await setFieldsValue({
|
||||
hospitalName: options[0]['label'],
|
||||
hospitalId: options[0]['value'],
|
||||
});
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="less" scoped>
|
||||
/** 时间和数字输入框样式 */
|
||||
:deep(.ant-input-number) {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
:deep(.ant-calendar-picker) {
|
||||
width: 100%;
|
||||
}
|
||||
</style>
|
||||
Reference in New Issue
Block a user