zck 1 год назад
Родитель
Сommit
1d312afc69
1 измененных файлов с 19 добавлено и 7 удалено
  1. 19 7
      src/view/yunyin/shengchanguanli/gongdanziliao.vue

+ 19 - 7
src/view/yunyin/shengchanguanli/gongdanziliao.vue

@@ -366,6 +366,8 @@
           <!-- 新增查询标准损耗 -->
           <el-dialog v-model="searchSHModel" :before-close="() => searchSHModel = false" id="tableFplb" @keydown="ent($event)" >
             <el-form>
+              <p style="font-size: 18px;">{{valkey}}</p>
+              <br>
               <div>
                 <div style="border:1px solid #eee; width:100%; height: 400px; overflow-y: auto">
                   <el-tree :data="getSHListdatas" :props="defaultProps" ref="table_fplb" @keydown.stop="handleTreeKeydown"
@@ -1409,6 +1411,7 @@ export default {
     return {
       currentTable: '', // 当前展示的表格
       activeName: 'first',
+      valkey:'',
     };
   },
   methods: {
@@ -1479,20 +1482,29 @@ const sh_num = ref(0)
 const getSHListdatas = ref([]);
 const searchSHModel = ref(false)
 const table_fplb = ref(null);
+const valkey = ref('')
 const handleKeyDown = async (event, x, y, prop) => {
-  event.stopPropagation();
-  console.log(event,x,y)
   const currentElement = document.getElementById(`input${x}${y}`);
   if (currentElement === null && currentElement === undefined) return
   let move = 0
   switch (event.keyCode) {
     case 13: // Enter
     if(x === 7){
-      console.log(112)
-    sh_num.value = y
+    const param = ref([])
+    let filteredData = ref([])
+    sh_num.value = y//保存行
     const WastageList_data = await WastageList({process: shdhh.value[y].gxmc})
-    const getLossCode_data = await getLossCode({ code: WastageList_data.data.slice(0, 3)});
-    const filteredData = getLossCode_data.data.filter(item => item.sys_bh.startsWith(WastageList_data.data.slice(0, 3)));
+    if (WastageList_data.data=== null) {//未查找到损耗代号
+      param.value = "";
+      valkey.value = '该工序没有查到损耗代号,请在下方自行选择'
+    }else{
+      param.value = WastageList_data.data.slice(0, 3);
+    }
+    const getLossCode_data = await getLossCode({ code: param.value});
+    // 根据 param.value 是否为空来决定是否过滤数据
+    filteredData = param.value === "" 
+  ? getLossCode_data.data // 如果 param.value 为空,返回完整数据
+  : getLossCode_data.data.filter(item => item.sys_bh.startsWith(param.value)); // 否则过滤数据
     console.log(filteredData);
     const data = filteredData;
 
@@ -1702,7 +1714,7 @@ const clearPreviousSelection = (tree) => {
 const SHNodeClick = (node,check) => {
   console.log('损耗node',node)
   console.log(getSHListdatas.value)
-  if(getSHListdatas.value[0].children){
+  if(node.children.length === 0){//点击了叶子节点
     sxzhscstableData.value[sh_num.value].损耗代号= node.sys_bh
     searchSHModel.value = false;
   }