|
@@ -956,7 +956,7 @@ function initDetailTable() {
|
|
|
$(".ui-jqgrid-sdiv").hide();
|
|
|
}
|
|
|
},
|
|
|
- colNames: ['发药', '拒退', '批号', '单号', '住院号', '床号', '次数', '姓名', '药品名称', '规格', '数量', '原发药量', '零售价', '金额', '执行时间', '医嘱', '给药方式','确认时间'
|
|
|
+ colNames: ['发药', '拒退', '批号', '追溯码', '单号', '住院号', '床号', '次数', '姓名', '药品名称', '规格', '数量', '原发药量', '零售价', '金额', '执行时间', '医嘱', '给药方式','确认时间'
|
|
|
, '频率', '剂量', '单位', '生日', '性别', '身份', '诊断', '科室', '病室', '是否婴儿', '请领人', '长期标志', '药品类型', '给药方式编码', '医嘱号',
|
|
|
'自费标志', '单列', '贵重', '毒麻', '审批标志', '药房编码', '规格', '医生编码', '药单类别', '药品编码', '口服开始时间', '口服结束时间', '帐页号', '流水号', '医生', '医保编码','执行科室(医技药单用)'],
|
|
|
colModel: [
|
|
@@ -1000,6 +1000,18 @@ function initDetailTable() {
|
|
|
hidden: (pageClass == 'T' || pageClass == 'HT') ? true : false,
|
|
|
edittype: "text"
|
|
|
},
|
|
|
+ {
|
|
|
+ name: 'drugTracCodg',
|
|
|
+ index: 'drugTracCodg',
|
|
|
+ align: 'center',
|
|
|
+ width: 40,
|
|
|
+ editable: true,
|
|
|
+ hidden: (pageClass == 'T' || pageClass == 'HT') ? true : false,
|
|
|
+ edittype: "text",
|
|
|
+ formatter: function (cellvalue, options, rowObject) {
|
|
|
+ return cellvalue || "";
|
|
|
+ }
|
|
|
+ },
|
|
|
{name: 'pageNo', index: 'pageNo', align: 'center', width: 30, hidden: true},
|
|
|
{name: 'inpatientNo', index: 'inpatientNo', align: 'center', width: 30},
|
|
|
{name: 'bedNo', index: 'bedNo', align: 'center', width: 30, hidden: pageClass == 'A' ? true : false},
|
|
@@ -1109,6 +1121,19 @@ function initDetailTable() {
|
|
|
if (celname === 'manuNo') {
|
|
|
return true
|
|
|
}
|
|
|
+ if (celname === 'drugTracCodg') {
|
|
|
+ // 处理追溯码输入
|
|
|
+ let rowData = $("#tb_detail_table").getRowData(rowid);
|
|
|
+ let $cell = $("#" + rowid + "_drugTracCodg");
|
|
|
+
|
|
|
+ // 如果输入的是追溯码(通常是一串数字或字母组合)
|
|
|
+ if (value && value.trim().length > 0) {
|
|
|
+ // 验证并添加追溯码
|
|
|
+ validateAndAddTracCodgWard(value.trim(), rowData, $cell);
|
|
|
+ return false; // 阻止默认的单元格保存行为
|
|
|
+ }
|
|
|
+ return true;
|
|
|
+ }
|
|
|
let data = $("#tb_detail_table").getRowData(rowid);
|
|
|
$("#tb_detail_table").setCell(rowid, iCol, value);
|
|
|
if (value == null || value == 0) {
|
|
@@ -1141,11 +1166,13 @@ function initDetailTable() {
|
|
|
$("#t_tb_detail_table").append("<button class='registration-no-color-foot-button' title='确认药单' id='detail_save' onclick='save(1)' style='color: green;margin-left: 10px;'><i class='fa fa-floppy-o'></i></button>");
|
|
|
} else {
|
|
|
$("#t_tb_detail_table").append("<button class='registration-no-color-foot-button' title='保存批号' id='manu_save_mx' style='color: green;margin-left: 10px;'><i class='fa fa-floppy-o'></i></button>");
|
|
|
+ $("#t_tb_detail_table").append("<button class='registration-no-color-foot-button' title='扫码框聚焦' id='btn_restore_scan' style='color: blue;margin-left: 10px;'><i class='fa fa-barcode'></i></button>");
|
|
|
}
|
|
|
$("#manu_save_mx").click(function (t) {
|
|
|
var obj = $('#tb_detail_table');
|
|
|
var rowIds = obj.getDataIDs();
|
|
|
var arrayData = new Array();
|
|
|
+ var tracCodgArrayData = new Array(); // 追溯码数据
|
|
|
if (rowIds.length > 0) {
|
|
|
for (var i = 0; i < rowIds.length; i++) {
|
|
|
let rowDate = obj.getRowData(rowIds[i]);
|
|
@@ -1158,16 +1185,55 @@ function initDetailTable() {
|
|
|
manuNo: rowDate.manuNo
|
|
|
});
|
|
|
}
|
|
|
+ // 保存追溯码数据
|
|
|
+ if (!isEmpty(rowDate.drugTracCodg)) {
|
|
|
+ tracCodgArrayData.push({
|
|
|
+ actOrderNo: rowDate.actOrderNo,
|
|
|
+ chargeCode: rowDate.chargeCode,
|
|
|
+ inpatientNo: rowDate.inpatientNo,
|
|
|
+ orderDate: rowDate.occTime,
|
|
|
+ drugTracCodg: rowDate.drugTracCodg
|
|
|
+ });
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
- request({
|
|
|
- url: '/modifyManuNoZy',
|
|
|
- method: 'POST',
|
|
|
- data: JSON.stringify(arrayData)
|
|
|
- }).then((res) => {
|
|
|
- successMesage(res);
|
|
|
- initButtonChange("#qld", 0);
|
|
|
- });
|
|
|
+
|
|
|
+ // 保存批号
|
|
|
+ if (arrayData.length > 0) {
|
|
|
+ request({
|
|
|
+ url: '/modifyManuNoZy',
|
|
|
+ method: 'POST',
|
|
|
+ data: JSON.stringify(arrayData)
|
|
|
+ }).then((res) => {
|
|
|
+ successMesage(res);
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+ // 保存追溯码
|
|
|
+ if (tracCodgArrayData.length > 0) {
|
|
|
+ request({
|
|
|
+ url: '/thmz/saveDrugTracCodg',
|
|
|
+ method: 'POST',
|
|
|
+ data: JSON.stringify(tracCodgArrayData)
|
|
|
+ }).then((res) => {
|
|
|
+ if (res.code === 0) {
|
|
|
+ successMesageSimaple("追溯码保存成功");
|
|
|
+ } else {
|
|
|
+ errorMesage(res);
|
|
|
+ }
|
|
|
+ }).catch((error) => {
|
|
|
+ console.error('保存追溯码失败:', error);
|
|
|
+ errorMesageSimaple("保存追溯码失败");
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+ initButtonChange("#qld", 0);
|
|
|
+ });
|
|
|
+
|
|
|
+ // 恢复扫码框聚焦按钮点击事件
|
|
|
+ $("#btn_restore_scan").click(function() {
|
|
|
+ $("#barCode").focus();
|
|
|
+ successMesageSimaple("扫码框已激活,可以继续扫码批号");
|
|
|
});
|
|
|
}
|
|
|
|
|
@@ -2108,3 +2174,146 @@ function saveSummaryData(printFlag, summaryData) {
|
|
|
});
|
|
|
}
|
|
|
|
|
|
+/**
|
|
|
+ * 验证并添加追溯码
|
|
|
+ * @param tracCodg 追溯码
|
|
|
+ * @param rowData 行数据
|
|
|
+ * @param $element 单元格元素
|
|
|
+ */
|
|
|
+function validateAndAddTracCodgWard(tracCodg, rowData, $element) {
|
|
|
+ // 构建验证数据,适配住院药房的数据结构
|
|
|
+ let validateData = {
|
|
|
+ drugTracCodg: tracCodg,
|
|
|
+ patientId: rowData.inpatientNo, // 住院药房使用inpatientNo
|
|
|
+ times: rowData.admissTimes, // 住院药房使用admissTimes
|
|
|
+ receiptNo: rowData.pageNo, // 住院药房使用pageNo
|
|
|
+ orderNo: rowData.actOrderNo, // 住院药房使用actOrderNo
|
|
|
+ itemNo: rowData.serial, // 住院药房使用serial
|
|
|
+ chargeItemCode: rowData.chargeCode, // 住院药房使用chargeCode
|
|
|
+ drugName: rowData.drugName,
|
|
|
+ specification: rowData.specification
|
|
|
+ };
|
|
|
+
|
|
|
+ console.log('住院药房验证追溯码参数:', validateData);
|
|
|
+ console.log('行数据:', rowData);
|
|
|
+
|
|
|
+ $.ajax({
|
|
|
+ type: "POST",
|
|
|
+ url: '/thmz/validateDrugTracCodgForDispensing',
|
|
|
+ contentType: "application/json;charset=UTF-8",
|
|
|
+ dataType: "json",
|
|
|
+ headers: {
|
|
|
+ 'Accept': 'application/json',
|
|
|
+ 'Authorization': 'Bearer ' + localStorage.getItem("token")
|
|
|
+ },
|
|
|
+ data: JSON.stringify(validateData),
|
|
|
+ success: function (res) {
|
|
|
+ console.log('验证响应:', res);
|
|
|
+ if (res.code == 0 && res.data && res.data.isValid) {
|
|
|
+ // 验证成功,添加到追溯码集合
|
|
|
+ addTracCodgToCellWard(tracCodg, $element);
|
|
|
+ successMesage(res);
|
|
|
+ // 验证成功后,保持单元格可编辑状态
|
|
|
+ $element.focus();
|
|
|
+ } else {
|
|
|
+ // 验证失败
|
|
|
+ errorMesage(res);
|
|
|
+ // 验证失败时,清理掉无效的追溯码
|
|
|
+ let currentContent = $element.html();
|
|
|
+ let codes = currentContent.split('<br>').filter(code => code.trim().length > 0);
|
|
|
+
|
|
|
+ // 去掉最后一个追溯码(无效的追溯码)
|
|
|
+ if (codes.length > 0) {
|
|
|
+ codes.pop();
|
|
|
+ // 重新设置单元格内容
|
|
|
+ let newContent = codes.join('<br>');
|
|
|
+ if (newContent) {
|
|
|
+ newContent += '<br>';
|
|
|
+ }
|
|
|
+ $element.html(newContent);
|
|
|
+
|
|
|
+ // 保持焦点在单元格末尾
|
|
|
+ $element.focus();
|
|
|
+ let range = document.createRange();
|
|
|
+ let selection = window.getSelection();
|
|
|
+ range.selectNodeContents($element[0]);
|
|
|
+ range.collapse(false);
|
|
|
+ selection.removeAllRanges();
|
|
|
+ selection.addRange(range);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ },
|
|
|
+ error: function (xhr, status, error) {
|
|
|
+ console.error('验证请求失败:', error);
|
|
|
+ errorMesageSimaple("验证请求失败");
|
|
|
+ // 错误时也清理掉无效的追溯码
|
|
|
+ let currentContent = $element.html();
|
|
|
+ let codes = currentContent.split('<br>').filter(code => code.trim().length > 0);
|
|
|
+
|
|
|
+ // 去掉最后一个追溯码(无效的追溯码)
|
|
|
+ if (codes.length > 0) {
|
|
|
+ codes.pop();
|
|
|
+ // 重新设置单元格内容
|
|
|
+ let newContent = codes.join('<br>');
|
|
|
+ if (newContent) {
|
|
|
+ newContent += '<br>';
|
|
|
+ }
|
|
|
+ $element.html(newContent);
|
|
|
+
|
|
|
+ // 保持焦点在单元格末尾
|
|
|
+ $element.focus();
|
|
|
+ let range = document.createRange();
|
|
|
+ let selection = window.getSelection();
|
|
|
+ range.selectNodeContents($element[0]);
|
|
|
+ range.collapse(false);
|
|
|
+ selection.removeAllRanges();
|
|
|
+ selection.addRange(range);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
+}
|
|
|
+
|
|
|
+/**
|
|
|
+ * 添加追溯码到单元格(住院药房版本)
|
|
|
+ * @param tracCodg 追溯码(单个追溯码,不包含分隔符)
|
|
|
+ * @param $element 单元格元素
|
|
|
+ */
|
|
|
+function addTracCodgToCellWard(tracCodg, $element) {
|
|
|
+ let currentValue = $element.html();
|
|
|
+
|
|
|
+ console.log('addTracCodgToCellWard 开始');
|
|
|
+ console.log('传入的追溯码:', tracCodg);
|
|
|
+ console.log('当前单元格内容:', currentValue);
|
|
|
+
|
|
|
+ if (isEmpty(currentValue)) {
|
|
|
+ // 如果单元格为空,直接设置追溯码
|
|
|
+ console.log('单元格为空,直接设置追溯码');
|
|
|
+ $element.html(tracCodg);
|
|
|
+ } else {
|
|
|
+ // 检查是否已存在该追溯码
|
|
|
+ let existingCodes = currentValue.split('<br>');
|
|
|
+ console.log('已存在的追溯码列表:', existingCodes);
|
|
|
+ console.log('是否已存在:', existingCodes.includes(tracCodg));
|
|
|
+
|
|
|
+ if (!existingCodes.includes(tracCodg)) {
|
|
|
+ // 如果不存在,添加<br>分隔符后追加
|
|
|
+ let newValue = currentValue + '<br>' + tracCodg;
|
|
|
+ console.log('添加追溯码,新内容:', newValue);
|
|
|
+ $element.html(newValue);
|
|
|
+ } else {
|
|
|
+ // 追溯码已存在,显示提示
|
|
|
+ console.log('追溯码已存在,显示提示');
|
|
|
+ if (typeof PNotify !== 'undefined') {
|
|
|
+ new PNotify({
|
|
|
+ title: '提示',
|
|
|
+ text: '该追溯码已添加',
|
|
|
+ type: 'info',
|
|
|
+ delay: 2000
|
|
|
+ });
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ console.log('addTracCodgToCellWard 结束,最终单元格内容:', $element.html());
|
|
|
+}
|
|
|
+
|