|
|
@@ -136,6 +136,10 @@
|
|
|
</template>
|
|
|
|
|
|
<script>
|
|
|
+ import {
|
|
|
+ updateVisitInfo
|
|
|
+ } from '@/config/api.js';
|
|
|
+
|
|
|
export default {
|
|
|
data() {
|
|
|
return {
|
|
|
@@ -165,40 +169,53 @@
|
|
|
onLoad(options) {
|
|
|
if (options.id) {
|
|
|
this.visitId = options.id;
|
|
|
- this.visitDetail.status = options.status || '待审核';
|
|
|
this.getVisitDetail();
|
|
|
}
|
|
|
},
|
|
|
methods: {
|
|
|
// 获取访问详情
|
|
|
getVisitDetail() {
|
|
|
- // 模拟数据,实际应该调用接口
|
|
|
- const mockDetail = {
|
|
|
- id: this.visitId,
|
|
|
- department: '技术部',
|
|
|
- employeeName: '张河嘉',
|
|
|
- visitReason: '参加业务研究计划',
|
|
|
- visitTime: '2025-08-09',
|
|
|
- visitorName: '安晓伟',
|
|
|
- visitorCompany: '某某某公司',
|
|
|
- visitorPhone: '13012345678',
|
|
|
- status: this.visitDetail.status, // 从上一页传来的状态
|
|
|
- useVehicle: true,
|
|
|
- vehicleNumber: '冀A·12345',
|
|
|
- pickupTime: '2025-08-09 16:30',
|
|
|
- pickupLocation: '石家庄新华区',
|
|
|
- accompanyPersons: [{
|
|
|
- name: '李四',
|
|
|
- phone: '13987654321'
|
|
|
- },
|
|
|
- {
|
|
|
- name: '王五',
|
|
|
- phone: '13876543210'
|
|
|
+ // 从缓存中获取数据
|
|
|
+ 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 = mockDetail;
|
|
|
+ }
|
|
|
+
|
|
|
+ // 设置详情数据
|
|
|
+ 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');
|
|
|
+ }
|
|
|
},
|
|
|
|
|
|
// 处理拒绝
|
|
|
@@ -220,49 +237,87 @@
|
|
|
},
|
|
|
|
|
|
// 确认通过
|
|
|
- approveVisit() {
|
|
|
+ async approveVisit() {
|
|
|
this.$refs.confirmPopup.close();
|
|
|
|
|
|
- // 模拟接口调用
|
|
|
uni.showLoading({
|
|
|
title: '处理中...'
|
|
|
});
|
|
|
|
|
|
- setTimeout(() => {
|
|
|
- uni.hideLoading();
|
|
|
+ try {
|
|
|
+ // 调用接口,状态改为 1=已访问(通过)
|
|
|
+ const response = await updateVisitInfo({
|
|
|
+ id: this.visitDetail.id,
|
|
|
+ visitStatus: '1'
|
|
|
+ });
|
|
|
|
|
|
- // 更新状态
|
|
|
- this.visitDetail.status = '待访问';
|
|
|
+ uni.hideLoading();
|
|
|
|
|
|
- // 显示成功提示
|
|
|
- this.resultType = 'success';
|
|
|
- this.resultTitle = '审核通过';
|
|
|
- this.resultMessage = '访问申请已通过,访客将收到通知';
|
|
|
- this.$refs.resultPopup.open();
|
|
|
- }, 1000);
|
|
|
+ if (response && response.code === 200) {
|
|
|
+ // 更新本地状态
|
|
|
+ this.visitDetail.status = '已访问';
|
|
|
+
|
|
|
+ // 显示成功提示
|
|
|
+ this.resultType = 'success';
|
|
|
+ this.resultTitle = '审核通过';
|
|
|
+ this.resultMessage = '访问申请已通过,访客将收到通知';
|
|
|
+ this.$refs.resultPopup.open();
|
|
|
+ } else {
|
|
|
+ uni.showToast({
|
|
|
+ title: response.msg || '操作失败',
|
|
|
+ icon: 'none'
|
|
|
+ });
|
|
|
+ }
|
|
|
+ } catch (error) {
|
|
|
+ uni.hideLoading();
|
|
|
+ console.error('审核通过失败:', error);
|
|
|
+ uni.showToast({
|
|
|
+ title: '操作失败,请重试',
|
|
|
+ icon: 'none'
|
|
|
+ });
|
|
|
+ }
|
|
|
},
|
|
|
|
|
|
// 确认拒绝
|
|
|
- rejectVisit() {
|
|
|
+ async rejectVisit() {
|
|
|
this.$refs.confirmPopup.close();
|
|
|
|
|
|
- // 模拟接口调用
|
|
|
uni.showLoading({
|
|
|
title: '处理中...'
|
|
|
});
|
|
|
|
|
|
- setTimeout(() => {
|
|
|
- uni.hideLoading();
|
|
|
+ try {
|
|
|
+ // 调用接口,状态改为 3=已拒绝
|
|
|
+ const response = await updateVisitInfo({
|
|
|
+ id: this.visitDetail.id,
|
|
|
+ visitStatus: '3'
|
|
|
+ });
|
|
|
|
|
|
- // 更新状态
|
|
|
- this.visitDetail.status = '已拒绝';
|
|
|
+ uni.hideLoading();
|
|
|
|
|
|
- // 显示成功提示
|
|
|
- this.resultType = 'success';
|
|
|
- this.resultTitle = '审核完成';
|
|
|
- this.resultMessage = '访问申请已拒绝,访客将收到通知';
|
|
|
- this.$refs.resultPopup.open();
|
|
|
- }, 1000);
|
|
|
+ if (response && response.code === 200) {
|
|
|
+ // 更新本地状态
|
|
|
+ this.visitDetail.status = '已拒绝';
|
|
|
+
|
|
|
+ // 显示成功提示
|
|
|
+ this.resultType = 'success';
|
|
|
+ this.resultTitle = '审核完成';
|
|
|
+ this.resultMessage = '访问申请已拒绝,访客将收到通知';
|
|
|
+ this.$refs.resultPopup.open();
|
|
|
+ } else {
|
|
|
+ uni.showToast({
|
|
|
+ title: response.msg || '操作失败',
|
|
|
+ icon: 'none'
|
|
|
+ });
|
|
|
+ }
|
|
|
+ } catch (error) {
|
|
|
+ uni.hideLoading();
|
|
|
+ console.error('拒绝访问失败:', error);
|
|
|
+ uni.showToast({
|
|
|
+ title: '操作失败,请重试',
|
|
|
+ icon: 'none'
|
|
|
+ });
|
|
|
+ }
|
|
|
},
|
|
|
|
|
|
// 关闭结果弹框
|