|
|
@@ -1855,18 +1855,55 @@ function saveRefundMedicine() {
|
|
|
headers: {'Accept': 'application/json', 'Authorization': 'Bearer ' + localStorage.getItem("token")},
|
|
|
data: JSON.stringify(datas),
|
|
|
success: function (res) {
|
|
|
+ // ========== 调试日志:AJAX成功响应 ==========
|
|
|
+ console.log('=== AJAX成功响应 ===');
|
|
|
+ console.log('响应状态: 成功');
|
|
|
+ console.log('响应数据:', res);
|
|
|
+
|
|
|
$("#btn_ty").attr("disabled", false);
|
|
|
if (res == '401' || res == 401) {
|
|
|
+ console.error('认证失败,跳转到登录页面');
|
|
|
window.location.href = '/thmz/login/view'
|
|
|
return;
|
|
|
}
|
|
|
if (res.code == 0) {
|
|
|
+ console.log('退药处理成功');
|
|
|
successMesage(res);
|
|
|
+
|
|
|
+ // ========== 调用退药医保接口 ==========
|
|
|
+ console.log('=== 开始调用退药医保接口 ===');
|
|
|
+ // 获取退药记录的基本信息
|
|
|
+ let refundData = $table.bootstrapTable('getData');
|
|
|
+ if (refundData && refundData.length > 0) {
|
|
|
+ let firstItem = refundData[0];
|
|
|
+ let patientId = firstItem.patient_id;
|
|
|
+ let times = firstItem.times;
|
|
|
+ let receiptNo = firstItem.receipt_no;
|
|
|
+ let orderNo = firstItem.order_no;
|
|
|
+ let realNo = firstItem.real_no;
|
|
|
+ let name = firstItem.name;
|
|
|
+
|
|
|
+ console.log('退药医保接口参数:', {
|
|
|
+ patientId: patientId,
|
|
|
+ times: times,
|
|
|
+ receiptNo: receiptNo,
|
|
|
+ orderNo: orderNo,
|
|
|
+ realNo: realNo,
|
|
|
+ name: name
|
|
|
+ });
|
|
|
+
|
|
|
+ // 调用退药医保接口
|
|
|
+ callYbReturnGoodsItem(realNo, orderNo, receiptNo, times, patientId, name);
|
|
|
+ } else {
|
|
|
+ console.warn('没有退药数据,跳过医保接口调用');
|
|
|
+ }
|
|
|
+
|
|
|
// 退药成功后重置匹配状态和全局数据
|
|
|
isTyOk = false;
|
|
|
window.currentRefundData = null;
|
|
|
initTbTable();
|
|
|
} else {
|
|
|
+ console.error('退药处理失败:', res.message);
|
|
|
errorMesage(res);
|
|
|
}
|
|
|
},
|
|
|
@@ -3226,4 +3263,142 @@ function callYbSaleGoodsItem(realNo, orderNo, receiptNo, times, patientId, name,
|
|
|
}
|
|
|
});
|
|
|
}
|
|
|
+}
|
|
|
+
|
|
|
+/**
|
|
|
+ * 调用医保商品退货接口
|
|
|
+ * @param realNo 流水号
|
|
|
+ * @param orderNo 处方号
|
|
|
+ * @param receiptNo 发票分票号
|
|
|
+ * @param times 次数
|
|
|
+ * @param patientId 病人ID
|
|
|
+ * @param name 病人姓名
|
|
|
+ */
|
|
|
+function callYbReturnGoodsItem(realNo, orderNo, receiptNo, times, patientId, name) {
|
|
|
+ // 获取退药明细数据
|
|
|
+ let tableData = $("#tb_table").bootstrapTable('getData');
|
|
|
+
|
|
|
+ if (!tableData || tableData.length === 0) {
|
|
|
+ console.log('没有退药明细数据,跳过医保接口调用');
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ // 获取当前用户信息(药师信息)
|
|
|
+ let currentUserName = localStorage.getItem('userName') || '';
|
|
|
+ let currentUserId = localStorage.getItem('userID') || '';
|
|
|
+
|
|
|
+ // 获取当前时间
|
|
|
+ let currentTime = new Date();
|
|
|
+ let selRetnTime = currentTime.getFullYear() + '-' +
|
|
|
+ String(currentTime.getMonth() + 1).padStart(2, '0') + '-' +
|
|
|
+ String(currentTime.getDate()).padStart(2, '0') + ' ' +
|
|
|
+ String(currentTime.getHours()).padStart(2, '0') + ':' +
|
|
|
+ String(currentTime.getMinutes()).padStart(2, '0') + ':' +
|
|
|
+ String(currentTime.getSeconds()).padStart(2, '0');
|
|
|
+
|
|
|
+ // 为每个退药药品调用一次医保接口
|
|
|
+ for (let i = 0; i < tableData.length; i++) {
|
|
|
+ let item = tableData[i];
|
|
|
+
|
|
|
+ // 只处理有退药数量的药品
|
|
|
+ if (item.dec_amount == 0) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+
|
|
|
+ // 获取医生姓名
|
|
|
+ let doctorName = item.doctor_name || item.name || '';
|
|
|
+ if (!doctorName) {
|
|
|
+ doctorName = '未知医生';
|
|
|
+ }
|
|
|
+
|
|
|
+ // 构建医保接口参数
|
|
|
+ let ybData = {
|
|
|
+ // 关联字段 - 直接传递到医保接口
|
|
|
+ patientId: patientId,
|
|
|
+ times: times,
|
|
|
+ receiptNo: receiptNo,
|
|
|
+ orderNo: orderNo,
|
|
|
+ chargeItemCode: item.charge_item_code,
|
|
|
+ realNo: realNo,
|
|
|
+
|
|
|
+ // // 医疗目录编码(医保编码)
|
|
|
+ // medListCodg: item.nationalCode || 'NMLC999',
|
|
|
+
|
|
|
+ // 销售/退货经办人姓名(必填参数)
|
|
|
+ selRetnOpterName: currentUserName,
|
|
|
+
|
|
|
+ // // 销售/退货数量
|
|
|
+ // selRetnCnt: item.dec_amount,
|
|
|
+
|
|
|
+ // // 销售/退货时间
|
|
|
+ // selRetnTime: selRetnTime,
|
|
|
+
|
|
|
+ // // 最终成交单价
|
|
|
+ // finlTrnsPric: item.unit_price,
|
|
|
+
|
|
|
+ // // 处方药标志
|
|
|
+ // rxFlag: item.rxFlag || '0',
|
|
|
+
|
|
|
+ // // 拆零标志(0-否;1-是)
|
|
|
+ // trdnFlag: item.clFlag || '0',
|
|
|
+
|
|
|
+ // 追溯码信息
|
|
|
+ drugtracinfo: []
|
|
|
+ };
|
|
|
+
|
|
|
+ // 处理追溯码(从退药匹配表格获取)
|
|
|
+ let tyTable = $('#ty_table_detail').bootstrapTable("getData");
|
|
|
+ if (tyTable && tyTable.length > 0) {
|
|
|
+ // 查找对应的追溯码
|
|
|
+ for (let j = 0; j < tyTable.length; j++) {
|
|
|
+ let tyItem = tyTable[j];
|
|
|
+ if (tyItem.chargeItemCode === item.charge_item_code &&
|
|
|
+ tyItem.serial === item.serial &&
|
|
|
+ tyItem.itemNo === item.item_no) {
|
|
|
+
|
|
|
+ if (tyItem.drugTracCodg && tyItem.drugTracCodg.trim() !== '') {
|
|
|
+ // 提取追溯码(去除HTML标签)
|
|
|
+ let tracCode = tyItem.drugTracCodg.replace(/<[^>]*>/g, '').trim();
|
|
|
+ if (tracCode) {
|
|
|
+ ybData.drugtracinfo.push({
|
|
|
+ drugTracCodg: tracCode
|
|
|
+ });
|
|
|
+ }
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ // 如果没有追溯码,添加空数组(保持数据结构一致)
|
|
|
+ if (ybData.drugtracinfo.length === 0) {
|
|
|
+ ybData.drugtracinfo = [];
|
|
|
+ }
|
|
|
+
|
|
|
+ console.log('调用医保退药接口,药品:', item.drugname, '参数:', ybData);
|
|
|
+
|
|
|
+ // 调用医保接口
|
|
|
+ $.ajax({
|
|
|
+ type: "POST",
|
|
|
+ url: '/Yb/returnGoodsItem',
|
|
|
+ contentType: "application/json;charset=UTF-8",
|
|
|
+ dataType: "json",
|
|
|
+ headers: {
|
|
|
+ 'Accept': 'application/json',
|
|
|
+ 'Authorization': 'Bearer ' + localStorage.getItem("token")
|
|
|
+ },
|
|
|
+ data: JSON.stringify(ybData),
|
|
|
+ success: function (res) {
|
|
|
+ console.log('医保退药接口调用成功:', res);
|
|
|
+ if (res.code !== 0) {
|
|
|
+ console.error('医保退药接口调用失败:', res.message);
|
|
|
+ // 医保接口失败不影响退药流程,只记录日志
|
|
|
+ }
|
|
|
+ },
|
|
|
+ error: function (xhr, status, error) {
|
|
|
+ console.error('医保退药接口调用失败:', error);
|
|
|
+ // 医保接口失败不影响退药流程,只记录日志
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
}
|