ZaiZai 11 tháng trước cách đây
mục cha
commit
c16a46683c

+ 8 - 3
src/views/tentative/acquisition/data.vue

@@ -110,7 +110,7 @@ import { onActivated, ref } from 'vue'
 import { useAppStore } from '~src/store'
 import { getErtractInfo } from '~api/other'
 import { HcDelMsg } from 'hc-vue3-ui'
-import { formValidate, getArrValue } from 'js-fast-way'
+import { formValidate, getArrValue, isNullES } from 'js-fast-way'
 import mainApi from '~api/tentative/acquisition/data'
 
 //变量
@@ -142,9 +142,14 @@ const getContractData = async () => {
     })
     const res = getArrValue(data)
     contractData.value = res
-    if (res.length > 0) {
-        searchForm.value.contractId = res[0].id
+    if (res.length <= 0) return
+    let cid
+    for (let i = 0; i < res.length; i++) {
+        if (contractId.value == res[i].id) {
+            cid = res[i].id
+        }
     }
+    searchForm.value.contractId = isNullES(cid) ? res[0].id : cid
 }
 
 //日期时间被选择

+ 9 - 9
src/views/tentative/collect/test.vue

@@ -189,20 +189,20 @@ const searchForm = ref({
 
 //获取合同段列表
 const getContractOpt = async () => {
-    const { error, code, data } = await getContractList({
+    const { data } = await getContractList({
         contractId: contractId.value,
         projectId: projectId.value,
     })
-    //判断状态
-    if (!error && code === 200) {
-        let resdata = getArrValue(data)
-        contractOptions.value = resdata
-        if (contractOptions.value.length > 0) {
-            searchForm.value.contractId = contractOptions.value[0].id
+    const res = getArrValue(data)
+    contractOptions.value = res
+    if (res.length <= 0) return
+    let cid
+    for (let i = 0; i < res.length; i++) {
+        if (contractId.value == res[i].id) {
+            cid = res[i].id
         }
-    } else {
-        contractOptions.value = []
     }
+    searchForm.value.contractId = isNullES(cid) ? res[0].id : cid
 }
 
 //获取汇总分类列表

+ 7 - 2
src/views/tentative/detect/commission.vue

@@ -230,9 +230,14 @@ const getContractData = async () => {
     })
     const res = getArrValue(data)
     contractData.value = res
-    if (res.length > 0) {
-        searchForm.value.contractId = res[0].id
+    if (res.length <= 0) return
+    let cid
+    for (let i = 0; i < res.length; i++) {
+        if (contractId.value == res[i].id) {
+            cid = res[i].id
+        }
     }
+    searchForm.value.contractId = isNullES(cid) ? res[0].id : cid
 }
 
 //获取状态

+ 7 - 2
src/views/tentative/detect/test.vue

@@ -373,9 +373,14 @@ const getContractData = async () => {
     })
     const res = getArrValue(data)
     contractData.value = res
-    if (res.length > 0) {
-        searchForm.value.contractId = res[0].id
+    if (res.length <= 0) return
+    let cid
+    for (let i = 0; i < res.length; i++) {
+        if (contractId.value == res[i].id) {
+            cid = res[i].id
+        }
     }
+    searchForm.value.contractId = isNullES(cid) ? res[0].id : cid
 }
 
 const qualifiedData = ref([

+ 8 - 3
src/views/tentative/material/modules/testSample/dispose.vue

@@ -59,10 +59,15 @@ const getContractData = async () => {
     })
     const res = getArrValue(data)
     contractData.value = res
-    if (res.length > 0) {
-        searchForm.value.contractId = res[0].id
-        searchClick()
+    if (res.length <= 0) return
+    let cid
+    for (let i = 0; i < res.length; i++) {
+        if (contractId.value == res[i].id) {
+            cid = res[i].id
+        }
     }
+    searchForm.value.contractId = isNullES(cid) ? res[0].id : cid
+    searchClick()
 }
 
 //监听数据

+ 8 - 3
src/views/tentative/material/modules/testSample/flow.vue

@@ -73,10 +73,15 @@ const getContractData = async () => {
     })
     const res = getArrValue(data)
     contractData.value = res
-    if (res.length > 0) {
-        searchForm.value.contractId = res[0].id
-        searchClick()
+    if (res.length <= 0) return
+    let cid
+    for (let i = 0; i < res.length; i++) {
+        if (contractId.value == res[i].id) {
+            cid = res[i].id
+        }
     }
+    searchForm.value.contractId = isNullES(cid) ? res[0].id : cid
+    searchClick()
 }
 
 //日期时间被选择

+ 8 - 3
src/views/tentative/material/modules/testSample/inventory.vue

@@ -132,10 +132,15 @@ const getContractData = async () => {
     })
     const res = getArrValue(data)
     contractData.value = res
-    if (res.length > 0) {
-        searchForm.value.contractId = res[0].id
-        searchClick()
+    if (res.length <= 0) return
+    let cid
+    for (let i = 0; i < res.length; i++) {
+        if (contractId.value == res[i].id) {
+            cid = res[i].id
+        }
     }
+    searchForm.value.contractId = isNullES(cid) ? res[0].id : cid
+    searchClick()
 }
 
 //日期时间被选择

+ 8 - 3
src/views/tentative/material/modules/testSample/leave.vue

@@ -95,10 +95,15 @@ const getContractData = async () => {
     })
     const res = getArrValue(data)
     contractData.value = res
-    if (res.length > 0) {
-        searchForm.value.contractId = res[0].id
-        searchClick()
+    if (res.length <= 0) return
+    let cid
+    for (let i = 0; i < res.length; i++) {
+        if (contractId.value == res[i].id) {
+            cid = res[i].id
+        }
     }
+    searchForm.value.contractId = isNullES(cid) ? res[0].id : cid
+    searchClick()
 }
 
 //日期时间被选择

+ 8 - 3
src/views/tentative/material/modules/testSample/testUnder.vue

@@ -120,10 +120,15 @@ const getContractData = async () => {
     })
     const res = getArrValue(data)
     contractData.value = res
-    if (res.length > 0) {
-        searchForm.value.contractId = res[0].id
-        searchClick()
+    if (res.length <= 0) return
+    let cid
+    for (let i = 0; i < res.length; i++) {
+        if (contractId.value == res[i].id) {
+            cid = res[i].id
+        }
     }
+    searchForm.value.contractId = isNullES(cid) ? res[0].id : cid
+    searchClick()
 }
 
 //日期时间被选择

+ 8 - 3
src/views/tentative/material/modules/testSample/tested.vue

@@ -128,10 +128,15 @@ const getContractData = async () => {
     })
     const res = getArrValue(data)
     contractData.value = res
-    if (res.length > 0) {
-        searchForm.value.contractId = res[0].id
-        searchClick()
+    if (res.length <= 0) return
+    let cid
+    for (let i = 0; i < res.length; i++) {
+        if (contractId.value == res[i].id) {
+            cid = res[i].id
+        }
     }
+    searchForm.value.contractId = isNullES(cid) ? res[0].id : cid
+    searchClick()
 }
 
 //搜索

+ 8 - 3
src/views/tentative/material/sampling.vue

@@ -323,10 +323,15 @@ const getContractData = async () => {
     })
     const res = getArrValue(data)
     contractData.value = res
-    if (res.length > 0) {
-        searchForm.value.contractId = res[0].id
-        searchClick()
+    if (res.length <= 0) return
+    let cid
+    for (let i = 0; i < res.length; i++) {
+        if (contractId.value == res[i].id) {
+            cid = res[i].id
+        }
     }
+    searchForm.value.contractId = isNullES(cid) ? res[0].id : cid
+    searchClick()
 }
 
 //获取用户列表