|
|
@@ -104,7 +104,7 @@
|
|
|
<el-col :span="24">
|
|
|
<el-form-item label="工单编号" prop="id" class="mab">
|
|
|
<el-input v-model="formData.sczl_gdbh" id="工单编号" placeholder="Enter回车"
|
|
|
- @keydown="ent1($event)" @blur="getGxMcsubmit"
|
|
|
+ @keydown="ent1($event,$index,row,'工单编号')"
|
|
|
style="width: 118px; margin-right: 5px;" />
|
|
|
<el-input v-model="formData.sczl_yjgx" id="yjgx" :readonly="true"
|
|
|
@keydown="ent1($event)" style="width: 80px; margin-right: 5px;" />
|
|
|
@@ -119,7 +119,7 @@
|
|
|
<el-row :gutter="24">
|
|
|
<el-col :span="6">
|
|
|
<el-form-item label="产量合计" prop="id" class="mab">
|
|
|
- <el-input v-model="formData.sczl_cl" id="产量合计" @keydown="ent1($event)"
|
|
|
+ <el-input v-model="formData.sczl_cl" id="产量合计" :readonly="true" @keydown="ent1($event)"
|
|
|
style="width: 150px;" />
|
|
|
</el-form-item>
|
|
|
</el-col>
|
|
|
@@ -708,9 +708,28 @@
|
|
|
const ent1 = (event,id1,id2,id3) => {
|
|
|
const inputs = document.getElementsByTagName('input');
|
|
|
const currentIndex = Array.from(inputs).indexOf(event.target);
|
|
|
- console.log(id3)
|
|
|
|
|
|
- if (event.keyCode === 13 && id3 === '流程单号') {
|
|
|
+ if (event.keyCode === 13 && id3 === '工单编号') {
|
|
|
+ getGxMcsubmit()
|
|
|
+ let nextIndex = currentIndex + 1;
|
|
|
+ let foundNext = false; // 标记是否找到下一个可用的输入框
|
|
|
+ while (nextIndex < inputs.length) {
|
|
|
+ if (inputs[nextIndex].disabled) {
|
|
|
+ console.log("当前输入框为disabled,跳过");
|
|
|
+ nextIndex++; // 跳过disabled的输入框
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ if (!inputs[nextIndex].readOnly) {
|
|
|
+ nextTick(() => {
|
|
|
+ inputs[nextIndex].focus();
|
|
|
+ inputs[nextIndex].select();
|
|
|
+ });
|
|
|
+ foundNext = true; // 找到下一个可用输入框
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ nextIndex++;
|
|
|
+ }
|
|
|
+ }else if (event.keyCode === 13 && id3 === '流程单号') {
|
|
|
console.log(id3);
|
|
|
|
|
|
// 获取所有相关的输入框值
|
|
|
@@ -728,78 +747,79 @@
|
|
|
];
|
|
|
|
|
|
// 获取当前输入框的值
|
|
|
- const currentValue = event.target.value;
|
|
|
-
|
|
|
- // 如果输入值为 0,跳过重复校验,直接跳转到下一个输入框
|
|
|
- if (currentValue === "0") {
|
|
|
- console.log("输入值为 0,无需校验");
|
|
|
+ let currentValue = event.target.value;
|
|
|
|
|
|
- // 跳转到下一个输入框
|
|
|
- let nextIndex = currentIndex + 1; // 从当前输入框的下一个开始查找
|
|
|
- let foundNext = false; // 标记是否找到下一个可用输入框
|
|
|
-
|
|
|
- while (nextIndex < inputs.length) {
|
|
|
- if (inputs[nextIndex].disabled) {
|
|
|
- console.log("当前输入框为 disabled,跳过");
|
|
|
- nextIndex++; // 跳过 disabled 的输入框
|
|
|
- continue;
|
|
|
- }
|
|
|
- if (!inputs[nextIndex].readOnly) {
|
|
|
- nextTick(() => {
|
|
|
- inputs[nextIndex].focus(); // 聚焦到下一个输入框
|
|
|
- inputs[nextIndex].select(); // 选中下一个输入框的内容
|
|
|
- });
|
|
|
- foundNext = true; // 标记已找到下一个输入框
|
|
|
- break;
|
|
|
- }
|
|
|
- nextIndex++;
|
|
|
- }
|
|
|
+ // 如果输入框为空,自动填充为 0
|
|
|
+ if (currentValue === "") {
|
|
|
+ console.log("输入框为空,自动填充为 0");
|
|
|
+ event.target.value = "0";
|
|
|
+ let nextIndex = currentIndex + 1;
|
|
|
+ let foundNext = false; // 标记是否找到下一个可用的输入框
|
|
|
+ while (nextIndex < inputs.length) {
|
|
|
+ if (inputs[nextIndex].disabled) {
|
|
|
+ console.log("当前输入框为disabled,跳过");
|
|
|
+ nextIndex++; // 跳过disabled的输入框
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ if (!inputs[nextIndex].readOnly) {
|
|
|
+ nextTick(() => {
|
|
|
+ inputs[nextIndex].focus();
|
|
|
+ inputs[nextIndex].select();
|
|
|
+ });
|
|
|
+ foundNext = true; // 找到下一个可用输入框
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ nextIndex++;
|
|
|
+ }
|
|
|
+ return;
|
|
|
+ }
|
|
|
|
|
|
- if (!foundNext) {
|
|
|
- console.log("没有更多可用的输入框");
|
|
|
- }
|
|
|
+ // 转换输入值为数字类型
|
|
|
+ currentValue = Number(currentValue);
|
|
|
|
|
|
- return; // 直接返回,不再执行后续校验逻辑
|
|
|
+ // 判断输入值是否小于 0
|
|
|
+ if (currentValue < 0) {
|
|
|
+ // 如果输入值小于 0,提示错误并清空输入框
|
|
|
+ event.target.value = "";
|
|
|
+ ElMessage({
|
|
|
+ type: 'error',
|
|
|
+ message: '输入的值不能小于 0,请重新输入',
|
|
|
+ });
|
|
|
+ return;
|
|
|
}
|
|
|
|
|
|
- // 检查当前值是否重复(值为 0 不算重复)
|
|
|
- const isDuplicate = allValues.filter((val) => val === currentValue && val !== "0").length > 0;
|
|
|
+ // 检查输入值是否重复
|
|
|
+ const isDuplicate = allValues.filter((val) => val === currentValue).length > 0;
|
|
|
|
|
|
if (isDuplicate) {
|
|
|
- // 如果输入值重复(0 除外),清空当前输入框并提示错误信息
|
|
|
- event.target.value = 0;
|
|
|
+ // 如果值重复,提示错误并清空输入框
|
|
|
+ event.target.value = "";
|
|
|
ElMessage({
|
|
|
type: 'error',
|
|
|
message: '输入的值已存在,请重新输入',
|
|
|
});
|
|
|
} else {
|
|
|
- console.log('输入值无重复');
|
|
|
-
|
|
|
- // 跳转到下一个输入框
|
|
|
- let nextIndex = currentIndex + 1; // 从当前输入框的下一个开始查找
|
|
|
- let foundNext = false; // 标记是否找到下一个可用输入框
|
|
|
-
|
|
|
- while (nextIndex < inputs.length) {
|
|
|
- if (inputs[nextIndex].disabled) {
|
|
|
- console.log("当前输入框为 disabled,跳过");
|
|
|
- nextIndex++; // 跳过 disabled 的输入框
|
|
|
- continue;
|
|
|
- }
|
|
|
- if (!inputs[nextIndex].readOnly) {
|
|
|
- nextTick(() => {
|
|
|
- inputs[nextIndex].focus(); // 聚焦到下一个输入框
|
|
|
- inputs[nextIndex].select(); // 选中下一个输入框的内容
|
|
|
- });
|
|
|
- foundNext = true; // 标记已找到下一个输入框
|
|
|
- break;
|
|
|
- }
|
|
|
- nextIndex++;
|
|
|
- }
|
|
|
-
|
|
|
- if (!foundNext) {
|
|
|
- console.log("没有更多可用的输入框");
|
|
|
- }
|
|
|
+ console.log("输入的值无重复");
|
|
|
+ // 值无重复,可以继续处理逻辑
|
|
|
}
|
|
|
+ let nextIndex = currentIndex + 1;
|
|
|
+ let foundNext = false; // 标记是否找到下一个可用的输入框
|
|
|
+ while (nextIndex < inputs.length) {
|
|
|
+ if (inputs[nextIndex].disabled) {
|
|
|
+ console.log("当前输入框为disabled,跳过");
|
|
|
+ nextIndex++; // 跳过disabled的输入框
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ if (!inputs[nextIndex].readOnly) {
|
|
|
+ nextTick(() => {
|
|
|
+ inputs[nextIndex].focus();
|
|
|
+ inputs[nextIndex].select();
|
|
|
+ });
|
|
|
+ foundNext = true; // 找到下一个可用输入框
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ nextIndex++;
|
|
|
+ }
|
|
|
}
|
|
|
else if (event.keyCode === 13 && id3 === '定额代号') {
|
|
|
console.log("定额代号");
|
|
|
@@ -1210,22 +1230,22 @@ else if (event.keyCode === 13 && id3 === '定额代号') {
|
|
|
document.getElementById('备注').select()
|
|
|
}
|
|
|
ent_sum()
|
|
|
- } else if (event.keyCode === 8) { // 删除箭头
|
|
|
- if (event.target.selectionStart === 0) {
|
|
|
- if (inputName != 1) {
|
|
|
- if (document.getElementById('fp' + (parseInt(inputName) - 1)).readOnly) {
|
|
|
- document.getElementById('bh' + (parseInt(inputName) - 1)).focus()
|
|
|
- document.getElementById('bh' + (parseInt(inputName) - 1)).setSelectionRange(0, 0)
|
|
|
- } else {
|
|
|
- document.getElementById('fp' + (parseInt(inputName) - 1)).focus()
|
|
|
- document.getElementById('fp' + (parseInt(inputName) - 1)).setSelectionRange(0, 0)
|
|
|
- }
|
|
|
- } else {
|
|
|
- document.getElementById('备注').focus()
|
|
|
- document.getElementById('备注').setSelectionRange(0, 0)
|
|
|
- }
|
|
|
- ent_sum()
|
|
|
- }
|
|
|
+ // } else if (event.keyCode === 8) { // 删除箭头
|
|
|
+ // if (event.target.selectionStart === 0) {
|
|
|
+ // if (inputName != 1) {
|
|
|
+ // if (document.getElementById('fp' + (parseInt(inputName) - 1)).readOnly) {
|
|
|
+ // document.getElementById('bh' + (parseInt(inputName) - 1)).focus()
|
|
|
+ // document.getElementById('bh' + (parseInt(inputName) - 1)).setSelectionRange(0, 0)
|
|
|
+ // } else {
|
|
|
+ // document.getElementById('fp' + (parseInt(inputName) - 1)).focus()
|
|
|
+ // document.getElementById('fp' + (parseInt(inputName) - 1)).setSelectionRange(0, 0)
|
|
|
+ // }
|
|
|
+ // } else {
|
|
|
+ // document.getElementById('备注').focus()
|
|
|
+ // document.getElementById('备注').setSelectionRange(0, 0)
|
|
|
+ // }
|
|
|
+ // ent_sum()
|
|
|
+ // }
|
|
|
} else if (event.keyCode === 37) { // 向左箭头
|
|
|
if (event.target.selectionStart === 0) {
|
|
|
if (inputName != 1) {
|
|
|
@@ -1917,7 +1937,12 @@ const entdedh = (event) => {
|
|
|
//刷新页面
|
|
|
getTableData()
|
|
|
}
|
|
|
-
|
|
|
+ setTimeout(() => {
|
|
|
+ const inputElement = document.getElementById('工单编号');
|
|
|
+ if (inputElement) {
|
|
|
+ inputElement.focus();
|
|
|
+ }
|
|
|
+ }, 100);
|
|
|
}
|
|
|
|
|
|
} else if (ADD.value == '修改'){
|