|
|
@@ -2,6 +2,10 @@
|
|
|
|
|
|
<!-- 任务详情 -->
|
|
|
<view class="container">
|
|
|
+ <!-- 状态标签 -->
|
|
|
+ <view class="status-bar" :class="getStatusBarClass(visitDetail.status)">
|
|
|
+ <text class="status-text">{{ visitDetail.status }}</text>
|
|
|
+ </view>
|
|
|
|
|
|
<!-- 详情内容 -->
|
|
|
<view class="detail-container">
|
|
|
@@ -174,6 +178,17 @@
|
|
|
}
|
|
|
},
|
|
|
methods: {
|
|
|
+ // 获取状态栏样式类
|
|
|
+ getStatusBarClass(status) {
|
|
|
+ const statusClassMap = {
|
|
|
+ '待访问': 'status-bar-pending-visit',
|
|
|
+ '已访问': 'status-bar-visited',
|
|
|
+ '待审核': 'status-bar-pending-review',
|
|
|
+ '已拒绝': 'status-bar-rejected'
|
|
|
+ };
|
|
|
+ return statusClassMap[status] || 'status-bar-default';
|
|
|
+ },
|
|
|
+
|
|
|
// 获取访问详情
|
|
|
getVisitDetail() {
|
|
|
// 从缓存中获取数据
|
|
|
@@ -239,96 +254,107 @@
|
|
|
this.confirmAction = '';
|
|
|
},
|
|
|
|
|
|
- // 确认通过
|
|
|
- async approveVisit() {
|
|
|
- this.$refs.confirmPopup.close();
|
|
|
+ // 确认通过
|
|
|
+ async approveVisit() {
|
|
|
+ this.$refs.confirmPopup.close();
|
|
|
+
|
|
|
+ uni.showLoading({
|
|
|
+ title: '处理中...'
|
|
|
+ });
|
|
|
|
|
|
- uni.showLoading({
|
|
|
- title: '处理中...'
|
|
|
+ try {
|
|
|
+ // 调用接口,状态改为 0=待访问(通过)
|
|
|
+ const response = await updateVisitInfo({
|
|
|
+ id: this.visitDetail.id,
|
|
|
+ visitStatus: '0'
|
|
|
});
|
|
|
|
|
|
- try {
|
|
|
- // 调用接口,状态改为 1=已访问(通过)
|
|
|
- const response = await updateVisitInfo({
|
|
|
- id: this.visitDetail.id,
|
|
|
- visitStatus: '0'
|
|
|
- });
|
|
|
+ uni.hideLoading();
|
|
|
|
|
|
- uni.hideLoading();
|
|
|
-
|
|
|
- if (response && response.code === 200) {
|
|
|
- // 更新本地状态
|
|
|
- this.visitDetail.status = '已访问';
|
|
|
-
|
|
|
- // 显示成功提示
|
|
|
- this.resultType = 'success';
|
|
|
- this.resultTitle = '审核通过';
|
|
|
- this.resultMessage = '访问申请已通过,访客将收到通知';
|
|
|
- this.$refs.resultPopup.open();
|
|
|
-
|
|
|
- // 通知 visitor.vue 刷新列表
|
|
|
- uni.$emit('refreshVisitList');
|
|
|
- } else {
|
|
|
- uni.showToast({
|
|
|
- title: response.msg || '操作失败',
|
|
|
- icon: 'none'
|
|
|
- });
|
|
|
- }
|
|
|
- } catch (error) {
|
|
|
- uni.hideLoading();
|
|
|
- console.error('审核通过失败:', error);
|
|
|
+ if (response && response.code === 200) {
|
|
|
+ // 实时更新本地状态
|
|
|
+ this.visitDetail.status = '待访问';
|
|
|
+
|
|
|
+ // 强制页面刷新
|
|
|
+ this.$forceUpdate();
|
|
|
+
|
|
|
+ // 显示成功提示
|
|
|
+ this.resultType = 'success';
|
|
|
+ this.resultTitle = '审核通过';
|
|
|
+ this.resultMessage = '访问申请已通过,访客将收到通知';
|
|
|
+ this.$refs.resultPopup.open();
|
|
|
+
|
|
|
+ // 通知 visitor.vue 刷新列表
|
|
|
+ uni.$emit('refreshVisitList');
|
|
|
+
|
|
|
+ console.log('审核通过,状态已更新为:', this.visitDetail.status);
|
|
|
+ } else {
|
|
|
uni.showToast({
|
|
|
- title: '操作失败,请重试',
|
|
|
+ title: response.msg || '操作失败',
|
|
|
icon: 'none'
|
|
|
});
|
|
|
}
|
|
|
+ } catch (error) {
|
|
|
+ uni.hideLoading();
|
|
|
+ console.error('审核通过失败:', error);
|
|
|
+ uni.showToast({
|
|
|
+ title: '操作失败,请重试',
|
|
|
+ icon: 'none'
|
|
|
+ });
|
|
|
+ }
|
|
|
|
|
|
- },
|
|
|
+ },
|
|
|
|
|
|
- // 确认拒绝
|
|
|
- async rejectVisit() {
|
|
|
- this.$refs.confirmPopup.close();
|
|
|
+ // 确认拒绝
|
|
|
+ async rejectVisit() {
|
|
|
+ this.$refs.confirmPopup.close();
|
|
|
+
|
|
|
+ uni.showLoading({
|
|
|
+ title: '处理中...'
|
|
|
+ });
|
|
|
|
|
|
- uni.showLoading({
|
|
|
- title: '处理中...'
|
|
|
+ try {
|
|
|
+ // 调用接口,状态改为 3=已拒绝
|
|
|
+ const response = await updateVisitInfo({
|
|
|
+ id: this.visitDetail.id,
|
|
|
+ visitStatus: '3'
|
|
|
});
|
|
|
|
|
|
- try {
|
|
|
- // 调用接口,状态改为 3=已拒绝
|
|
|
- const response = await updateVisitInfo({
|
|
|
- id: this.visitDetail.id,
|
|
|
- visitStatus: '3'
|
|
|
- });
|
|
|
+ uni.hideLoading();
|
|
|
|
|
|
- uni.hideLoading();
|
|
|
-
|
|
|
- if (response && response.code === 200) {
|
|
|
- // 更新本地状态
|
|
|
- this.visitDetail.status = '已拒绝';
|
|
|
-
|
|
|
- // 显示成功提示
|
|
|
- this.resultType = 'success';
|
|
|
- this.resultTitle = '审核完成';
|
|
|
- this.resultMessage = '访问申请已拒绝,访客将收到通知';
|
|
|
- this.$refs.resultPopup.open();
|
|
|
-// 通知 visitor.vue 刷新列表
|
|
|
- uni.$emit('refreshVisitList');
|
|
|
- } else {
|
|
|
- uni.showToast({
|
|
|
- title: response.msg || '操作失败',
|
|
|
- icon: 'none'
|
|
|
- });
|
|
|
- }
|
|
|
- } catch (error) {
|
|
|
- uni.hideLoading();
|
|
|
- console.error('拒绝访问失败:', error);
|
|
|
+ if (response && response.code === 200) {
|
|
|
+ // 实时更新本地状态
|
|
|
+ this.visitDetail.status = '已拒绝';
|
|
|
+
|
|
|
+ // 强制页面刷新
|
|
|
+ this.$forceUpdate();
|
|
|
+
|
|
|
+ // 显示成功提示
|
|
|
+ this.resultType = 'success';
|
|
|
+ this.resultTitle = '审核完成';
|
|
|
+ this.resultMessage = '访问申请已拒绝,访客将收到通知';
|
|
|
+ this.$refs.resultPopup.open();
|
|
|
+
|
|
|
+ // 通知 visitor.vue 刷新列表
|
|
|
+ uni.$emit('refreshVisitList');
|
|
|
+
|
|
|
+ console.log('审核拒绝,状态已更新为:', this.visitDetail.status);
|
|
|
+ } else {
|
|
|
uni.showToast({
|
|
|
- title: '操作失败,请重试',
|
|
|
+ title: response.msg || '操作失败',
|
|
|
icon: 'none'
|
|
|
});
|
|
|
}
|
|
|
+ } catch (error) {
|
|
|
+ uni.hideLoading();
|
|
|
+ console.error('拒绝访问失败:', error);
|
|
|
+ uni.showToast({
|
|
|
+ title: '操作失败,请重试',
|
|
|
+ icon: 'none'
|
|
|
+ });
|
|
|
+ }
|
|
|
|
|
|
- },
|
|
|
+ },
|
|
|
|
|
|
// 关闭结果弹框
|
|
|
closeResultPopup() {
|
|
|
@@ -347,6 +373,64 @@
|
|
|
padding-bottom: 140rpx;
|
|
|
}
|
|
|
|
|
|
+ // 状态栏样式
|
|
|
+ .status-bar {
|
|
|
+ margin: 20rpx;
|
|
|
+ padding: 20rpx 30rpx;
|
|
|
+ border-radius: 12rpx;
|
|
|
+ text-align: center;
|
|
|
+
|
|
|
+ .status-text {
|
|
|
+ font-size: 32rpx;
|
|
|
+ font-weight: 600;
|
|
|
+ }
|
|
|
+
|
|
|
+ &.status-bar-pending-visit {
|
|
|
+ background: linear-gradient(135deg, rgba(76, 175, 80, 0.1) 0%, rgba(76, 175, 80, 0.2) 100%);
|
|
|
+ border: 2rpx solid rgba(76, 175, 80, 0.3);
|
|
|
+
|
|
|
+ .status-text {
|
|
|
+ color: #4CAF50;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ &.status-bar-visited {
|
|
|
+ background: linear-gradient(135deg, rgba(33, 150, 243, 0.1) 0%, rgba(33, 150, 243, 0.2) 100%);
|
|
|
+ border: 2rpx solid rgba(33, 150, 243, 0.3);
|
|
|
+
|
|
|
+ .status-text {
|
|
|
+ color: #2196F3;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ &.status-bar-pending-review {
|
|
|
+ background: linear-gradient(135deg, rgba(255, 152, 0, 0.1) 0%, rgba(255, 152, 0, 0.2) 100%);
|
|
|
+ border: 2rpx solid rgba(255, 152, 0, 0.3);
|
|
|
+
|
|
|
+ .status-text {
|
|
|
+ color: #FF9800;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ &.status-bar-rejected {
|
|
|
+ background: linear-gradient(135deg, rgba(244, 67, 54, 0.1) 0%, rgba(244, 67, 54, 0.2) 100%);
|
|
|
+ border: 2rpx solid rgba(244, 67, 54, 0.3);
|
|
|
+
|
|
|
+ .status-text {
|
|
|
+ color: #F44336;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ &.status-bar-default {
|
|
|
+ background: linear-gradient(135deg, rgba(158, 158, 158, 0.1) 0%, rgba(158, 158, 158, 0.2) 100%);
|
|
|
+ border: 2rpx solid rgba(158, 158, 158, 0.3);
|
|
|
+
|
|
|
+ .status-text {
|
|
|
+ color: #999;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
.detail-container {
|
|
|
padding: 20rpx;
|
|
|
}
|