72.系统管理--》基础数据-》科室管理
This commit is contained in:
@@ -135,6 +135,7 @@
|
||||
import { ref, reactive } from 'vue';
|
||||
import { useRouter } from 'vue-router';
|
||||
import { ElMessage } from 'element-plus';
|
||||
import { getConfigKey, addConfig, updateConfig } from '@/api/system/config';
|
||||
|
||||
const router = useRouter();
|
||||
const formRef = ref(null);
|
||||
@@ -198,46 +199,72 @@ const handleSave = async () => {
|
||||
await formRef.value.validate();
|
||||
}
|
||||
|
||||
// 将表单数据转换为系统配置格式
|
||||
// 将表单数据转换为系统配置格式,并添加必要的默认值
|
||||
const configData = [
|
||||
{ configKey: 'medicalRecordFee', configValue: formData.medicalRecordFee, configName: '病历本费用' },
|
||||
{ configKey: 'patientCardFee', configValue: formData.patientCardFee, configName: '就诊卡费' },
|
||||
{ configKey: 'medicalRecordFlag', configValue: formData.medicalRecordFlag ? '1' : '0', configName: '病历费入账标志' },
|
||||
{ configKey: 'isNightShift', configValue: formData.isNightShift ? '1' : '0', configName: '是否启用晚班' },
|
||||
{ configKey: 'patientCardFlag', configValue: formData.patientCardFlag ? '1' : '0', configName: '就诊卡记账标志' },
|
||||
{ configKey: 'morningStartTime', configValue: formData.morningStartTime, configName: '上午接诊起始时间' },
|
||||
{ configKey: 'autoGenerateOutpatientNo', configValue: formData.autoGenerateOutpatientNo ? '1' : '0', configName: '自动产生门诊号' },
|
||||
{ configKey: 'allowModifyOutpatientNo', configValue: formData.allowModifyOutpatientNo ? '1' : '0', configName: '建档时是否允许修改门诊号' },
|
||||
{ configKey: 'afternoonStartTime', configValue: formData.afternoonStartTime, configName: '下午起始时间' },
|
||||
{ configKey: 'eveningStartTime', configValue: formData.eveningStartTime, configName: '晚上起始时间' },
|
||||
{ configKey: 'registrationValidity', configValue: formData.registrationValidity, configName: '挂号有效期' },
|
||||
{ configKey: 'registrationDocumentMode', configValue: formData.registrationDocumentMode, configName: '挂号单据模式' },
|
||||
{ configKey: 'exemptFlag', configValue: formData.exemptFlag ? '1' : '0', configName: '减免标志' },
|
||||
{ configKey: 'consultationFlag', configValue: formData.consultationFlag ? '1' : '0', configName: '义诊标志' },
|
||||
{ configKey: 'enableHolidayFeeFloat', configValue: formData.enableHolidayFeeFloat ? '1' : '0', configName: '启用法定节假日挂号费浮动' },
|
||||
{ configKey: 'guardianAge', configValue: formData.guardianAge, configName: '监护人规定年龄' },
|
||||
{ configKey: 'enableDoubleScreen', configValue: formData.enableDoubleScreen ? '1' : '0', configName: '门诊挂号启用双屏' },
|
||||
{ configKey: 'optionalRegistrationType', configValue: formData.optionalRegistrationType ? '1' : '0', configName: '挂号类型可选择' },
|
||||
{ configKey: 'isPrint', configValue: formData.isPrint ? '1' : '0', configName: '是否打印挂号单' },
|
||||
{ configKey: 'medicalRecordFee', configValue: formData.medicalRecordFee, configName: '病历本费用', configType: 'Y' },
|
||||
{ configKey: 'patientCardFee', configValue: formData.patientCardFee, configName: '就诊卡费', configType: 'Y' },
|
||||
{ configKey: 'medicalRecordFlag', configValue: formData.medicalRecordFlag ? '1' : '0', configName: '病历费入账标志', configType: 'Y' },
|
||||
{ configKey: 'isNightShift', configValue: formData.isNightShift ? '1' : '0', configName: '是否启用晚班', configType: 'Y' },
|
||||
{ configKey: 'patientCardFlag', configValue: formData.patientCardFlag ? '1' : '0', configName: '就诊卡记账标志', configType: 'Y' },
|
||||
{ configKey: 'morningStartTime', configValue: formData.morningStartTime, configName: '上午接诊起始时间', configType: 'Y' },
|
||||
{ configKey: 'autoGenerateOutpatientNo', configValue: formData.autoGenerateOutpatientNo ? '1' : '0', configName: '自动产生门诊号', configType: 'Y' },
|
||||
{ configKey: 'allowModifyOutpatientNo', configValue: formData.allowModifyOutpatientNo ? '1' : '0', configName: '建档时是否允许修改门诊号', configType: 'Y' },
|
||||
{ configKey: 'afternoonStartTime', configValue: formData.afternoonStartTime, configName: '下午起始时间', configType: 'Y' },
|
||||
{ configKey: 'eveningStartTime', configValue: formData.eveningStartTime, configName: '晚上起始时间', configType: 'Y' },
|
||||
{ configKey: 'registrationValidity', configValue: formData.registrationValidity, configName: '挂号有效期', configType: 'Y' },
|
||||
{ configKey: 'registrationDocumentMode', configValue: formData.registrationDocumentMode, configName: '挂号单据模式', configType: 'Y' },
|
||||
{ configKey: 'exemptFlag', configValue: formData.exemptFlag ? '1' : '0', configName: '减免标志', configType: 'Y' },
|
||||
{ configKey: 'consultationFlag', configValue: formData.consultationFlag ? '1' : '0', configName: '义诊标志', configType: 'Y' },
|
||||
{ configKey: 'enableHolidayFeeFloat', configValue: formData.enableHolidayFeeFloat ? '1' : '0', configName: '启用法定节假日挂号费浮动', configType: 'Y' },
|
||||
{ configKey: 'guardianAge', configValue: formData.guardianAge, configName: '监护人规定年龄', configType: 'Y' },
|
||||
{ configKey: 'enableDoubleScreen', configValue: formData.enableDoubleScreen ? '1' : '0', configName: '门诊挂号启用双屏', configType: 'Y' },
|
||||
{ configKey: 'optionalRegistrationType', configValue: formData.optionalRegistrationType ? '1' : '0', configName: '挂号类型可选择', configType: 'Y' },
|
||||
{ configKey: 'isPrint', configValue: formData.isPrint ? '1' : '0', configName: '是否打印挂号单', configType: 'Y' },
|
||||
];
|
||||
|
||||
let successCount = 0;
|
||||
let failedParams = [];
|
||||
|
||||
// 调用系统配置API保存每个参数
|
||||
for (const config of configData) {
|
||||
// 先查询是否存在该配置
|
||||
const existingConfig = await getConfigKey(config.configKey);
|
||||
if (existingConfig.data) {
|
||||
// 如果存在则更新
|
||||
await updateConfig({ ...config, configId: existingConfig.data.configId });
|
||||
} else {
|
||||
// 如果不存在则新增
|
||||
await addConfig(config);
|
||||
try {
|
||||
// 先查询是否存在该配置
|
||||
const existingConfig = await getConfigKey(config.configKey, { skipErrorMsg: true });
|
||||
|
||||
if (existingConfig.data && existingConfig.data.configId) {
|
||||
// 如果存在则更新,保留原有数据的configId
|
||||
await updateConfig({
|
||||
...config,
|
||||
configId: existingConfig.data.configId,
|
||||
createTime: existingConfig.data.createTime, // 保留创建时间
|
||||
remark: existingConfig.data.remark || '收费系统配置参数' // 保留或设置默认备注
|
||||
});
|
||||
} else {
|
||||
// 如果不存在则新增,添加默认备注
|
||||
await addConfig({
|
||||
...config,
|
||||
remark: '收费系统配置参数'
|
||||
});
|
||||
}
|
||||
successCount++;
|
||||
} catch (paramError) {
|
||||
console.error(`保存参数 ${config.configName} (${config.configKey}) 失败:`, paramError);
|
||||
failedParams.push(config.configName);
|
||||
// 继续处理下一个参数,不中断整体流程
|
||||
}
|
||||
}
|
||||
|
||||
ElMessage.success('保存成功');
|
||||
// 根据保存结果显示相应消息
|
||||
if (failedParams.length === 0) {
|
||||
ElMessage.success(`所有 ${successCount} 个参数保存成功`);
|
||||
} else if (successCount > 0) {
|
||||
ElMessage.warning(`${successCount} 个参数保存成功,但以下 ${failedParams.length} 个参数保存失败: ${failedParams.join(', ')}`);
|
||||
} else {
|
||||
ElMessage.error(`所有参数保存失败,请检查系统配置`);
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('保存失败:', error);
|
||||
ElMessage.error('保存失败,请重试');
|
||||
console.error('保存过程中发生错误:', error);
|
||||
ElMessage.error('保存操作异常,请重试');
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user