ZaiZai пре 9 месеци
родитељ
комит
dc1743c126
2 измењених фајлова са 59 додато и 22 уклоњено
  1. 1 1
      src/api/modules/project/contract.js
  2. 58 21
      src/views/project/detail/wbs.vue

+ 1 - 1
src/api/modules/project/contract.js

@@ -108,7 +108,7 @@ export default {
         return HcApi({
             url: '/api/blade-manager/contractInfo/tree',
             method: 'get',
-            data: form,
+            params: form,
         })
     },
     async findPostByType(category) {

+ 58 - 21
src/views/project/detail/wbs.vue

@@ -42,25 +42,31 @@
 </template>
 
 <script setup>
-import { nextTick, onMounted, ref, watch } from 'vue'
+import { onMounted, ref, watch } from 'vue'
 import { useAppStore } from '~src/store'
 import { deepClone, getArrValue, getObjValue, isNullES } from 'js-fast-way'
-import mainApi from '~api/project/project'
-import treeApi from '~api/wbs/tree'
+import projectApi from '~api/project/project'
+import contractApi from '~api/project/contract'
+
+const props = defineProps({
+    data: {
+        type: Object,
+        default: () => ({}),
+    },
+})
+
+//事件
+const emit = defineEmits(['close', 'next'])
 
 //缓存
 const store = useAppStore()
 
-//双向绑定
-const modelData = defineModel('modelValue', {
-    default: {},
-})
-
 //监听数据
-const formModel = ref({})
-watch(() => modelData.value, (data) => {
-    formModel.value = data
-}, { immediate: true, deep: true })
+const dataInfo = ref(props.data)
+watch(() => props.data, (data) => {
+    dataInfo.value = data
+    getDataApi()
+}, { deep: true })
 
 //监听
 const userInfo = ref(store.getUserInfo)
@@ -70,7 +76,7 @@ watch(() => store.getUserInfo, (info) => {
 
 //渲染完成
 onMounted(() => {
-    getWbsTreeList()
+    getDataApi()
 })
 
 //树配置
@@ -81,24 +87,55 @@ const treeProps = {
     label: 'title',
 }
 
-//获取WBS树列表
-const wbsId = ref('')
-const wbsTreeList = ref([])
-const isLoading = ref(false)
-const getWbsTreeList = async () => {
+//获取数据
+const getDataApi = async () => {
+    await getProjectDeatil()
+    if (isNullES(wbsId.value)) return
+    await getLeftTreeApi()
+    await getRightTreeApi()
+}
 
+//获取项目详情
+const wbsId = ref('')
+const projectInfo = ref({})
+const getProjectDeatil = async () => {
+    wbsId.value = ''
+    projectInfo.value = {}
+    const { pid } = getObjValue(dataInfo.value)
+    if (isNullES(pid)) return
+    const { data } = await projectApi.detail(pid)
+    const res = getObjValue(data)
+    projectInfo.value = res
+    wbsId.value = res.referenceWbsTemplateId
 }
 
-//左边树
+//获取WBS树列表
 const leftLoading = ref(false)
 const leftTreeData = ref([])
-
+const getLeftTreeApi = async () => {
+    leftLoading.value = true
+    const { pid } = getObjValue(dataInfo.value)
+    const { data } = await projectApi.findProjectTree({
+        projectId: pid,
+        wbsId: wbsId.value,
+    })
+    leftTreeData.value = getArrValue(data)
+    leftLoading.value = false
+}
 
 //获取右边数据
 const rightLoading = ref(false)
 const rightTreeData = ref([])
 const getRightTreeApi = async () => {
-
+    rightLoading.value = true
+    const { pid, cid } = getObjValue(dataInfo.value)
+    const { data } = await contractApi.getContractInfoTree({
+        wbsId: wbsId.value,
+        projectId: pid,
+        contractId: cid,
+    })
+    rightTreeData.value = getArrValue(data)
+    rightLoading.value = false
 }
 
 //左边树被展开