| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619 |
- <template>
-
- <!-- 任务详情 -->
- <view class="container">
- <!-- 状态标签 -->
- <view class="status-bar" :class="getStatusBarClass(visitDetail.status)">
- <text class="status-text">{{ visitDetail.status }}</text>
- </view>
- <!-- 详情内容 -->
- <view class="detail-container">
- <!-- 对接信息 -->
- <view class="section">
- <view class="section-title">
- <image class="title-icon" src="/static/images/person.png" mode="aspectFit"></image>
- <view class="title">
- 对接信息
- </view>
- </view>
- <view class="info-item">
- <text class="label">所属部门</text>
- <text class="value">{{visitDetail.department}}</text>
- </view>
- <view class="info-item">
- <text class="label">员工姓名</text>
- <text class="value">{{visitDetail.employeeName}}</text>
- </view>
- </view>
- <!-- 访问信息 -->
- <view class="section">
- <view class="section-title">
- <image class="title-icon" src="/static/images/calendar.png" mode="aspectFit"></image>
- <view class="title">
- 访问信息
- </view>
- </view>
- <view class="info-item">
- <text class="label">访问事由</text>
- <text class="value">{{visitDetail.visitReason}}</text>
- </view>
- <view class="info-item">
- <text class="label">到访时间</text>
- <text class="value">{{visitDetail.visitTime}}</text>
- </view>
- <view class="info-item">
- <text class="label">访客姓名</text>
- <text class="value">{{visitDetail.visitorName}}</text>
- </view>
- <view class="info-item">
- <text class="label">访客单位</text>
- <text class="value">{{visitDetail.visitorCompany}}</text>
- </view>
- <view class="info-item">
- <text class="label">手机号</text>
- <text class="value">{{visitDetail.visitorPhone}}</text>
- </view>
- </view>
- <!-- 随行人员 -->
- <view class="section" v-if="visitDetail.accompanyPersons && visitDetail.accompanyPersons.length > 0">
- <view class="section-title">
- <image class="title-icon" src="/static/images/person.png" mode="aspectFit"></image>
- <view class="title">
- 随行人员
- </view>
- </view>
- <view class="accompany-list">
- <view class="info-item" v-for="(person, index) in visitDetail.accompanyPersons" :key="index">
- <text class="label">随行人员{{index + 1}}</text>
- <view class="accompany-info">
- <text class="value">{{person.name}}</text>
- <text class="phone">{{person.phone}}</text>
- </view>
- </view>
- </view>
- </view>
- <!-- 使用车辆 -->
- <view class="section" v-if="visitDetail.useVehicle">
- <view class="section-title">
- <image class="title-icon" src="/static/images/cart.png" mode="aspectFit"></image>
- <view class="title">
- 车辆信息
- </view>
- <text class="vehicle-number">{{visitDetail.vehicleNumber}}</text>
- </view>
- <view class="info-item">
- <text class="label">接客时间</text>
- <text class="value">{{visitDetail.pickupTime}}</text>
- </view>
- <view class="info-item">
- <text class="label">接客地点</text>
- <text class="value">{{visitDetail.pickupLocation}}</text>
- </view>
- </view>
- </view>
- <!-- 操作按钮 - 仅待审核状态显示 -->
- <view class="action-container" v-if="visitDetail.status === '待审核'">
- <!-- <view class="action-container">-->
- <button class="reject-btn" @click="handleReject">拒绝</button>
- <button class="approve-btn" @click="handleApprove">通过</button>
- </view>
- <!-- 确认弹框 -->
- <uni-popup ref="confirmPopup" type="center">
- <view class="confirm-popup">
- <view class="popup-content">
- <view class="popup-title">{{confirmAction === 'approve' ? '确认通过' : '确认拒绝'}}</view>
- <view class="popup-message">
- {{confirmAction === 'approve' ? '确定要通过这个访问申请吗?' : '确定要拒绝这个访问申请吗?'}}
- </view>
- <view class="popup-buttons">
- <button class="cancel-btn" @click="cancelAction">取消</button>
- <button class="confirm-btn"
- @click="confirmAction === 'approve' ? approveVisit() : rejectVisit()">
- 确定
- </button>
- </view>
- </view>
- </view>
- </uni-popup>
- <!-- 结果提示弹框 -->
- <uni-popup ref="resultPopup" type="center">
- <view class="result-popup">
- <view class="popup-content">
- <view class="result-icon" :class="resultType">
- <uni-icons :type="resultType === 'success' ? 'checkmarkempty' : 'closeempty'" size="60"
- :color="resultType === 'success' ? '#52c41a' : '#ff4757'"></uni-icons>
- </view>
- <view class="popup-title">{{resultTitle}}</view>
- <view class="popup-message">{{resultMessage}}</view>
- <button class="close-btn" @click="closeResultPopup">确定</button>
- </view>
- </view>
- </uni-popup>
- </view>
- </template>
- <script>
- import {
- updateVisitInfo
- } from '@/config/api.js';
- export default {
- data() {
- return {
- visitId: '',
- visitDetail: {
- id: '',
- department: '',
- employeeName: '',
- visitReason: '',
- visitTime: '',
- visitorName: '',
- visitorCompany: '',
- visitorPhone: '',
- status: '',
- useVehicle: false,
- vehicleNumber: '',
- pickupTime: '',
- pickupLocation: '',
- accompanyPersons: []
- },
- confirmAction: '', // 'approve' 或 'reject'
- resultType: '', // 'success' 或 'error'
- resultTitle: '',
- resultMessage: ''
- }
- },
- onLoad(options) {
- if (options.id) {
- this.visitId = options.id;
- this.getVisitDetail();
- }
- },
- 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() {
- // 从缓存中获取数据
- const visitData = uni.getStorageSync('visitDetailData');
-
- if (visitData) {
- // 解析随行人员数据
- let accompanyPersons = [];
- if (visitData.accPerson) {
- try {
- const accPersonData = typeof visitData.accPerson === 'string' ? JSON.parse(visitData.accPerson) : visitData.accPerson;
- if (Array.isArray(accPersonData)) {
- accompanyPersons = accPersonData.map(person => ({
- name: person.name || person.accName || '',
- phone: person.phone || person.accTel || ''
- }));
- }
- } catch (error) {
- console.error('解析随行人员数据失败:', error);
- }
- }
-
- // 设置详情数据
- this.visitDetail = {
- id: visitData.id,
- department: visitData.visDept || '', // 访客单位作为部门
- employeeName: visitData.employeeName,
- visitReason: visitData.visitReason,
- visitTime: visitData.visitDate,
- visitorName: visitData.visitorName,
- visitorCompany: visitData.visitorCompany,
- visitorPhone: visitData.visitorPhone,
- status: visitData.status,
- useVehicle: visitData.useVehicle || false,
- vehicleNumber: visitData.vehicleNumber || '',
- pickupTime: visitData.pickupTime || '',
- pickupLocation: visitData.pickupLocation || '',
- accompanyPersons: accompanyPersons
- };
-
- // 清除缓存
- uni.removeStorageSync('visitDetailData');
- }
- },
- // 处理拒绝
- handleReject() {
- this.confirmAction = 'reject';
- this.$refs.confirmPopup.open();
- },
- // 处理通过
- handleApprove() {
- this.confirmAction = 'approve';
- this.$refs.confirmPopup.open();
- },
- // 取消操作
- cancelAction() {
- this.$refs.confirmPopup.close();
- this.confirmAction = '';
- },
- // 确认通过
- async approveVisit() {
- this.$refs.confirmPopup.close();
- uni.showLoading({
- title: '处理中...'
- });
- try {
- // 调用接口,状态改为 0=待访问(通过)
- const response = await updateVisitInfo({
- id: this.visitDetail.id,
- visitStatus: '0'
- });
- uni.hideLoading();
- 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: response.msg || '操作失败',
- icon: 'none'
- });
- }
- } catch (error) {
- uni.hideLoading();
- console.error('审核通过失败:', error);
- uni.showToast({
- title: '操作失败,请重试',
- icon: 'none'
- });
- }
- },
- // 确认拒绝
- async rejectVisit() {
- this.$refs.confirmPopup.close();
- uni.showLoading({
- title: '处理中...'
- });
- try {
- // 调用接口,状态改为 3=已拒绝
- const response = await updateVisitInfo({
- id: this.visitDetail.id,
- visitStatus: '3'
- });
- uni.hideLoading();
- 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: response.msg || '操作失败',
- icon: 'none'
- });
- }
- } catch (error) {
- uni.hideLoading();
- console.error('拒绝访问失败:', error);
- uni.showToast({
- title: '操作失败,请重试',
- icon: 'none'
- });
- }
- },
- // 关闭结果弹框
- closeResultPopup() {
- this.$refs.resultPopup.close();
- // 返回上一页
- uni.navigateBack();
- }
- }
- }
- </script>
- <style lang="scss" scoped>
- .container {
- min-height: 100vh;
- background-color: #f5f5f5;
- 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;
- }
- .section {
- background-color: #fff;
- border-radius: 16rpx;
- margin-bottom: 20rpx;
- padding: 30rpx;
- }
- .section-title {
- margin-bottom: 30rpx;
- display: flex;
- align-items: center;
- }
- .title {
- font-size: 32rpx;
- font-weight: 600;
- color: #333;
- }
- .title-icon {
- width: 40rpx;
- height: 40rpx;
- margin-right: 15rpx;
- }
- .vehicle-number {
- font-size: 28rpx;
- color: #666;
- font-weight: normal;
- margin-left: auto;
- }
- .info-item {
- display: flex;
- align-items: flex-start;
- margin-bottom: 24rpx;
- &:last-child {
- margin-bottom: 0;
- }
- }
- .label {
- width: 160rpx;
- font-size: 28rpx;
- color: #666;
- flex-shrink: 0;
- line-height: 1.5;
- }
- .value {
- flex: 1;
- font-size: 28rpx;
- color: #333;
- line-height: 1.5;
- word-break: break-all;
- }
- .accompany-info {
- flex: 1;
- display: flex;
- flex-direction: column;
- gap: 8rpx;
- .value {
- font-size: 28rpx;
- color: #333;
- }
- .phone {
- font-size: 24rpx;
- color: #666;
- }
- }
- .action-container {
- position: fixed;
- bottom: 0;
- left: 0;
- right: 0;
- padding: 20rpx;
- background-color: #fff;
- box-shadow: 0 -2rpx 8rpx rgba(0, 0, 0, 0.1);
- display: flex;
- gap: 20rpx;
- }
- .reject-btn,
- .approve-btn {
- flex: 1;
- height: 88rpx;
- border-radius: 44rpx;
- border: none;
- font-size: 32rpx;
- font-weight: 600;
- }
- .reject-btn {
- background-color: #fff;
- color: #ff4757;
- border: 2rpx solid #ff4757;
- }
- .approve-btn {
- background: #39833b;
- color: #fff;
- }
- // 弹框样式
- .confirm-popup,
- .result-popup {
- .popup-content {
- background-color: #fff;
- border-radius: 20rpx;
- padding: 60rpx 40rpx 40rpx;
- width: 560rpx;
- text-align: center;
- }
- .popup-title {
- font-size: 36rpx;
- font-weight: 600;
- color: #333;
- margin-bottom: 20rpx;
- }
- .popup-message {
- font-size: 28rpx;
- color: #666;
- line-height: 1.6;
- margin-bottom: 40rpx;
- }
- }
- .popup-buttons {
- display: flex;
- gap: 20rpx;
- .cancel-btn,
- .confirm-btn {
- flex: 1;
- height: 80rpx;
- border-radius: 40rpx;
- font-size: 28rpx;
- border: none;
- }
- .cancel-btn {
- background-color: #f5f5f5;
- color: #666;
- }
- .confirm-btn {
- background: linear-gradient(135deg, #ff6b35 0%, #ff9500 100%);
- color: #fff;
- }
- }
- .result-icon {
- margin-bottom: 30rpx;
- &.success {
- // success icon styling handled by uni-icons color
- }
- &.error {
- // error icon styling handled by uni-icons color
- }
- }
- .close-btn {
- width: 100%;
- height: 80rpx;
- background: linear-gradient(135deg, #ff6b35 0%, #ff9500 100%);
- border-radius: 40rpx;
- color: #fff;
- font-size: 28rpx;
- border: none;
- }
- </style>
|