|
|
@@ -123,14 +123,13 @@
|
|
|
</el-col>
|
|
|
<el-col :span="6">
|
|
|
<el-form-item label="定额代号" prop="id" label-width="100px" class="mab">
|
|
|
- <el-input v-model="formData.sczl_dedh" id="定额代号" @keydown="ent1($event)"
|
|
|
- @blur="getDedhsubmit" style="width: 150px;" />
|
|
|
+ <el-input v-model="formData.sczl_dedh" id="定额代号" @keydown="ent1($event,index,row,'定额代号')" style="width: 150px;" />
|
|
|
</el-form-item>
|
|
|
</el-col>
|
|
|
<el-col :span="6">
|
|
|
<el-form-item label="检验类别" prop="name" class="mab">
|
|
|
<el-input v-model="formData.sczl_检验类别" id="检验类别" placeholder="Enter回车"
|
|
|
- @keydown="ent1($event)" @blur="getLbsubmit" style="width: 150px;" />
|
|
|
+ @keydown="ent1($event,index,row,'检验类别')"style="width: 150px;" />
|
|
|
</el-form-item>
|
|
|
</el-col>
|
|
|
<el-col :span="6">
|
|
|
@@ -151,7 +150,7 @@
|
|
|
<el-col :span="6">
|
|
|
<el-form-item label="冲月定额" prop="id" class="mab" label-width="100px">
|
|
|
<el-input v-model="formData.sczl_冲定额" id="冲月定额" placeholder="Enter回车"
|
|
|
- @keydown="ent1($event)" @blur="getCdesubmit()" style="width: 100px;" />
|
|
|
+ @keydown="ent1($event,index,row,'冲月定额')" style="width: 100px;" />
|
|
|
</el-form-item>
|
|
|
</el-col>
|
|
|
</el-row>
|
|
|
@@ -160,23 +159,23 @@
|
|
|
<el-row :gutter="24">
|
|
|
<el-col :span="17">
|
|
|
<el-form-item label="流程单号" prop="id" class="mab">
|
|
|
- <el-input v-model="formData.流程单号1" id="流程单号1" @keydown="ent1($event)"
|
|
|
+ <el-input v-model="formData.流程单号1" id="流程单号1" @keydown="ent1($event,index,row,'流程单号')"
|
|
|
style="width: 60px; margin-right: 5px;" />
|
|
|
- <el-input v-model="formData.流程单号2" id="流程单号2" @keydown="ent1($event)"
|
|
|
+ <el-input v-model="formData.流程单号2" id="流程单号2" @keydown="ent1($event,index,row,'流程单号')"
|
|
|
style="width: 60px; margin-right: 5px;" />
|
|
|
- <el-input v-model="formData.流程单号3" id="流程单号3" @keydown="ent1($event)"
|
|
|
+ <el-input v-model="formData.流程单号3" id="流程单号3" @keydown="ent1($event,index,row,'流程单号')"
|
|
|
style="width: 60px; margin-right: 5px;" />
|
|
|
- <el-input v-model="formData.流程单号4" id="流程单号4" @keydown="ent1($event)"
|
|
|
+ <el-input v-model="formData.流程单号4" id="流程单号4" @keydown="ent1($event,index,row,'流程单号')"
|
|
|
style="width: 60px; margin-right: 5px;" />
|
|
|
- <el-input v-model="formData.流程单号5" id="流程单号5" @keydown="ent1($event)"
|
|
|
+ <el-input v-model="formData.流程单号5" id="流程单号5" @keydown="ent1($event,index,row,'流程单号')"
|
|
|
style="width: 60px; margin-right: 5px;" />
|
|
|
- <el-input v-model="formData.流程单号6" id="流程单号6" @keydown="ent1($event)"
|
|
|
+ <el-input v-model="formData.流程单号6" id="流程单号6" @keydown="ent1($event,index,row,'流程单号')"
|
|
|
style="width: 60px; margin-right: 5px;" />
|
|
|
- <el-input v-model="formData.流程单号7" id="流程单号7" @keydown="ent1($event)"
|
|
|
+ <el-input v-model="formData.流程单号7" id="流程单号7" @keydown="ent1($event,index,row,'流程单号')"
|
|
|
style="width: 60px; margin-right: 5px;" />
|
|
|
- <el-input v-model="formData.流程单号8" id="流程单号8" @keydown="ent1($event)"
|
|
|
+ <el-input v-model="formData.流程单号8" id="流程单号8" @keydown="ent1($event,index,row,'流程单号')"
|
|
|
style="width: 60px; margin-right: 5px;" />
|
|
|
- <el-input v-model="formData.流程单号9" id="流程单号9" @keydown="ent1($event)"
|
|
|
+ <el-input v-model="formData.流程单号9" id="流程单号9" @keydown="ent1($event,index,row,'流程单号')"
|
|
|
style="width: 60px;" />
|
|
|
</el-form-item>
|
|
|
</el-col>
|
|
|
@@ -286,7 +285,7 @@
|
|
|
</template>
|
|
|
</el-dialog>
|
|
|
|
|
|
- <el-dialog v-model="GetDedhVisible" title="选择" destroy-on-close width="600px">
|
|
|
+ <!-- <el-dialog v-model="GetDedhVisible" title="选择" destroy-on-close width="600px">
|
|
|
<el-aside width="250px">
|
|
|
<div class="JKWTree-tree">
|
|
|
<el-tree :data="GetDedhtreeData" :props="defaultProps" highlight-current="true"
|
|
|
@@ -294,7 +293,29 @@
|
|
|
@node-dblclick="handleNodeDoubleClick"></el-tree>
|
|
|
</div>
|
|
|
</el-aside>
|
|
|
- </el-dialog>
|
|
|
+ </el-dialog> -->
|
|
|
+
|
|
|
+ <el-dialog
|
|
|
+ v-model="GetDedhVisible"
|
|
|
+ title="定额代号"
|
|
|
+ id="tableFplb"
|
|
|
+ @keydown="entdedh($event)"
|
|
|
+ style="margin-top: 5%;"
|
|
|
+ >
|
|
|
+ <el-form>
|
|
|
+ <el-form-item label="定额代号" class="mab" prop="keyOrder"></el-form-item>
|
|
|
+ <div style="border:1px solid #eee; width:100%; height: 600px; overflow-y: auto;">
|
|
|
+ <el-tree
|
|
|
+ :data="GetDedhtreeData"
|
|
|
+ ref="table_fplb"
|
|
|
+ @keydown="handleTreeKeydown"
|
|
|
+ :props="{ children: 'children', label: 'label' }"
|
|
|
+ node-key="id"
|
|
|
+ @node-click="GetDedhhandleNodeClick"
|
|
|
+ ></el-tree>
|
|
|
+ </div>
|
|
|
+ </el-form>
|
|
|
+ </el-dialog>
|
|
|
|
|
|
|
|
|
|
|
|
@@ -688,24 +709,223 @@
|
|
|
}
|
|
|
|
|
|
|
|
|
+ let isProcessing = false; // 标志位
|
|
|
+ let lastFpSl = null; // 记录上一次输入的数量
|
|
|
+ const dialogbutton = ref(false); // 控制对话框显示
|
|
|
+ let enterCount = 0; // 记录回车键按下的次数
|
|
|
+
|
|
|
//键盘 input框跳转
|
|
|
const ent1 = (event,id1,id2,id3) => {
|
|
|
- if(id2 === 'bh0' && event.keyCode === 13){
|
|
|
- getyglist()
|
|
|
- }
|
|
|
const inputs = document.getElementsByTagName('input');
|
|
|
const currentIndex = Array.from(inputs).indexOf(event.target);
|
|
|
- if (event.keyCode === 13 || event.keyCode === 40) { // Enter 或向下箭头
|
|
|
- if (event.target.id == '其他备注') {
|
|
|
- ElMessageBox.confirm('数据存盘?', '提示', {
|
|
|
- confirmButtonText: '确定',
|
|
|
- cancelButtonText: '取消',
|
|
|
- type: 'warning'
|
|
|
- }).then(() => {
|
|
|
- enterDialog()
|
|
|
+ console.log(id3)
|
|
|
+
|
|
|
+ if (event.keyCode === 13 && id3 === '流程单号') {
|
|
|
+ console.log(id3);
|
|
|
+ // 获取所有相关的输入框值
|
|
|
+ const allValues = [
|
|
|
+ formData.value.流程单号1,
|
|
|
+ formData.value.流程单号2,
|
|
|
+ formData.value.流程单号3,
|
|
|
+ formData.value.流程单号4,
|
|
|
+ formData.value.流程单号5,
|
|
|
+ formData.value.流程单号6,
|
|
|
+ formData.value.流程单号7,
|
|
|
+ formData.value.流程单号8,
|
|
|
+ formData.value.流程单号9,
|
|
|
+ formData.value.流程单号10,
|
|
|
+ ];
|
|
|
+ // 获取当前输入框的值
|
|
|
+ const currentValue = event.target.value;
|
|
|
+
|
|
|
+ // 如果当前值为 0,不进行校验,直接跳转到下一个输入框
|
|
|
+ if (currentValue === "0") {
|
|
|
+ console.log("输入值为 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++;
|
|
|
+ }
|
|
|
+ if (!foundNext) {
|
|
|
+ console.log("没有更多可用的输入框");
|
|
|
+ }
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ // 检查是否有重复的值
|
|
|
+ const isDuplicate = allValues.filter((val) => val === currentValue).length > 1;
|
|
|
+
|
|
|
+ if (isDuplicate) {
|
|
|
+ // 如果有重复值,提示用户并清空当前输入框
|
|
|
+ event.target.value = 0;
|
|
|
+ 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("没有更多可用的输入框");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }else if (event.keyCode === 13 && id3 === '定额代号') {
|
|
|
+ console.log("定额代号");
|
|
|
+ GetDedh()
|
|
|
+ // getDedhsubmit(event,id1,id2,id3)
|
|
|
+ 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(id2 === 'bh0' && event.keyCode === 13){
|
|
|
+ getyglist()
|
|
|
+ }else if (event.keyCode === 13 && id3 === '检验类别') {
|
|
|
+ console.log("检验类别");
|
|
|
+ getLbsubmit()
|
|
|
+ let nextIndex = currentIndex + 1;
|
|
|
+ let foundNext = false; // 标记是否找到下一个可用的输入框
|
|
|
+ while (nextIndex < inputs.length) {
|
|
|
+ if (inputs[nextIndex].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 === '冲月定额') {
|
|
|
+ getCdesubmit()
|
|
|
+ let nextIndex = currentIndex + 1;
|
|
|
+ let foundNext = false; // 标记是否找到下一个可用的输入框
|
|
|
+ while (nextIndex < inputs.length) {
|
|
|
+ if (inputs[nextIndex].disabled) {
|
|
|
+ nextIndex++; // 跳过disabled的输入框
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ if (!inputs[nextIndex].readOnly) {
|
|
|
+ nextTick(() => {
|
|
|
+ inputs[nextIndex].focus();
|
|
|
+ inputs[nextIndex].select();
|
|
|
+ });
|
|
|
+ foundNext = true; // 找到下一个可用输入框
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ nextIndex++;
|
|
|
+ }
|
|
|
+ }else if (event.keyCode === 13 || event.keyCode === 40) {
|
|
|
+ console.log('其他')
|
|
|
+ let nextIndex = currentIndex + 1;
|
|
|
+ let foundNext = false; // 标记是否找到下一个可用的输入框
|
|
|
+ while (nextIndex < inputs.length) {
|
|
|
+ if (inputs[nextIndex].disabled) {
|
|
|
+ nextIndex++; // 跳过disabled的输入框
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ if (!inputs[nextIndex].readOnly) {
|
|
|
+ nextTick(() => {
|
|
|
+ inputs[nextIndex].focus();
|
|
|
+ inputs[nextIndex].select();
|
|
|
+ });
|
|
|
+ foundNext = true; // 找到下一个可用输入框
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ nextIndex++;
|
|
|
+ }
|
|
|
+ // 如果没有找到下一个可用输入框,提示用户
|
|
|
+ if (!foundNext) {
|
|
|
+ console.log("已经是最后一个输入框");
|
|
|
+ }
|
|
|
+ }else if (event.keyCode === 13 || event.keyCode === 40) {
|
|
|
+ if (event.target.id == '其他备注') {
|
|
|
+ ElMessageBox.confirm('数据存盘?', '提示', {
|
|
|
+ confirmButtonText: '确定',
|
|
|
+ cancelButtonText: '取消',
|
|
|
+ type: 'warning'
|
|
|
+ }).then(() => {
|
|
|
+ enterDialog()
|
|
|
+ })
|
|
|
+ }
|
|
|
+ for (let i = currentIndex + 1; i < inputs.length; i++) {
|
|
|
+ if (!inputs[i].readOnly) {
|
|
|
+ nextTick(() => {
|
|
|
+ inputs[i].focus();
|
|
|
+ inputs[i].select();
|
|
|
})
|
|
|
+ break;
|
|
|
}
|
|
|
- for (let i = currentIndex + 1; i < inputs.length; i++) {
|
|
|
+ }
|
|
|
+ if (event.target.id.substring(0, 2) == 'cl' || event.target.id.substring(0, 2) == 'fp') {
|
|
|
+ ent_sum()
|
|
|
+ }
|
|
|
+ } else if (event.keyCode === 38) { // 向上箭头
|
|
|
+ for (let i = currentIndex - 1; i >= 0; i--) {
|
|
|
+ if (!inputs[i].readOnly) {
|
|
|
+ nextTick(() => {
|
|
|
+ inputs[i].focus();
|
|
|
+ inputs[i].select();
|
|
|
+ })
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (event.target.id.substring(0, 2) == 'cl' || event.target.id.substring(0, 2) == 'fp') {
|
|
|
+ ent_sum()
|
|
|
+ }
|
|
|
+ } else if (event.keyCode === 37) { // 向左箭头
|
|
|
+ if (event.target.selectionStart === 0) {
|
|
|
+ for (let i = currentIndex - 1; i >= 0; i--) {
|
|
|
if (!inputs[i].readOnly) {
|
|
|
nextTick(() => {
|
|
|
inputs[i].focus();
|
|
|
@@ -717,8 +937,19 @@
|
|
|
if (event.target.id.substring(0, 2) == 'cl' || event.target.id.substring(0, 2) == 'fp') {
|
|
|
ent_sum()
|
|
|
}
|
|
|
- } else if (event.keyCode === 38) { // 向上箭头
|
|
|
- for (let i = currentIndex - 1; i >= 0; i--) {
|
|
|
+ }
|
|
|
+ } else if (event.keyCode === 39) { // 向右箭头
|
|
|
+ if (event.target.id == '其他备注') {
|
|
|
+ ElMessageBox.confirm('数据存盘?', '提示', {
|
|
|
+ confirmButtonText: '确定',
|
|
|
+ cancelButtonText: '取消',
|
|
|
+ type: 'warning'
|
|
|
+ }).then(() => {
|
|
|
+ enterDialog()
|
|
|
+ })
|
|
|
+ }
|
|
|
+ if (event.target.selectionStart === event.target.value.length) {
|
|
|
+ for (let i = currentIndex + 1; i < inputs.length; i++) {
|
|
|
if (!inputs[i].readOnly) {
|
|
|
nextTick(() => {
|
|
|
inputs[i].focus();
|
|
|
@@ -727,65 +958,12 @@
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
- if (event.target.id.substring(0, 2) == 'cl' || event.target.id.substring(0, 2) == 'fp') {
|
|
|
- ent_sum()
|
|
|
- }
|
|
|
- } else if (event.keyCode === 8) { // 删除箭头
|
|
|
- if (event.target.selectionStart === 0) {
|
|
|
- for (let i = currentIndex - 1; i >= 0; i--) {
|
|
|
- if (!inputs[i].readOnly) {
|
|
|
- nextTick(() => {
|
|
|
- inputs[i].focus();
|
|
|
- inputs[i].setSelectionRange(0, 0);
|
|
|
- })
|
|
|
- break;
|
|
|
- }
|
|
|
- }
|
|
|
- if (event.target.id.substring(0, 2) == 'cl' || event.target.id.substring(0, 2) == 'fp') {
|
|
|
- ent_sum()
|
|
|
- }
|
|
|
- }
|
|
|
- } else if (event.keyCode === 37) { // 向左箭头
|
|
|
- if (event.target.selectionStart === 0) {
|
|
|
- for (let i = currentIndex - 1; i >= 0; i--) {
|
|
|
- if (!inputs[i].readOnly) {
|
|
|
- nextTick(() => {
|
|
|
- inputs[i].focus();
|
|
|
- inputs[i].select();
|
|
|
- })
|
|
|
- break;
|
|
|
- }
|
|
|
- }
|
|
|
- if (event.target.id.substring(0, 2) == 'cl' || event.target.id.substring(0, 2) == 'fp') {
|
|
|
- ent_sum()
|
|
|
- }
|
|
|
- }
|
|
|
- } else if (event.keyCode === 39) { // 向右箭头
|
|
|
- if (event.target.id == '其他备注') {
|
|
|
- ElMessageBox.confirm('数据存盘?', '提示', {
|
|
|
- confirmButtonText: '确定',
|
|
|
- cancelButtonText: '取消',
|
|
|
- type: 'warning'
|
|
|
- }).then(() => {
|
|
|
- enterDialog()
|
|
|
- })
|
|
|
- }
|
|
|
- if (event.target.selectionStart === event.target.value.length) {
|
|
|
- for (let i = currentIndex + 1; i < inputs.length; i++) {
|
|
|
- if (!inputs[i].readOnly) {
|
|
|
- nextTick(() => {
|
|
|
- inputs[i].focus();
|
|
|
- inputs[i].select();
|
|
|
- })
|
|
|
- break;
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- if (event.target.id.substring(0, 2) == 'cl' || event.target.id.substring(0, 2) == 'fp') {
|
|
|
- ent_sum()
|
|
|
- }
|
|
|
+ }
|
|
|
+ if (event.target.id.substring(0, 2) == 'cl' || event.target.id.substring(0, 2) == 'fp') {
|
|
|
+ ent_sum()
|
|
|
}
|
|
|
}
|
|
|
+}
|
|
|
|
|
|
//追加字体颜色和不可输入
|
|
|
const setColorReadonly = (id) => {
|
|
|
@@ -1234,81 +1412,205 @@
|
|
|
})
|
|
|
}
|
|
|
|
|
|
- //定额代号回车事件
|
|
|
- const getDedhsubmit = () => {
|
|
|
- if (dialogSelectVisible.value) {
|
|
|
- return false
|
|
|
- }
|
|
|
- if (LbVisible.value) {
|
|
|
- return false
|
|
|
- }
|
|
|
- GetDedh()
|
|
|
- }
|
|
|
- let GetDedhtreeData = reactive([]);
|
|
|
- const GetDedhVisible = ref(false)
|
|
|
- //获取定额代号
|
|
|
- const GetDedh = async (value) => {
|
|
|
- const response = await shougonggetDedh();
|
|
|
- const treeData = {};
|
|
|
- // const data = [];
|
|
|
- // data[0] = response.data;
|
|
|
- // //判断值是否在选项中存在
|
|
|
- // const buildTree1 = (node) => {
|
|
|
- // const arr = [];
|
|
|
-
|
|
|
- // // 如果存在子节点,递归地添加它们
|
|
|
- // if (node.bh_mc && Array.isArray(node.bh_mc)) {
|
|
|
- // node.bh_mc.forEach(childNode => {
|
|
|
- // arr.push(...buildTree1(childNode)); // 递归调用
|
|
|
- // });
|
|
|
- // }else{
|
|
|
- // arr.push(node.sys_bh)
|
|
|
- // }
|
|
|
-
|
|
|
- // return arr;
|
|
|
- // };
|
|
|
- // // 构建树形结构的根节点
|
|
|
- // const Data = data.map(buildTree1);
|
|
|
-
|
|
|
- if (response.code == 0) {
|
|
|
- const data = [];
|
|
|
- data[0] = response.data;
|
|
|
- // 递归函数来构建树形结构
|
|
|
- const buildTree = (node) => {
|
|
|
- const treeNode = {
|
|
|
- label: node.sys_bh + '【' + node.sys_mc + '】',
|
|
|
- children: []
|
|
|
- };
|
|
|
-
|
|
|
- // 如果存在子节点,递归地添加它们
|
|
|
- if (node.bh_mc && Array.isArray(node.bh_mc)) {
|
|
|
- node.bh_mc.forEach(childNode => {
|
|
|
- treeNode.children.push(buildTree(childNode)); // 递归调用
|
|
|
- });
|
|
|
- }
|
|
|
|
|
|
- return treeNode;
|
|
|
- };
|
|
|
+
|
|
|
+// 定义状态
|
|
|
+let GetDedhtreeData = reactive([]); // 树形数据
|
|
|
+const GetDedhVisible = ref(false); // 弹窗显隐状态
|
|
|
+const activeNodeKey = ref(null); // 当前选中节点的 key
|
|
|
+const table_fplb = ref(null); // el-tree 的 ref
|
|
|
+ const defaultExpandedKey = ref(null); // 默认展开的节点 key
|
|
|
+ const selectIndex = ref(0); // 当前选中的索引
|
|
|
+
|
|
|
+// 获取定额代号并构建树形结构
|
|
|
+const GetDedh = async () => {
|
|
|
+ const response = await shougonggetDedh();
|
|
|
+ if (response.code === 0) {
|
|
|
+ // 封装数据为数组,便于递归处理根节点
|
|
|
+ const data = [];
|
|
|
+ data[0] = response.data;
|
|
|
+
|
|
|
+ // 递归构建树形结构
|
|
|
+ const buildTree = (node) => {
|
|
|
+ return {
|
|
|
+ label: `${node.sys_bh}【${node.sys_mc}】`,
|
|
|
+ id: node.sys_bh,
|
|
|
+ children: Array.isArray(node.bh_mc) ? node.bh_mc.map(buildTree) : []
|
|
|
+ };
|
|
|
+ };
|
|
|
+
|
|
|
+ // 构建树形结构并赋值给响应变量
|
|
|
+ GetDedhtreeData = data.map(buildTree);
|
|
|
+ GetDedhVisible.value = true; // 显示弹窗
|
|
|
+ }
|
|
|
+};
|
|
|
+
|
|
|
+// 节点点击事件
|
|
|
+const GetDedhhandleNodeClick = (nodeData) => {
|
|
|
+ console.log("单击节点:", nodeData);
|
|
|
+ if (!nodeData.children || nodeData.children.length === 0) {
|
|
|
+ // 如果点击的是子节点,则关闭弹窗并更新数据
|
|
|
+ formData.value.sczl_dedh = nodeData.label.split("【")[0]; // 提取定额代号
|
|
|
+ GetDedhVisible.value = false; // 关闭弹窗
|
|
|
+ }
|
|
|
+};
|
|
|
+
|
|
|
+// 树组件键盘事件
|
|
|
+const handleTreeKeydown = (event) => {
|
|
|
+ const tree = table_fplb.value; // 获取树实例
|
|
|
+ if (!tree) {
|
|
|
+ console.error("树组件未加载");
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ const focusedElement = document.activeElement;
|
|
|
+ const focusedNodeId = focusedElement?.getAttribute("data-key"); // 获取 DOM 的 data-key 属性
|
|
|
+
|
|
|
+ // 回车键
|
|
|
+ if (event.keyCode === 13 && focusedNodeId) {
|
|
|
+ tree.setCurrentKey(focusedNodeId); // 设置当前节点为选中
|
|
|
+ tree.$nextTick(() => {
|
|
|
+ const currentNode = tree.getCurrentNode(); // 获取当前选中的节点
|
|
|
+ if (!currentNode) {
|
|
|
+ console.warn("没有选中的节点");
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ // 展开当前节点并收起其他节点
|
|
|
+ Object.keys(tree.store.nodesMap).forEach((key) => {
|
|
|
+ tree.store.nodesMap[key].expanded = false; // 收起所有节点
|
|
|
+ });
|
|
|
+ tree.store.nodesMap[currentNode.id].expanded = true; // 展开当前节点
|
|
|
+
|
|
|
+ // 如果有子节点,选中第一个子节点
|
|
|
+ if (currentNode.children && currentNode.children.length > 0) {
|
|
|
+ const firstChild = currentNode.children[0];
|
|
|
+ const firstChildKey = firstChild.id.toString();
|
|
|
+ tree.setCurrentKey(firstChildKey); // 选中第一个子节点
|
|
|
+ setTimeout(() => {
|
|
|
+ const firstChildDom = tree.$el.querySelector(`[data-key="${firstChildKey}"]`);
|
|
|
+ if (firstChildDom) {
|
|
|
+ firstChildDom.focus();
|
|
|
+ firstChildDom.scrollIntoView({ block: "nearest" });
|
|
|
+ }
|
|
|
+ });
|
|
|
+ } else {
|
|
|
+ // 如果没有子节点,执行确认操作
|
|
|
+ console.log("当前子节点:", currentNode.label);
|
|
|
+ formData.value.sczl_dedh = currentNode.label.split("【")[0]
|
|
|
+ GetDedhVisible.value = false; // 关闭弹窗
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+ // 上下箭头键
|
|
|
+ else if (event.keyCode === 38 || event.keyCode === 40) {
|
|
|
+ const currentNode = tree.getCurrentNode();
|
|
|
+ if (currentNode) {
|
|
|
+ const currentNodeDom = tree.$el.querySelector(`[data-key="${currentNode.id}"]`);
|
|
|
+ if (currentNodeDom) {
|
|
|
+ currentNodeDom.focus();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+};
|
|
|
+
|
|
|
+// 弹窗键盘事件处理(绑定在弹窗上)
|
|
|
+const entdedh = (event) => {
|
|
|
+ console.log("键盘事件触发"); // 用于调试
|
|
|
+ event.preventDefault(); // 阻止浏览器默认行为(如滚动页面)
|
|
|
+ event.stopPropagation(); // 阻止事件冒泡
|
|
|
+
|
|
|
+ const tree = table_fplb.value?.$el;
|
|
|
+ if (!tree) return;
|
|
|
+
|
|
|
+ if (event.key === "ArrowDown" || event.key === "ArrowUp") {
|
|
|
+ // 上下箭头键:切换选中的兄弟节点
|
|
|
+ const focusedElement = document.activeElement;
|
|
|
+ const focusedNodeId = focusedElement?.getAttribute("data-key");
|
|
|
+ const currentNode = table_fplb.value?.store.nodesMap[focusedNodeId];
|
|
|
+
|
|
|
+ if (currentNode) {
|
|
|
+ let nextNode;
|
|
|
+ if (event.key === "ArrowDown") {
|
|
|
+ nextNode = table_fplb.value?.getNextSibling(currentNode);
|
|
|
+ } else if (event.key === "ArrowUp") {
|
|
|
+ nextNode = table_fplb.value?.getPreviousSibling(currentNode);
|
|
|
+ }
|
|
|
+
|
|
|
+ if (nextNode) {
|
|
|
+ const nextNodeKey = nextNode.data.id.toString();
|
|
|
+ table_fplb.value?.setCurrentKey(nextNodeKey); // 设置选中下一个节点
|
|
|
+ focusAndScrollToNode(nextNodeKey); // 聚焦到下一个节点并滚动到视图中
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ // 默认行为:展开所有节点并选中第一个节点
|
|
|
+ const firstNodeDom = tree.querySelector("[data-key]");
|
|
|
+ if (firstNodeDom) {
|
|
|
+ firstNodeDom.focus();
|
|
|
+ firstNodeDom.scrollIntoView({ block: "nearest" });
|
|
|
+
|
|
|
+ // 设置第一个节点为当前选中节点
|
|
|
+ const firstNodeId = firstNodeDom.getAttribute("data-key");
|
|
|
+ table_fplb.value?.setCurrentKey(firstNodeId);
|
|
|
+
|
|
|
+ // 获取第一个节点对象并展开所有子节点
|
|
|
+ const firstNode = table_fplb.value?.store.nodesMap[firstNodeId];
|
|
|
+ if (firstNode) {
|
|
|
+ table_fplb.value?.store.expandNode(firstNode, true);
|
|
|
+ expandAllNodes(firstNode); // 递归展开第一个节点的所有子节点
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+};
|
|
|
|
|
|
- // 构建树形结构的根节点
|
|
|
- const treeData = data.map(buildTree);
|
|
|
-
|
|
|
- GetDedhtreeData = treeData;
|
|
|
- GetDedhVisible.value = true
|
|
|
- }
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
- //定额代号树形结构单机
|
|
|
- const GetDedhhandleNodeClick = (nodeData, node, component) => {
|
|
|
- //存放当前节点的nodeId
|
|
|
- if (!nodeData.children || nodeData.children.length === 0) {
|
|
|
- // 点击的是子节点
|
|
|
- formData.value.sczl_dedh = nodeData.label.split("【")[0]
|
|
|
- GetDedhVisible.value = false
|
|
|
- }
|
|
|
- // 执行相应的父节点单击事件处理逻辑
|
|
|
- }
|
|
|
+
|
|
|
+ // let GetDedhtreeData = reactive([]);
|
|
|
+ // const GetDedhVisible = ref(false)
|
|
|
+
|
|
|
+ // //获取定额代号
|
|
|
+ // const GetDedh = async (value) => {
|
|
|
+ // const response = await shougonggetDedh();
|
|
|
+ // const treeData = {};
|
|
|
+ // if (response.code == 0) {
|
|
|
+ // const data = [];
|
|
|
+ // data[0] = response.data;
|
|
|
+ // // 递归函数来构建树形结构
|
|
|
+ // const buildTree = (node) => {
|
|
|
+ // const treeNode = {
|
|
|
+ // label: node.sys_bh + '【' + node.sys_mc + '】',
|
|
|
+ // children: []
|
|
|
+ // };
|
|
|
+
|
|
|
+ // // 如果存在子节点,递归地添加它们
|
|
|
+ // if (node.bh_mc && Array.isArray(node.bh_mc)) {
|
|
|
+ // node.bh_mc.forEach(childNode => {
|
|
|
+ // treeNode.children.push(buildTree(childNode)); // 递归调用
|
|
|
+ // });
|
|
|
+ // }
|
|
|
+
|
|
|
+ // return treeNode;
|
|
|
+ // };
|
|
|
+
|
|
|
+ // // 构建树形结构的根节点
|
|
|
+ // const treeData = data.map(buildTree);
|
|
|
+
|
|
|
+ // GetDedhtreeData = treeData;
|
|
|
+ // GetDedhVisible.value = true
|
|
|
+ // }
|
|
|
+
|
|
|
+ // }
|
|
|
+
|
|
|
+ // //定额代号树形结构单机
|
|
|
+ // const GetDedhhandleNodeClick = (nodeData, node, component) => {
|
|
|
+ // //存放当前节点的nodeId
|
|
|
+ // if (!nodeData.children || nodeData.children.length === 0) {
|
|
|
+ // // 点击的是子节点
|
|
|
+ // formData.value.sczl_dedh = nodeData.label.split("【")[0]
|
|
|
+ // GetDedhVisible.value = false
|
|
|
+ // }
|
|
|
+ // // 执行相应的父节点单击事件处理逻辑
|
|
|
+ // }
|
|
|
|
|
|
//检验类别失去焦点事件
|
|
|
const getLbsubmit = () => {
|
|
|
@@ -1475,6 +1777,16 @@
|
|
|
formData.value.sczl_fp10 = 0
|
|
|
formData.value.sczl_fp11 = 0
|
|
|
formData.value.sczl_fp12 = 0
|
|
|
+ formData.value.流程单号1 = 0
|
|
|
+ formData.value.流程单号2 = 0
|
|
|
+ formData.value.流程单号3 = 0
|
|
|
+ formData.value.流程单号4 = 0
|
|
|
+ formData.value.流程单号5 = 0
|
|
|
+ formData.value.流程单号6 = 0
|
|
|
+ formData.value.流程单号7 = 0
|
|
|
+ formData.value.流程单号8 = 0
|
|
|
+ formData.value.流程单号9 = 0
|
|
|
+ formData.value.流程单号10 = 0
|
|
|
}
|
|
|
});
|
|
|
}
|