Răsfoiți Sursa

refactor(mini): 优化人才详情页交互,简化文件操作

- 添加 handleOpenFile 函数支持 H5 和小程序环境打开文件
- 个人征信文件和工作视频:去掉下载图标,添加查看图标点击交互
- 去掉编辑按钮,联系按钮改为全宽显示

Co-Authored-By: Claude <noreply@anthropic.com>
yourname 1 săptămână în urmă
părinte
comite
a51c300891

+ 63 - 25
mini-ui-packages/yongren-talent-management-ui/src/pages/TalentDetail/TalentDetail.tsx

@@ -271,6 +271,54 @@ const TalentDetail: React.FC<TalentDetailProps> = () => {
     return `¥${amount.toLocaleString()}`
     return `¥${amount.toLocaleString()}`
   }
   }
 
 
+  // 打开文件URL的函数
+  const handleOpenFile = (url?: string, _fileName?: string) => {
+    if (!url) {
+      Taro.showToast({
+        title: '文件地址不存在',
+        icon: 'none'
+      })
+      return
+    }
+
+    try {
+      // 在H5环境中使用window.open
+      if (process.env.TARO_ENV === 'h5') {
+        window.open(url, '_blank')
+      } else {
+        // 在小程序中使用Taro.openDocument
+        Taro.downloadFile({
+          url: url,
+          success: (res) => {
+            if (res.statusCode === 200) {
+              Taro.openDocument({
+                filePath: res.tempFilePath,
+                showMenu: true,
+                fail: (_err) => {
+                  Taro.showToast({
+                    title: '文件打开失败',
+                    icon: 'none'
+                  })
+                }
+              })
+            }
+          },
+          fail: (_err) => {
+            Taro.showToast({
+              title: '文件下载失败',
+              icon: 'none'
+            })
+          }
+        })
+      }
+    } catch (_error) {
+      Taro.showToast({
+        title: '打开文件出错',
+        icon: 'none'
+      })
+    }
+  }
+
   return (
   return (
       <PageContainer padding={false} className="pb-0">
       <PageContainer padding={false} className="pb-0">
         <ScrollView
         <ScrollView
@@ -554,9 +602,9 @@ const TalentDetail: React.FC<TalentDetailProps> = () => {
                     </View>
                     </View>
                   ) : creditFiles && creditFiles.length > 0 ? (
                   ) : creditFiles && creditFiles.length > 0 ? (
                     <View className="space-y-3">
                     <View className="space-y-3">
-                      {creditFiles.map((file: { id: string; name: string; size?: number; createdAt?: string }) => (
+                      {creditFiles.map((file: { id: string; name: string; url?: string; size?: number; createdAt?: string }) => (
                         <View key={file.id} className="flex justify-between items-center p-3 bg-gray-50 rounded-lg">
                         <View key={file.id} className="flex justify-between items-center p-3 bg-gray-50 rounded-lg">
-                          <View className="flex items-center">
+                          <View className="flex items-center flex-1">
                             <Text className="i-heroicons-document-text-20-solid text-gray-400 mr-2" />
                             <Text className="i-heroicons-document-text-20-solid text-gray-400 mr-2" />
                             <View className="flex flex-col">
                             <View className="flex flex-col">
                               <Text className="text-sm text-gray-800">{file.name}</Text>
                               <Text className="text-sm text-gray-800">{file.name}</Text>
@@ -565,9 +613,11 @@ const TalentDetail: React.FC<TalentDetailProps> = () => {
                               </Text>
                               </Text>
                             </View>
                             </View>
                           </View>
                           </View>
-                          <View className="flex space-x-2">
-                            <Text className="i-heroicons-eye-20-solid text-blue-500" />
-                            <Text className="i-heroicons-arrow-down-tray-20-solid text-green-500" />
+                          <View
+                            className="p-2 active:bg-blue-100 rounded"
+                            onClick={() => handleOpenFile(file.url, file.name)}
+                          >
+                            <Text className="i-heroicons-eye-20-solid text-blue-500 text-lg" />
                           </View>
                           </View>
                         </View>
                         </View>
                       ))}
                       ))}
@@ -611,9 +661,9 @@ const TalentDetail: React.FC<TalentDetailProps> = () => {
                         return (
                         return (
                           <View key={category} className="space-y-2">
                           <View key={category} className="space-y-2">
                             <Text className="text-sm font-medium text-gray-600 mb-1">{category}</Text>
                             <Text className="text-sm font-medium text-gray-600 mb-1">{category}</Text>
-                            {categoryVideos.map((video: { id: string; title: string; uploadTime?: string; size?: number }) => (
+                            {categoryVideos.map((video: { id: string; title: string; url?: string; uploadTime?: string; size?: number }) => (
                               <View key={video.id} className="flex items-center justify-between p-3 bg-gray-50 rounded-lg">
                               <View key={video.id} className="flex items-center justify-between p-3 bg-gray-50 rounded-lg">
-                                <View className="flex items-center">
+                                <View className="flex items-center flex-1">
                                   <View className="w-10 h-10 bg-blue-100 rounded flex items-center justify-center mr-3">
                                   <View className="w-10 h-10 bg-blue-100 rounded flex items-center justify-center mr-3">
                                     <Text className="i-heroicons-play-20-solid text-blue-500 text-lg" />
                                     <Text className="i-heroicons-play-20-solid text-blue-500 text-lg" />
                                   </View>
                                   </View>
@@ -625,9 +675,11 @@ const TalentDetail: React.FC<TalentDetailProps> = () => {
                                     </Text>
                                     </Text>
                                   </View>
                                   </View>
                                 </View>
                                 </View>
-                                <View className="flex space-x-2">
+                                <View
+                                  className="p-2 active:bg-blue-100 rounded"
+                                  onClick={() => handleOpenFile(video.url, video.title)}
+                                >
                                   <Text className="i-heroicons-eye-20-solid text-blue-500 text-lg" />
                                   <Text className="i-heroicons-eye-20-solid text-blue-500 text-lg" />
-                                  <Text className="i-heroicons-arrow-down-tray-20-solid text-green-500 text-lg" />
                                 </View>
                                 </View>
                               </View>
                               </View>
                             ))}
                             ))}
@@ -643,10 +695,10 @@ const TalentDetail: React.FC<TalentDetailProps> = () => {
                 </View>
                 </View>
 
 
                 {/* 操作按钮 - 原型第831-839行 */}
                 {/* 操作按钮 - 原型第831-839行 */}
-                <View className="flex space-x-3 mt-4">
+                <View className="mt-4">
                   {/* 联系按钮 */}
                   {/* 联系按钮 */}
                   <View
                   <View
-                    className="flex-1 bg-blue-500 text-white py-3 rounded-lg font-medium flex items-center justify-center active:bg-blue-600"
+                    className="w-full bg-blue-500 text-white py-3 rounded-lg font-medium flex items-center justify-center active:bg-blue-600"
                     onClick={() => {
                     onClick={() => {
                       // 联系功能:拨打电话或跳转
                       // 联系功能:拨打电话或跳转
                       if (talentDetail.phone) {
                       if (talentDetail.phone) {
@@ -664,20 +716,6 @@ const TalentDetail: React.FC<TalentDetailProps> = () => {
                     <Text className="i-heroicons-phone-20-solid mr-2" />
                     <Text className="i-heroicons-phone-20-solid mr-2" />
                     <Text>联系</Text>
                     <Text>联系</Text>
                   </View>
                   </View>
-
-                  {/* 编辑按钮 */}
-                  <View
-                    className="flex-1 bg-gray-100 text-gray-800 py-3 rounded-lg font-medium flex items-center justify-center active:bg-gray-200"
-                    onClick={() => {
-                      // 编辑功能:跳转编辑页面
-                      Taro.navigateTo({
-                        url: `/pages/yongren/talent/edit?id=${talentId}`
-                      })
-                    }}
-                  >
-                    <Text className="i-heroicons-pencil-square-20-solid mr-2" />
-                    <Text>编辑</Text>
-                  </View>
                 </View>
                 </View>
 
 
               </View>
               </View>