Преглед на файлове

关联质检资料修改

duy преди 1 година
родител
ревизия
0e1b04c39f
променени са 2 файла, в които са добавени 91 реда и са изтрити 15 реда
  1. 75 11
      src/views/project/debit/contract/components/unit/link-data.vue
  2. 16 4
      src/views/project/debit/contract/unit.vue

+ 75 - 11
src/views/project/debit/contract/components/unit/link-data.vue

@@ -1,6 +1,6 @@
 <!-- 关联资料 -->
 <template>
-    <hc-new-dialog v-model="linkModal" is-table title="关联资料" widths="1200px">
+    <hc-new-dialog v-model="linkModal" is-table title="关联资料" widths="1200px" @close="closeModal">
         <span class="text-orange font-400">温馨提示:允许单对多、多对单、多对多的关联关系。关联后可在对应节点清单列表下查看“关联并继续”可继续进行关联。</span>
         <div class="title-box">
             <div class="title-box-left">WBS树</div>
@@ -11,7 +11,17 @@
                 <div class="relative h-full flex">
                     <div v-loading="treeLoading" class="hc_tree_card_border relative w-full">
                         <hc-body scrollbar padding="0px">
-                            <HcDataTree tree-key="id" show-checkbox :datas="leftTreeData" :h-props="treeProps" @node-tap="nodeElTreeClick" @check="treeNodeCheck" />
+                            <HcDataTree 
+                                tree-key="id" 
+                                show-checkbox 
+                                :datas="leftTreeData" 
+                                :h-props="lefttreeProps" 
+                                :default-checked-keys="defaultCheckedKeys" 
+                                :auto-expand-keys="autoExpandKeys" 
+                        
+                                @node-tap="nodeElTreeClick"
+                                @check="treeNodeCheck"
+                            />
                         </hc-body>
                     </div>
                 </div>
@@ -32,7 +42,7 @@
 
         <template #footer>
             <div class="dialog-footer">
-                <el-button hc-btn style="border: 1px solid var(--el-button-border-color);" @click="linkModal = false">
+                <el-button hc-btn style="border: 1px solid var(--el-button-border-color);" @click="closeModal">
                     <HcIcon name="close" />
                     <span>取消</span>
                 </el-button>
@@ -50,10 +60,10 @@
 </template>
 
 <script setup>
-import { ref, watch } from 'vue'
+import { nextTick, ref, watch } from 'vue'
 import { getArrValue, getObjValue } from 'js-fast-way'
 import { useAppStore } from '~src/store'
-
+import { getStoreValue, setStoreValue } from '~src/utils/storage'
 import unitApi from '~api/project/debit/contract/unit'
 import { linkEmits } from 'element-plus'
 const props = defineProps({
@@ -61,19 +71,31 @@ const props = defineProps({
         type: Boolean,
         default: false,
     },
+    isCheckId:{
+        type: Number,
+        default: 1,
+    },
+    checkIds:{
+        type: [Number, String],
+        default: '',
+    },
   
 })
+//事件
+const emit = defineEmits(['close'])
 const useAppState = useAppStore()
 const contractId = ref(useAppState.getContractId)
 const projectId = ref(useAppState.getProjectId)
-
-
-
+const isCheckId = ref(props.isCheckId)
+const checkIds = ref(props.checkIds)
 
 const linkModal = defineModel('modelValue', {
     default: false,
 })
-
+const closeModal = ()=>{
+    linkModal.value = false
+    emit('close')
+}
 //获取两棵树的数据
 const treeLoading = ref(false)
 const leftTreeData = ref([])
@@ -89,29 +111,71 @@ const getTwotreeData = async () => {
     if (!error && code === 200) {
         leftTreeData.value = getArrValue(data['meterTree'])
         rightTreeData.value = getArrValue(data['wbsTree'])
+        if (isCheckId.value === 2) {
+            nextTick(()=>{
+                addDisabledFlag(leftTreeData.value)
+                console.log(leftTreeData.value, 'leftTreeData.value11111')
+            })
+        }
     
+            
     } else {
         leftTreeData.value = []
         rightTreeData.value = []
     }
 }
+
+const addDisabledFlag = (data) =>{
+  data.forEach(node => {
+    // 给当前节点添加 disabled 属性
+    node.disabled = true
+
+    // 如果当前节点有子节点,则递归调用 addDisabledFlag 函数
+    if (node.children && node.children.length > 0) {
+      addDisabledFlag(node.children)
+    }
+  })
+}
 //数据格式
 const treeProps = {
     label: 'nodeName',
     children: 'children',
 }
-//wbs
+const lefttreeProps = {
+    label: 'nodeName',
+    children: 'children',
+    disabled: 'disabled',
+}
+const defaultCheckedKeys = ref([])
+ const autoExpandKeys = ref([])
 //监听
 watch(() => [
 props.linkModal,
-], ([link]) => {
+props.isCheckId,
+props.checkIds,
+], ([link, check, ids]) => {
     linkModal.value = link
+    isCheckId.value = check
+    checkIds.value = ids
     getTwotreeData()
+    console.log(getStoreValue('wbsTreeExpandKeys'), '111111')
+
+    if (check === 2) {
+        const keys = getStoreValue('wbsTreeExpandKeys')
+        autoExpandKeys.value = keys
+        defaultCheckedKeys.value = [ids]
+        meterIds.value = ids
+     
+    } else {
+        autoExpandKeys.value = []
+        defaultCheckedKeys.value = []
+    }
 }, { immediate: true })
 
 
 const sureLoading = ref(false)
 const sureClick = async (type)=>{
+
     if (!meterIds.value || !wbsIds.value) {
         window.$message.warning('请先选择需要关联的节点')
         return

+ 16 - 4
src/views/project/debit/contract/unit.vue

@@ -5,7 +5,7 @@
                 <template #header>
                     <div class="w-full flex justify-between">
                         <el-button hc-btn type="primary" :loading="setLoading" @click="setTree">重新设置treeCode</el-button>
-                        <el-button hc-btn type="primary" :loading="linkLoading" @click="linkDataClick">关联资料</el-button>
+                        <el-button hc-btn type="primary" :loading="linkLoading" @click="linkDataClick(1)">关联资料</el-button>
                     </div>
                 </template>
                 <hc-lazy-tree
@@ -48,7 +48,7 @@
                     </div>
                     <HcTitle title="质检关联清单">
                         <template #extra>
-                            <el-button hc-btn type="primary" @click="linkDataClick">关联</el-button>
+                            <el-button hc-btn type="primary" @click="linkDataClick(2)">关联</el-button>
                             <el-button hc-btn type="primary">批量取消</el-button>
                         </template>
                     </HcTitle>
@@ -177,7 +177,7 @@
         </hc-new-dialog>
         <!-- 
         关联资料 -->
-        <linkData v-model="linkModal" />
+        <linkData :link-modal="linkModal" :is-check-id="isCheckId" :check-ids="checkTreeId" @close="closeLink" @save="saveLink" />
     </div>
 </template>
 
@@ -360,11 +360,13 @@ const treeLoadMenu = ({ item, level }, resolve) => {
     }
 }
 const menuType = ref('')
+const treeClickdata = ref()
 const treeMenuTap = ({ key, node, data, keys }) => {
     const { isDecompositionData } = data
     isInfoView.value = node.isLeaf
     menuType.value = key
     getTreeNodeDetail(data)
+    treeClickdata.value = data
     setStoreValue('wbsTreeExpandKeys', keys)
     TreeAutoExpandKeys.value = keys || []
     if (data?.isLock !== 1) {
@@ -647,9 +649,19 @@ const typeoptions = ref([
 ])
 const typevalue = ref('')
 //关联资料
+const isCheckId = ref(1)
 const linkLoading = ref(false)
 const linkModal = ref(false)
-const linkDataClick = ()=>{
+const linkDataClick = (type)=>{
+    console.log(type, 'type1111111')
     linkModal.value = true
+    isCheckId.value = type
+}
+const closeLink = ()=>{
+    linkModal.value = false
+}
+const saveLink = ()=>{
+    linkModal.value = false
+    getTreeNodeDetail(treeClickdata)
 }
 </script>