|
|
@@ -783,8 +783,74 @@ const gd_lcdCancel = async () => {
|
|
|
});
|
|
|
};
|
|
|
|
|
|
- const SLIndex = ref(0);
|
|
|
- const JYCurrent = ref(0);
|
|
|
+
|
|
|
+ // 数量回车事件
|
|
|
+ let selectData = []; // 初始化为数组
|
|
|
+ const handleFpslEnter = async (event, index, row, title) => {
|
|
|
+ // 保存当前行索引
|
|
|
+ selectIndex.value = index;
|
|
|
+
|
|
|
+ // 如果数量为 0,则清空对应字段并直接返回
|
|
|
+ if (row.fp_sl === 0 || row.fp_sl === '0' || row.fp_sl === '') {
|
|
|
+ detailData.table[index].fp_gxmc = '';
|
|
|
+ detailData.table[index].fp_bz = '';
|
|
|
+ detailData.table[index].fp_bh = '';
|
|
|
+ detailData.table[index].fp_name = '';
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ // 计算总数
|
|
|
+ let total = 0;
|
|
|
+ detailData.table.forEach((item) => {
|
|
|
+ if (item.fp_sl != 0 && item.fp_sl != '') {
|
|
|
+ total += parseInt(item.fp_sl);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ detailData.qczl_fp = total;
|
|
|
+
|
|
|
+ // 调用接口获取数据
|
|
|
+ const params = {
|
|
|
+ type: row.fp_lb,
|
|
|
+ order: detailData.qczl_gdbh,
|
|
|
+ yjno: detailData.qczl_yjno,
|
|
|
+ };
|
|
|
+
|
|
|
+ let res;
|
|
|
+ try {
|
|
|
+ res = await getGxAndLeader(params);
|
|
|
+ console.log("接口返回结果", res);
|
|
|
+ if (res.code !== 0) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ } catch (e) {
|
|
|
+ console.log(e);
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ // 解析返回的数据
|
|
|
+ const decodedData = res.data.map(item => ({
|
|
|
+ sczl_gxmc: decodeEntities(item.sczl_gxmc),
|
|
|
+ sczl_bzdh: item.sczl_bzdh,
|
|
|
+ sczl_jtbbh: item.sczl_jtbh,
|
|
|
+ sczl_bh1: item.sczl_bh1,
|
|
|
+ name: item.name.trim(),
|
|
|
+ }));
|
|
|
+
|
|
|
+ // 如果数据为空,直接返回
|
|
|
+ if (decodedData.length === 0) {
|
|
|
+ console.log("接口返回数据为空");
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ // 初始化选中数据
|
|
|
+ selectData = decodedData;
|
|
|
+ SLIndex.value = 0; // 初始化索引为第一个
|
|
|
+ setCurrent(selectData[0]); // 设置当前选中为第一个
|
|
|
+ dialogSelectVisible2.value = true; // 显示弹窗
|
|
|
+ };
|
|
|
+
|
|
|
+ // 选择逻辑
|
|
|
+ const SLIndex = ref(0); // 初始化索引为 0
|
|
|
const selectSL = (event) => {
|
|
|
console.log("键盘事件触发", event.keyCode);
|
|
|
if (event.keyCode === 40) { // 向下箭头
|
|
|
@@ -807,17 +873,18 @@ const gd_lcdCancel = async () => {
|
|
|
console.log("回车键触发");
|
|
|
|
|
|
// 如果未通过上下箭头选择,则默认选中第一个
|
|
|
- if (SLIndex.value === null || SLIndex.value === undefined) {
|
|
|
+ if (SLIndex.value === null || SLIndex.value === undefined || selectData.length === 0) {
|
|
|
SLIndex.value = 0; // 默认选中第一个
|
|
|
}
|
|
|
|
|
|
// 获取当前选中的数据
|
|
|
const selectedRow = selectData[SLIndex.value];
|
|
|
+ if (!selectedRow) {
|
|
|
+ console.log("选中数据为空");
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
console.log("关闭弹窗,选中数据为:", selectedRow);
|
|
|
- console.log(selectedRow.sczl_gxmc);
|
|
|
- console.log(selectedRow.sczl_bzdh);
|
|
|
- console.log(selectedRow.sczl_bh1);
|
|
|
- console.log(selectedRow.name);
|
|
|
|
|
|
// 确保 selectIndex.value 是有效的当前行索引
|
|
|
if (selectIndex.value !== null) {
|
|
|
@@ -1341,6 +1408,7 @@ const gd_lcdCancel = async () => {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ let isProcessing = false; // 标志位
|
|
|
//新增回车事件
|
|
|
const ent1 = async(event,index,row,title) => {
|
|
|
const inputs = document.getElementsByTagName('input');
|
|
|
@@ -1453,39 +1521,61 @@ const gd_lcdCancel = async () => {
|
|
|
nextIndex++;
|
|
|
}
|
|
|
}else if (event.keyCode === 13 && title === '数量') {
|
|
|
+ if (isProcessing) {
|
|
|
+ console.log("当前正在处理回车事件,忽略重复触发");
|
|
|
+ return; // 如果正在处理,直接返回
|
|
|
+ }
|
|
|
+
|
|
|
+ isProcessing = true; // 标志正在处理
|
|
|
+ event.preventDefault(); // 阻止默认行为
|
|
|
+
|
|
|
console.log("数量回车");
|
|
|
-
|
|
|
- // 判断数量是否为 0
|
|
|
+
|
|
|
+ // 去掉数量前导的0
|
|
|
+ if (typeof row.fp_sl === 'string') {
|
|
|
+ row.fp_sl = row.fp_sl.replace(/^0+(?=\d)/, '');
|
|
|
+ }
|
|
|
+
|
|
|
+ // 判断数量是否为 0 或为空
|
|
|
if (row.fp_sl === '0' || row.fp_sl === '' || row.fp_sl === 0) {
|
|
|
console.log("数量为 0,清空对应字段");
|
|
|
- detailData.table[index].fp_gxmc = '';
|
|
|
- detailData.table[index].fp_bz = '';
|
|
|
- detailData.table[index].fp_bh = '';
|
|
|
- detailData.table[index].fp_name = '';
|
|
|
+ ['fp_gxmc', 'fp_bz', 'fp_bh', 'fp_name'].forEach(field => {
|
|
|
+ detailData.table[index][field] = '';
|
|
|
+ });
|
|
|
} else {
|
|
|
- handleFpslEnter(event, index, row, title);
|
|
|
+ // 异步调用 handleFpslEnter
|
|
|
+ await handleFpslEnter(event, index, row, title);
|
|
|
+
|
|
|
+ if (!detailData.table[index].fp_gxmc) {
|
|
|
+ console.log("字段 fp_gxmc 为空,不能跳转到下一个输入框");
|
|
|
+ isProcessing = false; // 重置标志
|
|
|
+ return; // 阻止跳转
|
|
|
+ }
|
|
|
}
|
|
|
-
|
|
|
- // 焦点移动到下一个可用输入框
|
|
|
+
|
|
|
+ // 焦点跳转逻辑
|
|
|
let nextIndex = currentIndex + 1;
|
|
|
- let foundNext = false; // 标记是否找到下一个可用的输入框
|
|
|
+ let foundNext = false;
|
|
|
+
|
|
|
while (nextIndex < inputs.length) {
|
|
|
- if (inputs[nextIndex].disabled) {
|
|
|
- // 当前输入框为 disabled,跳过
|
|
|
- nextIndex++;
|
|
|
- continue;
|
|
|
- }
|
|
|
- if (!inputs[nextIndex].readOnly) {
|
|
|
- nextTick(() => {
|
|
|
- inputs[nextIndex].focus();
|
|
|
- inputs[nextIndex].select();
|
|
|
- });
|
|
|
- foundNext = true; // 找到下一个可用输入框
|
|
|
+ const nextInput = inputs[nextIndex];
|
|
|
+ if (!nextInput.disabled && !nextInput.readOnly) {
|
|
|
+ nextInput.focus();
|
|
|
+ nextInput.select();
|
|
|
+ foundNext = true;
|
|
|
+ console.log(`焦点已跳转到输入框索引: ${nextIndex}`);
|
|
|
break;
|
|
|
}
|
|
|
nextIndex++;
|
|
|
}
|
|
|
-}else if (event.keyCode === 13 || event.keyCode === 40 && title === '') {
|
|
|
+
|
|
|
+ if (!foundNext) {
|
|
|
+ console.log("未找到下一个可用的输入框");
|
|
|
+ }
|
|
|
+
|
|
|
+ isProcessing = false; // 标志位重置,允许下一次回车处理
|
|
|
+}
|
|
|
+else if (event.keyCode === 13 || event.keyCode === 40 && title === '') {
|
|
|
console.log('其他')
|
|
|
let nextIndex = currentIndex + 1;
|
|
|
let foundNext = false; // 标记是否找到下一个可用的输入框
|
|
|
@@ -1547,65 +1637,7 @@ const gd_lcdCancel = async () => {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- //数量回车事件
|
|
|
- // const selectData = reactive([])
|
|
|
- let selectData = []
|
|
|
- const handleFpslEnter = async (event, index, row, title) => {
|
|
|
- // 保存当前行索引
|
|
|
- selectIndex.value = index;
|
|
|
-
|
|
|
- // 如果数量为 0,则清空对应字段并直接返回
|
|
|
- if (row.fp_sl === 0 || row.fp_sl === '0' || row.fp_sl === '') {
|
|
|
- detailData.table[index].fp_gxmc = '';
|
|
|
- detailData.table[index].fp_bz = '';
|
|
|
- detailData.table[index].fp_bh = '';
|
|
|
- detailData.table[index].fp_name = '';
|
|
|
- return;
|
|
|
- }
|
|
|
-
|
|
|
- // 只有数量为 1 时弹出页面
|
|
|
- // if (row.fp_sl === '1') {
|
|
|
- // 计算总数
|
|
|
- let total = 0;
|
|
|
- detailData.table.forEach((item) => {
|
|
|
- if (item.fp_sl != 0 && item.fp_sl != '') {
|
|
|
- total += parseInt(item.fp_sl);
|
|
|
- }
|
|
|
- });
|
|
|
- detailData.qczl_fp = total;
|
|
|
-
|
|
|
- // 调用接口获取数据
|
|
|
- const params = {
|
|
|
- type: row.fp_lb,
|
|
|
- order: detailData.qczl_gdbh,
|
|
|
- yjno: detailData.qczl_yjno,
|
|
|
- };
|
|
|
-
|
|
|
- let res;
|
|
|
- try {
|
|
|
- res = await getGxAndLeader(params);
|
|
|
- if (res.code !== 0) {
|
|
|
- return;
|
|
|
- }
|
|
|
- } catch (e) {
|
|
|
- console.log(e);
|
|
|
- return;
|
|
|
- }
|
|
|
-
|
|
|
- // 解析返回的数据
|
|
|
- const decodedData = res.data.map(item => ({
|
|
|
- sczl_gxmc: decodeEntities(item.sczl_gxmc),
|
|
|
- sczl_bzdh: item.sczl_bzdh,
|
|
|
- sczl_jtbbh: item.sczl_jtbh,
|
|
|
- sczl_bh1: item.sczl_bh1,
|
|
|
- name: item.name.trim(),
|
|
|
- }));
|
|
|
-
|
|
|
- selectData = decodedData;
|
|
|
- setCurrent(selectData[0]);
|
|
|
- dialogSelectVisible2.value = true; // 显示弹窗
|
|
|
- // }
|
|
|
- };
|
|
|
+
|
|
|
|
|
|
//删除按钮
|
|
|
const handleDelete = () => {
|