Browse Source

获取抽检目录修改

duy 1 năm trước cách đây
mục cha
commit
ee3e2aa23e

+ 13 - 38
src/views/transfer/components/entry-sampling/hc-tree.vue

@@ -2,7 +2,7 @@
     <el-tree
         ref="ElTreeRef" v-loading="treeLoaing"
         :class="ui"
-        :data="ElTreeData"
+        :data="treeData"
         :indent="0"
         :props="ElTreeProps"
         accordion
@@ -23,59 +23,34 @@
 </template>
 
 <script setup>
-import { onMounted, ref } from 'vue'
-//import dataFillQuery from '~api/data-fill/query';
-import { getArrValue, getObjValue } from 'js-fast-way'
-import initialgApi from '~api/initial/initial'
-
+import { ref, watch } from 'vue'
 //参数
 const props = defineProps({
     ui: {
         type: String,
         default: '',
     },
-    projectId: {
-        type: [String, Number],
-        default: '',
-    },
-    contractId: {
-        type: [String, Number],
-        default: '',
-    },
-    types:{
-        type: [String, Number],
-        default: '',
+    treeData:{
+        type:Array,
+        default:()=>[],
     },
 })
-const projectId = ref(props.projectId)
-const types = ref(props.types)
 
-onMounted(()=>{
-    getElTreeData()
+const treeData = ref(props.treeData)
+
+//监听
+watch(() => [
+    props.treeData,
+], ([TreeData]) => {
+    treeData.value = TreeData
 })
+
 //变量
 const ElTreeRef = ref(null)
 const ElTreeProps = ref({
     children: 'children',
     label: 'nodeName',
 })
-const treeLoaing = ref(false)
-const getElTreeData = async ()=>{
-    treeLoaing.value = true
-    const { error, code, data } = await initialgApi.getUnitAllNode({
-        projectId: projectId.value,
-        types:types.value,
-    })
-    treeLoaing.value = false
-    if (!error && code === 200) {
-        console.log(data, 'data')
-        ElTreeData.value = getArrValue(data)
-    } else {
-        ElTreeData.value = []
-     
-    }
-}
-const ElTreeData = ref( [])
 </script>
 
 <style lang="scss" scoped>

+ 25 - 6
src/views/transfer/entry-sampling.vue

@@ -60,7 +60,7 @@
                     <span class="text-orange text-sm">为您分配抽检范围,若有异动,可手动勾选想要验收的部分</span>
                 </template>
 
-                <HcTree :types="checkList.join(',')" :project-id="projectId" style="margin-bottom: 10px;" />
+                <HcTree style="margin-bottom: 10px;" :tree-data="ElTreeData" />
 
                 <template #action>
                     <div class="hc-card-action-diy">
@@ -86,6 +86,8 @@ import { ref } from 'vue'
 import { useAppStore } from '~src/store'
 import { useRouter } from 'vue-router'
 import HcTree from './components/entry-sampling/hc-tree.vue'
+import initialgApi from '~api/initial/initial'
+import { getArrValue } from 'js-fast-way'
 
 //变量
 const router = useRouter()
@@ -110,15 +112,31 @@ const emptyTypeClick = () => {
 const isNull = ref(true)
 const isCard = ref(false)
 const isLoading = ref(false)
+const treeLoaing = ref(false)
+const getElTreeData = async ()=>{
+    treeLoaing.value = true
+    const { error, code, data } = await initialgApi.getUnitAllNode({
+        projectId: projectId.value,
+        types:checkList.value.join(','),
+    })
+    treeLoaing.value = false
+    if (!error && code === 200) {
+        console.log(data, 'data')
+        ElTreeData.value = getArrValue(data)
+    } else {
+        ElTreeData.value = []
+     
+    }
+}
+const ElTreeData = ref( [])
 
 //确认分配
-const confirmAllocationClick = () => {
+const confirmAllocationClick = async () => {
     isNull.value = false
     isLoading.value = true
-    setTimeout(() => {
-        isCard.value = true
-        isLoading.value = false
-    }, 3000)
+    await getElTreeData()
+    isCard.value = true
+    isLoading.value = false
 }
 
 //确认并进入抽检
@@ -128,6 +146,7 @@ const ToInspection = () => {
     })
 }
 
+
 //清空重置
 const clearResetClick = () => {
     isNull.value = true