This commit is contained in:
2025-08-21 14:25:49 +08:00
parent 98d98e41f2
commit 2833f7d28b
8 changed files with 1127 additions and 1099 deletions

View File

@@ -1,330 +1,337 @@
<template>
<view class="add-repair-container">
<!-- 可滚动内容区 -->
<view class="add-repair-scroll-content">
<!-- 地址选择 -->
<view class="add-repair-section">
<view class="add-repair-detail">
<view class="add-repair-detail1">详细地址 </view>
<input type="text" v-model="repairInfo.location" placeholder="请输入地址" class="add-repair-detail2" />
</view>
</view>
<!-- 报事报修类型 -->
<view class="add-repair-section">
<view class="add-repair-label">报事报修</view>
<view class="repair-type" @click="chooseType">
<text class="text-type">{{ selectedType }}</text>
<image class="right-arrow" src="/static/ic_right_arrow_g.png" />
</view>
<view class="add-repair-label">问题详情 <text class="add-repair-optional">(非必填)</text></view>
<textarea v-model="repairInfo.remark" class="add-repair-detail-textarea" placeholder="如果以上报事不能解决您的问题,可以在这里填写说明" />
</view>
<!-- 上传照片 -->
<view class="add-repair-section">
<view class="add-repair-label">上传照片 <text class="add-repair-optional">(非必填最多三张)</text></view>
<u-upload
:fileList="selectedImages"
@on-list-change="onListChange"
@delete="deletePic"
name="upload"
multiple
maxCount="3"
width="180"
height="180"
:autoUpload="false"
></u-upload>
</view>
<!-- 提交按钮 -->
<button class="add-repair-submit-btn" @click="submit">提交</button>
</view>
</view>
</template>
<script>
// 导入MediaSelector和MediaType
import MediaSelector, { MediaType } from '@/utils/mediaSelector';
import {
uploadFiles
} from '@/common/upload.js';
import toast from '../../../../uview-ui/libs/function/toast';
export default {
data() {
return {
repairInfo:{
location:'',
type:'1942879389453230082',
orderImgUrl:'',
remark:''
},
repairTypes: [],
selectedType: '',
selectedImages: [] // 存储已选图片
}
},
onLoad() {
this.getOrderType()
},
methods: {
selectType(item) {
this.selectedType = item;
},
async getOrderType() {
let params = {parentId:'1952989217332658178'}
let res = await this.$u.api.getRepairTypes(params);
if (res.code == '200') {
this.repairTypes = res.data
this.repairInfo.type = res.data[0].id;
this.selectType(res.data[0].orderTypeName)
}
},
// 删除图片
deletePic(event) {
this.selectedImages.splice(event.index, 1);
},
// 图片列表变化处理
onListChange(list) {
this.selectedImages = list;
},
async submit() {
if(!this.repairInfo.location) {
toast('请先填写地址')
return
}
if(this.selectedImages.length<=0){
this.realSubmit()
return
<template>
<view class="add-repair-container">
<!-- 可滚动内容区 -->
<view class="add-repair-scroll-content">
<!-- 地址选择 -->
<!-- <view class="add-repair-section">
<view class="add-repair-detail">
<view class="add-repair-detail1">详细地址 </view>
<input type="text" v-model="repairInfo.location" placeholder="请输入地址" class="add-repair-detail2" />
</view>
</view> -->
<!-- 报事报修类型 -->
<view class="add-repair-section">
<view class="add-repair-label">详细地址</view>
<input type="text" v-model="repairInfo.location" placeholder="请输入地址" class="add-repair-detail2" />
<view class="add-repair-label">报事报修</view>
<view class="repair-type" @click="chooseType">
<text class="text-type">{{ selectedType }}</text>
<image class="right-arrow" src="/static/ic_right_arrow_g.png" />
</view>
<view class="add-repair-label">问题详情 <text class="add-repair-optional">(非必填)</text></view>
<textarea v-model="repairInfo.remark" class="add-repair-detail-textarea" placeholder="如果以上报事不能解决您的问题,可以在这里填写说明" />
</view>
<!-- 上传照片 -->
<view class="add-repair-section">
<view class="add-repair-label">上传照片 <text class="add-repair-optional">(非必填最多三张)</text></view>
<u-upload
:fileList="selectedImages"
@on-list-change="onListChange"
@delete="deletePic"
name="upload"
multiple
maxCount="3"
width="180"
height="180"
:autoUpload="false"
></u-upload>
</view>
<!-- 提交按钮 -->
<button class="add-repair-submit-btn" @click="submit">提交</button>
</view>
</view>
</template>
<script>
// 导入MediaSelector和MediaType
import MediaSelector, { MediaType } from '@/utils/mediaSelector';
import {
uploadFiles
} from '@/common/upload.js';
import toast from '../../../../uview-ui/libs/function/toast';
export default {
data() {
return {
repairInfo:{
location:'',
type:'1942879389453230082',
orderImgUrl:'',
remark:''
},
repairTypes: [],
selectedType: '',
selectedImages: [] // 存储已选图片
}
},
onLoad() {
this.getOrderType()
},
methods: {
selectType(item) {
this.selectedType = item;
},
async getOrderType() {
let params = {parentId:'1952989217332658178'}
let res = await this.$u.api.getRepairTypes(params);
if (res.code == '200') {
this.repairTypes = res.data
this.repairInfo.type = res.data[0].id;
this.selectType(res.data[0].orderTypeName)
}
},
// 删除图片
deletePic(event) {
this.selectedImages.splice(event.index, 1);
},
// 图片列表变化处理
onListChange(list) {
this.selectedImages = list;
},
async submit() {
if(!this.repairInfo.location) {
toast('请先填写地址')
return
}
if(this.selectedImages.length<=0){
this.realSubmit()
return
}
console.log("t1",this.selectedImages)
const images = this.selectedImages
.map(item => item?.path?.replace('file://', '') || item?.url || null)
.filter(path => path !== null);
if (images.length === 0) {
this.realSubmit();
return;
}
const result = await uploadFiles({
files: images,
url: this.vuex_config.baseUrl + '/resource/oss/upload',
name: 'file',
vm: this // 关键:用于注入 token 等
});
// 遍历result获取data.url加上,分割
const urls = result.map(item => item.data?.url || '').filter(url => url !== '');
this.repairInfo.orderImgUrl = urls.join(',');
this.realSubmit()
},
async realSubmit(){
let res = await this.$u.api.addOrder2(this.repairInfo);
if (res.code == '200') {
// 关闭页面前发送事件通知前页面刷新
uni.$emit('refreshData', '');
// 返回上一页
uni.navigateBack();
}
},
// 添加chooseType方法实现
chooseType() {
uni.showActionSheet({
itemList: this.repairTypes.map(item => item.orderTypeName),
success: (res) => {
this.selectedType = this.repairTypes[res.tapIndex].orderTypeName;
this.repairInfo.type = this.repairTypes[res.tapIndex].id;
},
fail: (err) => {
console.log('用户取消选择或出错', err);
}
});
},
goRepaired(){
uni.navigateTo({ url: '/pages/sys/user/myRepair/repaired' });
},
goSelectLocation(){
uni.navigateTo({ url: '/pages/sys/user/myRepair/selectLocation' });
}
}
}
</script>
<style scoped>
.add-repair-container {
height: 100vh;
background: #f7f7f7;
display: flex;
flex-direction: column;
}
.add-repair-scroll-content {
flex: 1;
overflow-y: auto;
padding-bottom: 40rpx;
}
.add-repair-section {
background: #fff;
border-radius: 12rpx;
margin: 22rpx 30rpx 0 30rpx;
padding: 24rpx 46rpx 24rpx 44rpx;
}
.repair-type {
width: 363rpx;
height: 73rpx;
background: #F7F7F7;
border-radius: 10rpx;
padding:0rpx 28rpx 0rpx 35rpx;
display: flex;
align-items: center;
justify-content: space-between;
margin-bottom: 40rpx;
}
.text-type{
font-size: 24rpx;
color:#808080;
}
.right-arrow{
width: 11rpx;
height: 21rpx;
}
.add-repair-address-btn {
width: 100%;
height: 48rpx;
background: #fff;
border: 2rpx solid #2186FF;
border-radius: 8rpx;
margin-bottom: 30rpx;
padding-left: 18rpx;
display: flex;
align-items: center;
justify-content: center;
}
.add-repair-address-text {
font-size: 24rpx;
color: #007CFF;
margin-right: 15rpx;
}
.add-repair-address-img {
width: 11rpx;
height: 21rpx;
}
.add-repair-detail {
display: flex;
flex-direction: row;
align-items: center;
}
.add-repair-detail1 {
font-size: 26rpx;
font-weight: bold;
color: #000;
}
.add-repair-detail2 {
width: 460rpx;
height: 98rpx;
background-color: #F7F8FA;
border-radius: 10rpx;
font-size: 24rpx;
color: #676767;
margin-left: 25rpx;
padding-left: 15rpx;
}
.add-repair-label {
font-size: 32rpx;
color: #000000;
font-weight: 500;
margin-bottom: 41rpx;
}
.add-repair-label2 {
font-size: 32rpx;
color: #000000;
font-weight: 500;
margin-bottom: 25rpx;
margin-top: 25rpx;
}
.add-repair-type-list {
display: flex;
flex-wrap: wrap;
gap: 28rpx 21rpx;
}
.add-repair-type-btn {
flex: 0 0 calc((100% - 42rpx) / 3);
box-sizing: border-box;
height: 73rpx;
background: #F2F7FF;
color: #2186FF;
font-size: 26rpx;
border-radius: 8rpx;
display: flex;
align-items: center;
justify-content: center;
border: none;
}
.add-repair-type-btn.selected {
background: #2186FF;
color: #fff;
border: 2rpx solid #2186FF;
}
.add-repair-type-btn.dashed {
border: 2rpx dashed #BDBDBD;
background: #fff;
color: #2186FF;
}
.add-repair-optional {
color: #888;
font-size: 24rpx;
font-weight: 400;
}
.add-repair-detail-textarea {
width: 75vw;
min-height: 120rpx;
background: #F7F8FA;
border-radius: 10rpx;
font-size: 28rpx;
color: #888;
padding: 18rpx;
margin-top: 18rpx;
}
.add-repair-submit-btn {
width: 60vw;
height: 73rpx;
background: linear-gradient(90deg, #005DE9 0%, #4B9BFF 100%);
color: #fff;
font-size: 32rpx;
border: none;
border-radius: 40rpx;
margin: 100rpx auto 0 auto;
display: block;
font-weight: bold;
box-shadow: 0 8rpx 24rpx rgba(0, 0, 0, 0.18);
}
.filter(path => path !== null);
if (images.length === 0) {
this.realSubmit();
return;
}
const result = await uploadFiles({
files: images,
url: this.vuex_config.baseUrl + '/resource/oss/upload',
name: 'file',
vm: this // 关键:用于注入 token 等
});
// 遍历result获取data.url加上,分割
const urls = result.map(item => item.data?.url || '').filter(url => url !== '');
this.repairInfo.orderImgUrl = urls.join(',');
this.realSubmit()
},
async realSubmit(){
let res = await this.$u.api.addOrder2(this.repairInfo);
if (res.code == '200') {
// 关闭页面前发送事件通知前页面刷新
uni.$emit('refreshData', '');
// 返回上一页
uni.navigateBack();
}
},
// 添加chooseType方法实现
chooseType() {
uni.showActionSheet({
itemList: this.repairTypes.map(item => item.orderTypeName),
success: (res) => {
this.selectedType = this.repairTypes[res.tapIndex].orderTypeName;
this.repairInfo.type = this.repairTypes[res.tapIndex].id;
},
fail: (err) => {
console.log('用户取消选择或出错', err);
}
});
},
goRepaired(){
uni.navigateTo({ url: '/pages/sys/user/myRepair/repaired' });
},
goSelectLocation(){
uni.navigateTo({ url: '/pages/sys/user/myRepair/selectLocation' });
}
}
}
</script>
<style scoped>
.add-repair-container {
height: 100vh;
background: #f7f7f7;
display: flex;
flex-direction: column;
}
.add-repair-scroll-content {
flex: 1;
overflow-y: auto;
padding-bottom: 40rpx;
}
.add-repair-section {
background: #fff;
border-radius: 12rpx;
margin: 22rpx 30rpx 0 30rpx;
padding: 24rpx 46rpx 24rpx 44rpx;
}
.repair-type {
width: 100%;
height: 98rpx;
background: #F7F8FA;
border-radius: 10rpx;
padding: 0 20rpx;
display: flex;
align-items: center;
justify-content: space-between;
margin-bottom: 40rpx;
box-sizing: border-box;
}
.text-type{
font-size: 24rpx;
color:#808080;
}
.right-arrow{
width: 11rpx;
height: 21rpx;
}
.add-repair-address-btn {
width: 100%;
height: 48rpx;
background: #fff;
border: 2rpx solid #2186FF;
border-radius: 8rpx;
margin-bottom: 30rpx;
padding-left: 18rpx;
display: flex;
align-items: center;
justify-content: center;
}
.add-repair-address-text {
font-size: 24rpx;
color: #007CFF;
margin-right: 15rpx;
}
.add-repair-address-img {
width: 11rpx;
height: 21rpx;
}
.add-repair-detail {
display: flex;
flex-direction: row;
align-items: center;
}
.add-repair-detail1 {
font-size: 26rpx;
font-weight: bold;
color: #000;
}
.add-repair-detail2 {
width: 100%;
height: 98rpx;
background-color: #F7F8FA;
border-radius: 10rpx;
font-size: 24rpx;
color: #676767;
padding: 0 20rpx;
margin-bottom: 40rpx;
box-sizing: border-box;
}
.add-repair-label {
font-size: 32rpx;
color: #000000;
font-weight: 500;
margin-bottom: 41rpx;
}
.add-repair-label2 {
font-size: 32rpx;
color: #000000;
font-weight: 500;
margin-bottom: 25rpx;
margin-top: 25rpx;
}
.add-repair-type-list {
display: flex;
flex-wrap: wrap;
gap: 28rpx 21rpx;
}
.add-repair-type-btn {
flex: 0 0 calc((100% - 42rpx) / 3);
box-sizing: border-box;
height: 73rpx;
background: #F2F7FF;
color: #2186FF;
font-size: 26rpx;
border-radius: 8rpx;
display: flex;
align-items: center;
justify-content: center;
border: none;
}
.add-repair-type-btn.selected {
background: #2186FF;
color: #fff;
border: 2rpx solid #2186FF;
}
.add-repair-type-btn.dashed {
border: 2rpx dashed #BDBDBD;
background: #fff;
color: #2186FF;
}
.add-repair-optional {
color: #888;
font-size: 24rpx;
font-weight: 400;
}
.add-repair-detail-textarea {
width: 100%;
min-height: 120rpx;
background: #F7F8FA;
border-radius: 10rpx;
font-size: 28rpx;
color: #888;
padding: 18rpx;
margin-top: 18rpx;
box-sizing: border-box;
}
.add-repair-submit-btn {
width: 60vw;
height: 73rpx;
background: linear-gradient(90deg, #005DE9 0%, #4B9BFF 100%);
color: #fff;
font-size: 32rpx;
border: none;
border-radius: 40rpx;
margin: 100rpx auto 0 auto;
display: block;
font-weight: bold;
box-shadow: 0 8rpx 24rpx rgba(0, 0, 0, 0.18);
}
</style>

View File

@@ -1,489 +1,466 @@
<template>
<view class="repair-container">
<!-- 可滚动内容区 -->
<scroll-view scroll-y class="repair-scroll-content" @scroll="handleScroll">
<!-- 空状态 -->
<view v-if="records.length === 0" class="repair-empty-box">
<view class="repair-empty-img-box">
<image src="/static/ic_my_repair_01.png" class="repair-empty-img" />
</view>
<view class="repair-add-btn-box">
<image src="/static/ic_my_repair_02.png" class="repair-add-btn" @click="addRepair" />
</view>
</view>
<!-- 有数据时 -->
<view v-else class="repair-list-box">
<view v-for="(item, idx) in records" :key="idx" class="repair-card" @click="showDetail(item)">
<view class="repair-row">
<view class="repair-no">工单号{{ item.orderNo }}</view>
<view class="repair-status" :class="getStatusColor(item.status)">
{{ getStatusLabel(item.status) }}
</view>
</view>
<image class="repair-line-image" src="/static/ic_my_repair_03.png" />
<view class="repair-info">建立时间{{ item.createTime }}</view>
<view class="repair-info">报事内容{{ item.typeName }}</view>
<view class="repair-info">报事位置{{ item.location }}</view>
<view v-if="getStatusLabel(item.status) === '已结束'" class="repair-eval-btn eval-btn-right">服务评价
</view>
</view>
<!-- 悬浮新增按钮 -->
<image src="/static/ic_my_repair_02.png" :class="['repair-add-btn-fixed', { 'hide': isAddBtnHidden }]"
@click="addRepair" />
</view>
</scroll-view>
<!-- 详情弹窗 -->
<view v-if="showDetailDialog" class="repair-detail-mask" @click.self="closeDetail">
<view class="repair-detail-dialog">
<view class="repair-detail-title">报事详情
<image src="/static/ic_close_01.png" class="repair-detail-close" @click.stop="closeDetail" />
</view>
<view class="repair-detail-progress-box">
<view class="repair-detail-progress">
<view v-for="(step, idx) in progressSteps" :key="idx" class="repair-detail-step">
<view
:class="['repair-detail-dot', detailStep >= idx ? 'active' : '', (detailStep === idx && detailStatus !== '已结束') ? 'current' : '']">
</view>
<view v-if="idx < progressSteps.length - 1"
:class="['repair-detail-line', detailStep > idx ? 'active' : '']"></view>
</view>
</view>
<view class="repair-detail-progress-labels">
<view v-for="(step, idx) in progressSteps" :key="idx" class="repair-detail-label">{{ step }}
</view>
</view>
</view>
<view class="repair-detail-info">建立时间{{ detailItem.createTime }}</view>
<view class="repair-detail-info">报事内容{{ detailItem.typeName }}</view>
<view class="repair-detail-info">报事位置{{ detailItem.location }}</view>
<button v-if="getStatusLabel(detailItem.status) === '已结束'" class="repair-detail-btn"
@click="goTEvaluate">评价服务</button>
</view>
</view>
</view>
</template>
<script>
export default {
data() {
return {
// 空数组可切换空状态
records: [],
showDetailDialog: false,
detailItem: {},
detailStep: 0,
detailStatus: '',
progressSteps: ['创建工单', '已接单', '处理中', '已结束'],
lastScrollTop: 0,
isAddBtnHidden: false
}
},
onLoad() {
this.getOrders()
},
onShow() {
uni.$once('refreshData',s=> {
this.getOrders()
});
},
methods: {
goBack() {
uni.navigateBack();
},
addRepair() {
uni.navigateTo({
url: '/pages/sys/user/myRepair/addRepair'
});
},
async getOrders() {
let params = {
"type": "1952989217332658178"
}
let res = await this.$u.api.getOrderList(params);
if (res.code == '200') {
this.records = res.rows
}
},
getStatusColor(status) {
const statusMap = {
0: 'orange',
1: 'doing',
2: 'doing',
3: 'doing',
4: 'done'
};
return statusMap[status] || '';
},
showDetail(item) {
this.detailItem = item;
// 进度映射
if (item.status == 0) {
this.detailStep = 0;
this.detailStatus = '创建工单';
} else if (item.status == 4) {
this.detailStep = 3;
this.detailStatus = '已结束';
} else if (item.status == 3) {
this.detailStep = 2;
this.detailStatus = '处理中';
} else {
this.detailStep = 1;
this.detailStatus = '已接单';
}
this.showDetailDialog = true;
},
closeDetail() {
this.showDetailDialog = false;
},
getStatusLabel(status) {
const statusMap = {
0: '创建工单',
1: '已接单',
2: '已接单',
3: '处理中',
4: '已结束'
};
return statusMap[status] || '';
},
goTEvaluate() {
// 将detailItem转换为JSON字符串并进行编码以确保安全传输
const detailItemStr = encodeURIComponent(JSON.stringify(this.detailItem));
uni.navigateTo({
url: `/pages/sys/user/myRepair/repairEvaluate?detailItem=${detailItemStr}`
});
},
handleScroll(e) {
const scrollTop = e.detail.scrollTop;
// 为了避免过于频繁的触发,可以设置一个阈值
if (Math.abs(scrollTop - this.lastScrollTop) < 20) {
return;
}
if (scrollTop > this.lastScrollTop && scrollTop > 50) {
// 向下滚动,隐藏按钮
this.isAddBtnHidden = true;
} else {
// 向上滚动,显示按钮
this.isAddBtnHidden = false;
}
this.lastScrollTop = scrollTop;
}
}
}
</script>
<style scoped>
.repair-container {
height: 100vh;
background: #f7f7f7;
display: flex;
flex-direction: column;
}
.repair-navbar {
width: 100%;
height: 120rpx;
padding-top: 40rpx;
display: flex;
align-items: center;
justify-content: center;
position: relative;
background: #fff;
flex-shrink: 0;
/* 防止被压缩 */
}
.repair-back {
position: absolute;
left: 37rpx;
width: 15rpx;
height: 33rpx;
}
.repair-title {
font-size: 36rpx;
color: #000;
font-weight: 500;
}
.repair-scroll-content {
flex: 1;
overflow-y: auto;
padding-bottom: 40rpx;
}
.repair-empty-box {
margin: 48rpx 24rpx 0 24rpx;
position: relative;
}
.repair-empty-img-box {
border: 2rpx dashed #BDBDBD;
border-radius: 8rpx;
background: #fafbfc;
width: 100%;
min-height: 220rpx;
display: flex;
align-items: center;
justify-content: center;
}
.repair-empty-img {
width: 90%;
max-width: 400rpx;
height: 180rpx;
object-fit: contain;
margin: 24rpx auto;
}
.repair-add-btn-box {
position: absolute;
right: 24rpx;
bottom: -40rpx;
}
.repair-add-btn {
width: 80rpx;
height: 80rpx;
border: 2rpx dashed #BDBDBD;
border-radius: 50%;
background: #fff;
box-shadow: 0 2rpx 8rpx rgba(0, 0, 0, 0.08);
}
.repair-list-box {
margin: 32rpx 0 0 0;
padding: 0 24rpx;
position: relative;
}
.repair-card {
background: #fff;
border-radius: 12rpx;
margin-bottom: 24rpx;
box-shadow: 0 2rpx 8rpx rgba(0, 0, 0, 0.03);
padding-top: 25rpx;
padding-bottom: 32rpx;
}
.repair-row {
display: flex;
align-items: center;
justify-content: space-between;
margin-bottom: 12rpx;
margin-top: 25rpx;
margin-left: 19rpx;
margin-right: 50rpx;
}
.repair-no {
font-size: 24rpx;
color: #0B0B0B;
font-weight: 500;
}
.repair-status {
font-size: 24rpx;
font-weight: 500;
}
.repair-line-image {
margin: left 29rpx;
margin-right: 39rpx;
height: 2rpx;
margin-bottom: 29rpx;
}
.repair-status.orange {
color: #F3AB44;
}
.repair-status.doing {
color: #00C9AA;
}
.repair-status.done {
color: #8A8A8A;
}
.repair-info {
font-size: 24rpx;
color: #888;
margin-bottom: 30rpx;
margin-left: 47rpx;
}
.repair-eval-btn {
margin-top: -20rpx;
margin-bottom: 0;
margin-left: auto;
margin-right: 44rpx;
display: flex;
justify-content: flex-end;
align-items: center;
padding: 0 18rpx;
height: 44rpx;
line-height: 44rpx;
border-radius: 8rpx;
border: 2rpx solid #2186FF;
color: #2186FF;
font-size: 24rpx;
background: #fff;
font-weight: 500;
width: fit-content;
}
.repair-add-btn-fixed {
position: fixed;
right: 40rpx;
bottom: 80rpx;
width: 100rpx;
height: 100rpx;
z-index: 100;
transition: transform 0.3s ease;
transform: translateX(0);
}
.repair-add-btn-fixed.hide {
transform: translateX(200%);
}
.repair-detail-mask {
position: fixed;
left: 0;
top: 0;
right: 0;
bottom: 0;
background: rgba(0, 0, 0, 0.45);
z-index: 999;
display: flex;
align-items: flex-end;
justify-content: center;
}
.repair-detail-dialog {
width: 100vw;
background: #fff;
border-radius: 18rpx 18rpx 0 0;
box-shadow: 0 -2rpx 24rpx rgba(0, 0, 0, 0.10);
padding: 52rpx 56rpx 69rpx 56rpx;
margin-bottom: 0;
}
.repair-detail-title {
font-size: 36rpx;
color: #000;
text-align: center;
position: relative;
margin-bottom: 48rpx;
}
.repair-detail-close {
width: 32rpx;
height: 32rpx;
position: absolute;
right: 0;
top: 0;
}
.repair-detail-progress-box {
height: 107rpx;
margin-bottom: 41rpx;
background: #F7F7F7;
border-radius: 10rpx;
display: flex;
flex-direction: column;
justify-content: center;
align-items: stretch;
}
.repair-detail-progress {
display: flex;
align-items: center;
justify-content: space-between;
margin-bottom: 5rpx;
margin-left: 75rpx;
width: 100%;
}
.repair-detail-step {
display: flex;
align-items: center;
flex: 1;
position: relative;
}
.repair-detail-dot {
width: 22rpx;
height: 22rpx;
border-radius: 50%;
background: #BDBDBD;
border: 2rpx solid #BDBDBD;
position: relative;
z-index: 2;
}
.repair-detail-dot.active {
background: #2186FF;
border-color: #2186FF;
}
.repair-detail-dot.current {
background: #EF8D00;
border-color: #EF8D00;
}
.repair-detail-line {
flex: 1;
height: 4rpx;
background: #BDBDBD;
margin: 0 2rpx;
z-index: 1;
}
.repair-detail-line.active {
background: #2186FF;
}
.repair-detail-progress-labels {
display: flex;
justify-content: space-between;
margin-left: 0;
width: 100%;
}
.repair-detail-label {
font-size: 22rpx;
color: #888;
text-align: center;
flex: 1;
position: relative;
top: 8rpx;
}
.repair-detail-info {
font-size: 26rpx;
color: #222;
margin-bottom: 30rpx;
}
.repair-detail-btn {
width: 445rpx;
height: 73rpx;
background: linear-gradient(90deg, #005DE9 0%, #4B9BFF 100%);
color: #fff;
font-size: 32rpx;
border: none;
border-radius: 30rpx;
margin-top: 32rpx;
font-weight: 600;
margin-top: 100rpx;
}
</style>
/* 让服务评价按钮靠右 */
.eval-btn-right {
margin-left: auto;
display: block;
width: fit-content;
}
<template>
<view class="repair-container">
<!-- 可滚动内容区 -->
<scroll-view
scroll-y
class="repair-scroll-content"
refresher-background="#f7f7f7"
@scroll="handleScroll"
@scrolltolower="loadMore"
refresher-enabled
:refresher-triggered="refreshing"
@refresherrefresh="onRefresh">
<!-- 空状态 -->
<view v-if="records.length === 0 && !loading" class="repair-empty-box">
<view class="repair-empty-img-box">
<image src="/static/ic_my_repair_01.png" class="repair-empty-img" />
</view>
<view class="repair-add-btn-box">
<image src="/static/ic_my_repair_02.png" class="repair-add-btn" @click="addRepair" />
</view>
</view>
<!-- 有数据时 -->
<view v-else class="repair-list-box">
<view v-for="(item, idx) in records" :key="idx" class="repair-card" @click="showDetail(item)">
<view class="repair-row">
<view class="repair-no">工单号{{ item.orderNo }}</view>
<view class="repair-status" :class="getStatusColor(item.status)">
{{ getStatusLabel(item.status) }}
</view>
</view>
<image class="repair-line-image" src="/static/ic_my_repair_03.png" />
<view class="repair-info">建立时间{{ item.createTime }}</view>
<view class="repair-info">报事内容{{ item.typeName }}</view>
<view class="repair-info">报事位置{{ item.location }}</view>
<view v-if="getStatusLabel(item.status) === '已结束'" class="repair-eval-btn eval-btn-right">服务评价</view>
</view>
<!-- 加载提示 -->
<view v-if="loading" style="text-align:center;color:#999;font-size:26rpx;padding:20rpx;">
加载中...
</view>
<view v-if="finished && records.length > 0" style="text-align:center;color:#999;font-size:26rpx;padding:20rpx;">
没有更多数据了
</view>
<!-- 悬浮新增按钮 -->
<image src="/static/ic_my_repair_02.png" :class="['repair-add-btn-fixed', { 'hide': isAddBtnHidden }]"
@click="addRepair" />
</view>
</scroll-view>
<!-- 详情弹窗 -->
<view v-if="showDetailDialog" class="repair-detail-mask" @click.self="closeDetail">
<view class="repair-detail-dialog">
<view class="repair-detail-title">报事详情
<image src="/static/ic_close_01.png" class="repair-detail-close" @click.stop="closeDetail" />
</view>
<view class="repair-detail-progress-box">
<view class="repair-detail-progress">
<view v-for="(step, idx) in progressSteps" :key="idx" class="repair-detail-step">
<view
:class="['repair-detail-dot', detailStep >= idx ? 'active' : '', (detailStep === idx && detailStatus !== '已结束') ? 'current' : '']">
</view>
<view v-if="idx < progressSteps.length - 1"
:class="['repair-detail-line', detailStep > idx ? 'active' : '']"></view>
</view>
</view>
<view class="repair-detail-progress-labels">
<view v-for="(step, idx) in progressSteps" :key="idx" class="repair-detail-label">{{ step }}</view>
</view>
</view>
<view class="repair-detail-info">建立时间{{ detailItem.createTime }}</view>
<view class="repair-detail-info">报事内容{{ detailItem.typeName }}</view>
<view class="repair-detail-info">报事位置{{ detailItem.location }}</view>
<button v-if="getStatusLabel(detailItem.status) === '已结束'" class="repair-detail-btn"
@click="goTEvaluate">评价服务</button>
</view>
</view>
</view>
</template>
<script>
export default {
data() {
return {
records: [],
showDetailDialog: false,
detailItem: {},
detailStep: 0,
detailStatus: '',
progressSteps: ['创建工单', '已接单', '处理中', '已结束'],
lastScrollTop: 0,
isAddBtnHidden: false,
// 分页相关
pageNum: 1,
pageSize: 10,
finished: false,
loading: false,
refreshing: false
}
},
onLoad() {
this.onRefresh()
},
onShow() {
uni.$once('refreshData', () => {
this.onRefresh()
});
},
methods: {
goBack() {
uni.navigateBack();
},
addRepair() {
uni.navigateTo({
url: '/pages/sys/user/myRepair/addRepair'
});
},
// 获取工单列表
async getOrders(reset = false) {
if (this.loading) return;
if (reset) {
this.pageNum = 1;
this.finished = false;
this.records = [];
}
this.loading = true;
let params = {
type: "1952989217332658178",
pageNum: this.pageNum,
pageSize: this.pageSize
};
let res = await this.$u.api.getOrderList(params);
if (res.code == '200') {
const rows = res.rows || [];
if (reset) {
this.records = rows;
} else {
this.records = this.records.concat(rows);
}
if (rows.length < this.pageSize) {
this.finished = true;
} else {
this.pageNum++;
}
}
this.loading = false;
this.refreshing = false;
},
// 下拉刷新
onRefresh() {
this.refreshing = true;
this.getOrders(true);
},
// 滚动加载更多
loadMore() {
if (!this.finished) {
this.getOrders(false);
}
},
getStatusColor(status) {
const statusMap = {
0: 'orange',
1: 'doing',
2: 'doing',
3: 'doing',
4: 'done'
};
return statusMap[status] || '';
},
showDetail(item) {
this.detailItem = item;
if (item.status == 0) {
this.detailStep = 0;
this.detailStatus = '创建工单';
} else if (item.status == 4) {
this.detailStep = 3;
this.detailStatus = '已结束';
} else if (item.status == 3) {
this.detailStep = 2;
this.detailStatus = '处理中';
} else {
this.detailStep = 1;
this.detailStatus = '已接单';
}
this.showDetailDialog = true;
},
closeDetail() {
this.showDetailDialog = false;
},
getStatusLabel(status) {
const statusMap = {
0: '创建工单',
1: '已接单',
2: '已接单',
3: '处理中',
4: '已结束'
};
return statusMap[status] || '';
},
goTEvaluate() {
const detailItemStr = encodeURIComponent(JSON.stringify(this.detailItem));
uni.navigateTo({
url: `/pages/sys/user/myRepair/repairEvaluate?detailItem=${detailItemStr}`
});
},
handleScroll(e) {
const scrollTop = e.detail.scrollTop;
if (Math.abs(scrollTop - this.lastScrollTop) < 20) return;
if (scrollTop > this.lastScrollTop && scrollTop > 50) {
this.isAddBtnHidden = true;
} else {
this.isAddBtnHidden = false;
}
this.lastScrollTop = scrollTop;
}
}
}
</script>
<style scoped>
.repair-container {
height: 100vh;
background: #f7f7f7;
display: flex;
flex-direction: column;
}
.repair-scroll-content {
flex: 1;
overflow-y: auto;
padding-bottom: 40rpx;
}
.repair-empty-box {
margin: 48rpx 24rpx 0 24rpx;
position: relative;
}
.repair-empty-img-box {
border: 2rpx dashed #BDBDBD;
border-radius: 8rpx;
background: #fafbfc;
width: 100%;
min-height: 220rpx;
display: flex;
align-items: center;
justify-content: center;
}
.repair-empty-img {
width: 90%;
max-width: 400rpx;
height: 180rpx;
object-fit: contain;
margin: 24rpx auto;
}
.repair-add-btn-box {
position: absolute;
right: 24rpx;
bottom: -40rpx;
}
.repair-add-btn {
width: 80rpx;
height: 80rpx;
border: 2rpx dashed #BDBDBD;
border-radius: 50%;
background: #fff;
box-shadow: 0 2rpx 8rpx rgba(0, 0, 0, 0.08);
}
.repair-list-box {
margin: 32rpx 0 0 0;
padding: 0 24rpx;
position: relative;
}
.repair-card {
background: #fff;
border-radius: 12rpx;
margin-bottom: 24rpx;
box-shadow: 0 2rpx 8rpx rgba(0, 0, 0, 0.03);
padding-top: 25rpx;
padding-bottom: 32rpx;
}
.repair-row {
display: flex;
align-items: center;
justify-content: space-between;
margin-bottom: 12rpx;
margin-top: 25rpx;
margin-left: 19rpx;
margin-right: 50rpx;
}
.repair-no {
font-size: 24rpx;
color: #0B0B0B;
font-weight: 500;
}
.repair-status {
font-size: 24rpx;
font-weight: 500;
}
.repair-status.orange { color: #F3AB44; }
.repair-status.doing { color: #00C9AA; }
.repair-status.done { color: #8A8A8A; }
.repair-line-image {
margin-left: 29rpx;
margin-right: 39rpx;
height: 2rpx;
margin-bottom: 29rpx;
}
.repair-info {
font-size: 24rpx;
color: #888;
margin-bottom: 30rpx;
margin-left: 47rpx;
}
.repair-eval-btn {
margin-top: -20rpx;
margin-bottom: 0;
margin-left: auto;
margin-right: 44rpx;
display: flex;
justify-content: flex-end;
align-items: center;
padding: 0 18rpx;
height: 44rpx;
line-height: 44rpx;
border-radius: 8rpx;
border: 2rpx solid #2186FF;
color: #2186FF;
font-size: 24rpx;
background: #fff;
font-weight: 500;
width: fit-content;
}
.repair-add-btn-fixed {
position: fixed;
right: 40rpx;
bottom: 80rpx;
width: 100rpx;
height: 100rpx;
z-index: 100;
transition: transform 0.3s ease;
transform: translateX(0);
}
.repair-add-btn-fixed.hide { transform: translateX(200%); }
.repair-detail-mask {
position: fixed;
left: 0;
top: 0;
right: 0;
bottom: 0;
background: rgba(0, 0, 0, 0.45);
z-index: 999;
display: flex;
align-items: flex-end;
justify-content: center;
}
.repair-detail-dialog {
width: 100vw;
background: #fff;
border-radius: 18rpx 18rpx 0 0;
box-shadow: 0 -2rpx 24rpx rgba(0, 0, 0, 0.10);
padding: 52rpx 56rpx 69rpx 56rpx;
margin-bottom: 0;
}
.repair-detail-title {
font-size: 36rpx;
color: #000;
text-align: center;
position: relative;
margin-bottom: 48rpx;
}
.repair-detail-close {
width: 32rpx;
height: 32rpx;
position: absolute;
right: 0;
top: 0;
}
.repair-detail-progress-box {
height: 107rpx;
margin-bottom: 41rpx;
background: #F7F7F7;
border-radius: 10rpx;
display: flex;
flex-direction: column;
justify-content: center;
align-items: stretch;
}
.repair-detail-progress {
display: flex;
align-items: center;
justify-content: space-between;
margin-bottom: 5rpx;
margin-left: 75rpx;
width: 100%;
}
.repair-detail-step {
display: flex;
align-items: center;
flex: 1;
position: relative;
}
.repair-detail-dot {
width: 22rpx;
height: 22rpx;
border-radius: 50%;
background: #BDBDBD;
border: 2rpx solid #BDBDBD;
position: relative;
z-index: 2;
}
.repair-detail-dot.active {
background: #2186FF;
border-color: #2186FF;
}
.repair-detail-dot.current {
background: #EF8D00;
border-color: #EF8D00;
}
.repair-detail-line {
flex: 1;
height: 4rpx;
background: #BDBDBD;
margin: 0 2rpx;
z-index: 1;
}
.repair-detail-line.active { background: #2186FF; }
.repair-detail-progress-labels {
display: flex;
justify-content: space-between;
margin-left: 0;
width: 100%;
}
.repair-detail-label {
font-size: 22rpx;
color: #888;
text-align: center;
flex: 1;
position: relative;
top: 8rpx;
}
.repair-detail-info {
font-size: 26rpx;
color: #222;
margin-bottom: 30rpx;
}
.repair-detail-btn {
width: 445rpx;
height: 73rpx;
background: linear-gradient(90deg, #005DE9 0%, #4B9BFF 100%);
color: #fff;
font-size: 32rpx;
border: none;
border-radius: 30rpx;
margin-top: 100rpx;
font-weight: 600;
}
/* 让服务评价按钮靠右 */
.eval-btn-right {
margin-left: auto;
display: block;
width: fit-content;
}
</style>

View File

@@ -1,10 +1,12 @@
<template>
<view class="warn-container">
<!-- 顶部导航 -->
<view class="warn-navbar">
<image src="/static/ic_back.png" class="warn-back" @click="goBack" />
<text class="warn-title">预警处理</text>
<text class="warn-right-txt" @click="goStatistics">预警统计</text>
</view>
<!-- tab栏 -->
<view class="warn-tabs">
<view v-for="(tab, idx) in tabs" :key="idx" :class="['warn-tab', { active: idx === activeTab }]"
@@ -15,13 +17,13 @@
</view>
<!-- 列表区 -->
<scroll-view scroll-y class="warn-list">
<scroll-view class="warn-list" scroll-y refresher-enabled refresher-background="#f7f7f7"
:refresher-triggered="refresherTriggered" @refresherrefresh="onRefresh" @scrolltolower="loadMore"
:lower-threshold="50">
<view v-for="(item, idx) in list" :key="idx" class="warn-card" @click="goDetail2(item)">
<view class="warn-row">
<view class="warn-no">{{item.smallTypeName}}</view>
<view class="warn-status">
{{item.levelName}}
</view>
<view class="warn-status">{{item.levelName}}</view>
</view>
<image class="warn-line-image" src="/static/ic_my_repair_03.png" />
<view class="warn-info">预警内容{{ item.description }}</view>
@@ -32,6 +34,15 @@
<view class="warn-eval-btn">去处理</view>
</view>
</view>
<!-- 底部加载提示 -->
<view v-if="loading" style="text-align:center;color:#999;font-size:26rpx;padding:20rpx;">
加载中...
</view>
<view v-if="noMore[activeTab]" style="text-align:center;color:#999;font-size:26rpx;padding:20rpx;">
没有更多数据了
</view>
</scroll-view>
</view>
</template>
@@ -42,56 +53,75 @@
return {
tabs: ["待处理", "全部"],
activeTab: 0,
tabData: [
[],
[]
],
tabLoaded: [false, false],
], // 每个 tab 的数据
pageNum: [1, 1], // 每个 tab 当前页码
pageSize: 10,
noMore: [false, false], // 每个 tab 是否没有更多数据
tabLoaded: [false, false], // tab 是否加载过
loading: false,
lastScrollTop: 0,
refresherTriggered: false
};
},
computed: {
list() {
return this.tabData[this.activeTab];
},
},
onShow() {
uni.$once('refreshData',s=> {
this.loadTabData(this.activeTab);
});
}
},
created() {
this.loadTabData(this.activeTab);
this.onRefresh()
},
methods: {
goBack() {
uni.navigateBack();
},
// 切换 tab
async changeTab(idx) {
this.activeTab = idx;
if (!this.tabLoaded[idx]) {
await this.loadTabData(idx);
this.onRefresh()
}
},
// 下拉刷新
async onRefresh() {
this.refresherTriggered = true;
this.pageNum[this.activeTab] = 1;
this.noMore[this.activeTab] = false;
this.tabData[this.activeTab] = [];
await this.loadTabData(this.activeTab);
this.refresherTriggered = false;
},
// 滚动加载更多
async loadMore() {
if (this.loading || this.noMore[this.activeTab]) return;
this.pageNum[this.activeTab]++;
await this.loadTabData(this.activeTab);
},
// 请求数据
async loadTabData(idx) {
this.loading = true;
let params = {};
if (idx == 0) {
params = {
'states': [20, 30, 31, 32]
}
let params = {
pageNum: this.pageNum[idx],
pageSize: this.pageSize
};
// 待处理
if (idx === 0) {
params.states = [20, 30, 31, 32];
}
let res = await this.$u.api.getWarns(params);
if (res.code == "200") {
this.$set(this.tabData, idx, res.rows);
let rows = res.rows || [];
if (rows.length < this.pageSize) {
this.noMore[idx] = true;
}
this.$set(this.tabData, idx, [...this.tabData[idx], ...rows]);
}
this.$set(this.tabLoaded, idx, true);
this.tabLoaded[idx] = true;
this.loading = false;
},
goDetail(item) {
const itemStr = encodeURIComponent(JSON.stringify(item));
uni.navigateTo({
@@ -101,7 +131,7 @@
goDetail2(item) {
const itemStr = encodeURIComponent(JSON.stringify(item));
uni.navigateTo({
url: "/pages/sys/workbench/earlyWarning/warnDetail?item=" + itemStr+"&pageType=detail",
url: "/pages/sys/workbench/earlyWarning/warnDetail?item=" + itemStr + "&pageType=detail",
});
},
goStatistics() {
@@ -109,7 +139,7 @@
url: "/pages/sys/workbench/earlyWarning/warnStatistics"
});
}
},
}
};
</script>

View File

@@ -1,253 +1,261 @@
<template>
<view class="order-container" @click="handleOutsideClick">
<view class="filter">
<!-- 工单类型按钮 -->
<view class="filter-btn" @click.stop="togglePopup('type')">
{{ !selectedFilters.type ||selectedFilters.type.orderTypeName === '全部' ? '工单类型' : selectedFilters.type.orderTypeName }}
<image class="filter-img" src="/static/ic_down_arrow_g.png" />
<view v-if="activePopup === 'type'" class="dropdown">
<view class="dropdown-triangle"></view>
<view class="dropdown-list">
<view v-for="(item, index) in typeList" :key="index" class="dropdown-item"
@click.stop="selectFilter('type', item)">
{{ item.orderTypeName }}
</view>
</view>
</view>
</view>
<!-- 工单状态按钮 -->
<view v-if="activeTab == 1" class="filter-btn" @click.stop="togglePopup('status')">
{{ !selectedFilters.status || selectedFilters.status.name === '全部' ? '工单状态' : selectedFilters.status.name }}
<image class="filter-img" src="/static/ic_down_arrow_g.png" />
<view v-if="activePopup === 'status'" class="dropdown">
<view class="dropdown-triangle"></view>
<view class="dropdown-list">
<view v-for="(item, index) in statusList" :key="index" class="dropdown-item"
@click.stop="selectFilter('status', item)">
{{ item.name }}
</view>
</view>
</view>
</view>
<!-- 处理人按钮 -->
<view class="filter-btn" @click.stop="togglePopup('handler')">
{{ !selectedFilters.handler || selectedFilters.handler.name === '全部' ? '处理人' : selectedFilters.handler.name }}
<image class="filter-img" src="/static/ic_down_arrow_g.png" />
<view v-if="activePopup === 'handler'" class="dropdown">
<view class="dropdown-triangle"></view>
<view class="dropdown-list">
<view v-for="(item, index) in handlerList" :key="index" class="dropdown-item"
@click.stop="selectFilter('handler', item)">
{{ item.name }}
</view>
</view>
</view>
</view>
</view>
<!-- tab栏 -->
<view class="order-tabs">
<view v-for="(tab, idx) in tabs" :key="idx" :class="['order-tab', { active: idx === activeTab }]"
@click="changeTab(idx)">
{{ tab }}
<view v-if="idx === activeTab" class="tab-underline"></view>
</view>
</view>
<!-- 列表区 -->
<scroll-view scroll-y class="order-list" @scroll="handleScroll">
<view v-for="(item, idx) in list" :key="idx" class="order-card" @click="goDetail(item)">
<view class="order-row">
<view class="order-no">工单号{{ item.orderNo }}</view>
<view class="order-status" :class="getStatusColor(item.status)">
{{ getStatusLabel(item.status) }}
</view>
</view>
<image class="order-line-image" src="/static/ic_my_repair_03.png" />
<view class="order-info">工单名称{{ item.orderName }}</view>
<view class="order-info">工单类型{{ item.typeName }}</view>
<view class="order-info">创建时间{{ item.createTime }}</view>
<view class="order-info">
{{ item.createTime }}-{{ item.planCompleTime }}
</view>
<view v-if="item.statusText === '已结束'" class="order-eval-btn eval-btn-right">
服务评价
</view>
</view>
</scroll-view>
<!-- 悬浮新增按钮 -->
<image v-if="false" src="/static/ic_my_repair_02.png" :class="['order-add-btn-fixed', { hide: isAddBtnHidden }]"
@click="addOrder" />
</view>
</template>
<script>
export default {
data() {
return {
tabs: ["待办", "全部"],
activeTab: 0,
tabData: [
[],
[]
],
tabLoaded: [false, false],
loading: false,
lastScrollTop: 0,
isAddBtnHidden: false,
activePopup: null, // 当前显示哪个弹窗null表示都关闭
selectedFilters: {
type: null,
status: null,
handler: null,
},
typeList: [{
'orderTypeName': '全部'
}],
statusList: [],
handlerList: [
{
"name": '全部'
},
],
};
},
computed: {
list() {
return this.tabData[this.activeTab];
},
},
created() {
console.log("t1","!1111")
this.loadTabData(this.activeTab);
this.loadFilterData();
},
methods: {
goBack() {
uni.navigateBack();
},
addOrder() {
uni.navigateTo({
url: "/pages/sys/workbench/order/addOrder",
});
},
handleScroll(e) {
const scrollTop = e.detail.scrollTop;
if (Math.abs(scrollTop - this.lastScrollTop) < 20) return;
this.isAddBtnHidden = scrollTop > this.lastScrollTop && scrollTop > 50;
this.lastScrollTop = scrollTop;
},
async changeTab(idx) {
this.activeTab = idx;
if (!this.tabLoaded[idx]) {
await this.loadTabData(idx);
}
},
async loadTabData(idx) {
this.loading = true;
let params = {};
if (this.selectedFilters.type && this.selectedFilters.type.id) {
params.type = this.selectedFilters.type.id
}
if(this.selectedFilters.status&&this.selectedFilters.status.id){
params.status = this.selectedFilters.status.id
}
if(this.selectedFilters.handler&&this.selectedFilters.handler.value){
params.handler = this.selectedFilters.handler.value
}
if(idx == 0){
params.status = "1,2"
}
let res = await this.$u.api.getOrderList2(params);
if (res.code == "200") {
this.$set(this.tabData, idx, res.rows);
}
this.$set(this.tabLoaded, idx, true);
this.loading = false;
},
getStatusLabel(status) {
const statusMap = {
0: "创建工单",
1: "已接单",
2: "已接单",
3: "处理中",
4: "已完成",
};
return statusMap[status] || "";
},
getStatusColor(status) {
const statusMap = {
0: "orange",
1: "doing",
2: "doing",
3: "doing",
4: "done",
};
return statusMap[status] || "";
},
goDetail(item) {
const itemStr = encodeURIComponent(JSON.stringify(item));
uni.navigateTo({
url: "/pages/sys/workbench/order/orderDetail?item=" + itemStr,
});
},
togglePopup(name) {
if (this.activePopup === name) {
this.activePopup = null;
} else {
this.activePopup = name;
}
},
selectFilter(name, value) {
this.selectedFilters[name] = value;
this.activePopup = null;
this.loadTabData(this.activeTab)
},
handleOutsideClick() {
if (this.activePopup !== null) {
this.activePopup = null;
}
},
async loadFilterData() {
// 工单类型
let resType = await this.$u.api.getOrdersType();
if (resType.code === 200) {
this.typeList = [...this.typeList, ...resType.rows];
}
let handlers = await this.$u.api.getHandler();
if(handlers.code === 200){
this.handlerList = [...this.handlerList,...handlers.data]
}
this.statusList = [{
name: "全部"
},
{
name: "创建工单",
id:"0"
},
{
name: "已接单",
id:"1,2"
},
{
name: "处理中",
id:"3"
},
{
name: "已完成",
id:"4"
},
];
},
},
};
<template>
<view class="order-container" @click="handleOutsideClick">
<!-- 筛选区 -->
<view class="filter">
<!-- 工单类型按钮 -->
<view class="filter-btn" @click.stop="togglePopup('type')">
{{ !selectedFilters.type || selectedFilters.type.orderTypeName === '全部' ? '工单类型' : selectedFilters.type.orderTypeName }}
<image class="filter-img" src="/static/ic_down_arrow_g.png" />
<view v-if="activePopup === 'type'" class="dropdown">
<view class="dropdown-triangle"></view>
<view class="dropdown-list">
<view v-for="(item, index) in typeList" :key="index" class="dropdown-item"
@click.stop="selectFilter('type', item)">
{{ item.orderTypeName }}
</view>
</view>
</view>
</view>
<!-- 工单状态按钮 -->
<view v-if="activeTab == 1" class="filter-btn" @click.stop="togglePopup('status')">
{{ !selectedFilters.status || selectedFilters.status.name === '全部' ? '工单状态' : selectedFilters.status.name }}
<image class="filter-img" src="/static/ic_down_arrow_g.png" />
<view v-if="activePopup === 'status'" class="dropdown">
<view class="dropdown-triangle"></view>
<view class="dropdown-list">
<view v-for="(item, index) in statusList" :key="index" class="dropdown-item"
@click.stop="selectFilter('status', item)">
{{ item.name }}
</view>
</view>
</view>
</view>
<!-- 处理人按钮 -->
<view class="filter-btn" @click.stop="togglePopup('handler')">
{{ !selectedFilters.handler || selectedFilters.handler.name === '全部' ? '处理人' : selectedFilters.handler.name }}
<image class="filter-img" src="/static/ic_down_arrow_g.png" />
<view v-if="activePopup === 'handler'" class="dropdown">
<view class="dropdown-triangle"></view>
<view class="dropdown-list">
<view v-for="(item, index) in handlerList" :key="index" class="dropdown-item"
@click.stop="selectFilter('handler', item)">
{{ item.name }}
</view>
</view>
</view>
</view>
</view>
<!-- tab栏 -->
<view class="order-tabs">
<view v-for="(tab, idx) in tabs" :key="idx" :class="['order-tab', { active: idx === activeTab }]"
@click="changeTab(idx)">
{{ tab }}
<view v-if="idx === activeTab" class="tab-underline"></view>
</view>
</view>
<!-- 列表区 -->
<scroll-view
scroll-y
class="order-list"
:refresher-enabled="true"
:refresher-triggered="isRefreshing"
refresher-background="#f7f7f7"
@refresherrefresh="onRefresh"
@scrolltolower="onLoadMore"
@scroll="handleScroll"
>
<view v-for="(item, idx) in list" :key="idx" class="order-card" @click="goDetail(item)">
<view class="order-row">
<view class="order-no">工单号{{ item.orderNo }}</view>
<view class="order-status" :class="getStatusColor(item.status)">
{{ getStatusLabel(item.status) }}
</view>
</view>
<image class="order-line-image" src="/static/ic_my_repair_03.png" />
<view class="order-info">工单名称{{ item.orderName }}</view>
<view class="order-info">工单类型{{ item.typeName }}</view>
<view class="order-info">创建时间{{ item.createTime }}</view>
<view class="order-info">
{{ item.createTime }}-{{ item.planCompleTime }}
</view>
<view v-if="item.statusText === '已结束'" class="order-eval-btn eval-btn-right">
服务评价
</view>
</view>
<!-- 加载更多提示 -->
<view v-if="loading" style="text-align:center;color:#999;font-size:26rpx;padding:20rpx;">
加载中...
</view>
<view v-if="!hasMore && list.length > 0" style="text-align:center;color:#999;font-size:26rpx;padding:20rpx;">
没有更多数据了
</view>
</scroll-view>
</view>
</template>
<script>
export default {
data() {
return {
tabs: ["待办", "全部"],
activeTab: 0,
// 每个 tab 分页数据
tabData: [
{ list: [], pageNum: 1, pageSize: 10, hasMore: true },
{ list: [], pageNum: 1, pageSize: 10, hasMore: true },
],
tabLoaded: [false, false],
isRefreshing: false, // 控制下拉刷新动画
loading: false,
lastScrollTop: 0,
isAddBtnHidden: false,
activePopup: null,
selectedFilters: {
type: null,
status: null,
handler: null,
},
typeList: [{ orderTypeName: '全部' }],
statusList: [],
handlerList: [{ name: "全部" }],
};
},
computed: {
list() {
return this.tabData[this.activeTab].list;
},
hasMore() {
return this.tabData[this.activeTab].hasMore;
}
},
created() {
this.loadFilterData()
this.onRefresh();
},
methods: {
async changeTab(idx) {
this.activeTab = idx;
if (!this.tabLoaded[idx]) {
this.isRefreshing = true;
await this.onRefresh();
}
},
async onRefresh() {
const tab = this.tabData[this.activeTab];
tab.pageNum = 1;
tab.hasMore = true;
this.isRefreshing = true;
await this.loadTabData(this.activeTab);
this.isRefreshing = false;
},
async onLoadMore() {
const tab = this.tabData[this.activeTab];
if (!tab.hasMore || this.loading) return;
tab.pageNum++;
this.loading = true;
await this.loadTabData(this.activeTab);
this.loading = false;
},
async loadTabData(idx) {
let params = {
pageNum: this.tabData[idx].pageNum,
pageSize: this.tabData[idx].pageSize,
};
if (this.selectedFilters.type && this.selectedFilters.type.id) {
params.type = this.selectedFilters.type.id;
}
if (this.selectedFilters.status && this.selectedFilters.status.id) {
params.status = this.selectedFilters.status.id;
}
if (this.selectedFilters.handler && this.selectedFilters.handler.value) {
params.handler = this.selectedFilters.handler.value;
}
if (idx == 0) {
params.status = "1,2";
}
let res = await this.$u.api.getOrderList2(params);
if (res.code == "200") {
if (this.tabData[idx].pageNum === 1) {
this.tabData[idx].list = res.rows;
} else {
this.tabData[idx].list = [...this.tabData[idx].list, ...res.rows];
}
// 判断是否还有更多数据
this.tabData[idx].hasMore = res.rows.length >= this.tabData[idx].pageSize;
}
this.$set(this.tabLoaded, idx, true);
},
// 其它方法保持不变
handleScroll(e) {
const scrollTop = e.detail.scrollTop;
if (Math.abs(scrollTop - this.lastScrollTop) < 20) return;
this.isAddBtnHidden = scrollTop > this.lastScrollTop && scrollTop > 50;
this.lastScrollTop = scrollTop;
},
getStatusLabel(status) {
const statusMap = {
0: "创建工单",
1: "已接单",
2: "已接单",
3: "处理中",
4: "已完成",
};
return statusMap[status] || "";
},
getStatusColor(status) {
const statusMap = {
0: "orange",
1: "doing",
2: "doing",
3: "doing",
4: "done",
};
return statusMap[status] || "";
},
goDetail(item) {
const itemStr = encodeURIComponent(JSON.stringify(item));
uni.navigateTo({
url: "/pages/sys/workbench/order/orderDetail?item=" + itemStr,
});
},
togglePopup(name) {
this.activePopup = this.activePopup === name ? null : name;
},
selectFilter(name, value) {
this.selectedFilters[name] = value;
this.activePopup = null;
this.onRefresh();
},
handleOutsideClick() {
if (this.activePopup !== null) {
this.activePopup = null;
}
},
async loadFilterData() {
let resType = await this.$u.api.getOrdersType();
if (resType.code === 200) {
this.typeList = [...this.typeList, ...resType.rows];
}
let handlers = await this.$u.api.getHandler2();
if (handlers.code === 200) {
this.handlerList = [...this.handlerList, ...handlers.data];
}
this.statusList = [
{ name: "全部" },
{ name: "创建工单", id: "0" },
{ name: "已接单", id: "1,2" },
{ name: "处理中", id: "3" },
{ name: "已完成", id: "4" },
];
},
},
};
</script>
<style scoped>

View File

@@ -38,11 +38,11 @@
</view>
<!-- 底部操作按钮 -->
<view v-if="(!this.isManager&&this.detailStep == 2) || this.detailStep == 0" class="btn-group">
<view v-if="((!this.isManager&&this.detailStep != 0) || (this.isManager&&this.detailStep == 0))&&this.detailStep!=3" class="btn-group">
<button class="btn ghost"
@click="transfer">{{this.isManager ? '指派':this.detailStep == 0 ? '拒绝':'转派'}}</button>
<button v-if="!this.isManager" class="btn primary"
@click="complete">{{this.detailStep == 0 ? '接单':'完成'}}</button>
@click="transfer">{{this.isManager ? '指派':this.detailStep == 1 ? '开始':'完成'}}</button>
<button v-if="this.detailStep == 1" class="btn primary"
@click="complete">转派</button>
</view>
<SelectUser :visible.sync="showSelect" :list="users" :multiple="false" @confirm="onConfirm" />