|
|
@@ -55,7 +55,7 @@
|
|
|
<el-row :gutter="24">
|
|
|
<el-col :span="5">
|
|
|
<el-form-item label="日期">
|
|
|
- <el-input type="date" max="9999-12-31" v-model="detailData.qczl_rq" id = '日期' @keydown="ent1($event)" @focus="rqHandleFocus()"
|
|
|
+ <el-input type="date" max="9999-12-31" v-model="detailData.qczl_rq" @keydown="ent1($event)" @focus="rqHandleFocus()"
|
|
|
style="width: 130px;" />
|
|
|
</el-form-item>
|
|
|
</el-col>
|
|
|
@@ -138,9 +138,10 @@
|
|
|
: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,$index, row,'废品类别')" />
|
|
|
+ <el-input v-model="row.fp_lb" @keydown="ent1($event)" @blur="handleFplbEnter($index, row)" />
|
|
|
</template>
|
|
|
</el-table-column>
|
|
|
+
|
|
|
<el-table-column label="数量" width="100">
|
|
|
<template #default="{ row, $index }">
|
|
|
<el-input v-model="row.fp_sl" @keydown="ent1($event)" @blur="handleFpslEnter($index, row)" />
|
|
|
@@ -169,6 +170,7 @@
|
|
|
</el-table>
|
|
|
</el-scrollbar>
|
|
|
</el-form>
|
|
|
+
|
|
|
<template #footer>
|
|
|
<div class="dialog-footer">
|
|
|
<el-button @click="closeDialog">取 消</el-button>
|
|
|
@@ -178,19 +180,20 @@
|
|
|
</template>
|
|
|
</el-dialog>
|
|
|
|
|
|
- <!-- 废品类别弹出 -->
|
|
|
- <el-dialog v-model="dialogSelectVisible1" id="tableFplb" @keydown="ent($event)" >
|
|
|
+ <!-- 废品类别弹出选项框 -->
|
|
|
+ <el-dialog v-model="dialogSelectVisible1" id="tableFplb" @keydown="ent($event)" @opened="focusFirstNode">
|
|
|
<el-form>
|
|
|
- <el-form-item label="废品类别" class="mab" prop="keyOrder"></el-form-item>
|
|
|
- <div style="border:1px solid #eee; width:100%; height: 500px; overflow-y: auto">
|
|
|
- <el-tree :data="selecTreeData" ref="table_fplb"
|
|
|
- @keydown="handleTreeKeydown"
|
|
|
+ <div>
|
|
|
+ <el-form-item label="废品类别 :" class="mab" prop="keyOrder"></el-form-item>
|
|
|
+ <div style="border:1px solid #eee; width:100%; height: 400px; overflow-y: auto">
|
|
|
+ <el-tree :data="selecTreeData" ref="table_fplb"
|
|
|
:props="{ children: 'children',label: 'label'}"
|
|
|
- :default-expanded-keys="[2]"
|
|
|
node-key="id" @node-click="handleFplbClick">
|
|
|
</el-tree>
|
|
|
</div>
|
|
|
+ </div>
|
|
|
</el-form>
|
|
|
+
|
|
|
</el-dialog>
|
|
|
|
|
|
<!-- 弹出选项框 数量 -->
|
|
|
@@ -242,6 +245,7 @@
|
|
|
</div>
|
|
|
</el-dialog>
|
|
|
|
|
|
+
|
|
|
<!-- 弹出选项框 工单 -->
|
|
|
<el-dialog v-model="dialogSelectVisible" title="选择" destroy-on-close width="1000px"
|
|
|
@keydown="selectGX($event)">
|
|
|
@@ -736,21 +740,91 @@ const gd_lcdCancel = async () => {
|
|
|
})
|
|
|
}
|
|
|
|
|
|
+ const selecTreeData = ref([])
|
|
|
+ const table_fplb = ref()
|
|
|
+ // 废品类别回车
|
|
|
+ const handleFplbEnter = async(index, row) => {
|
|
|
+ //上个弹窗还未关闭或者值为空
|
|
|
+ if(dialogSelectVisible2.value || !row.fp_lb){
|
|
|
+ return
|
|
|
+ }
|
|
|
+ let flag = true
|
|
|
+
|
|
|
+ //查询废品类别
|
|
|
+ const res = await getWastInfo()
|
|
|
+ if (res.code == 0) {
|
|
|
+ const obj = res.data
|
|
|
+ const children = []
|
|
|
+ let i = 0
|
|
|
+ for (const subCategory in obj.废品分类) {
|
|
|
+ if (flag && Object.prototype.hasOwnProperty.call(obj.废品分类, subCategory)) {
|
|
|
+ let j = 0
|
|
|
+ const subChildren = []
|
|
|
+ obj.废品分类[subCategory].map(item => {
|
|
|
+ if(item==row.fp_lb){
|
|
|
+ flag = false
|
|
|
+ return
|
|
|
+ }
|
|
|
+ subChildren.push({
|
|
|
+ id: i+'-'+j,
|
|
|
+ label: item,
|
|
|
+ children: []
|
|
|
+ })
|
|
|
+ j++
|
|
|
+ })
|
|
|
|
|
|
+ children.push({
|
|
|
+ id: i,
|
|
|
+ label: subCategory,
|
|
|
+ children: subChildren
|
|
|
+ })
|
|
|
+ i++
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if(!flag){
|
|
|
+ return
|
|
|
+ }
|
|
|
+ //渲染数据
|
|
|
+ selecTreeData.value = children
|
|
|
+ selectIndex = index
|
|
|
+ dialogSelectVisible1.value = true
|
|
|
+ // nextTick(() => {
|
|
|
+ // // 手动设置选中节点,如果默认选中不生效,可以使用此方法
|
|
|
+ // if (table_fplb.value) {
|
|
|
+ // const tree = table_fplb.value?.$el; // 访问组件实例的 $el
|
|
|
+ // if (tree) {
|
|
|
+ // const node = tree.querySelector('[data-key="0"]');
|
|
|
+ // if (node) {
|
|
|
+ // node.scrollIntoView();
|
|
|
+ // node.focus(); // 尝试聚焦
|
|
|
+ // console.log(document.activeElement === node); // 输出检查
|
|
|
+ // }
|
|
|
+ // }
|
|
|
+
|
|
|
+ // }
|
|
|
+ // });
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
+ 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
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
let selectData = [] // 将const改为let
|
|
|
+
|
|
|
const handleFpslEnter = async (index, row) => {
|
|
|
selectIndex = index
|
|
|
- if(dialogSelectVisible1.value){return}
|
|
|
+ if(dialogSelectVisible1.value){
|
|
|
+ return
|
|
|
+ }
|
|
|
if (row.fp_sl == '0' || row.fp_sl == '') {
|
|
|
detailData.table[index].fp_gxmc = ''
|
|
|
detailData.table[index].fp_bz = ''
|
|
|
@@ -1064,13 +1138,6 @@ const gd_lcdCancel = async () => {
|
|
|
// 新增数据
|
|
|
const handleShowAdd = async () => {
|
|
|
type.value = '新增'
|
|
|
- dialogFormVisible.value = true
|
|
|
- setTimeout(() => {
|
|
|
- const inputElement = document.getElementById('日期');
|
|
|
- if (inputElement) {
|
|
|
- inputElement.focus();
|
|
|
- }
|
|
|
- }, 100);
|
|
|
if (currentRow.value == undefined) {
|
|
|
// 循环13行数据
|
|
|
const table = []
|
|
|
@@ -1164,78 +1231,13 @@ const gd_lcdCancel = async () => {
|
|
|
// }, 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) {
|
|
|
const tree = table_fplb.value?.$el; // 访问组件实例的 $el
|
|
|
- console.log(111,tree)
|
|
|
if (tree) {
|
|
|
- const node = tree.querySelector('[data-key]');
|
|
|
- console.log(222,node)
|
|
|
- dialogSelectVisible1.value = false;
|
|
|
-
|
|
|
+ const node = tree.querySelector('[data-key="0"]');
|
|
|
if (node) {
|
|
|
node.scrollIntoView();
|
|
|
node.focus(); // 尝试聚焦}
|
|
|
@@ -1246,20 +1248,9 @@ const processTreeData = (categories, prefix) => {
|
|
|
}
|
|
|
|
|
|
}
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
- const ent1 = (event,index,row,title) => {
|
|
|
+ const ent1 = (event) => {
|
|
|
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;
|
|
|
@@ -1291,19 +1282,18 @@ 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--) {
|