项目详细数据渲染
This commit is contained in:
parent
5be32acd1b
commit
fc905f080e
|
|
@ -1,5 +1,5 @@
|
|||
// 建制相关API
|
||||
import { del, get, post, put } from "@/utils/request";
|
||||
import { get } from "@/utils/request";
|
||||
|
||||
/**
|
||||
* 获取建制数据列表
|
||||
|
|
@ -19,30 +19,3 @@ export function getInstitutionalList(params = {}) {
|
|||
};
|
||||
return get("/app/formed/listFormed", { ...defaultParams, ...params });
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建建制项目
|
||||
* @param {Object} data - 项目数据
|
||||
* @returns {Promise} 返回创建结果
|
||||
*/
|
||||
export function createInstitutional(data) {
|
||||
return post("/app/formed/createFormed", data);
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新建制项目
|
||||
* @param {Object} data - 项目数据
|
||||
* @returns {Promise} 返回更新结果
|
||||
*/
|
||||
export function updateInstitutional(data) {
|
||||
return put("/app/formed/updateFormed", data);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除建制项目
|
||||
* @param {string} id - 项目ID
|
||||
* @returns {Promise} 返回删除结果
|
||||
*/
|
||||
export function deleteInstitutional(id) {
|
||||
return del(`/app/formed/deleteFormed/${id}`);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -9,3 +9,7 @@ import { get } from "@/utils/request";
|
|||
export function getInstitutionalDetail(formedId) {
|
||||
return get("/app/formed/formedDetail", { formedId });
|
||||
}
|
||||
|
||||
export function getProjectSchedule(formedId) {
|
||||
return get("/app/article/listFormed", { formedId });
|
||||
}
|
||||
|
|
|
|||
|
|
@ -77,7 +77,10 @@
|
|||
|
||||
<script>
|
||||
import CommonEnum from "../../enum/common";
|
||||
import { getInstitutionalDetail } from "../../api/institutionalStructure/institutionalStructureDetail";
|
||||
import {
|
||||
getInstitutionalDetail,
|
||||
getProjectSchedule,
|
||||
} from "../../api/institutionalStructure/institutionalStructureDetail";
|
||||
|
||||
export default {
|
||||
components: {},
|
||||
|
|
@ -146,14 +149,53 @@ export default {
|
|||
methods: {
|
||||
// 加载页面数据
|
||||
async loadPageData() {
|
||||
this.loading = true;
|
||||
try {
|
||||
const response = await getInstitutionalDetail(this.formedId);
|
||||
if (response.code === 200) {
|
||||
this.projectDetails = response.data;
|
||||
// 并行请求优化(如果两个请求无依赖关系)
|
||||
const [detailResponse, scheduleResponse] = await Promise.all([
|
||||
getInstitutionalDetail(this.formedId),
|
||||
getProjectSchedule(this.formedId),
|
||||
]);
|
||||
|
||||
// 处理机构详情数据
|
||||
if (detailResponse?.code === 200) {
|
||||
this.projectDetails = detailResponse.data;
|
||||
} else {
|
||||
console.warn("获取机构详情失败:", detailResponse?.message);
|
||||
uni.showToast({
|
||||
title: "获取详情失败",
|
||||
icon: "none",
|
||||
});
|
||||
}
|
||||
|
||||
// 处理项目进度数据
|
||||
if (scheduleResponse?.code === 200) {
|
||||
// 注意:这里应该是合并数据还是替换数据?
|
||||
// 方案1:直接赋值(如果只需要进度数据)
|
||||
this.scheduleData = scheduleResponse.rows;
|
||||
|
||||
// 方案2:合并到projectDetails(如果需要合并)
|
||||
// this.projectDetails = {
|
||||
// ...this.projectDetails,
|
||||
// schedule: scheduleResponse.rows
|
||||
// };
|
||||
} else {
|
||||
console.warn("获取项目进度失败:", scheduleResponse?.message);
|
||||
uni.showToast({
|
||||
title: "获取进度失败",
|
||||
icon: "none",
|
||||
});
|
||||
}
|
||||
} catch (error) {
|
||||
console.error("获取页面数据失败:", error);
|
||||
uni.showToast({
|
||||
title: "数据加载失败",
|
||||
icon: "none",
|
||||
});
|
||||
|
||||
// 可选:重试逻辑
|
||||
// setTimeout(() => this.loadPageData(), 2000);
|
||||
} finally {
|
||||
// 可以在这里关闭加载状态
|
||||
this.loading = false;
|
||||
}
|
||||
},
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user