优化计划展示界面

This commit is contained in:
2025-09-10 19:27:42 +08:00
parent a1950872fc
commit 91f160b07e
5 changed files with 85 additions and 34 deletions

File diff suppressed because one or more lines are too long

21
frontend/dist/assets/index.48fb8fe6.js vendored Normal file

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@@ -4,8 +4,8 @@
<meta charset="UTF-8"> <meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>猪场管理系统</title> <title>猪场管理系统</title>
<script type="module" crossorigin src="/assets/index.9fd2dfb4.js"></script> <script type="module" crossorigin src="/assets/index.48fb8fe6.js"></script>
<link rel="stylesheet" href="/assets/index.9a05129d.css"> <link rel="stylesheet" href="/assets/index.2ad61d14.css">
</head> </head>
<body> <body>
<div id="app"></div> <div id="app"></div>

View File

@@ -55,15 +55,7 @@
<span>{{ plan.execution_limit > 0 ? plan.execution_limit : '无限制' }}</span> <span>{{ plan.execution_limit > 0 ? plan.execution_limit : '无限制' }}</span>
</div> </div>
<div v-if="plan.parent_id" class="info-item"> <!-- 移除主计划中的父计划ID和顺序显示 -->
<label>父计划ID:</label>
<span>{{ plan.parent_id }}</span>
</div>
<div v-if="plan.order_in_parent !== null" class="info-item">
<label>父计划中顺序:</label>
<span>{{ plan.order_in_parent }}</span>
</div>
</div> </div>
<div class="plan-steps"> <div class="plan-steps">
@@ -140,7 +132,12 @@
<div class="info-item"> <div class="info-item">
<label>顺序:</label> <label>顺序:</label>
<span>{{ subPlan.order_in_parent }}</span> <span>{{ (subPlan.order_in_parent || 0) + 1 }}</span>
</div>
<div v-if="subPlan.parent_id" class="info-item">
<label>父计划:</label>
<span>{{ getParentPlanName(subPlan.parent_id) }}(id:{{ subPlan.parent_id }})</span>
</div> </div>
</div> </div>
@@ -239,6 +236,8 @@ export default {
if (response.ok && data.code === 0) { if (response.ok && data.code === 0) {
this.plan = data.data this.plan = data.data
// 加载子计划的详细信息(包括步骤)
await this.loadSubPlanDetails()
} else { } else {
this.error = data.message || '获取计划详情失败' this.error = data.message || '获取计划详情失败'
} }
@@ -250,11 +249,63 @@ export default {
} }
}, },
// 加载子计划详情
async loadSubPlanDetails() {
if (!this.plan || !this.plan.sub_plans || this.plan.sub_plans.length === 0) {
return
}
// 遍历所有子计划
for (let i = 0; i < this.plan.sub_plans.length; i++) {
const subPlan = this.plan.sub_plans[i]
// 如果子计划没有步骤或步骤为空,则加载详细信息
if (!subPlan.steps || subPlan.steps.length === 0) {
try {
const response = await fetch(`/api/v1/feed/plan/detail?id=${subPlan.id}`, {
method: 'GET',
headers: {
'Content-Type': 'application/json',
'Authorization': 'Bearer ' + localStorage.getItem('authToken')
}
})
const data = await response.json()
if (response.ok && data.code === 0) {
// 用详细信息替换原来的简略信息
this.plan.sub_plans[i] = data.data
}
} catch (error) {
console.error(`获取子计划 ${subPlan.id} 详情失败:`, error)
}
}
}
},
// 返回列表 // 返回列表
goBack() { goBack() {
this.$router.push('/feed/plan') this.$router.push('/feed/plan')
}, },
// 获取父计划名称
getParentPlanName(parentId) {
// 如果父计划就是当前主计划
if (this.plan && this.plan.id === parentId) {
return this.plan.name
}
// 检查是否在子计划中
if (this.plan && this.plan.sub_plans) {
const parentPlan = this.plan.sub_plans.find(plan => plan.id === parentId)
if (parentPlan) {
return parentPlan.name
}
}
// 默认返回"未知父计划"
return '未知父计划'
},
// 编辑计划 // 编辑计划
editPlan() { editPlan() {
// TODO: 实现编辑计划逻辑 // TODO: 实现编辑计划逻辑