浏览代码

创建项目

ZaiZai 10 月之前
父节点
当前提交
13da75e044
共有 1 个文件被更改,包括 36 次插入103 次删除
  1. 36 103
      src/views/project/info/log.vue

+ 36 - 103
src/views/project/info/log.vue

@@ -51,7 +51,7 @@
 <script setup>
 import { nextTick, onMounted, ref, watch } from 'vue'
 import { useAppStore } from '~src/store'
-import { deepClone, getArrValue, getObjValue, isNullES } from 'js-fast-way'
+import { getArrValue, getObjValue, isNullES } from 'js-fast-way'
 import mainApi from '~api/project/project'
 import treeApi from '~api/wbs/tree'
 
@@ -93,133 +93,66 @@ const wbsId = ref('')
 const wbsTreeList = ref([])
 const isLoading = ref(false)
 const getWbsTreeList = async () => {
-    /*isLoading.value = true
-    const type = templateType.value
-    const { data } = await mainApi.findWbsTreeList(type)
+    isLoading.value = true
+    const { data } = await mainApi.findLogWbsTreeList()
     // 格式化数据
-    const res = getObjValue(data)
-    let arr = [{ label: '公有库', data: [] }, { label: '私有库', data: [] }]
-    const wbsInfos = getArrValue(res.wbsInfos), wbsPrivates = getArrValue(res.wbsTreePrivates)
+    let arr = [{ label: '公有库', data: [] }], res = getArrValue(data)
     // 公有库
-    wbsInfos.forEach((item) => {
+    res.forEach((item) => {
         item.value = item.id
         item.label = item.wbsName
     })
-    arr[0].data = wbsInfos
-    // 私有库
-    wbsPrivates.forEach((item) => {
-        item.label = item.projectName
-        item.value = item.wbsId + ',' + item.projectId
-    })
-    arr[1].data = wbsPrivates
+    arr[0].data = res
     wbsTreeList.value = arr
     //处理选中
     const form = getObjValue(formModel.value)
-    wbsId.value = type === 1 ? form.referenceWbsTemplateId : form.referenceWbsTemplateIdTrial
-    if (type === 3) wbsId.value = form.referenceWbsTemplateIdMeter
-    if (type === 5) wbsId.value = form.referenceWbsTemplateIdLar
-    if (type === -1) wbsId.value = ''
+    let refId = form.referenceLogWbsTemplateId
+    if (isNullES(refId) || refId <= 0 || Number(form.wbsType) <= 0) {
+        wbsId.value = ''
+        isLoading.value = false
+        return
+    }
+    wbsId.value = refId
     isLoading.value = false
-    await wbsChange(wbsId.value)*/
+    await getLeftTreeData()
+    await getRightTreeApi()
 }
 
 //左边树
 const leftLoading = ref(false)
 const leftTreeData = ref([])
+const getLeftTreeData = async () => {
+    if (isNullES(wbsId.value)) return
+    leftLoading.value = true
+    const { tenant_id } = getObjValue(userInfo.value)
+    const { data } = await treeApi.getAlltree({
+        tenantId: tenant_id,
+        type: '1',
+        wbsId: wbsId.value,
+    })
+    leftTreeData.value = getArrValue(data)
+    leftLoading.value = false
+}
 
 //切换wbs树
 const isDisabled = ref(false)
-const referenceWbsId = ref('')
-const referenceWbsType = ref('')
-const wbsChange = async (val) => {
-    /*isDisabled.value = false
-    leftLoading.value = true
-    referenceWbsId.value = val
-    //无值
-    if (isNullES(val)) {
-        await getRightTreeApi()
-        return
-    }
-    //私有库
-    if (val.toString().indexOf(',') >= 0) {
-        referenceWbsType.value = 'private'
-        let ids = val.toString().split(',')
-        const { data } = await mainApi.findProjectTree({
-            projectId: ids[1],
-            wbsId: ids[0],
-        })
-        leftTreeData.value = getArrValue(data)
-        leftLoading.value = false
-        await getRightTreeApi()
-        return
-    }
-    //公有库
-    if (val.length > 0) {
-        referenceWbsType.value = 'public'
-        const { tenant_id } = getObjValue(userInfo.value)
-        const { data } = await treeApi.getAlltree({
-            tenantId: tenant_id,
-            type: '1',
-            wbsId: val,
-        })
-        leftTreeData.value = getArrValue(data)
-        leftLoading.value = false
-        await getRightTreeApi()
-    }*/
+const wbsChange = (val) => {
+    getLeftTreeData()
 }
 
 //获取右边数据
 const rightLoading = ref(false)
 const rightTreeData = ref([])
 const getRightTreeApi = async () => {
-    /*rightLoading.value = true
-    isDisabled.value = true
-    let refId = referenceWbsId.value
-    if (isNullES(refId)) {
-        isDisabled.value = false
-        rightLoading.value = false
-        return
-    }
-    //私有
-    if (refId.toString().length > 0 && referenceWbsType.value === 'private') {
-        let ids = refId.toString().split(',')
-        if (ids.length > 1) {
-            refId = ids[0]
-            let list = wbsTreeList.value[1].data
-            refId = list.filter(({ projectId }) => projectId === ids[1])[0].pkeyId
-        }
-    }
-    //引用被删会出现 wbsType -1
-    if (refId && refId > 0) {
-        let priv = {}
-        //私有
-        if (referenceWbsType.value === 'private') {
-            let list = wbsTreeList.value[1].data
-            for (let i = 0; i < list.length; i++) {
-                if (list[i].pkeyId === refId) {
-                    refId = list[i].wbsId + ',' + list[i].projectId
-                    priv.wbsId = list[i].wbsId
-                    priv.projectId = list[i].projectId
-                    priv.value = list[i].value
-                    priv.pkeyId = list[i].pkeyId
-                    break
-                }
-            }
-        } else {
-            //公有
-            refId = referenceWbsId.value
-        }
-    }
+    if (isNullES(wbsId.value)) return
+    rightLoading.value = true
     const form = getObjValue(formModel.value)
     const { data } = await mainApi.findProjectTree({
         projectId: form.id,
-        wbsId: refId,
+        wbsId: wbsId.value,
     })
-    const projectTree = getArrValue(data)
-    isDisabled.value = projectTree.length > 0
-    rightTreeData.value = projectTree
-    setRightTree()
-    rightLoading.value = false*/
+    rightTreeData.value = getArrValue(data)
+    rightLoading.value = false
 }
 
 //默认全部引用
@@ -350,7 +283,7 @@ const delTreeClick = () => {
 }
 
 const setRightTree = () => {
-    let ids = []
+    /*let ids = []
     const data = rightTreeData.value
     for (let i = 0; i < data.length; i++) {
         getLeafIds(ids, data[i])
@@ -359,7 +292,7 @@ const setRightTree = () => {
     const e = leftTreeRef.value
     nextTick(() => {
         e.setCheckedKeys(ids, true)
-    })
+    })*/
 }
 
 const getLeafIds = (ids, data) => {