|
@@ -111,6 +111,71 @@ $(function () {
|
|
|
});
|
|
|
// 追溯码数量确认弹框的确认发药按钮
|
|
|
$("#confirmTracCodgSend").click(function (t) {
|
|
|
+ // ================= 新增:确认发药时再次验证追溯码数量 =================
|
|
|
+ // 目的:确保追溯码数量与处方数量完全匹配才能发药
|
|
|
+ // 获取处方明细表格数据
|
|
|
+ let tableData = $("#tb_table_right").bootstrapTable('getData');
|
|
|
+ let hasMismatch = false;
|
|
|
+ let mismatchMessage = '';
|
|
|
+
|
|
|
+ console.log('确认发药时验证追溯码数量,表格数据:', tableData);
|
|
|
+
|
|
|
+ // 遍历每种药品,检查追溯码数量
|
|
|
+ for (let i = 0; i < tableData.length; i++) {
|
|
|
+ let drug = tableData[i];
|
|
|
+ let prescriptionQuantity = parseInt(drug.quantity) || 0; // 处方数量
|
|
|
+ let tracCodgCount = 0; // 追溯码数量
|
|
|
+
|
|
|
+ // 计算该药品的追溯码数量
|
|
|
+ if (!isEmpty(drug.drugTracCodg)) {
|
|
|
+ // 按<br>分割追溯码,过滤空值
|
|
|
+ let tracCodgList = drug.drugTracCodg.split('<br>').filter(code => code.length > 0);
|
|
|
+ tracCodgCount = tracCodgList.length;
|
|
|
+ }
|
|
|
+
|
|
|
+ console.log('药品:', drug.drugname, '处方数量:', prescriptionQuantity, '追溯码数量:', tracCodgCount);
|
|
|
+
|
|
|
+ // 检查数量是否匹配
|
|
|
+ if (tracCodgCount !== prescriptionQuantity) {
|
|
|
+ hasMismatch = true;
|
|
|
+ let difference = tracCodgCount - prescriptionQuantity;
|
|
|
+ let differenceText = '';
|
|
|
+
|
|
|
+ if (difference > 0) {
|
|
|
+ differenceText = '多输入 ' + difference + ' 个';
|
|
|
+ } else {
|
|
|
+ differenceText = '缺少 ' + Math.abs(difference) + ' 个';
|
|
|
+ }
|
|
|
+
|
|
|
+ mismatchMessage += '药品【' + drug.drugname + '】: 处方数量 ' + prescriptionQuantity + ',追溯码数量 ' + tracCodgCount + ',' + differenceText + ';\n';
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ // 如果数量不匹配,阻止发药并显示错误提示
|
|
|
+ if (hasMismatch) {
|
|
|
+ console.error('追溯码数量不匹配,阻止发药:', mismatchMessage);
|
|
|
+ errorMesageSimaple('追溯码数量与处方数量不匹配,无法发药!\n\n' + mismatchMessage);
|
|
|
+ return; // 阻止后续操作
|
|
|
+ }
|
|
|
+ // ================= 新增结束 =================
|
|
|
+
|
|
|
+ // ================= 原代码(已隐藏,可能复用) =================
|
|
|
+ /*
|
|
|
+ // 获取存储的发药参数
|
|
|
+ let sendParams = window.pendingSendParams;
|
|
|
+ if (sendParams) {
|
|
|
+ // 隐藏确认弹框
|
|
|
+ $('#tracCodgConfirmModal').modal('hide');
|
|
|
+ // 执行发药处理
|
|
|
+ sendMedicineProcessing(sendParams.realNo, sendParams.orderNo, sendParams.receiptNo,
|
|
|
+ sendParams.times, sendParams.patientId, sendParams.name, sendParams.pharPracCertNo);
|
|
|
+ // 清除存储的参数
|
|
|
+ window.pendingSendParams = null;
|
|
|
+ }
|
|
|
+ */
|
|
|
+ // ================= 原代码结束 =================
|
|
|
+
|
|
|
+ // ================= 新增:数量匹配时的处理逻辑 =================
|
|
|
// 获取存储的发药参数
|
|
|
let sendParams = window.pendingSendParams;
|
|
|
if (sendParams) {
|
|
@@ -121,7 +186,9 @@ $(function () {
|
|
|
sendParams.times, sendParams.patientId, sendParams.name, sendParams.pharPracCertNo);
|
|
|
// 清除存储的参数
|
|
|
window.pendingSendParams = null;
|
|
|
+ console.log('追溯码数量验证通过,执行发药处理');
|
|
|
}
|
|
|
+ // ================= 新增结束 =================
|
|
|
});
|
|
|
|
|
|
$("#printSend").click(function (t) {
|