20250528-修复列表显示问题

This commit is contained in:
luoyu 2025-05-28 11:43:10 +08:00
parent b824f5b388
commit 18429b2799
6 changed files with 178 additions and 116 deletions

View File

@ -159,6 +159,16 @@ Page({
reservationIsDataAll: false,
['search.status.value']: e.detail
})
// 更新状态文本
const statusOption = this.data.search.status.option;
const selectedOption = statusOption.find(option => option.value === e.detail);
if (selectedOption) {
this.setData({
['search.status.text']: selectedOption.text
});
}
this.getDataList()
},
changeSearchSort(e) {
@ -169,6 +179,16 @@ Page({
reservationIsDataAll: false,
['search.sort.value']: e.detail
})
// 更新排序文本
const sortOption = this.data.search.sort.option;
const selectedOption = sortOption.find(option => option.value === e.detail);
if (selectedOption) {
this.setData({
['search.sort.text']: selectedOption.text
});
}
this.getDataList()
},
/**
@ -206,14 +226,7 @@ Page({
_this.setData({
userData: userDetail
})
// 获取数据
let userId = _this.data.userData.id
// 获取预约数据
_this.getReservationData({
userId,
pageNum: _this.data.reservationPageNum,
pageSize: _this.data.reservationPageSize,
})
// 获取两周后时间,默认只能选两周之后,管理员可以选一年后的
const today = new Date()
const newDate = new Date(today)
@ -225,6 +238,9 @@ Page({
_this.setData({
maxDate: newDate.getTime()
})
// 获取数据
_this.getDataList()
},
// 获取数据
@ -267,8 +283,9 @@ Page({
role: _this.data.userData.roomRole, // 按不同角色去查询预约记录。1.普通用户, 3.会议服务人员 ,5.会议管理员
pageNum,
pageSize,
userId: _this.data.userData.id, // 确保传递用户ID
title: _this.data.search.title.value,
status: _this.data.search.status.value,
status: _this.data.search.status.value === '' ? null : _this.data.search.status.value,
sort: _this.data.search.sort.value, // 排序
}).then(res => {
console.log('selectReservationListByUserIdRq', res);
@ -332,6 +349,9 @@ Page({
// 格式化数据
formartData(queryDataList) {
// 格式化数据
let _this = this;
let userRole = _this.data.userData.roomRole; // 获取用户角色
return queryDataList.map(item => {
let isNowDay = false
let nowDate = selfFormatTimeYMD(getNowDate())
@ -352,6 +372,7 @@ Page({
let showApprove = false // 显示审批操作
let statusName = ''
// 预约状态1 取消 3 驳回 4 占用 5 待审核 7 审核通过,待开始 9 进行中 11已结束
if (statusValue == 1) {
// 取消
// 状态字体颜色
@ -361,37 +382,43 @@ Page({
if (statusValue == 3) {
// 驳回,可以修改
statusColor = "#333333"
// showCancel = true
// showEdit = true
statusName = '已驳回'
}
if (statusValue == 4) {
// 占用,可以修改
// 占用,仅管理员可以修改
statusName = '已占用'
if (userRole == 5) { // 只有管理员可以编辑和取消占用
showEdit = true
showCancel = true
// showStaff = true
statusName = '已占用'
}
}
if (statusValue == 5) {
// 待审核,普通用户只能取消,管理员可以修改
showEdit = true
// showCancel = true
showApprove = true
// showStaff = true
// 待审核,管理员可以审批
statusName = '待审核'
if (userRole == 5) { // 只有管理员可以编辑和审批
showEdit = true
showApprove = true
}
}
if (statusValue == 7) {
// 审核通过,管理员可修改
showCancel = true
showStaff = true
showEdit = true
statusName = '待开始'
if (userRole == 5) { // 只有管理员可以取消、编辑和分配会务人员
showCancel = true
showEdit = true
showStaff = true
}
}
if (statusValue == 9) {
// 进行中
statusName = '进行中'
}
if (statusValue == 11) {
// 已结束
statusColor = "#333333"
statusName = '已结束'
}
// 赋值
item.showCancel = showCancel
item.showEdit = showEdit

View File

@ -10,8 +10,8 @@
</van-button>
</view>
</van-dropdown-item>
<van-dropdown-item value="{{ search.status.value }}" options="{{ search.status.option }}" bind:change="changeSearchStatus" />
<van-dropdown-item value="{{ search.sort.value }}" options="{{ search.sort.option }}" bind:change="changeSearchSort" />
<van-dropdown-item id="status" title="{{ search.status.text || '预约状态' }}" value="{{ search.status.value }}" options="{{ search.status.option }}" bind:change="changeSearchStatus" />
<van-dropdown-item id="sort" title="{{ search.sort.text || '排序方式' }}" value="{{ search.sort.value }}" options="{{ search.sort.option }}" bind:change="changeSearchSort" />
</van-dropdown-menu>
<view class="itemView" wx:for="{{reservationDataList}}" wx:for-item="item" wx:key="*this">
<view class="headView">
@ -28,8 +28,8 @@
</view>
</view>
<view class="priceView">
<view class="cancelContent" wx:if="{{item.status == 1 && item.operate[0].content}}">取消原因:{{item.operate[item.operate.length - 1].content}}</view>
<view class="cancelContent" wx:if="{{item.status == 3 && item.operate[0].content}}">驳回原因:{{item.operate[item.operate.length - 1].content}}</view>
<view class="cancelContent" wx:if="{{item.status == 1 && item.operate && item.operate.length > 0}}">取消原因:{{item.operate[item.operate.length - 1].content}}</view>
<view class="cancelContent" wx:if="{{item.status == 3 && item.operate && item.operate.length > 0}}">驳回原因:{{item.operate[item.operate.length - 1].content}}</view>
</view>
<view class="btnView">
<!-- <view class="btn" wx:if="{{item.showInvite}}">去邀请

View File

@ -165,13 +165,6 @@ Page({
this.setData({
['search.status.text']: selectedOption.text
});
// 手动更新页面组件
if (this.selectComponent) {
const dropdown = this.selectComponent('.van-dropdown-menu');
if (dropdown) {
dropdown.updateItemTitle(1, selectedOption.text);
}
}
}
this.getDataList()
@ -184,6 +177,16 @@ Page({
reservationIsDataAll: false,
['search.sort.value']: e.detail
})
// 更新排序文本
const sortOption = this.data.search.sort.option;
const selectedOption = sortOption.find(option => option.value === e.detail);
if (selectedOption) {
this.setData({
['search.sort.text']: selectedOption.text
});
}
this.getDataList()
},
/**
@ -195,22 +198,28 @@ Page({
// 检查是否有URL参数指定状态
if (options && options.status) {
const statusValue = parseInt(options.status) || 7;
// 找到对应的状态文本
const statusOption = _this.data.search.status.option;
const selectedOption = statusOption.find(option => option.value === statusValue);
let statusText = selectedOption ? selectedOption.text : '待开始';
this.setData({
['search.status.value']: parseInt(options.status) || 7
['search.status.value']: statusValue,
['search.status.text']: statusText
});
} else {
// 默认设置为"待开始"状态
const statusOption = _this.data.search.status.option;
const selectedOption = statusOption.find(option => option.value === 7);
this.setData({
['search.status.text']: selectedOption ? selectedOption.text : '待开始'
});
}
// 初始化状态文本
const statusOption = _this.data.search.status.option;
const selectedOption = statusOption.find(option => option.value === _this.data.search.status.value);
let statusText = '待开始';
if (selectedOption) {
statusText = selectedOption.text;
}
_this.setData({
userData: userDetail,
['search.status.text']: statusText
userData: userDetail
})
// 获取两周后时间,默认只能选两周之后,管理员可以选一年后的
@ -227,13 +236,6 @@ Page({
// 使用getDataList统一获取数据确保应用筛选条件
_this.getDataList();
// 获取参与数据
// _this.getParticipateData({
// userId,
// pageNum: _this.data.participatePageNum,
// pageSize: _this.data.participatePageSize
// })
},
// 获取数据
@ -300,10 +302,9 @@ Page({
role: _this.data.userData.roomRole, // 按不同角色去查询预约记录。1.普通用户, 3.会议服务人员 ,5.会议管理员
pageNum,
pageSize,
// userId,
// parkId: 25,
userId: _this.data.userData.id, // 确保传递用户ID
title: _this.data.search.title.value, // 会议名称
status: _this.data.search.status.value, // 预约状态
status: _this.data.search.status.value === '' ? null : _this.data.search.status.value, // 预约状态
sort: _this.data.search.sort.value, // 排序
}).then(res => {
console.log('selectReservationListByUserIdRq', res);
@ -368,6 +369,9 @@ Page({
// 格式化数据
formartData(queryDataList) {
// 格式化数据
let _this = this;
let userRole = _this.data.userData.roomRole; // 获取当前用户角色
return queryDataList.map(item => {
// 判断是否是当天
let isNowDay = false
@ -379,7 +383,7 @@ Page({
// 添加星期几属性用于颜色判断
item.weekDay = getWeekday(item.start)
item.timeSlot = selfFormatTimeYMD(item.start) + ' ' + selfFormatTimeHM(item.start) + '~' + selfFormatTimeHM(item.end);
item.timeSlot = selfFormatTimeYMD(item.start) + ' ' + getWeekday(item.start) + ' ' + selfFormatTimeHM(item.start) + '~' + selfFormatTimeHM(item.end);
// 状态字体颜色
let statusColor = "#FFB119";
// 按钮是否显示
@ -387,44 +391,34 @@ Page({
let showCancel = false // 显示取消操作
let showEdit = false // 显示编辑操作
let statusName = ''
// 该处为普通用户列表
// 1)待审核 管理员可修改 5
// 2)已取消 用户可修改 1
// 3)已驳回 用户可修改,管理员可修改
// 4)待开始 管理员可修改 7
// 5)进行中 不修改 9
// 6)已结束 不修改 11
// 预约状态1 取消 3 驳回 4 占用 5 待审核 7 审核通过,待开始 9 进行中 11已结束
if (statusValue == 1) {
// 取消
// 状态字体颜色
statusColor = "#333333"
showEdit = true
showEdit = userRole == 1 // 普通用户可以修改已取消的预约
statusName = '已取消'
}
if (statusValue == 3) {
// 驳回,可以修改
statusColor = "#333333"
// showCancel = true
showEdit = true
showEdit = userRole == 1 // 普通用户可以修改被驳回的预约
statusName = '已驳回'
}
if (statusValue == 4) {
// 占用,普通人员不存在此情况
// showEdit = true
// showCancel = true
statusName = '已占用'
}
if (statusValue == 5) {
// 待审核,普通用户只能取消,管理员可以修改
showCancel = true
// 待审核,普通用户只能取消
showCancel = userRole == 1 // 只有普通用户可以取消自己提交的预约
statusName = '待审核'
}
if (statusValue == 7) {
// 审核通过,不允许修改,允许取消
// 审核通过,允许取消
statusName = '已通过'
showCancel = true
showCancel = userRole == 1 // 只有普通用户可以取消自己通过的预约
}
if (statusValue == 9) {
// 进行中
@ -436,6 +430,7 @@ Page({
statusColor = "#333333"
statusName = '已结束'
}
// 赋值
item.showCancel = showCancel;
item.showEdit = showEdit;

View File

@ -50,7 +50,7 @@
</view>
</van-tab>
</van-tabs> -->
<van-dropdown-menu class="van-dropdown-menu">
<van-dropdown-menu>
<van-dropdown-item id="item" title="{{ search.title.text }}">
<van-cell>
<van-field clearable value="{{ search.title.value }}" placeholder="请输入会议名称模糊查询" bind:change="changeSearchTitle" />
@ -61,8 +61,8 @@
</van-button>
</view>
</van-dropdown-item>
<van-dropdown-item title="" value="{{ search.status.value }}" options="{{ search.status.option }}" bind:change="changeSearchStatus" />
<van-dropdown-item value="{{ search.sort.value }}" options="{{ search.sort.option }}" bind:change="changeSearchSort" />
<van-dropdown-item id="status" title="{{ search.status.text || '预约状态' }}" value="{{ search.status.value }}" options="{{ search.status.option }}" bind:change="changeSearchStatus" />
<van-dropdown-item id="sort" title="{{ search.sort.text || '排序方式' }}" value="{{ search.sort.value }}" options="{{ search.sort.option }}" bind:change="changeSearchSort" />
</van-dropdown-menu>
<view class="itemView" wx:for="{{reservationDataList}}" wx:for-item="item" wx:key="*this">
<view class="headView">
@ -80,17 +80,12 @@
</view>
</view>
<view class="priceView">
<view class="cancelContent" wx:if="{{item.status == 1 && item.operate[0].content}}">取消原因:{{item.operate[item.operate.length - 1].content}}</view>
<view class="cancelContent" wx:if="{{item.status == 1 && item.operate && item.operate.length > 0}}">取消原因:{{item.operate[item.operate.length - 1].content}}</view>
<view class="cancelContent" wx:if="{{item.status == 3 && item.operate && item.operate.length > 0}}">驳回原因:{{item.operate[item.operate.length - 1].content}}</view>
</view>
<view class="btnView">
<!-- <view class="btn" wx:if="{{item.showInvite}}">去邀请
<button class="shareBtn" open-type="share" data-id="{{item.id}}">转发</button>
</view> -->
<van-button style="margin-right: 10rpx;" size="small" plain type="warning" wx:if="{{item.showCancel}}" bind:tap="cancelConfirm" data-id="{{item.id}}">取消预约</van-button>
<van-button style="margin-right: 10rpx;" size="small" plain type="info" wx:if="{{item.showEdit}}" bind:tap="editConfirm" data-id="{{item.id}}">修改信息</van-button>
<!-- <view class="btn" wx:if="{{item.showCancel}}" bind:tap="cancelConfirm" data-id="{{item.id}}">取消预约</view>
<view class="btn" wx:if="{{item.showCancel}}" bind:tap="editConfirm" data-id="{{item.id}}">修改信息</view> -->
<!-- <view class="btn" wx:if="{{item.showDetail}}" bind:tap="jumpMeetingDetail" data-id="{{item.id}}">查看详情</view> -->
</view>
</view>
<view class="loadAllLine" wx:if="{{reservationIsDataAll}}">

View File

@ -5,7 +5,9 @@ import Notify from '@vant/weapp/notify/notify';
import {
selfFormatTimeYMD,
selfFormatTimeHM
selfFormatTimeHM,
getWeekday,
getNowDate
} from "../../../../utils/util.js"
import {
@ -36,6 +38,7 @@ Page({
value: ''
},
status: {
text: '待开始',
value: 7,
option: [{
text: '全部会议',
@ -80,6 +83,16 @@ Page({
reservationIsDataAll: false,
['search.status.value']: e.detail
})
// 更新状态文本
const statusOption = this.data.search.status.option;
const selectedOption = statusOption.find(option => option.value === e.detail);
if (selectedOption) {
this.setData({
['search.status.text']: selectedOption.text
});
}
this.getDataList()
},
/**
@ -87,17 +100,34 @@ Page({
*/
onLoad(options) {
let _this = this;
let userDetail = wx.getStorageSync('user')
// 检查是否有URL参数指定状态
if (options && options.status) {
const statusValue = parseInt(options.status) || 7;
// 找到对应的状态文本
const statusOption = _this.data.search.status.option;
const selectedOption = statusOption.find(option => option.value === statusValue);
let statusText = selectedOption ? selectedOption.text : '待开始';
this.setData({
['search.status.value']: statusValue,
['search.status.text']: statusText
});
} else {
// 确保默认显示"待开始"
this.setData({
['search.status.value']: 7,
['search.status.text']: '待开始'
});
}
_this.setData({
userData: wx.getStorageSync('user'),
userData: userDetail
})
// 获取数据
let userId = _this.data.userData.id
// 获取预约数据
_this.getReservationData({
userId,
pageNum: _this.data.reservationPageNum,
pageSize: _this.data.reservationPageSize,
})
_this.getDataList()
},
// 获取数据
@ -137,11 +167,12 @@ Page({
} = param
// 查询数据
selectReservationListByUserIdRq({
role: 3, // 按不同角色去查询预约记录。1.普通用户, 3.会议服务人员 ,5.会议管理员
role: _this.data.userData.roomRole, // 按不同角色去查询预约记录。1.普通用户, 3.会议服务人员 ,5.会议管理员
pageNum,
pageSize,
userId: _this.data.userData.id, // 确保传递用户ID
title: _this.data.search.title.value,
status: _this.data.search.status.value
status: _this.data.search.status.value === '' ? null : _this.data.search.status.value
}).then(res => {
console.log('selectReservationListByUserIdRq', res);
// 判断数据是否全部查询
@ -204,7 +235,19 @@ Page({
// 格式化数据
formartData(queryDataList) {
// 格式化数据
let _this = this;
let userRole = _this.data.userData.roomRole; // 获取当前用户角色
return queryDataList.map(item => {
let isNowDay = false
let nowDate = selfFormatTimeYMD(getNowDate())
if (nowDate == selfFormatTimeYMD(item.start)) {
isNowDay = true
}
item.isNowDay = isNowDay
// 添加星期几属性用于颜色判断
item.weekDay = getWeekday(item.start)
item.timeSlot = selfFormatTimeYMD(item.start) + ' '+ getWeekday(item.start) + ' ' + selfFormatTimeHM(item.start) + '~' + selfFormatTimeHM(item.end);
// 状态字体颜色
let statusColor = "#FFB119";
@ -213,7 +256,6 @@ Page({
let showCancel = false // 显示取消操作
let showEdit = false // 显示编辑操作
let showStaff = false // 显示会务人员
let showApprove = false // 显示审批操作
let statusName = ''
// 预约状态1 取消 3 驳回 4 占用 5 待审核 7 审核通过,待开始 9 进行中 11已结束
if (statusValue == 1) {
@ -225,41 +267,34 @@ Page({
if (statusValue == 3) {
// 驳回,可以修改
statusColor = "#333333"
showCancel = true
showEdit = true
statusName = '已驳回'
}
if (statusValue == 4) {
// 占用,可以修改,取消
showEdit = true
showCancel = true
showStaff = true
statusName = '已占用'
}
if (statusValue == 5) {
// 待审核,普通用户只能取消,管理员可以修改
showEdit = true
showCancel = true
showApprove = true
showStaff = true
// 待审核
statusName = '待审核'
}
if (statusValue == 7) {
// 审核通过,可以取消,不允许修改
showCancel = true
showStaff = true
// 审核通过,服务人员只能查看详情
statusName = '待开始'
}
if (statusValue == 9) {
// 进行中
statusColor = "#333333"
statusName = '进行中'
}
if (statusValue == 11) {
// 已结束
statusColor = "#333333"
statusName = '已结束'
}
// 赋值
item.showCancel = false
item.showEdit = false
item.showApprove = false
item.showStaff = false
item.showCancel = showCancel
item.showEdit = showEdit
item.showStaff = showStaff
item.statusName = statusName
// 状态字体颜色
item.statusColor = statusColor;
@ -271,6 +306,12 @@ Page({
console.log(`JSON error : ${error}`);
}
}
for (let key in item) {
// null设置为空
if (item[key] == null) {
item[key] = ''
}
}
return item
})
},
@ -288,7 +329,11 @@ Page({
* 生命周期函数--监听页面初次渲染完成
*/
onReady() {
// 确保状态值和文本正确初始化
this.setData({
['search.status.value']: 7,
['search.status.text']: '待开始'
});
},
/**

View File

@ -10,7 +10,7 @@
</van-button>
</view>
</van-dropdown-item>
<van-dropdown-item value="{{ search.status.value }}" options="{{ search.status.option }}" bind:change="changeSearchStatus" />
<van-dropdown-item id="status" title="{{ search.status.text }}" value="{{ search.status.value }}" options="{{ search.status.option }}" bind:change="changeSearchStatus" />
</van-dropdown-menu>
<view class="itemView" wx:for="{{reservationDataList}}" wx:for-item="item" wx:key="*this">
<view class="headView">
@ -26,8 +26,8 @@
</view>
</view>
<view class="priceView">
<view class="cancelContent" wx:if="{{item.status == 1 && item.operate[0].content}}">取消原因:{{item.operate[0].content}}</view>
<view class="cancelContent" wx:if="{{item.status == 3 && item.operate[0].content}}">驳回原因:{{item.operate[0].content}}</view>
<view class="cancelContent" wx:if="{{item.status == 1 && item.operate && item.operate.length > 0}}">取消原因:{{item.operate[item.operate.length - 1].content}}</view>
<view class="cancelContent" wx:if="{{item.status == 3 && item.operate && item.operate.length > 0}}">驳回原因:{{item.operate[item.operate.length - 1].content}}</view>
</view>
</view>
<view class="loadAllLine" wx:if="{{reservationIsDataAll}}">