|
|
@@ -138,7 +138,7 @@
|
|
|
:header-row-style="{ height: '20px' }" :header-cell-style="{ padding: '0px' }">
|
|
|
<el-table-column label="废品类别" width="200">
|
|
|
<template #default="{ row, $index }">
|
|
|
- <el-input v-model="row.fp_lb" @keydown="ent1($event)" @blur="handleFplbEnter($index, row)" />
|
|
|
+ <el-input v-model="row.fp_lb" @keydown="ent1($event,$index, row,'废品类别')" />
|
|
|
</template>
|
|
|
</el-table-column>
|
|
|
<el-table-column label="数量" width="100">
|
|
|
@@ -186,7 +186,7 @@
|
|
|
<el-tree :data="selecTreeData" ref="table_fplb"
|
|
|
@keydown="handleTreeKeydown"
|
|
|
:props="{ children: 'children',label: 'label'}"
|
|
|
- :default-expanded-keys="[1]"
|
|
|
+ :default-expanded-keys="[2]"
|
|
|
node-key="id" @node-click="handleFplbClick">
|
|
|
</el-tree>
|
|
|
</div>
|
|
|
@@ -739,62 +739,6 @@ const gd_lcdCancel = async () => {
|
|
|
|
|
|
|
|
|
|
|
|
-//tree中data数据
|
|
|
-const refTree = ref(null)
|
|
|
- const selecTreeData = ref([])
|
|
|
- const table_fplb = ref()
|
|
|
- const handleFplbEnter = async (index, row) => {
|
|
|
- if (dialogSelectVisible1.value || !row.fp_lb) {
|
|
|
- return;
|
|
|
- }
|
|
|
- dialogSelectVisible1.value = true;
|
|
|
- const res = await getWastInfo();
|
|
|
- if (res.code === 0) {
|
|
|
- const obj = res.data;
|
|
|
- const children = processTreeData(obj.废品分类, row.fp_lb);
|
|
|
- selecTreeData.value = children;
|
|
|
- }
|
|
|
-};
|
|
|
-
|
|
|
-const processTreeData = (categories, prefix) => {
|
|
|
- const result = [];
|
|
|
- for (const categoryKey in categories) {
|
|
|
- if (Object.prototype.hasOwnProperty.call(categories, categoryKey) && categoryKey.startsWith(prefix)) {
|
|
|
- const items = categories[categoryKey];
|
|
|
- const categoryNode = {
|
|
|
- id: categoryKey,
|
|
|
- label: categoryKey,
|
|
|
- children: []
|
|
|
- };
|
|
|
- for (const item of items) {
|
|
|
- categoryNode.children.push({
|
|
|
- id: `${categoryKey}-${items.indexOf(item)}`,
|
|
|
- label: item,
|
|
|
- children: []
|
|
|
- });
|
|
|
- }
|
|
|
- result.push(categoryNode);
|
|
|
- }
|
|
|
- }
|
|
|
- return result;
|
|
|
-};
|
|
|
- const handleFplbClick = (node, check) => {
|
|
|
- console.log(node, check)
|
|
|
- if (node.children && node.children.length > 0) {
|
|
|
- console.log(11);
|
|
|
- } else {
|
|
|
- detailData.table[selectIndex].fp_lb = node.label
|
|
|
- dialogSelectVisible1.value = false
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- const handleTreeKeydown = (event) => {
|
|
|
- console.log("event",event.keyCode)
|
|
|
- if(event.keyCode === 13){
|
|
|
- console.log("回车打开")
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
|
|
|
|
|
|
|
|
|
@@ -1220,7 +1164,68 @@ const processTreeData = (categories, prefix) => {
|
|
|
// }, 0)
|
|
|
}
|
|
|
|
|
|
- //
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+//tree中data数据
|
|
|
+const refTree = ref(null)
|
|
|
+ const selecTreeData = ref([])
|
|
|
+ const table_fplb = ref()
|
|
|
+ const handleFplbEnter = async (event,index,row,title) => {
|
|
|
+ if (dialogSelectVisible1.value || !row.fp_lb) {
|
|
|
+ console.log(1)
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ dialogSelectVisible1.value = true;
|
|
|
+ const res = await getWastInfo();
|
|
|
+ if (res.code === 0) {
|
|
|
+ const obj = res.data;
|
|
|
+ const children = processTreeData(obj.废品分类, row.fp_lb);
|
|
|
+ selecTreeData.value = children;
|
|
|
+ }
|
|
|
+ };
|
|
|
+
|
|
|
+const processTreeData = (categories, prefix) => {
|
|
|
+ const result = [];
|
|
|
+ for (const categoryKey in categories) {
|
|
|
+ if (Object.prototype.hasOwnProperty.call(categories, categoryKey) && categoryKey.startsWith(prefix)) {
|
|
|
+ const items = categories[categoryKey];
|
|
|
+ const categoryNode = {
|
|
|
+ id: categoryKey,
|
|
|
+ label: categoryKey,
|
|
|
+ children: []
|
|
|
+ };
|
|
|
+ for (const item of items) {
|
|
|
+ categoryNode.children.push({
|
|
|
+ id: `${categoryKey}-${items.indexOf(item)}`,
|
|
|
+ label: item,
|
|
|
+ children: []
|
|
|
+ });
|
|
|
+ }
|
|
|
+ result.push(categoryNode);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return result;
|
|
|
+};
|
|
|
+ const handleFplbClick = (node, check) => {
|
|
|
+ console.log(node, check)
|
|
|
+ if (node.children && node.children.length > 0) {
|
|
|
+ console.log(11);
|
|
|
+ } else {
|
|
|
+ detailData.table[selectIndex].fp_lb = node.label
|
|
|
+ dialogSelectVisible1.value = false
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ const handleTreeKeydown = (event) => {
|
|
|
+ console.log("event",event.keyCode)
|
|
|
+ if(event.keyCode === 13){
|
|
|
+ console.log("回车打开")
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
const ent = (event) => {
|
|
|
if(document.activeElement.id=='tableFplb'){
|
|
|
if (table_fplb.value) {
|
|
|
@@ -1229,6 +1234,8 @@ const processTreeData = (categories, prefix) => {
|
|
|
if (tree) {
|
|
|
const node = tree.querySelector('[data-key]');
|
|
|
console.log(222,node)
|
|
|
+ dialogSelectVisible1.value = false;
|
|
|
+
|
|
|
if (node) {
|
|
|
node.scrollIntoView();
|
|
|
node.focus(); // 尝试聚焦}
|
|
|
@@ -1242,12 +1249,17 @@ const processTreeData = (categories, prefix) => {
|
|
|
|
|
|
|
|
|
|
|
|
-
|
|
|
|
|
|
-
|
|
|
- const ent1 = (event) => {
|
|
|
+ const ent1 = (event,index,row,title) => {
|
|
|
const inputs = document.getElementsByTagName('input');
|
|
|
const currentIndex = Array.from(inputs).indexOf(event.target);
|
|
|
+ if (event.keyCode === 13 && title === '废品类别') {
|
|
|
+ handleFplbEnter(event,index,row,title);
|
|
|
+ }
|
|
|
+// if (event.keyCode === 13 && title === '数量') {
|
|
|
+
|
|
|
+// }
|
|
|
+
|
|
|
|
|
|
if (event.keyCode === 13 || event.keyCode === 40) { // Enter 或向下箭头
|
|
|
let nextIndex = currentIndex + 1;
|
|
|
@@ -1279,18 +1291,19 @@ const processTreeData = (categories, prefix) => {
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
- } 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;
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
+// }
|
|
|
+ // 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;
|
|
|
+ // }
|
|
|
+ // }
|
|
|
+ // }
|
|
|
} else if (event.keyCode === 37) { // 向左箭头
|
|
|
if (event.target.selectionStart === 0) {
|
|
|
for (let i = currentIndex - 1; i >= 0; i--) {
|