|
@@ -195,14 +195,13 @@
|
|
|
</template>
|
|
|
<script setup lang="ts">
|
|
|
import { ElMessage } from 'element-plus'
|
|
|
-import request from '@/config/axios'
|
|
|
import { industryList } from '@/utils/business'
|
|
|
import UserOrgTree from '@/views/OaSystem/components/UserOrgTree/index.vue'
|
|
|
import DistrictTree from '@/views/OaSystem/components/DistrictTree/index.vue'
|
|
|
import ProjectTypeTree from '@/views/OaSystem/components/ProjectTypeTree/index.vue'
|
|
|
import AddSubProject from '@/views/OaSystem/projectCenter/projectDetail/components/xmxx/AddSubProject.vue'
|
|
|
-import { useQuery } from '@tanstack/vue-query'
|
|
|
-import { getProjectWithChildrenById } from '@/service/project'
|
|
|
+import { useMutation, useQuery } from '@tanstack/vue-query'
|
|
|
+import { getProjectWithChildrenById, saveProject } from '@/service/project'
|
|
|
import ProjectMember from '@/views/OaSystem/projectCenter/projectDetail/components/xmxx/ProjectMember.vue'
|
|
|
import ProjectMileStone from '@/views/OaSystem/projectCenter/projectDetail/components/xmxx/ProjectMileStone.vue'
|
|
|
|
|
@@ -211,7 +210,7 @@ const props = defineProps<{ editor: boolean }>()
|
|
|
const { editor } = toRefs(props)
|
|
|
const { query } = useRoute()
|
|
|
const { id: _mainProjectId = '', subId = '' } = query
|
|
|
-const currentProjectId = ref<string>(_mainProjectId)
|
|
|
+const currentProjectId = ref<string>()
|
|
|
const isMaster = computed(() => _mainProjectId === currentProjectId.value)
|
|
|
/***
|
|
|
* 查询项目和子项目详情数据
|
|
@@ -227,19 +226,26 @@ const { data: originData, refetch } = useQuery(
|
|
|
async () => await getProjectWithChildrenById(_mainProjectId as string),
|
|
|
{
|
|
|
onSuccess: (tData) => {
|
|
|
- switchProjectInfo(subId !== '' ? subId : _mainProjectId, tData)
|
|
|
+ const targetId =
|
|
|
+ (currentProjectId.value ?? '') === ''
|
|
|
+ ? subId !== ''
|
|
|
+ ? subId
|
|
|
+ : _mainProjectId
|
|
|
+ : currentProjectId.value
|
|
|
+ switchProjectInfo(targetId, tData)
|
|
|
},
|
|
|
enabled: (_mainProjectId ?? '') !== ''
|
|
|
}
|
|
|
)
|
|
|
|
|
|
// 选择当前查看项目
|
|
|
-const switchProjectInfo = (switchId: string, data = originData.value) => {
|
|
|
+const switchProjectInfo = (switchId: string, data = originData) => {
|
|
|
+ const { children, ...other } = unref(data)
|
|
|
currentProjectId.value = switchId
|
|
|
if (switchId === _mainProjectId) {
|
|
|
- projectDetail.value = data
|
|
|
+ projectDetail.value = { ...other }
|
|
|
} else {
|
|
|
- projectDetail.value = data?.children?.find(({ id }) => id === switchId)
|
|
|
+ projectDetail.value = { ...(children?.find(({ id }) => id === switchId) ?? {}) }
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -264,17 +270,16 @@ const onHandleSuccess = () => {
|
|
|
* 项目编辑保存成操作
|
|
|
* **/
|
|
|
const saveProjectHandle = (): void => {
|
|
|
- const urlApi = `/project`
|
|
|
- request.put({ url: urlApi, data: projectDetail.value }, '/business').then((resultData) => {
|
|
|
- if (resultData) {
|
|
|
- ElMessage({
|
|
|
- message: '保存项目成功',
|
|
|
- type: 'success'
|
|
|
- })
|
|
|
- }
|
|
|
- })
|
|
|
+ save(projectDetail.value)
|
|
|
}
|
|
|
|
|
|
+const { mutate: save } = useMutation(saveProject, {
|
|
|
+ onSuccess: () => {
|
|
|
+ refetch()
|
|
|
+ ElMessage({ message: '保存项目成功', type: 'success' })
|
|
|
+ }
|
|
|
+})
|
|
|
+
|
|
|
defineExpose({
|
|
|
saveProjectHandle,
|
|
|
handleAddSubProject
|