Explorar el Código

试验保存修改

duy hace 3 meses
padre
commit
0f2685c98a

+ 9 - 0
src/api/modules/basic/code.js

@@ -79,4 +79,13 @@ export default {
             params: form,
         })
     },
+    //关联上次设备
+    
+   async lastTrailDeviceInfo(form) {
+        return HcApi({
+            url: '/api/blade-business/detection/self/lastTrailDeviceInfo',
+            method: 'get',
+            params: form,
+        })
+    },
 }

+ 42 - 17
src/views/tentative/detect/components/basicInfo.vue

@@ -1,7 +1,7 @@
 <template>
     <hc-drawer v-model="isShow" to-id="node-card-target" is-close>
         <div class="relative bg-white" style="height: 100%">
-            <hc-card title="基础信息" scrollbar>
+            <hc-card v-loading="infoLoad" title="基础信息" scrollbar>
                 <template #header>
                     <div class="text-bold">基础信息</div>
                 </template>
@@ -157,7 +157,7 @@
                     <div class="text-bold">设备信息</div>
                     <div>
                         <el-link type="primary" @click.stop="linkAcquisitionClick(item, index)">关联设备</el-link>
-                        <el-link type="primary" class="ml-2">关联上次设备</el-link>
+                        <el-link v-loading="linkLastLoad" type="primary" class="ml-2" @click="linkLast">关联上次设备</el-link>
                     </div>
                 </div>
                 <div>
@@ -255,7 +255,9 @@ const projectId = ref(props.projectId)
 const contractId = ref(props.contractId)
 const ids = ref(props.ids)
 
-const handleRefresh = () => {}
+const handleRefresh = () => {
+     getInfoData()
+}
 const isShow = defineModel('modelValue', {
     default: false,
 })
@@ -320,9 +322,10 @@ const basicInfoData = ref({
                 samplingDate:'',
     },
 })
-
+const infoLoad = ref(false)
 const getInfoData = async () => {
-console.log(nodeId.value, dataId.value, projectId.value)
+infoLoad.value = true
+
     const { error, code, data } = await codeApi.getBaseInfo({
         nodeId: nodeId.value,
         id: dataId.value,
@@ -331,7 +334,7 @@ console.log(nodeId.value, dataId.value, projectId.value)
         
     })
     //处理数据
-
+infoLoad.value = false
     if (!error && code === 200) {
       console.log(data, '基础信息数据')
         basicInfoData.value = getObjValue(data)
@@ -534,19 +537,41 @@ const handleSave = async () => {
         .join(',')
 
     basicInfoData.value.standardInfoIds = standardInfoIds
-    // emit('change', basicInfoData.value)
-    handleSaveLoad.value = true
-          const { error, code, data, msg } = await dataApi.saveExcelBussData({
-                    ...basicInfoData.value,
-                    isBatchSave: 1,
-                })
-            handleSaveLoad.value = false
-            if (!error && code === 200) {
-                window.$message.success(msg)
-                isShow.value = false
+    emit('change', basicInfoData.value)
+    // handleSaveLoad.value = true
+    //       const { error, code, data, msg } = await dataApi.saveExcelBussData({
+    //                 ...basicInfoData.value,
+    //                 isBatchSave: 1,
+    //             })
+    //         handleSaveLoad.value = false
+    //         if (!error && code === 200) {
+    //             window.$message.success(msg)
+    //             isShow.value = false
 
               
-            }
+    //         }
+}
+//关联上次设备
+const linkLastLoad = ref(false)
+const linkLast = async ()=>{
+    linkLastLoad.value = true
+    const { error, code, data } = await codeApi.lastTrailDeviceInfo({
+         nodeId: nodeId.value,
+        contractId: contractId.value,
+    })
+      linkLastLoad.value = false
+    if (!error && code === 200) {
+         console.log(data)
+         let rows = getArrValue(data)
+        if (rows.length > 0) {
+           rows.forEach((item)=>{
+                basicInfoData.value.trailDeviceUseInfoDTOS.push(item)
+            })
+        }
+         
+    
+    }
+
 }
 </script>
 

+ 14 - 3
src/views/tentative/detect/test-form.vue

@@ -10,7 +10,7 @@
                 <el-button hc-btn type="primary" @click="BasicClick">基础信息</el-button>
                 <el-button
                     :disabled="NodeStatus === '3' || listItemData.length <= 0" :loading="tableFormSaveLoading" hc-btn
-                    color="#12C060" style="color: white; font-weight: bold" @click="tableFormSaveClick"
+                    color="#12C060" style="color: white; font-weight: bold" @click="tableFormSaveClick(false)"
                 >
                     保存
                 </el-button>
@@ -1029,8 +1029,9 @@ const linksSampleModalClose = () => {
 }
 
 //保存
+
 const tableFormSaveLoading = ref(false)
-const tableFormSaveClick = async () => {
+const tableFormSaveClick = async (saveType) => {
     await useClick()
     //false是编辑
     if (tabTypeKey.value === '2' && listItemBaseData.value.detectionResult === '') {
@@ -1231,8 +1232,14 @@ const tableFormSaveClick = async () => {
                     return
 
                 }
+                let obj = saveType ? basicInfoData.value : listItemBaseData.value
+                console.log(obj, 'obj')
+                
+                    
+
                 const { error, code, data, msg } = await dataApi.saveExcelBussData({
-                    ...listItemBaseData.value,
+                    // ...listItemBaseData.value,
+                    ...obj,
                     isBatchSave: 1,
                     dataInfo: { orderList: FormData },
                     // deviceUseIds:listDeviceUseIds.value
@@ -1588,8 +1595,12 @@ const isShowBasic = ref(false)
 const BasicClick = () => {
     isShowBasic.value = true
 }
+const basicInfoData = ref({})
 const basicInfoChange = (val) => {
    console.log(val, 'val')
+   tableFormSaveClick(true)
+   basicInfoData.value = val
+
    
 }
 </script>