index.vue
4.51 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
<template>
<view class="pending-plan-detail">
<!-- 计划详情卡片 -->
<view class="detail-card" v-for="i in planInfo" :key="i.planNo">
<!-- 标题行 -->
<view class="detail-item">
<text class="label">计划名称:</text>
<text class="value up-line-1">{{ i.planName || '-' }}</text>
</view>
<!-- 计划编码行 -->
<view class="detail-item">
<text class="label">计划编码:</text>
<text class="value up-line-1">{{ i.planNo || '-' }}</text>
</view>
<!-- 养护周期行 -->
<view class="detail-item">
<text class="label">养护周期:</text>
<text class="value up-line-1">{{ i.rate || '-' }} {{ uni.$dict.getDictLabel('cycle_id_type', i.cycleId) }}
</text>
</view>
<!-- cycle_id_type-->
<!-- 计划完成次数行 -->
<view class="detail-item">
<text class="label">计划完成次数:</text>
<text class="value up-line-1">{{ i.planNum || 0 }} 次</text>
</view>
<!-- 已完成次数行 + 查看记录按钮 -->
<view class="detail-item flex-between">
<view class="left-wrap">
<text class="label">已完成次数:</text>
<text class="value up-line-1">{{ planInfo.i || 0 }} 次</text>
</view>
<!-- 查看记录按钮(限制宽度+紧凑样式) -->
<up-button
v-if="i.planFinishNum>0"
type="primary"
size="mini"
@click="gotoFinishPlanDetail(i)"
:style="{ width: '80px', height: '28px', fontSize: '14px', borderRadius: 4 }"
>
查看记录
</up-button>
</view>
<!-- 计划有效期行 -->
<view class="detail-item">
<text class="label">计划有效期:</text>
<!-- <text class="value up-line-1">{{ planInfo && planInfo.validTime ? planInfo.validTime : '-' }}</text>-->
<text class="value up-line-1">{{ timeFormat(i.beginTime, 'yyyy-mm-dd') }} 至
{{ timeFormat(i.endTime, 'yyyy-mm-dd') }}
</text>
</view>
</view>
<!-- 底部新增记录按钮 status=3-->
<view class="fixed-bottom-btn-wrap" v-if="finishState==1">
<up-button
type="primary"
size="default"
@click="addNewRecord"
:style="{ width: '100%', height: '88rpx', fontSize: '32rpx', borderRadius: 0 }"
>
新增记录
</up-button>
</view>
</view>
</template>
<script setup>
import { timeFormat } from '@/uni_modules/uview-plus';
import { ref } from 'vue';
import { onLoad, onShow } from '@dcloudio/uni-app';
import { inspectionPlanDetail } from "@/api/patrol-manage/patrol-plan";
// 响应式数据定义
const planInfo = ref([]);
const batchNo = ref('')
const planNo = ref('')
const finishState = ref('')
// 页面加载接收参数
onLoad((options) => {
console.log('计划ID:', options.batchNo);
batchNo.value = options.batchNo;
// planNo.value = options.planNo;
finishState.value = options.status
});
// 页面显示时请求数据
onShow(() => {
if (!batchNo.value) {
uni.showToast({
title: '计划ID不存在',
icon: 'none'
});
return;
}
getPlanDetail(batchNo.value);
});
const getPlanDetail = async () => {
const queryData = {
batchNo: batchNo.value,
finishState: finishState.value
}
console.log(queryData)
const planInfoRes = await inspectionPlanDetail(queryData)
planInfo.value = planInfoRes
console.log(planInfoRes)
};
// 跳转到已完成计划明细
const gotoFinishPlanDetail = (i) => {
uni.navigateTo({
url: `/pages-sub/daily/patrol-manage/finish-plan-detail/index?planNo=${i.planNo}`
});
};
// 新增记录
const addNewRecord = () => {
uni.navigateTo({
url: `/pages-sub/daily/patrol-manage/add-patrol-record/index?planNo=${planInfo.value[0].planNo}&batchNo=${batchNo.value}`,
});
};
</script>
<style scoped lang="scss">
.pending-plan-detail {
}
.detail-card {
padding: 20rpx;
background-color: #fff;
margin-bottom: 20px;
}
.detail-item {
display: flex;
align-items: center;
font-size: 28rpx;
line-height: 1.8;
padding: 10rpx 0;
border-bottom: 1px solid #f5f5f5;
&:last-child {
border-bottom: none;
}
}
.flex-between {
display: flex;
justify-content: space-between;
align-items: center;
.left-wrap {
display: flex;
align-items: center;
flex: 1; // 占满剩余空间,按钮靠右
}
}
.label {
color: #999;
width: 200rpx;
flex-shrink: 0;
}
.value {
color: #333;
flex: 1;
word-break: break-all;
}
</style>