فهرست منبع

关联原材料报告

duy 2 سال پیش
والد
کامیت
b02625d3f3
2فایلهای تغییر یافته به همراه154 افزوده شده و 1 حذف شده
  1. 14 1
      src/views/tentative/detect/test-form.vue
  2. 140 0
      src/views/tentative/material/components/TestTreeMaterial.vue

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

@@ -141,7 +141,9 @@
             <div class="hc-links-sample-modal-box">
                 <div class="hc-links-sample-tree-box">
                     <el-scrollbar>
-                        <TestTree :projectId="projectId" :wbsTempId="projectInfo?.referenceWbsTemplateIdTrial" :wbsType="2" :tenantId="userInfo?.tenant_id" @nodeTap="linksRawTreeClick" :fromType="true" :nodeId="nodeId"/>
+                        <test-tree-material :projectId="projectId" :wbsTempId="projectInfo?.referenceWbsTemplateIdTrial" :wbsType="2" :tenantId="userInfo?.tenant_id" @nodeTap="linksRawTreeClick" :fromType="true" :nodeId="nodeId"
+                        :MixRatioTestTreeData="MixRatioTestTreeData"
+                        />
                     </el-scrollbar>
                 </div>
                 <div class="hc-links-sample-table-box">
@@ -178,10 +180,12 @@ import ListItem from "./components/ListItem.vue"
 import DivisionTree from "./components/DivisionTree.vue"
 import DivisionTree1 from "./components/DivisionTree1.vue"
 import dataApi from "~api/tentative/detect/test";
+import samplingApi from "~api/tentative/material/sampling"
 import divisionApi from "~api/data-fill/division";
 import queryApi from '~api/data-fill/query';
 import {getStoreData,setStoreData} from '~src/utils/storage'
 import TestTree from "../material/components/TestTree.vue"
+import TestTreeMaterial from "../material/components/TestTreeMaterial.vue"
 import {getArrValue, getObjValue, getObjNullValue,isString} from "vue-utils-plus";
 import {getDictionary} from "~api/other";
 import {rowsToId} from "~uti/tools";
@@ -592,9 +596,18 @@ const linksRelateModalClose = () => {
 
 //关联原材检测报告
 const linksRawModal = ref(false)
+const MixRatioTestTreeData=ref([])
 const linksRawModalClick = () => {
     linksRawModal.value = true
+    getTreeData()
 }
+const getTreeData=async(node,reslove)=>{
+        const {error, code, data} = await samplingApi.getMixRatioTestTree({
+            pKeyId: nodeId,
+        })
+         MixRatioTestTreeData.value = getArrValue(data)
+}
+
 const linkNodeid=ref('')
 //树被点击
 const linksRawTreeClick = ({data}) => {

+ 140 - 0
src/views/tentative/material/components/TestTreeMaterial.vue

@@ -0,0 +1,140 @@
+<template>
+    <ElTree class="hc-tree-node tree-line"
+            :class="ui"
+            ref="ElTreeRef"
+            :props="ElTreeProps"
+            :data="treedata"
+            highlight-current
+            accordion
+            node-key="primaryKeyId"
+            :default-expanded-keys="defaultExpandedCids"
+            @node-click="ElTreeClick"
+            :indent="0">
+        <template #default="{ node, data }">
+            <div class="data-custom-tree-node" :id="`${idPrefix}${data['primaryKeyId']}`">
+                <div class="label" :class="node.level === 1?'level-name':''">{{ node.label }}</div>
+            </div>
+        </template>
+    </ElTree>
+
+</template>
+
+<script setup>
+import {ref,nextTick,watch} from "vue";
+import samplingApi from "~api/tentative/material/sampling"
+import {isItem,getArrValue} from "vue-utils-plus"
+
+//参数
+const props = defineProps({
+    projectId: {
+        type: [String,Number],
+        default: ''
+    },
+    contractId: {
+        type: [String,Number],
+        default: ''
+    },
+    wbsTempId: {
+        type: [String,Number],
+        default: ''
+    },
+    tenantId: {
+        type: [String,Number],
+        default: ''
+    },
+    wbsType: {
+        type: [String,Number],
+        default: ''
+    },
+    autoExpandKeys: {
+        type: Array,
+        default: () => ([])
+    },
+    idPrefix: {
+        type: String,
+        default: 'test-tree-'
+    },
+    ui: {
+        type: String,
+        default: ''
+    },
+    fromType:{
+        type:Boolean,
+        default:false
+    },
+    nodeId:{
+        type: [String,Number],
+        default: ''
+    },
+    MixRatioTestTreeData:{
+        type: Array,
+        default: () => ([])
+    }
+})
+
+//变量
+const ElTreeRef = ref(null)
+const ElTreeProps = ref({
+    label: 'title',
+    children: 'children',
+    isLeaf: 'hasChildren'
+})
+const TreeExpandKey = ref(props.autoExpandKeys)
+const projectId = ref(props.projectId);
+const contractId = ref(props.contractId);
+const wbsTempId = ref(props.wbsTempId);
+const tenantId = ref(props.tenantId);
+const wbsType = ref(props.wbsType);
+const idPrefix = ref(props.idPrefix);
+const fromTypedata=ref(props.fromType)
+const treedata=ref(props.MixRatioTestTreeData)
+
+//监听
+watch(() => [
+    props.autoExpandKeys,
+    props.projectId,
+    props.contractId,
+    props.wbsTempId,
+    props.tenantId,
+    props.idPrefix,
+    props.wbsType,
+    props.fromType
+], ([expandKeys, UserProjectId, UserContractId, UserWbsTempId, UserTenantId, UserIdPrefix, wbs_type,fromType]) => {
+    TreeExpandKey.value = expandKeys
+    projectId.value = UserProjectId
+    contractId.value = UserContractId
+    wbsTempId.value = UserWbsTempId
+    tenantId.value = UserTenantId
+    idPrefix.value = UserIdPrefix
+    wbsType.value = wbs_type
+    fromTypedata.value=fromType
+})
+
+//事件
+const emit = defineEmits(['menuTap','nodeTap', 'nodeLoading'])
+
+//树形结构异步加载数据
+const defaultExpandedCids = ref([])
+
+//节点被点击
+const ElTreeClick = async (data,node) => {
+    let autoKeysArr = []
+    await getNodeExpandKeys(node, autoKeysArr)
+    const autoKeys = autoKeysArr.reverse()
+    emit('nodeTap', {node, data, keys: autoKeys})
+}
+
+//处理自动展开的节点KEY
+const getNodeExpandKeys = async (node, newKeys) => {
+    const parent = node?.parent ?? []
+    const primaryKeyId = node?.data?.primaryKeyId ?? ''
+    if (primaryKeyId) {
+        newKeys.push(primaryKeyId)
+        await getNodeExpandKeys(parent, newKeys)
+    }
+}
+</script>
+
+<style lang="scss" scoped>
+@import "../../../../styles/app/tree.scss";
+</style>