叫号显示屏页面开发,诊疗目录新增或修改时添加医保编码唯一性校验。

This commit is contained in:
2026-01-04 14:24:33 +08:00
parent ddf1553846
commit 1311e87e13
6 changed files with 645 additions and 3 deletions

View File

@@ -116,7 +116,11 @@
</el-col>
<el-col :span="8">
<el-form-item label="医保编码" prop="conditionCode">
<el-input v-model="form.ybNo" placeholder="" />
<el-input
v-model="form.ybNo"
placeholder=""
clearable
/>
</el-form-item>
</el-col>
</el-row>
@@ -363,6 +367,7 @@ import {
deptTreeSelect,
editDiagnosisTreatment,
getDiagnosisTreatmentList,
getDiseaseTreatmentByYbNo,
locationTreeSelect,
} from './diagnosistreatment';
import PopoverList from '@/components/OpenHis/popoverList/index.vue';
@@ -454,6 +459,7 @@ const treatmentItems = ref([
const medicineSearchKey = ref('');
const isFirstOpen = ref(true); // 标记是否首次打开弹窗
const totalPrice = ref('0.00'); // 总价
const isValidatingYbNo = ref(false); // 标记是否正在校验医保编码
// 计算总价
function calculateTotalPrice() {
@@ -597,8 +603,31 @@ function reset() {
proxy.resetForm('diagnosisTreatmentRef');
}
async function validateYbNoUnique(ybNo, currentId = null) {
if (!ybNo || ybNo.trim() === '') {
return true; // 空值不进行校验
}
try {
const response = await getDiseaseTreatmentByYbNo(ybNo);
const data = response.data;
if (data && data.length > 0) {
// 检查是否存在相同的医保编码,排除当前编辑的记录
const existingRecord = data.find(item => item.id !== currentId);
if (existingRecord) {
return false; // 医保编码已存在
}
}
return true; // 医保编码唯一
} catch (error) {
console.error('医保编码校验失败:', error);
return true; // 校验失败时允许提交,由后端处理
}
}
/** 提交按钮 */
function submitForm() {
async function submitForm() {
form.value.ybFlag ? (form.value.ybFlag = 1) : (form.value.ybFlag = 0);
form.value.ybMatchFlag ? (form.value.ybMatchFlag = 1) : (form.value.ybMatchFlag = 0);
form.value.ruleId ? (form.value.ruleId = 1) : (form.value.ruleId = 0);
@@ -606,8 +635,26 @@ function submitForm() {
treatmentItems.value.length > 0 && treatmentItems.value[0].adviceDefinitionId != ''
? JSON.stringify(treatmentItems.value)
: undefined;
proxy.$refs['diagnosisTreatmentRef'].validate((valid) => {
proxy.$refs['diagnosisTreatmentRef'].validate(async (valid) => {
if (valid) {
// 医保编码唯一性校验
if (form.value.ybNo) {
try {
isValidatingYbNo.value = true;
const isUnique = await validateYbNoUnique(form.value.ybNo, form.value.id);
if (!isUnique) {
proxy.$modal.msgWarning('医保编码已存在,请输入其他医保编码');
return;
}
} catch (error) {
console.error('医保编码校验失败:', error);
proxy.$modal.msgError('医保编码校验失败,请稍后重试');
return;
} finally {
isValidatingYbNo.value = false;
}
}
if (form.value.id != undefined) {
editDiagnosisTreatment(form.value).then((response) => {
// 触发自定义事件,并传递数据给父组件