吉安感知网项目-前端
chenyao
20 hours ago 4c390d209b45d516fbe2f7552d26048687c83972
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
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
<template>
    <view class="handle-work-page">
        <u-navbar title="处置记录" :is-back="true" back-text="" :back-icon-size="40" @left-click="onBackClick"></u-navbar>
 
        <!-- 把上传处置放在滚动区域外面,固定在头部 -->
        <view v-if="eventStatus != 4" class="upload_handle" @click="uploadHadle">+上传处置</view>
 
        <scroll-view class="record-scroll" scroll-y :lower-threshold="80" @scrolltolower="loadMore">
            <view class="record-list">
                <view class="record-card" v-for="(item, index) in recordList" :key="index">
                    <!-- 第一行:名称 + 状态 -->
                    <view class="card-row-top">
                        <text class="card-name">{{ item.disposeUserName }}</text>
                        <text class="card-status" :class="statusClass(item.disposeStatus)">
                            {{ getStatusLabel(item.disposeStatus) }}
                        </text>
                    </view>
                    <!-- 第二行:标题 -->
                    <view class="card-title">
                        <text>{{ item.disposeContent }}</text>
                    </view>
                    <!-- 第三行:图片列表 -->
                    <view class="card-images" v-if="item.attachUrl && item.attachUrl.length">
                        <image
                            v-for="(img, imgIdx) in item.attachUrl"
                            :key="imgIdx"
                            :src="img"
                            mode="aspectFill"
                            class="card-image"
                            @click="previewImage(item.attachUrl, imgIdx)"
                        />
                    </view>
                    <!-- 第四行:日期 -->
                    <view class="card-row-bottom">
                        <text class="card-date">{{ formatDate(item.operateTime) }}</text>
                    </view>
                </view>
            </view>
 
            <!-- 暂无数据 -->
            <view class="noData" v-if="!loading && recordList.length === 0">
                <text>暂无处置记录</text>
            </view>
            <!-- 加载提示 -->
            <view class="loadingMore">
                <text v-if="loading">加载中...</text>
                <text v-else-if="!hasMore && recordList.length > 0">没有更多了</text>
            </view>
        </scroll-view>
    </view>
</template>
 
<script setup>
import { ref } from 'vue'
import { onLoad } from '@dcloudio/uni-app'
import dayjs from 'dayjs'
import { getDisposeRecords } from '@/api/work/index.js'
 
const eventId = ref('')
const eventStatus = ref('')
const recordList = ref([])
const loading = ref(false)
const hasMore = ref(true)
const listParams = ref({
    current: 1,
    size: 3,
})
 
// 获取状态文本
const getStatusLabel = status => {
    const map = {
        0: '待确认',
        1: '处置中',
        2: '已退回',
        3: '已处置',
        4: '已完成',
    }
    return map[status] || '未知'
}
 
// 状态样式类名
const statusClass = status => {
    if (status === 1) return 'status-processing'
    if (status === 3) return 'status-handled'
    if (status === 4) return 'status-completed'
    return ''
}
 
// 格式化日期
const formatDate = dateString => {
    if (!dateString) return ''
    return dayjs(dateString).format('YYYY-MM-DD HH:mm')
}
 
// 读取工单标识
onLoad(options => {
    eventId.value = options?.id ?? ''
    eventStatus.value = options?.eventStatus ?? ''
    getRecordList()
})
 
onShow(() => {
    getRecordList()
})
 
// 获取处置记录列表
const getRecordList = async () => {
    if (loading.value || !hasMore.value) return
    loading.value = true
    const res = await getDisposeRecords({ eventId: eventId.value })
    recordList.value = res.data.data
    loading.value = false
}
 
function uploadHadle() {
    // 取最后一条记录的状态值,列表为空时取页面进入时的状态
    const status = recordList.value.length
        ? recordList.value[recordList.value.length - 1]?.disposeStatus
        : eventStatus.value
    uni.navigateTo({
        url: `/subPackages/workDetail/HandleWorking/index?id=${eventId.value}&eventStatus=${status}`,
    })
}
 
// 加载更多
const loadMore = () => {
    if (loading.value || !hasMore.value) return
    listParams.value.current++
    getRecordList()
}
 
// 图片预览
const previewImage = (attachments, index) => {
    uni.previewImage({
        urls: attachments,
        current: index,
    })
}
 
// 返回按钮点击事件
const onBackClick = () => {
    uni.navigateBack()
}
</script>
 
<style scoped lang="scss">
.handle-work-page {
    // #ifdef APP-PLUS
  padding-top: 188rpx;
  // #endif
  // #ifdef H5
  padding-top: 88rpx;
  // #endif
    :deep() {
        .u-navbar__content {
            background: url('https://wrj.shuixiongit.com/aiskyminio/cloud-bucket/ztzf_app_assets/images/user/bg.png')
                no-repeat !important;
            background-size: 100% !important;
            height: 88rpx !important;
        }
    }
 
    display: flex;
    flex-direction: column;
    height: 100vh; // 新增:占满全屏
    background: #f6f6f6;
    box-sizing: border-box;
 
    :deep(.u-navbar) {
        position: fixed !important;
        top: 0;
        left: 0;
        right: 0;
        z-index: 100;
    }
 
    :deep(.u-navbar__content) {
        height: 88rpx !important;
    }
}
 
// 上传处置按钮 - 移到滚动区域外面
.upload_handle {
    // #ifdef APP-PLUS
    //padding-top: 70rpx;
    // #endif
    height: 80rpx; // 改大一点,方便点击
    display: flex;
    align-items: center;
    justify-content: flex-end;
    padding-right: 24rpx;
    // margin: 0 0 12rpx 0; // 上下间距
    color: #1d6fe9;
    font-size: 28rpx;
    flex-shrink: 0; // 防止被压缩
    background: #f6f6f6; // 背景色,避免和滚动区域混在一起
}
 
.record-scroll {
    flex: 1; // 占满剩余高度
    // padding-top: 24rpx;
    padding: 10rpx 24rpx 24rpx 24rpx; // 左右下内边距
    box-sizing: border-box;
}
 
.record-list {
    display: flex;
    flex-direction: column;
    gap: 20rpx;
    padding-bottom: 10rpx;
}
 
.record-card {
    background: #ffffff;
    border-radius: 12rpx;
    padding: 24rpx;
    box-shadow: 0 2rpx 8rpx rgba(0, 0, 0, 0.06);
}
 
.card-row-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16rpx;
}
 
.card-name {
    font-family: Source Han Sans CN, Source Han Sans CN;
    font-weight: 500;
    font-size: 28rpx;
    color: #222324;
}
 
.card-status {
    font-family: Source Han Sans CN, Source Han Sans CN;
    font-weight: 400;
    // font-size: 44px;
    padding: 4px 16px;
    border-radius: 6px;
    color: #ffffff;
    background: #999;
 
    &.status-processing {
        background: #1d6fe9;
    }
    &.status-handled {
        background: #e6a23c;
    }
    &.status-completed {
        background: #00b578;
    }
}
 
.card-title {
    font-family: Source Han Sans CN, Source Han Sans CN;
    font-weight: 400;
    font-size: 30rpx;
    color: #222324;
    line-height: 1.6;
    margin-bottom: 16rpx;
    word-break: break-all;
}
 
.card-images {
    display: flex;
    gap: 12rpx;
    margin-bottom: 16rpx;
    overflow: hidden;
}
 
.card-image {
    width: 160rpx;
    height: 160rpx;
    border-radius: 8rpx;
    flex-shrink: 0;
}
 
.card-row-bottom {
    display: flex;
    justify-content: flex-end;
}
 
.card-date {
    font-family: Source Han Sans CN, Source Han Sans CN;
    font-weight: 400;
    font-size: 24rpx;
    color: #999;
}
 
.noData {
    display: flex;
    justify-content: center;
    align-items: center;
    height: 400rpx;
    font-size: 28rpx;
    color: #999;
}
 
.loadingMore {
    display: flex;
    justify-content: center;
    align-items: center;
    height: 80rpx;
    font-size: 28rpx;
    color: #999;
}
</style>