Procházet zdrojové kódy

试验自检填报切换tab数据保留

duy před 2 roky
rodič
revize
17a7d47adc

+ 128 - 25
src/views/tentative/detect/components/ListItem.vue

@@ -197,7 +197,13 @@ const props = defineProps({
     nodeIdvalue:{
         type: String,
         default: () => ('')
+    },
+    alllistData:{
+       type: Array,
+        default: () => ([])
     }
+
+    
 })
 
 const {isString, getObjNullValue, getArrValue} = isType()
@@ -211,14 +217,17 @@ const projectId = ref(useAppState.getProjectId);
 const contractId = ref(useAppState.getContractId);
 const tabTypeKeyInfo=ref(props.tabTypeKey)
 const nodeIdvaluedata=ref(props.nodeIdvalue)
+const alllistDataval=ref(props.alllistData)
 
 //监听
 watch(() => [
     props.datas,
-    props.tabTypeKey
-], ([datas,TabTypeKey]) => {
+    props.tabTypeKey,
+    props.alllistData
+], ([datas,TabTypeKey,AlllistData]) => {
     listDatas.value = datas
     tabTypeKeyInfo.value=TabTypeKey
+    alllistDataval.value=AlllistData
     setFormDataNum(datas)
 })
 
@@ -285,18 +294,25 @@ const CollapseChange = async (name) => {
     if (names.length > 0) {
         getOffsetTop(name)
         const index = names[1]
-        const item = listDatas.value[index]
+        let item = listDatas.value[index]
           emit('upcheckTableId', item.id)
         formKeyIds.value = getValString(item.pKeyId)
-        console.log(nodeIdvaluedata.value,'nodeIdvaluedata.value');
-        console.log(item,'item');
+        console.log(alllistDataval.value,'alllistDataval');
+        alllistDataval.value.forEach((item1)=>{
+            if (item1.pkeyId==item.pKeyId) {
+                if(item1.oper){
+                    item.isTableFormRender=true;
+                    item=item1
+                    item.pKeyId=item1.pkeyId
+                }
+            }
+            console.log(item,'item');
+        })
         if (!item.isTableFormRender) {
-      
-          
-                await getBussDataInfo(item, index)
-            
-          
-          
+            await getBussDataInfo(item, index)
+        }else{
+             await getBussDataInfo1(item, index)
+                
         }
         
         //渲染表单
@@ -381,22 +397,104 @@ const getBussDataInfo = async (item, index) => {
             id: id||nodeIdvaluedata.value,
             pkeyId: pkeyIds
         }, false)
-        data.forEach((item1)=>{
-             const resData = getObjNullValue(item1)
-            if (!error && code === 200 && resData) {
-                HTableForm.setPickerKey(resData)
-                const InitObj = getFormDataInit(item) //有数据,关联数据
-                formData.value[index] = {
-                    ...resData, ...InitObj,
-                    isCollapseLoad: true
-                }
-            }else {
-                formData.value[index] = {
-                    ...getFormDataInit(item),
-                    isCollapseLoad: true
+        console.log(item,'item2222');
+        if(item.oper){
+            console.log(11111111);
+             HTableForm.setPickerKey([item])
+             formData.value[index] = {
+                        ...item,
+                        isCollapseLoad: true
+            }
+        }else{
+            console.log(2222222222);
+            data.forEach((item1)=>{
+                const resData = getObjNullValue(item1)
+                if (!error && code === 200 && resData) {
+                    HTableForm.setPickerKey(resData)
+                    const InitObj = getFormDataInit(item) //有数据,关联数据
+                    formData.value[index] = {
+                        ...resData, ...InitObj,
+                        isCollapseLoad: true
+                    }
+                }else {
+                    formData.value[index] = {
+                        ...getFormDataInit(item),
+                        isCollapseLoad: true
+                    }
                 }
+            })
+ 
+        }
+
+        // data.forEach((item1)=>{
+        //      const resData = getObjNullValue(item1)
+        //     if (!error && code === 200 && resData) {
+        //         HTableForm.setPickerKey(resData)
+        //         const InitObj = getFormDataInit(item) //有数据,关联数据
+        //         formData.value[index] = {
+        //             ...resData, ...InitObj,
+        //             isCollapseLoad: true
+        //         }
+        //     }else {
+        //         formData.value[index] = {
+        //             ...getFormDataInit(item),
+        //             isCollapseLoad: true
+        //         }
+        //     }
+        // })
+
+
+        // if (!error && code === 200 && resData) {
+        //     HTableForm.setPickerKey(resData)
+        //     const InitObj = getFormDataInit(item) //有数据,关联数据
+        //     formData.value[index] = {
+        //         ...resData, ...InitObj,
+        //         isCollapseLoad: true
+        //     }
+        // } else {
+        //     formData.value[index] = {
+        //         ...getFormDataInit(item),
+        //         isCollapseLoad: true
+        //     }
+        // }
+    } else {
+        window?.$message?.warning('pkeyId为空')
+    }
+}
+const getBussDataInfo1 = async (item, index) => {
+    const pkeyIds = getValString(item.pKeyId)
+    if (pkeyIds) {
+        const { id } = baseData.value
+        const {error, code, data} = await dataApi.getBussDataInfo({
+            id: id||nodeIdvaluedata.value,
+            pkeyId: pkeyIds
+        }, false)
+       
+        if(item.oper){
+             HTableForm.setPickerKey([item])
+             formData.value[index] = {
+                        ...item,
+                        isCollapseLoad: true
             }
-        })
+        }
+        // data.forEach((item1)=>{
+        //      const resData = getObjNullValue(item1)
+        //     if (!error && code === 200 && resData) {
+        //         HTableForm.setPickerKey(resData)
+        //         const InitObj = getFormDataInit(item) //有数据,关联数据
+        //         formData.value[index] = {
+        //             ...resData, ...InitObj,
+        //             isCollapseLoad: true
+        //         }
+        //     }else {
+        //         formData.value[index] = {
+        //             ...getFormDataInit(item),
+        //             isCollapseLoad: true
+        //         }
+        //     }
+        // })
+
+
         // if (!error && code === 200 && resData) {
         //     HTableForm.setPickerKey(resData)
         //     const InitObj = getFormDataInit(item) //有数据,关联数据
@@ -419,6 +517,9 @@ const toBackClick = () => {
         path: '/tentative/detect/test',
         query: {}
     })
+    setTimeout(() => {
+                            window?.location?.reload()  //刷新页面
+      }, 1000);
 }
 //单个保存
 const tableFormSaveLoading = ref(false)
@@ -450,6 +551,8 @@ const saveExcelBussData = async (item, index, showTip = true) => {
     if (!getObjNullValue(formRegExpJson.value)) {
         tableFormSaveLoading.value = true
         const InitObj = getFormDataInit(item)
+       baseData.value.tableType= tabTypeKeyInfo.value
+       console.log(  baseData.value.tableType,'  baseData.value.tableType');
         const {error, code} = await dataApi.saveExcelBussData({
             ...baseData.value,
             isBatchSave:0,

+ 2 - 4
src/views/tentative/detect/test-form.vue

@@ -49,6 +49,7 @@
                  @updeviceUseIds="updeviceUseIds"
                  @upcheckTableId="upcheckTableId"
                  :nodeIdvalue="nodeIdvalue"
+                 :alllistData="alllistData"
                 />
             </el-scrollbar>
             <template #action>
@@ -101,7 +102,6 @@
                                 :defaultCheckarr="defaultCheckarrIds" 
                                 :ElTreeProps="seaElTreeProps" 
                                 :defaultExpandAll="true" 
-                                :check-strictly="true" 
                                 :divisionLoading="searchlinksRelateTreeLoading"/>
                             </template>
                             
@@ -112,7 +112,6 @@
                                @nodeTap="divisionTreeClick"
                                 @nodeCheck="divisionTreeCheck"
                                  :defaultCheckarr="defaultCheckarrIds"  
-                               
                                 :divisionLoading="isdivisionLoading"
                                 :linksRelateSearchTreeVal="linksRelateSearchTreeVal"
                                 />
@@ -806,7 +805,6 @@ const tableFormSaveClick = async () => {
             let FormRegExpJson = ListItemRef.value?.getFormRegExpJson()
                console.log(isaddType,'isaddType');
             //效验数据
-          
             if (FormData.length > 0) {
               if(  listItemBaseData.value.detectionResult===''&& listItemBaseData.value.tableType == "1,2"){
                    window.$message?.warning('请选择报告单是否合格')
@@ -850,7 +848,7 @@ const tableFormSaveClick = async () => {
               }
               
             } else {
-                
+                 console.log(FormData,'FormData133333333333');
                 if(!isaddType){
                         window.$message?.warning('请先选择你需要编辑的表格')
                     bussPdfsClick(router.currentRoute.value.query.id)