|
@@ -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
|