|
|
@@ -91,25 +91,151 @@ const OrderDetail: React.FC = () => {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- // 获取订单视频查询函数(模拟数据)
|
|
|
+ // 获取企业用户信息
|
|
|
+ const getEnterpriseUserInfo = () => {
|
|
|
+ try {
|
|
|
+ const userInfoStr = Taro.getStorageSync('enterpriseUserInfo')
|
|
|
+ if (!userInfoStr) return null
|
|
|
+
|
|
|
+ // 尝试解析JSON字符串
|
|
|
+ let userInfo = userInfoStr
|
|
|
+ if (typeof userInfoStr === 'string') {
|
|
|
+ userInfo = JSON.parse(userInfoStr)
|
|
|
+ }
|
|
|
+
|
|
|
+ // 处理双重编码情况:{"data": "{\"id\":2,...}"}
|
|
|
+ if (userInfo && typeof userInfo === 'object' && userInfo.data) {
|
|
|
+ if (typeof userInfo.data === 'string') {
|
|
|
+ userInfo = JSON.parse(userInfo.data)
|
|
|
+ } else {
|
|
|
+ userInfo = userInfo.data
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ return userInfo || null
|
|
|
+ } catch (error) {
|
|
|
+ console.error('获取企业用户信息失败:', error)
|
|
|
+ return null
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ // 获取订单视频查询函数
|
|
|
const fetchOrderVideosQuery = async (orderId: number) => {
|
|
|
- // TODO: 集成真实API,使用 enterpriseOrderClient['company-videos'].$get
|
|
|
- // 暂时返回模拟数据
|
|
|
- return [
|
|
|
- { id: 1, name: '2024-01月打卡视频', type: 'checkin_video' as const, size: '15MB', uploadTime: '2024-01-15' },
|
|
|
- { id: 2, name: '1月工资发放视频', type: 'salary_video' as const, size: '20MB', uploadTime: '2024-01-20' },
|
|
|
- { id: 3, name: '个税申报视频', type: 'tax_video' as const, size: '12MB', uploadTime: '2024-01-25' },
|
|
|
- ] as VideoItem[]
|
|
|
+ try {
|
|
|
+ const userInfo = getEnterpriseUserInfo()
|
|
|
+ const companyId = userInfo?.companyId || 0
|
|
|
+
|
|
|
+ if (!companyId) {
|
|
|
+ console.warn('未找到企业ID,返回空视频列表')
|
|
|
+ return [] as VideoItem[]
|
|
|
+ }
|
|
|
+
|
|
|
+ // 获取企业视频列表
|
|
|
+ const response = await enterpriseOrderClient['company-videos'].$get({
|
|
|
+ query: {
|
|
|
+ companyId,
|
|
|
+ page: 1,
|
|
|
+ pageSize: 50 // 获取前50个视频
|
|
|
+ }
|
|
|
+ })
|
|
|
+
|
|
|
+ if (response.ok) {
|
|
|
+ const data = await response.json() as any
|
|
|
+ const videos = data?.data || []
|
|
|
+
|
|
|
+ // 转换API数据到UI格式
|
|
|
+ const transformedVideos = videos.map((video: any) => {
|
|
|
+ // 根据assetType确定视频类型
|
|
|
+ let videoType: 'checkin_video' | 'salary_video' | 'tax_video' = 'checkin_video'
|
|
|
+ if (video.assetType === 'salary_video') videoType = 'salary_video'
|
|
|
+ if (video.assetType === 'tax_video') videoType = 'tax_video'
|
|
|
+
|
|
|
+ return {
|
|
|
+ id: video.id || video.fileId || 0,
|
|
|
+ name: video.file?.name || `视频-${video.id}`,
|
|
|
+ type: videoType,
|
|
|
+ size: video.file?.size ? `${Math.round(video.file.size / 1024 / 1024)}MB` : '未知大小',
|
|
|
+ uploadTime: video.file?.uploadTime ? new Date(video.file.uploadTime).toISOString().split('T')[0] : '未知日期'
|
|
|
+ } as VideoItem
|
|
|
+ })
|
|
|
+
|
|
|
+ return transformedVideos
|
|
|
+ } else {
|
|
|
+ throw new Error('获取视频列表失败')
|
|
|
+ }
|
|
|
+ } catch (error) {
|
|
|
+ console.error('获取订单视频失败:', error)
|
|
|
+ // 返回空列表
|
|
|
+ return [] as VideoItem[]
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
- // 获取订单统计数据查询函数(模拟数据)
|
|
|
+
|
|
|
+ // 获取订单统计数据查询函数
|
|
|
const fetchOrderStatisticsQuery = async (orderId: number) => {
|
|
|
- // TODO: 集成真实API,使用 enterpriseOrderClient['checkin-statistics'].$get 和 ['video-statistics'].$get
|
|
|
- // 暂时返回模拟数据
|
|
|
- return {
|
|
|
- checkinStats: { current: 24, total: 30, percentage: 80 },
|
|
|
- salaryVideoStats: { current: 18, total: 30, percentage: 60 },
|
|
|
- taxVideoStats: { current: 15, total: 30, percentage: 50 },
|
|
|
+ try {
|
|
|
+ const userInfo = getEnterpriseUserInfo()
|
|
|
+ const companyId = userInfo?.companyId || 0
|
|
|
+
|
|
|
+ if (!companyId) {
|
|
|
+ console.warn('未找到企业ID,返回空统计数据')
|
|
|
+ return {
|
|
|
+ checkinStats: { current: 0, total: 0, percentage: 0 },
|
|
|
+ salaryVideoStats: { current: 0, total: 0, percentage: 0 },
|
|
|
+ taxVideoStats: { current: 0, total: 0, percentage: 0 },
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ // 获取打卡统计数据
|
|
|
+ const checkinResponse = await enterpriseOrderClient['checkin-statistics'].$get({
|
|
|
+ query: { companyId }
|
|
|
+ })
|
|
|
+
|
|
|
+ // 获取视频统计数据
|
|
|
+ const videoResponse = await enterpriseOrderClient['video-statistics'].$get({
|
|
|
+ query: { companyId }
|
|
|
+ })
|
|
|
+
|
|
|
+ if (checkinResponse.ok && videoResponse.ok) {
|
|
|
+ const checkinData = await checkinResponse.json() as any
|
|
|
+ const videoData = await videoResponse.json() as any
|
|
|
+
|
|
|
+ // 解析统计数据
|
|
|
+ // 假设API返回格式:{ checkinVideoCount: number, totalPersonCount: number, ... }
|
|
|
+ // 视频统计返回格式:{ salaryVideoCount: number, taxVideoCount: number, checkinVideoCount: number, ... }
|
|
|
+ const checkinCount = checkinData?.checkinVideoCount || 0
|
|
|
+ const totalPersonCount = checkinData?.totalPersonCount || 0
|
|
|
+ const salaryVideoCount = videoData?.salaryVideoCount || 0
|
|
|
+ const taxVideoCount = videoData?.taxVideoCount || 0
|
|
|
+
|
|
|
+ return {
|
|
|
+ checkinStats: {
|
|
|
+ current: checkinCount,
|
|
|
+ total: totalPersonCount,
|
|
|
+ percentage: totalPersonCount > 0 ? Math.round((checkinCount / totalPersonCount) * 100) : 0
|
|
|
+ },
|
|
|
+ salaryVideoStats: {
|
|
|
+ current: salaryVideoCount,
|
|
|
+ total: totalPersonCount,
|
|
|
+ percentage: totalPersonCount > 0 ? Math.round((salaryVideoCount / totalPersonCount) * 100) : 0
|
|
|
+ },
|
|
|
+ taxVideoStats: {
|
|
|
+ current: taxVideoCount,
|
|
|
+ total: totalPersonCount,
|
|
|
+ percentage: totalPersonCount > 0 ? Math.round((taxVideoCount / totalPersonCount) * 100) : 0
|
|
|
+ },
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ throw new Error('获取统计数据失败')
|
|
|
+ }
|
|
|
+ } catch (error) {
|
|
|
+ console.error('获取订单统计数据失败:', error)
|
|
|
+ // 返回默认数据
|
|
|
+ return {
|
|
|
+ checkinStats: { current: 0, total: 0, percentage: 0 },
|
|
|
+ salaryVideoStats: { current: 0, total: 0, percentage: 0 },
|
|
|
+ taxVideoStats: { current: 0, total: 0, percentage: 0 },
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
|