feat:访客申请的同意和拒绝

This commit is contained in:
weiwei committed 2025-09-25 16:30:22 +08:00
1 parent 9182384487
commit 064c13c7b0
4 files changed
+106 -89

No files matched your search

+5 -5
View File
@@ -1,8 +1,8 @@
/// <reference types="vite/client" />
declare module '*.vue' {
import { DefineComponent } from 'vue'
// eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/ban-types
const component: DefineComponent<{}, {}, any>
export default component
declare module "*.vue" {
import { DefineComponent } from "vue"
// eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/ban-types
const component: DefineComponent<any>
export default component
}
+24 -5
View File
@@ -2,8 +2,21 @@
<crud-layout title="详情" mainIsScroll bg="/static/page/blue-bg.png">
<view v-if="detail.id">
<view class="h-20rpx" />
<tm-alert v-if="alertList[detail.checkStatus]" :showClose="false" skin="normal" :color="alertList[detail.checkStatus].color">
{{ alertList[detail.checkStatus].text }}
<tm-alert
v-if="alertListType2[detail.checkStatus] && detail.type == '2'"
:showClose="false"
skin="normal"
:color="alertListType2[detail.checkStatus].color"
>
{{ alertListType2[detail.checkStatus].text }}
</tm-alert>
<tm-alert
v-if="alertListType1[detail.checkStatus] && detail.type == '1'"
:showClose="false"
skin="normal"
:color="alertListType1[detail.checkStatus].color"
>
{{ alertListType1[detail.checkStatus].text }}
</tm-alert>
<tm-sheet :margin="[0, 20]" class="second-text-30">
<tm-text class="prefix_title" font-size="32">访客信息</tm-text>
@@ -16,7 +29,7 @@
<text>{{ detail.mobile }}</text>
</view>
<view class="flex mt-1">
<text class="w-220rpx mr-6">来访公司名称</text>
<text class="w-220rpx mr-6">访客公司名称</text>
<text>{{ detail.companyName }}</text>
</view>
<view class="flex mt-1">
@@ -75,12 +88,18 @@ import { ref } from "vue"
import { onLoad } from "@dcloudio/uni-app"
import { invitationApi } from "@/sheep/api"
const alertList = {
1: { color: "#2db7f5", text: "访客未接受邀约" },
const alertListType2 = {
1: { color: "#2db7f5", text: "访客还未接受邀约" },
2: { color: "#52c41a", text: "访客待到访" },
3: { color: "#f5a623", text: "访客拒绝了邀约" },
5: { color: "#f5222d", text: "您取消了邀约" },
}
const alertListType1 = {
1: { color: "#2db7f5", text: "您还未接受访客申请" },
2: { color: "#52c41a", text: "访客待到访" },
3: { color: "#f5a623", text: "您拒绝了访客申请" },
5: { color: "#f5222d", text: "访客申请者取消了申请" },
}
const detail = ref<any>({})
const visitorReasonList = ref<{ title: string; id: string }[]>([])
@@ -15,7 +15,7 @@
@scroll="pageHook.scroll"
>
<template #top>
<!-- <view class="bg-white rounded-20rpx my-20rpx font-bold py-1">
<view class="bg-white rounded-20rpx my-20rpx font-bold py-1">
<z-tabs
:list="[
{ name: '访客申请', value: 0 },
@@ -28,25 +28,26 @@
fontSize: '30rpx',
backgroundColor: '#ECF4F9',
padding: '12rpx 64rpx',
marginTop: '10rpx',
borderRadius: '20rpx',
border: '1px solid #007AFF',
}"
:inactive-style="{
fontSize: '30rpx',
padding: '12rpx 64rpx',
marginTop: '10rpx',
border: '1px solid transparent',
}"
:badge-style="{
whiteSpace: 'nowrap',
position: 'relative',
top: '-14rpx',
left: '-72rpx',
// whiteSpace: 'nowrap',
// position: 'relative',
// top: '-14rpx',
// left: '-72rpx',
}"
@change="onTabChange"
/>
</view> -->
</view>
<view class="h-20rpx" />
<view class="bg-white rounded-16rpx px-20rpx">
<z-tabs :list="tabs" @change="doTab" />
</view>
@@ -61,27 +62,46 @@
<view class="sub-text-26">{{ v.vstartDate + " ~ " + v.vendDate }}</view>
</view>
<view class="m-2 h-1rpx bg-#A0A0A044"></view>
<view class="flex justify-between sub-text-26 whitespace-nowrap">
<!-- <view>{{ v.name }}</view> -->
<view>访客手机号:{{ v.mobile }}</view>
<!-- <view v-if="v.reasonValue">拜访原因:{{ visitorReasonList.find((item) => item.id == v.reasonValue)?.title || "" }}</view> -->
<view>
<tm-button class="px-1 mr-2" size="xs" @click.stop="goDetail(v)">查看详情</tm-button>
<tm-button v-if="v.checkStatus != '5' && v.checkStatus != '3'" class="px-1" size="xs" color="danger" @click.stop="cancel(v)">
取消邀约
</tm-button>
<view class="sub-text-26 whitespace-nowrap ml-4">
<view class="flex">
<text class="w-160rpx">访客姓名</text>
<text>{{ v.name || "---" }}</text>
</view>
<view class="flex">
<text class="w-160rpx">访客手机</text>
<text>{{ v.mobile || "---" }}</text>
</view>
<view class="flex">
<text class="w-160rpx">邀请人</text>
<text>{{ v.userName || "---" }}</text>
</view>
<view class="flex">
<text class="w-160rpx">拜访原因</text>
<text>{{ visitorReasonList.find((item) => item.id == v.reasonValue)?.title || "---" }}</text>
</view>
<view class="flex justify-end gap-1 mt-2">
<template v-if="v.type == '1'">
<tm-modal v-if="v.checkStatus == '1'" title="确定接受访客申请吗?" height="auto" @confirm="visitorCheck(v.id, '2')">
<template #trigger><tm-button class="px-1" size="xs" color="success">接受申请</tm-button></template>
</tm-modal>
<tm-modal v-if="v.checkStatus == '1'" title="确定拒绝访客申请吗?" height="auto" @confirm="visitorCheck(v.id, '3')">
<template #trigger><tm-button class="px-1" size="xs" color="danger">拒绝申请</tm-button></template>
</tm-modal>
<tm-button class="px-1" size="xs" @click.stop="goDetail(v)">查看详情</tm-button>
</template>
<template v-if="v.type == '2'">
<tm-button class="px-1 mr-2" size="xs" @click.stop="goDetail(v)">查看详情</tm-button>
<tm-modal
v-if="v.checkStatus != '5' && v.checkStatus != '3'"
title="确定取消邀约吗?"
height="auto"
@confirm="visitorCheck(v.id, '5')"
>
<template #trigger><tm-button class="px-1" size="xs" color="danger">取消邀约</tm-button></template>
</tm-modal>
</template>
</view>
</view>
<!-- <view class="flex justify-end items-center gap-2"> -->
<!-- <view v-if="v.checkStatus == 1" class="flex items-center gap-2">
<tm-modal title="确定审核通过吗?" height="auto" @confirm="visitorCheck(v.id, 2)">
<template v-slot:trigger><tm-button class="px-1" size="s">审核通过</tm-button></template>
</tm-modal>
<tm-modal title="确定审核拒绝吗?" height="auto" @confirm="visitorCheck(v.id, 3)">
<template v-slot:trigger><tm-button class="px-1" size="s" color="danger">审核拒绝</tm-button></template>
</tm-modal>
</view> -->
<!-- </view> -->
</view>
</z-paging>
@@ -114,11 +134,11 @@ const tabs = [
{ value: "3", name: "已拒绝", disabled: false },
{ value: "5", name: "已取消", disabled: false },
]
const visitorReasonList = ref<{ title: string; id: string }[]>([])
const state = reactive<any>({
params: {
checkStatus: tabs[0].value,
type: 2, // type为1:主动申请 type为2:邀约 type为3:后台创建
type: 1, // type为1:访客端主动申请 type为2:邀约端邀约 type为3:后台创建
},
})
const pageRef = ref<any>(null)
@@ -126,6 +146,7 @@ const pageRef = ref<any>(null)
onShow(async () => {
const isLogin = await hooks.useCheckLogin()
if (!isLogin) return
getVisitorReasonList()
})
const doTab = (e: any) => {
@@ -142,54 +163,41 @@ const query = (page: number, pagesize: number) => {
pageHook.startPage(page, pagesize, false, state.params)
}
// const onTabChange = (e: number) => {
// state.params.type = e + 1
// pageRef.value.reload(false)
// }
const onTabChange = (e: number) => {
state.params.type = e + 1
pageRef.value.reload(true)
}
// 审核通过/拒绝
// const visitorCheck = async (id: string, checkStatus: number | string) => {
// try {
// const { code, msg } = await invitationApi.updateCheckStatus({ id, checkStatus })
// if (code == 0) {
// uni.showToast({ title: "操作成功", icon: "success" })
// pageRef.value.reload(false)
// return
// }
// uni.showToast({ title: msg, icon: "error" })
// } catch (error: any) {
// uni.showToast({ title: error.message, icon: "error" })
// }
// }
// 获取拜访原因列表
const getVisitorReasonList = async () => {
const { code, data } = await invitationApi.getDictListByType("1")
if (code == 0 && data) {
visitorReasonList.value = data.map((item: any) => ({ title: item.label, id: item.value }))
return
}
visitorReasonList.value = []
}
// 接受申请、拒绝申请、取消邀约(1:审核中 2:接受申请 3:拒绝申请 5:取消邀约)
const visitorCheck = async (id: string, checkStatus: "1" | "2" | "3" | "5") => {
if (!id) return uni.showToast({ title: "id不存在", icon: "error" })
try {
uni.showLoading({ title: "加载中...", mask: true })
const { code, msg } = await invitationApi.updateCheckStatus({ id, checkStatus })
if (code != 0) return uni.showToast({ title: msg || "操作失败", icon: "error" })
pageRef.value.reload(false)
uni.showToast({ title: "操作成功", icon: "success" })
} finally {
uni.hideLoading()
}
}
// 查看详情
const goDetail = (v: any) => {
if (!v.id || !v.token) return uni.showToast({ title: "id不存在", icon: "none" })
router.jump("/pages/integrated/visitor/detail", { id: v.id, token: v.token })
}
// 取消邀约
const cancel = async (v: any) => {
if (!v.id) return uni.showToast({ title: "id不存在", icon: "error" })
uni.showModal({
title: "提示",
content: "是否确定取消预约",
confirmColor: "#0094ff",
success: async (res) => {
if (!res.confirm) return
try {
uni.showLoading({ title: "取消邀约中...", mask: true })
const { code, msg } = await invitationApi.updateCheckStatus({ id: v.id, checkStatus: 5 })
if (code != 0) return uni.showToast({ title: msg || "取消失败", icon: "error" })
pageRef.value.reload(false)
uni.showToast({ title: "取消成功", icon: "success" })
} finally {
uni.hideLoading()
}
},
})
}
const goInvitation = () => {
uni.redirectTo({ url: "/pages/integrated/visitor/invitation" })
}
-10
View File
@@ -95,16 +95,6 @@ onMounted(() => {
})
function goPage(item) {
// 访客邀约功能正在开发中
if (item.name === "visitor") {
uni.showToast({
title: "访客邀约功能正在开发中",
icon: "none",
duration: 2000,
})
return
}
if (item.url) {
uni.navigateTo({ url: item.url })
}