8
0
ZaiZai 10 сар өмнө
parent
commit
97b75f5dcd

+ 35 - 2
src/views/project/info/detail.vue

@@ -6,7 +6,8 @@
                 <HcTemplate v-if="tabsKey === '2'" ref="tempRef" v-model="basicForm" />
                 <template #action>
                     <el-button hc-btn class="mr-4" :loading="submitLoading" @click="saveAndExit">保存并退出</el-button>
-                    <el-button hc-btn type="primary" :loading="submitLoading" @click="saveAndNextStep">保存并进入下一步</el-button>
+                    <el-button v-if="tabsKey > '1'" hc-btn type="success" :loading="submitLoading" @click="saveAndBackStep">保存并返回上一步</el-button>
+                    <el-button v-if="tabsKey < '4'" hc-btn type="primary" :loading="submitLoading" @click="saveAndNextStep">保存并进入下一步</el-button>
                 </template>
             </hc-tab-card>
         </div>
@@ -101,12 +102,34 @@ const saveAndExit = async () => {
     drawerClose()
 }
 
+//保存并返回上一步
+const saveAndBackStep = async () => {
+    const type = tabsKey.value
+    const isRes = await saveDataApi()
+    if (!isRes) return
+    isDisabled.value = false
+    if (type === '4') {
+        tabsKey.value = '3'
+    } else if (type === '3') {
+        tabsKey.value = '2'
+    } else if (type === '2') {
+        tabsKey.value = '1'
+    }
+}
+
 //保存并进入下一步
 const saveAndNextStep = async () => {
+    const type = tabsKey.value
     const isRes = await saveDataApi()
     if (!isRes) return
     isDisabled.value = false
-    tabsKey.value = '2'
+    if (type === '1') {
+        tabsKey.value = '2'
+    } else if (type === '2') {
+        tabsKey.value = '3'
+    } else if (type === '3') {
+        tabsKey.value = '4'
+    }
 }
 
 //ref
@@ -128,6 +151,16 @@ const saveDataApi = async () => {
             window?.$message?.success('保存成功')
         }
         return code === 200
+    } else if (tabsKey.value === '2') {
+        //分配WBS模版
+        const obj = await tempRef.value.getTreeObj()
+        submitLoading.value = true
+        const { code } = await mainApi.submitWbsTreeInProject(obj)
+        submitLoading.value = false
+        if (code === 200) {
+            window?.$message?.success('保存成功')
+        }
+        return code === 200
     }
 }
 

+ 38 - 5
src/views/project/info/template.vue

@@ -382,7 +382,7 @@ const getLeafIds = (ids, data) => {
     }
 }
 
-const getTreeAllId = (name) => {
+const getTreeAllId = async (name) => {
     let tree
     if (name === 'left') {
         tree = leftTreeRef.value
@@ -394,16 +394,16 @@ const getTreeAllId = (name) => {
     }
     let ids = []
     for (let i = 0; i < tree.data.length; i++) {
-        getIds(ids, tree.data[i])
+        await getIds(ids, tree.data[i])
     }
     return ids.join(',')
 }
 
-const getIds = (ids, data) => {
+const getIds = async (ids, data) => {
     ids.push(data.id)
     if (data.children && data.children.length) {
         for (let i = 0; i < data.children.length; i++) {
-            getIds(ids, data.children[i])
+            await getIds(ids, data.children[i])
         }
     }
 }
@@ -430,10 +430,43 @@ const formatWbsId = (rid) => {
     }
 }
 
+const rightObj = ref({})
 const setCheckTreeChange = () => {
     let recordId = formatWbsId(wbsId.value)
-    console.log(recordId)
+    rightObj.value = {
+        wbsId: recordId,
+        data: rightTreeData.value,
+    }
+}
+
+const getTreeObj = async () => {
+    const form = getObjValue(formModel.value)
+    const ids = await getTreeAllId('right')
+    const wbs_id = wbsId.value
+    let obj = {
+        wbsId: wbs_id,
+        projectId: form.id,
+        wbsType: templateType.value,
+        wbsTreeIds: ids,
+    }
+    if (wbs_id.toString().indexOf(',') >= 0) {
+        //私有库
+        obj.referenceType = 'private'
+        let ids = wbs_id.toString().split(',')
+        obj.wbsId = ids[0]
+        obj.referencePrivateWbsProjectId = ids[1]
+        obj.primaryKeyId = leftTreeData.value[0].primaryKeyId
+    } else {
+        //公有库
+        obj.referenceType = 'public'
+        obj.wbsId = wbs_id
+    }
+    return obj
 }
+
+defineExpose({
+    getTreeObj,
+})
 </script>
 
 <style lang="scss">