bug 514 537 538 540 543

This commit is contained in:
Ranyunqiao
2026-05-18 17:44:15 +08:00
committed by guanyu
parent eec170e788
commit 082245d10d
12 changed files with 512 additions and 396 deletions

View File

@@ -116,7 +116,7 @@ import {computed, getCurrentInstance, ref, watch} from 'vue';
import {Refresh} from '@element-plus/icons-vue';
import {patientInfo} from '../../store/patient.js';
import {getSurgery} from './api';
import {getOrgList} from '@/views/doctorstation/components/api.js';
import {getDepartmentList} from '@/api/public.js';
const { proxy } = getCurrentInstance();
@@ -182,25 +182,32 @@ const hasMatchedFields = computed(() => {
/** 查询科室 */
const getLocationInfo = async () => {
const res = await getOrgList();
orgOptions.value = res.data.records;
const res = await getDepartmentList();
orgOptions.value = res.data || [];
};
const recursionFun = (targetDepartment) => {
if (!targetDepartment || !orgOptions.value || orgOptions.value.length === 0) {
return '';
}
let name = '';
for (let index = 0; index < orgOptions.value.length; index++) {
const obj = orgOptions.value[index];
if (obj.id == targetDepartment) {
name = obj.name;
}
const subObjArray = obj['children'];
for (let index = 0; index < subObjArray.length; index++) {
const item = subObjArray[index];
if (item.id == targetDepartment) {
name = item.name;
// 统一处理:扁平列表和树形结构都适用
const findInList = (list) => {
for (const node of list) {
if (String(node.id) === String(targetDepartment)) {
name = node.name;
return true;
}
// 树形结构:递归查找 children
if (node.children && node.children.length > 0) {
if (findInList(node.children)) {
return true;
}
}
}
}
return false;
};
findInList(orgOptions.value);
return name;
};

View File

@@ -232,64 +232,21 @@ onMounted(() => {
* type(1watch监听类型 2:点击保存类型)
* selectProjectIds(选中项目的id数组)
* */
const projectWithDepartment = (selectProjectIds, type) => {
//1.获取选中的项目 2.判断项目的执行科室是否相同 3.判断执行科室是否配置 4.将项目的执行科室复值到执行科室下拉选位置
let isRelease = true;
// 选中项目的数组
const arr = [];
// 根据选中的项目id查找对应的项目
selectProjectIds.forEach((element) => {
const searchData = applicationList.value.find((item) => {
return element == item.adviceDefinitionId;
});
arr.push(searchData);
});
// 清空科室
form.targetDepartment = '';
if (arr.length > 0) {
const obj = arr[0];
// 判断科室是否相同
const isCompare = arr.every((item) => {
return item.orgId == obj.orgId;
});
if (!isCompare) {
ElMessage({
type: 'error',
message: '执行科室不同',
});
isRelease = false;
}
// 选中项目中的执行科室id与全部科室数据做匹配
const findItem = findTreeItem(orgOptions.value, obj.orgId);
if (!findItem) {
isRelease = false;
ElMessage({
type: 'error',
message: '未找到项目执行的科室',
});
}
if (type == 1) {
if (isRelease) {
form.targetDepartment = findItem.id;
}
}
const projectWithDepartment = (selectProjectIds) => {
if (!selectProjectIds || selectProjectIds.length === 0) {
form.targetDepartment = '';
}
return isRelease;
};
// 监听选择项目变化
watch(
() => transferValue.value,
(newValue) => {
projectWithDepartment(newValue, 1);
}
);
watch(() => transferValue.value, (newValue) => {
projectWithDepartment(newValue);
});
const submit = () => {
if (transferValue.value.length == 0) {
return proxy.$message.error('请选择申请单');
return proxy.$message.error('请选择手术项目');
}
if (!projectWithDepartment(transferValue.value, 2)) {
return;
if (!form.targetDepartment) {
return proxy.$message.error('请选择发往科室');
}
let applicationListAllFilter = applicationListAll.value.filter((item) => {
return transferValue.value.includes(item.adviceDefinitionId);
@@ -302,7 +259,7 @@ const submit = () => {
unitCode: item.unitCode,
unitPrice: item.price,
totalPrice: item.price,
positionId: item.positionId,
positionId: form.targetDepartment || item.positionId, // 用户手动选择的发往科室优先于项目默认执行科室
definitionId: item.chargeItemDefinitionId,
accountId: patientInfo.value.accountId,
};

View File

@@ -1195,7 +1195,7 @@ function handleSave() {
// 此处签发处方和单行保存处方传参相同后台已经将传参存为JSON字符串此处直接转换为JSON即可
loading.value = true;
let list = saveList.map((item) => {
const parsedContent = JSON.parse(item.contentJson);
const parsedContent = item.contentJson ? JSON.parse(item.contentJson) : {};
return {
...parsedContent,
adviceType: item.adviceType,

View File

@@ -375,7 +375,8 @@ const filterKeywords = ref({});
const queryParams = ref({
pageSize: 100,
pageNum: 1,
adviceTypes: '2,3',
// 默认加载全部类型药品1+耗材2+诊疗3
adviceTypes: [1, 2, 3],
});
/**
* 医嘱提交数据模型
@@ -557,12 +558,26 @@ function loadDepartmentOptions() {
function getAdviceBaseInfos() {
adviceLoading.value = true;
queryParams.value.searchKey = searchText.value;
queryParams.value.adviceTypes = adviceType.value;
// 字典值(3=诊疗,4=耗材)映射为后端adviceType(2=耗材,3=诊疗)
if (adviceType.value === 4) {
queryParams.value.adviceTypes = [2];
} else if (adviceType.value === 3) {
queryParams.value.adviceTypes = [3];
} else {
queryParams.value.adviceTypes = [1, 2, 3];
}
queryParams.value.organizationId = orgId.value;
queryParams.value.pricingFlag = 1; // 划价标记
getAdviceBaseInfo(queryParams.value)
.then((res) => {
AdviceBaseInfoList.value = res.data?.records || [];
const list = res.data?.records || [];
// 药品(1)和耗材(2)必须有库存才能展示,诊疗(3)无库存概念不过滤
AdviceBaseInfoList.value = list.filter(item => {
if (item.adviceType === 1 || item.adviceType === 2) {
return item.inventoryList && item.inventoryList.length > 0;
}
return true;
});
})
.finally(() => {
adviceLoading.value = false;

View File

@@ -386,7 +386,7 @@
:disabled="viewStatus == 'view'"
v-model="scope.row.itemQuantityDisplay"
placeholder=""
@change="(value) => handleItemQuantityChange(scope.row, value)"
@input="(value) => handleItemQuantityChange(scope.row, value)"
:class="{ 'error-border': scope.row.error }"
/>
</div>
@@ -971,6 +971,10 @@ function handleItemQuantityChange(row, value) {
quantityTemp = value;
}
row.totalPrice = ((row.price * quantityTemp) / row.partPercent).toFixed(2);
// 数量变更后重置保存标记,允许重新提交
row.isSave = false;
// 同步更新底部合计金额
handleTotalAmount();
}
function handelApply() {
@@ -1262,128 +1266,108 @@ function editBatchTransfer(index) {
}
function handleSave(row, index) {
rowList.value = [];
if (route.query.supplyBusNo) {
// 编辑
forms.purchaseinventoryList.map((row, index) => {
if (row) {
proxy.$refs['receiptHeaderRef'].validate((valid) => {
if (valid) {
proxy.$refs['formRef'].validate((valid) => {
if (valid) {
if (row.unitCode == row.unitList.minUnitCode) {
row.itemQuantity = forms.purchaseinventoryList[index].olditemQuantity
? forms.purchaseinventoryList[index].olditemQuantity
: forms.purchaseinventoryList[index].itemQuantity;
} else {
row.itemQuantity = forms.purchaseinventoryList[index].itemMaxQuantity
? forms.purchaseinventoryList[index].itemMaxQuantity
: forms.purchaseinventoryList[index].itemQuantity;
}
// let rows = JSON.parse(JSON.stringify(row))
// delete rows.itemMaxQuantity
if (row.unitCode == row.unitCode_dictText) {
if (row.unitCode_dictText == row.unitList.minUnitCode_dictText) {
row.unitCode = row.unitList.minUnitCode;
} else {
row.unitCode = row.unitList.unitCode;
row.unitCode_dictText = row.unitList.unitCode_dictText;
}
}
if (row.unitCode == row.unitList.unitCode) {
row.unitCode_dictText = row.unitList.unitCode_dictText;
} else if (row.unitCode == row.unitList.minUnitCode) {
row.unitCode_dictText = row.unitList.minUnitCode_dictText;
}
if (!forms.purchaseinventoryList[index].price || forms.purchaseinventoryList[index].price <= 0) {
proxy.$message.warning('调拨单价不能为空或为0请检查');
return;
}
forms.purchaseinventoryList[index].totalPrice =
forms.purchaseinventoryList[index].price * forms.purchaseinventoryList[index].itemQuantity;
rowList.value.push(JSON.parse(JSON.stringify(row)));
if (
rowList._rawValue &&
rowList._rawValue.length == forms.purchaseinventoryList.length
) {
addTransferProducts(rowList._rawValue);
}
}
});
}
});
}
});
} else {
//新增
form.purchaseinventoryList.map((row, index) => {
if (row) {
proxy.$refs['receiptHeaderRef'].validate((valid) => {
if (valid) {
proxy.$refs['formRef'].validate((valid) => {
if (valid) {
let rows = JSON.parse(JSON.stringify(row));
delete rows.itemMaxQuantity;
if (rows.unitCode == rows.unitList.minUnitCode) {
rows.itemQuantity = form.purchaseinventoryList[index].olditemQuantity
? form.purchaseinventoryList[index].olditemQuantity
: form.purchaseinventoryList[index].itemQuantity;
} else {
rows.itemQuantity = form.purchaseinventoryList[index].itemMaxQuantity
? form.purchaseinventoryList[index].itemMaxQuantity
: form.purchaseinventoryList[index].itemQuantity;
}
if (rows.unitCode == rows.unitCode_dictText) {
if (rows.unitCode_dictText == rows.unitList.minUnitCode_dictText) {
rows.unitCode = rows.unitList.minUnitCode;
} else {
rows.unitCode = rows.unitList.unitCode;
rows.unitCode_dictText = rows.unitList.unitCode_dictText;
}
}
if (rows.unitCode == rows.unitList.unitCode) {
rows.unitCode_dictText = rows.unitList.unitCode_dictText;
} else if (rows.unitCode == rows.unitList.minUnitCode) {
rows.unitCode_dictText = rows.unitList.minUnitCode_dictText;
}
if (!form.purchaseinventoryList[index].price || form.purchaseinventoryList[index].price <= 0) {
proxy.$message.warning('调拨单价不能为空或为0请检查');
return;
}
form.purchaseinventoryList[index].totalPrice =
form.purchaseinventoryList[index].price * form.purchaseinventoryList[index].itemQuantity;
rowList.value.push(JSON.parse(JSON.stringify(rows)));
if (
rowList._rawValue &&
rowList._rawValue.length == form.purchaseinventoryList.length
) {
addTransferProducts(rowList._rawValue);
}
}
});
}
});
}
});
// 过滤出未保存的行,已保存的行不重复提交
const listToCheck = route.query.supplyBusNo
? forms.purchaseinventoryList
: form.purchaseinventoryList;
const unsavedList = listToCheck.filter(item => !item.isSave);
if (unsavedList.length === 0) {
proxy.$modal.msgWarning('所有行均已保存,无需重复提交');
return;
}
// 先校验表头
proxy.$refs['receiptHeaderRef'].validate((headerValid) => {
if (!headerValid) return;
// 逐行校验(避免异步回调导致重复提交)
const rowsToSave = [];
for (let i = 0; i < form.purchaseinventoryList.length; i++) {
const r = form.purchaseinventoryList[i];
if (!r) continue;
// 跳过已保存的行,避免重复提交导致预扣减库存叠加
if (r.isSave) continue;
// 校验当前行的必填字段
let rowValid = true;
for (const prop of ['name', 'unitCode']) {
const formRef = proxy.$refs['formRef'];
if (formRef && formRef.validateField) {
formRef.validateField(`purchaseinventoryList.${i}.${prop}`, (valid) => {
if (valid) rowValid = false;
});
}
}
if (!rowValid) {
proxy.$modal.msgWarning('第' + (i + 1) + '行数据不完整,请检查');
return;
}
// 单价校验
if (!r.price || r.price <= 0) {
proxy.$modal.msgWarning('第' + (i + 1) + '行调拨单价不能为空或为0');
return;
}
// 单位处理
const rowData = route.query.supplyBusNo
? JSON.parse(JSON.stringify(forms.purchaseinventoryList[i]))
: JSON.parse(JSON.stringify(r));
delete rowData.itemMaxQuantity;
if (rowData.unitCode == rowData.unitList?.minUnitCode) {
rowData.itemQuantity = r.olditemQuantity || r.itemQuantity;
} else {
rowData.itemQuantity = r.itemMaxQuantity || r.itemQuantity;
}
if (rowData.unitCode == rowData.unitCode_dictText) {
if (rowData.unitCode_dictText == rowData.unitList?.minUnitCode_dictText) {
rowData.unitCode = rowData.unitList.minUnitCode;
} else {
rowData.unitCode = rowData.unitList.unitCode;
rowData.unitCode_dictText = rowData.unitList.unitCode_dictText;
}
}
if (rowData.unitCode == rowData.unitList?.unitCode) {
rowData.unitCode_dictText = rowData.unitList.unitCode_dictText;
} else if (rowData.unitCode == rowData.unitList?.minUnitCode) {
rowData.unitCode_dictText = rowData.unitList.minUnitCode_dictText;
}
// 计算总价
r.totalPrice = r.price * rowData.itemQuantity;
rowsToSave.push(rowData);
}
// 所有行校验通过,一次性提交
if (rowsToSave.length > 0) {
addTransferProducts(rowsToSave);
}
});
}
function addTransferProducts(rowList) {
addTransferProduct(JSON.parse(JSON.stringify(rowList))).then((res) => {
// 当前行没有id视为首次新增
// if (!row.id) {
// data.isAdding = false; // 允许新增下一行
// }
if (res.data) {
proxy.$message.success('保存成功!');
let newIdIndex = 0;
form.purchaseinventoryList.map((row, index) => {
form.purchaseinventoryList[index].id = res.data[index];
// 只有未保存的行才会拿到新 id和提交顺序一致
if (!row.isSave && res.data[newIdIndex]) {
form.purchaseinventoryList[index].id = res.data[newIdIndex];
newIdIndex++;
}
form.purchaseinventoryList[index].isSave = true;
});
if (route.query.supplyBusNo) {
// 编辑
let newIdIdx = 0;
forms.purchaseinventoryList.map((row, index) => {
forms.purchaseinventoryList[index].id = res.data[index];
if (!row.isSave && res.data[newIdIdx]) {
forms.purchaseinventoryList[index].id = res.data[newIdIdx];
newIdIdx++;
}
forms.purchaseinventoryList[index].isSave = true;
});
}