|
|
@@ -293,6 +293,7 @@ function sendMedicineProcessing(realNo, orderNo, receiptNo, times, patientId, na
|
|
|
},
|
|
|
drugTracCodgList: drugTracCodgData // 添加药品追溯码数据
|
|
|
};
|
|
|
+ console.log("sendMedicineProcessing1111111111111",temp)
|
|
|
$.ajax({
|
|
|
type: "POST",
|
|
|
url: '/thmz/sendMedicineProcessing',
|
|
|
@@ -1433,17 +1434,33 @@ function prescriptionDetail(realNo, orderNo, receiptNo, times, patientId, confir
|
|
|
* @param {点击列的整行数据} row
|
|
|
* @param {td 元素} $element
|
|
|
*/
|
|
|
+ // onClickCell: function (field, value, row, $element) {
|
|
|
+ // if (field === 'drugTracCodg') {
|
|
|
+ // $element.attr('contenteditable', true);
|
|
|
+ // $element.focus();
|
|
|
+ // $element.blur(function () {
|
|
|
+ // let index = $element.parent().data('index');
|
|
|
+ // let tdValue = $element.html();
|
|
|
+ // saveCellData($('#tb_table_right'), index, field, tdValue);
|
|
|
+ // })
|
|
|
+ // }
|
|
|
+ // },
|
|
|
onClickCell: function (field, value, row, $element) {
|
|
|
if (field === 'drugTracCodg') {
|
|
|
$element.attr('contenteditable', true);
|
|
|
$element.focus();
|
|
|
|
|
|
- // 添加扫码输入监听(新增功能,不影响原有逻辑)
|
|
|
+ // 添加扫码输入监听(带防抖)
|
|
|
let inputTimer = null;
|
|
|
+ let lastInputValue = '';
|
|
|
|
|
|
- $element.off('input.tracCodg').on('input.tracCodg', function(e) {
|
|
|
+ $element.off('input.scan').on('input.scan', function(e) {
|
|
|
let inputValue = e.target.textContent || e.target.innerText;
|
|
|
|
|
|
+ console.log('扫码输入事件触发,输入值:', inputValue);
|
|
|
+ console.log('输入值长度:', inputValue ? inputValue.length : 0);
|
|
|
+ console.log('输入值是否包含<br>:', inputValue ? inputValue.includes('<br>') : false);
|
|
|
+
|
|
|
// 清除之前的定时器
|
|
|
if (inputTimer) {
|
|
|
clearTimeout(inputTimer);
|
|
|
@@ -1452,15 +1469,38 @@ function prescriptionDetail(realNo, orderNo, receiptNo, times, patientId, confir
|
|
|
// 设置防抖定时器,0.5秒后触发验证
|
|
|
inputTimer = setTimeout(function() {
|
|
|
if (inputValue && inputValue.trim().length > 0) {
|
|
|
- // 保存当前内容,用于验证失败时恢复
|
|
|
- let originalContent = $element.html();
|
|
|
- validateAndAddTracCodg(inputValue.trim(), row, $element, originalContent);
|
|
|
+ // 获取最后一个完整的追溯码(根据国家药监局规定,追溯码长度为20位)
|
|
|
+ let currentInput = inputValue.trim();
|
|
|
+ let lastCode = '';
|
|
|
+
|
|
|
+ // 如果输入长度超过20位,取最后20位作为追溯码
|
|
|
+ if (currentInput.length >= 20) {
|
|
|
+ lastCode = currentInput.slice(-20);
|
|
|
+ } else {
|
|
|
+ // 如果输入长度不足20位,不进行验证
|
|
|
+ console.log('输入长度不足20位,不进行验证:', currentInput.length);
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ // 验证追溯码长度是否为20位
|
|
|
+ if (lastCode.length !== 20) {
|
|
|
+ console.log('追溯码长度不正确,不进行验证:', lastCode.length);
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ console.log('防抖触发,准备验证追溯码:', lastCode);
|
|
|
+ console.log('完整输入值:', currentInput);
|
|
|
+ console.log('提取的追溯码:', lastCode);
|
|
|
+ console.log('追溯码长度:', lastCode.length);
|
|
|
+
|
|
|
+ // 验证最后一个完整的追溯码
|
|
|
+ validateAndAddTracCodg(lastCode, row, $element);
|
|
|
}
|
|
|
}, 500);
|
|
|
});
|
|
|
|
|
|
// 保持原有的失去焦点保存逻辑
|
|
|
- $element.off('blur.tracCodg').blur(function () {
|
|
|
+ $element.off('blur.save').on('blur.save', function () {
|
|
|
let index = $element.parent().data('index');
|
|
|
let tdValue = $element.html();
|
|
|
saveCellData($('#tb_table_right'), index, field, tdValue);
|
|
|
@@ -2859,7 +2899,7 @@ $(document).ready(function () {
|
|
|
* @param rowData 行数据
|
|
|
* @param $element 单元格元素
|
|
|
*/
|
|
|
-function validateAndAddTracCodg(tracCodg, rowData, $element, originalContent) {
|
|
|
+function validateAndAddTracCodg(tracCodg, rowData, $element) {
|
|
|
// 构建验证数据,只包含可以从rowData中获取的字段
|
|
|
let validateData = {
|
|
|
drugTracCodg: tracCodg, // 这是用户扫码输入的追溯码
|
|
|
@@ -2898,21 +2938,14 @@ function validateAndAddTracCodg(tracCodg, rowData, $element, originalContent) {
|
|
|
} else {
|
|
|
// 验证失败
|
|
|
errorMesage(res);
|
|
|
- // 验证失败时,恢复原始内容
|
|
|
- if (originalContent !== undefined) {
|
|
|
- $element.html(originalContent);
|
|
|
- }
|
|
|
- // 保持焦点,让用户继续扫码
|
|
|
+ // 验证失败时,保持焦点,让用户继续扫码
|
|
|
$element.focus();
|
|
|
}
|
|
|
},
|
|
|
error: function (xhr, status, error) {
|
|
|
console.error('验证请求失败:', error);
|
|
|
errorMesageSimaple("验证请求失败");
|
|
|
- // 错误时也恢复原始内容
|
|
|
- if (originalContent !== undefined) {
|
|
|
- $element.html(originalContent);
|
|
|
- }
|
|
|
+ // 错误时保持焦点,让用户继续扫码
|
|
|
$element.focus();
|
|
|
}
|
|
|
});
|
|
|
@@ -2920,24 +2953,34 @@ function validateAndAddTracCodg(tracCodg, rowData, $element, originalContent) {
|
|
|
|
|
|
/**
|
|
|
* 添加追溯码到单元格
|
|
|
- * @param tracCodg 追溯码
|
|
|
+ * @param tracCodg 追溯码(单个追溯码,不包含分隔符)
|
|
|
* @param $element 单元格元素
|
|
|
*/
|
|
|
function addTracCodgToCell(tracCodg, $element) {
|
|
|
let currentValue = $element.html();
|
|
|
- let newValue = '';
|
|
|
+
|
|
|
+ console.log('addTracCodgToCell 开始');
|
|
|
+ console.log('传入的追溯码:', tracCodg);
|
|
|
+ console.log('当前单元格内容:', currentValue);
|
|
|
|
|
|
if (isEmpty(currentValue)) {
|
|
|
- newValue = tracCodg;
|
|
|
+ // 如果单元格为空,直接设置追溯码
|
|
|
+ console.log('单元格为空,直接设置追溯码');
|
|
|
+ $element.html(tracCodg);
|
|
|
} else {
|
|
|
// 检查是否已存在该追溯码
|
|
|
let existingCodes = currentValue.split('<br>');
|
|
|
+ console.log('已存在的追溯码列表:', existingCodes);
|
|
|
+ console.log('是否已存在:', existingCodes.includes(tracCodg));
|
|
|
+
|
|
|
if (!existingCodes.includes(tracCodg)) {
|
|
|
- newValue = currentValue + '<br>' + tracCodg;
|
|
|
+ // 如果不存在,添加<br>分隔符后追加
|
|
|
+ let newValue = currentValue + '<br>' + tracCodg;
|
|
|
+ console.log('添加追溯码,新内容:', newValue);
|
|
|
+ $element.html(newValue);
|
|
|
} else {
|
|
|
- // 追溯码已存在,显示提示但不显示错误样式
|
|
|
- console.log('追溯码已存在:', tracCodg);
|
|
|
- // 使用简单的提示,而不是错误消息
|
|
|
+ // 追溯码已存在,显示提示
|
|
|
+ console.log('追溯码已存在,显示提示');
|
|
|
if (typeof PNotify !== 'undefined') {
|
|
|
new PNotify({
|
|
|
title: '提示',
|
|
|
@@ -2946,9 +2989,8 @@ function addTracCodgToCell(tracCodg, $element) {
|
|
|
delay: 2000
|
|
|
});
|
|
|
}
|
|
|
- return;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- $element.html(newValue);
|
|
|
+ console.log('addTracCodgToCell 结束,最终单元格内容:', $element.html());
|
|
|
}
|