对接在线报修的新增报修和报修详情接口
This commit is contained in:
@@ -11,6 +11,8 @@
|
||||
</view>
|
||||
|
||||
<!-- 报修类型Tab -->
|
||||
<scroll-view class="scroll-container" scroll-y="true"
|
||||
:lower-threshold="100">
|
||||
<view class="repair-type-tabs">
|
||||
<view
|
||||
class="type-tab"
|
||||
@@ -66,22 +68,21 @@
|
||||
<view class="repair-item" v-for="(item, index) in repairList" :key="index">
|
||||
<!-- 标题和状态 -->
|
||||
<view class="item-header">
|
||||
<text class="item-title">{{ item.title || '报修' }}</text>
|
||||
<text class="item-title">{{ item.houseName || '报修' }}</text>
|
||||
<text class="item-status" :class="item.statusClass">{{ item.status }}</text>
|
||||
</view>
|
||||
|
||||
<!-- 标签 -->
|
||||
<view class="item-tags" v-if="item.repairTypeName || item.category">
|
||||
<text class="tag" v-if="item.repairTypeName">{{ item.repairTypeName }}</text>
|
||||
<text class="tag" v-if="item.category">{{ item.category }}</text>
|
||||
<view class="item-tags" v-if="item.maintenanceItemName">
|
||||
<text class="tag" v-if="item.maintenanceItemName">{{ item.maintenanceItemName }}</text>
|
||||
</view>
|
||||
|
||||
<!-- 内容 -->
|
||||
<view class="item-content">
|
||||
{{ item.content || item.description || '' }}
|
||||
{{ item.problem || '' }}
|
||||
</view>
|
||||
|
||||
<!-- 图片占位 -->
|
||||
<!-- 图片 -->
|
||||
<view class="item-imgs" v-if="item.imageList && item.imageList.length">
|
||||
<view class="img-placeholder" v-for="(img, idx) in item.imageList" :key="idx">
|
||||
<image :src="typeof img === 'string' ? img : img.img" style="width: 100%;height: 100%;"></image>
|
||||
@@ -90,7 +91,7 @@
|
||||
|
||||
<!-- 时间和详情 -->
|
||||
<view class="item-footer">
|
||||
<text class="item-time">{{ item.time || item.createTime || '' }}</text>
|
||||
<text class="item-time">{{ item.orderDate || '' }}</text>
|
||||
<text class="detail-btn" @click="goDetail(item)">报修详情</text>
|
||||
</view>
|
||||
</view>
|
||||
@@ -100,12 +101,13 @@
|
||||
<text class="empty-text">暂无数据</text>
|
||||
</view>
|
||||
</view>
|
||||
</scroll-view>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { ref, watch } from 'vue';
|
||||
import { onLoad } from '@dcloudio/uni-app';
|
||||
import { onLoad,onUnload } from '@dcloudio/uni-app';
|
||||
import { getQueryRepair } from '../api/api.js';
|
||||
|
||||
// 报修类型(public:公共报修,personal:个人报修)
|
||||
@@ -115,6 +117,9 @@ const activeStatus = ref('pending');
|
||||
|
||||
const repairList = ref([]);
|
||||
const loading = ref(false);
|
||||
const pageNum = ref(1);
|
||||
const pageSize = ref(10);
|
||||
const maintenanceItemId = ref('');
|
||||
|
||||
// 状态映射
|
||||
const statusMap = {
|
||||
@@ -123,6 +128,13 @@ const statusMap = {
|
||||
completed: { text: '已完成', class: 'completed', value: '2' }
|
||||
};
|
||||
|
||||
const getStatusInfo = (val) => {
|
||||
if (val === '0' || val === 0) return statusMap.pending;
|
||||
if (val === '1' || val === 1) return statusMap.assigned;
|
||||
if (val === '2' || val === 2) return statusMap.completed;
|
||||
return null;
|
||||
};
|
||||
|
||||
// 获取报修列表
|
||||
const fetchRepairList = async () => {
|
||||
const villageId = uni.getStorageSync('currentVillageId');
|
||||
@@ -133,23 +145,26 @@ const fetchRepairList = async () => {
|
||||
|
||||
loading.value = true;
|
||||
try {
|
||||
const statusInfo = statusMap[activeStatus.value];
|
||||
const params = {
|
||||
villageId,
|
||||
// 报修类型:0-公共报修,1-个人报修(按后端实际字段调整)
|
||||
projectType: activeType.value === 'public' ? '0' : '1',
|
||||
// 状态:0-待派单,1-已派单,2-已完成(按后端实际字段调整)
|
||||
problemStatus: statusInfo.value
|
||||
// maintenanceItemId: maintenanceItemId.value,
|
||||
pageSize: pageSize.value,
|
||||
pageNum: pageNum.value,
|
||||
problemStatus: statusMap[activeStatus.value].value
|
||||
};
|
||||
const res = await getQueryRepair(params);
|
||||
console.log('接口返回:', res);
|
||||
if (res.code === 200) {
|
||||
// 按后端实际返回结构调整
|
||||
const list = res.data|| [];
|
||||
repairList.value = list.map(item => ({
|
||||
...item,
|
||||
status: statusInfo.text,
|
||||
statusClass: statusInfo.class
|
||||
}));
|
||||
// 兼容多种分页返回结构
|
||||
const list = res.data?.rows || [];
|
||||
repairList.value = list.map(item => {
|
||||
const statusInfo = getStatusInfo(item.problemStatus);
|
||||
const images = item.problemImageUrl ? item.problemImageUrl.split(',').filter(Boolean) : [];
|
||||
if (statusInfo) {
|
||||
return { ...item, status: statusInfo.text, statusClass: statusInfo.class, imageList: images };
|
||||
}
|
||||
return { ...item, imageList: images };
|
||||
});
|
||||
} else {
|
||||
uni.showToast({ title: res.msg || '获取失败', icon: 'none' });
|
||||
}
|
||||
@@ -193,15 +208,18 @@ const goBack = () => {
|
||||
}
|
||||
// 跳转报修详情
|
||||
const goDetail = (item) => {
|
||||
const itemStr = encodeURIComponent(JSON.stringify(item))
|
||||
uni.navigateTo({
|
||||
url: `/pageSubPack/online-repair/repairDetail?item = ${itemStr}`
|
||||
url: `/pageSubPack/online-repair/repairDetail?id=${item.id}`
|
||||
});
|
||||
};
|
||||
|
||||
onLoad(() => {
|
||||
fetchRepairList();
|
||||
// maintenanceItemId.value = option.maintenanceProjectId || '' // 接收维修项目id
|
||||
fetchRepairList()
|
||||
});
|
||||
onUnload(() =>{
|
||||
|
||||
})
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
@@ -251,6 +269,14 @@ onLoad(() => {
|
||||
.nav-right {
|
||||
width: 60rpx;
|
||||
}
|
||||
/* 滚动区域 */
|
||||
.scroll-container {
|
||||
flex: 1;
|
||||
width: 100%;
|
||||
height: calc(100vh - 100px);
|
||||
overflow-y: auto;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
/* 报修类型Tab */
|
||||
.repair-type-tabs {
|
||||
display: flex;
|
||||
@@ -338,6 +364,7 @@ onLoad(() => {
|
||||
font-weight: bold;
|
||||
color: #333;
|
||||
padding-right: 20rpx;
|
||||
width: 77%;
|
||||
}
|
||||
.item-status {
|
||||
font-size: 14px;
|
||||
|
||||
Reference in New Issue
Block a user