|
@@ -11,7 +11,7 @@
|
|
|
<div class="relative h-full flex">
|
|
|
<div v-loading="treeLoading" class="hc_tree_card_border relative w-full">
|
|
|
<hc-body scrollbar padding="0px">
|
|
|
- <hc-lazy-tree tree-key="id" show-checkbox @load="treeLoadNode" @node-tap="nodeElTreeClick" @check="treeNodeCheck" />
|
|
|
+ <HcDataTree tree-key="id" show-checkbox :datas="leftTreeData" :h-props="treeProps" @node-tap="nodeElTreeClick" @check="treeNodeCheck" />
|
|
|
</hc-body>
|
|
|
</div>
|
|
|
</div>
|
|
@@ -19,7 +19,15 @@
|
|
|
<div class="link-data-icon">
|
|
|
<HcIcon type="primary" name="arrow-right-double" style="font-size: 22px;" />
|
|
|
</div>
|
|
|
- <div class="link-data-right">3</div>
|
|
|
+ <div class="link-data-right">
|
|
|
+ <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="pkeyId" show-checkbox :datas="rightTreeData" :h-props="treeProps" @node-tap="nodeElTreeClickRight" @check="treeNodeCheckRight" />
|
|
|
+ </hc-body>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
</div>
|
|
|
|
|
|
<template #footer>
|
|
@@ -28,11 +36,11 @@
|
|
|
<HcIcon name="close" />
|
|
|
<span>取消</span>
|
|
|
</el-button>
|
|
|
- <el-button hc-btn type="primary" :loading="sureLoading" @click="sureClick">
|
|
|
+ <el-button hc-btn type="primary" :loading="sureLoading" @click="sureClick(1)">
|
|
|
<HcIcon name="check" />
|
|
|
<span>关联并退出</span>
|
|
|
</el-button>
|
|
|
- <el-button hc-btn type="primary" :loading="sureLoading" @click="sureClick">
|
|
|
+ <el-button hc-btn type="primary" :loading="sureLoading" @click="sureClick(2)">
|
|
|
<HcIcon name="check" />
|
|
|
<span>关联并继续</span>
|
|
|
</el-button>
|
|
@@ -45,7 +53,9 @@
|
|
|
import { ref, watch } from 'vue'
|
|
|
import { getArrValue, getObjValue } from 'js-fast-way'
|
|
|
import { useAppStore } from '~src/store'
|
|
|
-import { queryWbsTreeData } from '~api/other'
|
|
|
+
|
|
|
+import unitApi from '~api/project/debit/contract/unit'
|
|
|
+import { linkEmits } from 'element-plus'
|
|
|
const props = defineProps({
|
|
|
linkModal: {
|
|
|
type: Boolean,
|
|
@@ -55,58 +65,106 @@ const props = defineProps({
|
|
|
})
|
|
|
const useAppState = useAppStore()
|
|
|
const contractId = ref(useAppState.getContractId)
|
|
|
-const contractInfo = ref(useAppState.getContractInfo)
|
|
|
-const { contractType } = contractInfo.value
|
|
|
-const classifyType = ref(contractType === 2 ? '2' : '1')
|
|
|
+const projectId = ref(useAppState.getProjectId)
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
|
|
|
const linkModal = defineModel('modelValue', {
|
|
|
default: false,
|
|
|
})
|
|
|
|
|
|
-
|
|
|
+//获取两棵树的数据
|
|
|
+const treeLoading = ref(false)
|
|
|
+const leftTreeData = ref([])
|
|
|
+const rightTreeData = ref([])
|
|
|
+const getTwotreeData = async () => {
|
|
|
+ treeLoading.value = true
|
|
|
+ const { error, code, data } = await unitApi.getMeterTreeAndWbsTree({
|
|
|
+ projectId:projectId.value,
|
|
|
+ contractId:contractId.value,
|
|
|
+
|
|
|
+ })
|
|
|
+ treeLoading.value = false
|
|
|
+ if (!error && code === 200) {
|
|
|
+ leftTreeData.value = getArrValue(data['meterTree'])
|
|
|
+ rightTreeData.value = getArrValue(data['wbsTree'])
|
|
|
+
|
|
|
+ } else {
|
|
|
+ leftTreeData.value = []
|
|
|
+ rightTreeData.value = []
|
|
|
+ }
|
|
|
+}
|
|
|
+//数据格式
|
|
|
+const treeProps = {
|
|
|
+ label: 'nodeName',
|
|
|
+ children: 'children',
|
|
|
+}
|
|
|
+//wbs
|
|
|
//监听
|
|
|
watch(() => [
|
|
|
props.linkModal,
|
|
|
], ([link]) => {
|
|
|
linkModal.value = link
|
|
|
+ getTwotreeData()
|
|
|
}, { immediate: true })
|
|
|
|
|
|
|
|
|
const sureLoading = ref(false)
|
|
|
-const sureClick = ()=>{
|
|
|
+const sureClick = async (type)=>{
|
|
|
+ if (!meterIds.value || !wbsIds.value) {
|
|
|
+ window.$message.warning('请先选择需要关联的节点')
|
|
|
+ return
|
|
|
+ }
|
|
|
+ sureLoading.value = true
|
|
|
+ const { error, code, data, msg } = await unitApi.LinkMeterTreeAndWbsTree({
|
|
|
+ projectId:projectId.value,
|
|
|
+ contractId:contractId.value,
|
|
|
+ meterIds:meterIds.value,
|
|
|
+ wbsIds:wbsIds.value,
|
|
|
+
|
|
|
+ })
|
|
|
+ sureLoading.value = false
|
|
|
+ if (!error && code === 200) {
|
|
|
+ window.$message.success(msg)
|
|
|
+ if (type === 1) {
|
|
|
+ linkModal.value = false
|
|
|
+ }
|
|
|
|
|
|
+ } else {
|
|
|
+ window.$message.error(msg)
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
-//wbs树数据
|
|
|
-const treeLoading = ref(false)
|
|
|
-const treeLoadNode = async ({ node, item, level }, resolve) => {
|
|
|
- let contractIdRelation = '', parentId = '', primaryKeyId = ''
|
|
|
- if (level !== 0) {
|
|
|
- const nodeData = getObjValue(item)
|
|
|
- contractIdRelation = nodeData?.contractIdRelation || ''
|
|
|
- parentId = contractIdRelation ? nodeData?.primaryKeyId : nodeData?.id
|
|
|
- primaryKeyId = nodeData?.id || ''
|
|
|
- }
|
|
|
- treeLoading.value = true
|
|
|
- //获取数据
|
|
|
- const { data } = await queryWbsTreeData({
|
|
|
- contractId: contractId.value || '',
|
|
|
- contractIdRelation,
|
|
|
- primaryKeyId,
|
|
|
- parentId,
|
|
|
- classifyType: classifyType.value,
|
|
|
- tableOwner:classifyType.value,
|
|
|
-
|
|
|
+
|
|
|
+const nodeElTreeClick = ()=>{
|
|
|
+
|
|
|
+}
|
|
|
+const meterIds = ref('')
|
|
|
+const wbsIds = ref('')
|
|
|
+const treeNodeCheck = (_, { checkedNodes }) => {
|
|
|
+ console.log(checkedNodes, 'checkedNodes')
|
|
|
+ let arr = []
|
|
|
+ checkedNodes.forEach(ele => {
|
|
|
+ if (!ele.hasChild) {
|
|
|
+ arr.push(ele.id)
|
|
|
+ }
|
|
|
})
|
|
|
- treeLoading.value = false
|
|
|
- resolve(getArrValue(data))
|
|
|
-
|
|
|
+
|
|
|
+ meterIds.value = arr.join(',')
|
|
|
}
|
|
|
-const nodeElTreeClick = ()=>{
|
|
|
+const nodeElTreeClickRight = ()=>{
|
|
|
|
|
|
}
|
|
|
-const treeNodeCheck = (_, { checkedKeys }) => {
|
|
|
- console.log(checkedKeys, 'checkedKeys')
|
|
|
+const treeNodeCheckRight = (_, { checkedNodes }) => {
|
|
|
+ let arr = []
|
|
|
+ checkedNodes.forEach(ele => {
|
|
|
+ if (!ele.hasChild) {
|
|
|
+ arr.push(ele.pkeyId)
|
|
|
+ }
|
|
|
+ })
|
|
|
+
|
|
|
+ wbsIds.value = arr.join(',')
|
|
|
}
|
|
|
</script>
|
|
|
|