Selaa lähdekoodia

简历附件上传

Xiao_123 8 kuukautta sitten
vanhempi
commit
cf50a99efc
10 muutettua tiedostoa jossa 308 lisäystä ja 16 poistoa
  1. 37 0
      api/file.js
  2. 28 0
      api/user.js
  3. 60 12
      pagesA/resume/index.vue
  4. 94 0
      static/style/index.css
  5. 0 0
      static/style/index.min.css
  6. 9 0
      static/style/index.scss
  7. 7 0
      utils/config.js
  8. 19 0
      utils/date.js
  9. 51 0
      utils/preview.js
  10. 3 4
      utils/request.js

+ 37 - 0
api/file.js

@@ -0,0 +1,37 @@
+import { baseUrl, tenantId, apiPath } from '@/utils/config'
+
+// 文件上传
+export const uploadFileTest = (file) => {
+  uni.showLoading({
+    title: '上传中'
+  })
+  return new Promise((resolve, reject) => {
+    uni.uploadFile({
+      url: baseUrl + apiPath + '/infra/file/upload',
+      filePath: file,
+      name: 'file',
+      header: {
+        Accept: '*/*',
+        'tenant-id': tenantId,
+      },
+      success: (uploadFileRes) => {
+        let result = JSON.parse(uploadFileRes.data)
+        if (result.error === 1) {
+          uni.showToast({
+            icon: 'none',
+            title: result.msg
+          })
+        } else {
+          return resolve(result)
+        }
+      },
+      fail: (error) => {
+        console.log('上传失败:', error)
+        return resolve(false)
+      },
+      complete: () => {
+        uni.hideLoading()
+      }
+    })
+  })
+}

+ 28 - 0
api/user.js

@@ -61,4 +61,32 @@ export const getPublicRatio = () => {
       auth: false
     }
   })
+}
+
+// 上传附件简历
+export const saveResume = (data) => {
+  return request({
+    url: '/menduner/system/person/resume/person/cv/save',
+    method: 'POST',
+    data,
+    custom: {
+      auth: true,
+      showLoading: false
+    }
+  })
+}
+
+// 删除附件简历
+export const deleteResume = (id) => {
+  return request({
+    url: '/menduner/system/person/resume/person/cv/remove',
+    method: 'DELETE',
+    params: {
+      id
+    },
+    custom: {
+      auth: true,
+      showLoading: false
+    }
+  })
 }

+ 60 - 12
pagesA/resume/index.vue

@@ -2,22 +2,37 @@
   <view class="ss-p-b-100">
     <view v-if="bioList.length > 0">
 			<uni-card v-for="(item, index) in bioList" :key="index" :is-shadow="true" :border='false' shadow="0px 0px 3px 1px rgba(0,0,0,0.1)">
-				<view style="font-weight: bold;">{{ item.fileName ? item.fileName : `简历${index + 1}` }}</view>
-				<view>上传时间:{{ item.createTime }}</view>
+				<view class="d-flex align-center">
+          <view @click="preview(item.url)"  style="flex: 1;">
+            <view style="font-weight: bold;">{{ item.title }}</view>
+				    <view>上传时间:{{ timesTampChange(item.createTime, 'Y-M-D') }}</view>
+          </view>
+          <view class="ss-m-l-30" style="width: 60rpx;">
+            <uni-icons @click="handleOpenPopup(item)" type="more-filled" size="20"></uni-icons>
+          </view>
+        </view>
 			</uni-card>
 		</view>
 		<view v-else class="nodata-img-parent">
 			<image src="https://minio.citupro.com/dev/static/nodata.png" mode="widthFix" style="width: 100vw;height: 100vh;"></image>
 		</view>
     <view class="bottom-sticky">
-      <button class="recomm-button" @click="handleUpload">从微信导入简历</button>
+      <button class="recomm-button" @click="handleUpload">从微信聊天中导入简历</button>
     </view>
+
+    <uni-popup ref="popup" type="bottom">
+      <button class="big-cancel-button" style="color: #333 !important;" @click="handleDelete">删除附件</button>
+      <button class="big-cancel-button" @click="popup.close(); currentId = ''">取消</button>
+    </uni-popup>
   </view>
 </template>
 
 <script setup>
 import { ref } from 'vue'
-import { getPersonResumeCv } from '@/api/user'
+import { getPersonResumeCv, saveResume, deleteResume } from '@/api/user'
+import { uploadFileTest } from '@/api/file'
+import { timesTampChange } from '@/utils/date'
+import { preview } from '@/utils/preview'
 
 // 获取附件
 const bioList = ref([])
@@ -27,19 +42,53 @@ const getList = async () => {
 }
 getList()
 
+// 更多
+const currentId = ref('')
+const popup = ref()
+const handleOpenPopup = (item) => {
+  currentId.value = item.id
+  popup.value.open()
+}
+
+// 删除附件
+const handleDelete = async () => {
+  if (!currentId.value) return
+  await deleteResume(currentId.value)
+  uni.showToast({
+    title: '删除成功',
+    icon: 'success',
+    duration: 2000
+  })
+  currentId.value = ''
+  popup.value.close()
+  getList()
+}
+
+// 上传附件
 const handleUpload = () => {
   wx.chooseMessageFile({
     count: 1,
     type: 'file',
     success (res) {
-      console.log(res,'res');
-      const tempFilePaths = res.tempFiles.map(item=>{
-        return item.path
-      })
-      let name = res.tempFiles[0].name
+      const title = res.tempFiles[0].name
+      const path = res.tempFiles[0].path
       //效验是否为支持的文件格式
-      if(/\.(pdf|docx|doc)$/.test(name)){
-        console.log(tempFilePaths, name, '============')
+      if(/\.(pdf|docx|doc)$/.test(title)){
+        uploadFileTest(path).then(async (res) => {
+          if (!res.data) {
+            uni.showToast({
+              title: '上传失败',
+              icon: 'none'
+            })
+            return
+          }
+          await saveResume({ title, url: res.data })
+          uni.showToast({
+            title: '上传成功',
+            icon: 'success'
+          })
+          getList()
+        })
       }else{
         uni.showToast({
           icon: 'none',
@@ -54,5 +103,4 @@ const handleUpload = () => {
 </script>
 
 <style scoped lang="scss">
-
 </style>

+ 94 - 0
static/style/index.css

@@ -165,6 +165,90 @@
   cursor: pointer;
 }
 
+.defaultBgc {
+  background-color: #f2f4f7;
+}
+
+.f-horizon {
+  display: flex;
+  justify-content: space-between;
+  align-items: center;
+  flex-direction: row;
+  margin: 15rpx;
+}
+
+.f-horizon-center {
+  display: flex;
+  justify-content: center;
+  align-items: center;
+  flex-direction: row;
+  margin: 5rpx;
+}
+
+/* 列表触底暂无更多 */
+.noMore {
+  text-align: center;
+  color: grey;
+}
+
+.salary-text {
+  float: right;
+  color: #ff770d;
+}
+
+.list-shape {
+  padding: 10px 30rpx;
+  margin-top: 10px;
+  background-color: #fff;
+}
+
+.tag-gap {
+  margin: 10rpx 10rpx 10rpx 0;
+}
+
+.viewider {
+  margin: 0 10rpx;
+}
+
+.ml {
+  margin-left: 20rpx;
+}
+
+.mr {
+  margin-right: 20rpx;
+}
+
+.cer-end {
+  position: absolute;
+  top: 85%;
+  right: 16%;
+}
+
+.cer-text {
+  text-decoration: underline;
+  margin: 0 5rpx;
+}
+
+.dis {
+  display: flex;
+  align-items: center;
+}
+
+.show-more {
+  width: 26vw;
+  white-space: nowrap;
+  overflow: hidden;
+  text-overflow: ellipsis;
+}
+
+.mr-10 {
+  margin-right: 10rpx;
+}
+
+.divider {
+  color: #e4d4d2;
+}
+
 .default-active {
   color: var(--v-primary-base) !important;
 }
@@ -9011,3 +9095,13 @@
   margin: 20px auto;
   background-color: grey !important;
 }
+
+.big-cancel-button {
+  width: 90vw;
+  height: 44px;
+  line-height: 44px;
+  margin: 20px auto;
+  background-color: #fff !important;
+  color: #b3aeae;
+  font-size: 28rpx;
+}

Tiedoston diff-näkymää rajattu, sillä se on liian suuri
+ 0 - 0
static/style/index.min.css


+ 9 - 0
static/style/index.scss

@@ -474,4 +474,13 @@
   margin: 20px auto;
   background-color: grey !important;
   // border-radius: 25px;
+}
+.big-cancel-button {
+  width: 90vw;
+  height:44px;
+  line-height: 44px;
+  margin:20px auto;
+  background-color: #fff !important;
+  color: #b3aeae;
+  font-size: 28rpx;
 }

+ 7 - 0
utils/config.js

@@ -0,0 +1,7 @@
+export const baseUrl = 'http://menduner.citupro.com:7878'
+// const baseUrl = 'https://menduner.citupro.com:2443'
+
+// 租户id
+export const tenantId = '155'
+
+export const apiPath = '/app-api'

+ 19 - 0
utils/date.js

@@ -0,0 +1,19 @@
+// 时间戳转换为年月日时分秒
+export const timesTampChange = (timestamp, format = 'Y-M-D h:m:s') => {
+  if (!timestamp) return ''
+  const date = new Date(timestamp)
+  const Y = date.getFullYear().toString()
+  const M = (date.getMonth() + 1).toString().padStart(2, '0')
+  const D = date.getDate().toString().padStart(2, '0')
+
+  const h = date.getHours().toString().padStart(2, '0')
+  const m = date.getMinutes().toString().padStart(2, '0')
+  const s = date.getSeconds().toString().padStart(2, '0')
+
+  const formatter = { 'Y': Y, 'M': M, 'D': D, 'h': h, 'm': m, 's': s } // 替换format中的占位符
+  let formattedDate = format.replace(/Y|M|D|h|m|s/g, matched => formatter[matched]) // 使用正则表达式匹配并替换占位符
+  
+  if (!formattedDate) formattedDate = Y + '-' + M + '-' + D + ' ' + h + ':' + m + ':' + s
+
+  return formattedDate
+}

+ 51 - 0
utils/preview.js

@@ -0,0 +1,51 @@
+// 允许打开的文件类型
+const typeList = ['doc', 'docx', 'xls', 'xlsx', 'ppt', 'pptx', 'pdf']
+
+// 文件预览
+export function preview (url) {
+  uni.showLoading({
+    title: '文件加载中...'
+  })
+  wx.downloadFile({
+    url,
+    success: function (res) {
+      const filePath = res.tempFilePath
+      const arr = res.tempFilePath.split('.')
+      const fileType = arr[1]
+      if (!typeList.includes(fileType)) {
+        uni.showToast({
+          icon: "none",
+          title: '暂未支持此类型的文件查看',
+          duration: 2000,
+        })
+        return
+      } 
+      wx.openDocument({
+        filePath: filePath,
+        fileType,
+        showMenu: true, //显示右上角菜单
+        success: function (res) {
+          console.log(res, "openDocument")
+          console.log("打开文档成功")
+        },
+        fail: res => {
+          uni.showToast({
+            icon: 'none',
+            title: res.errMsg,
+            duration: 5000
+          })
+        }
+      })
+    },
+    fail: (res) => {
+      uni.showToast({
+        icon: 'none',
+        title: res.errMsg,
+        duration: 5000
+      })
+    },
+    complete: res => {
+      uni.hideLoading()
+    }
+  })
+}

+ 3 - 4
utils/request.js

@@ -6,9 +6,8 @@
 import Request from 'luch-request';
 import { refreshToken } from '@/api/common';
 import { userStore } from '@/store/user'
+import { baseUrl, tenantId, apiPath } from './config'
 
-const baseUrl = 'http://menduner.citupro.com:7878'
-// const baseUrl = 'https://menduner.citupro.com:2443'
 const options = {
 	// 显示操作成功消息 默认不显示
 	showSuccess: false,
@@ -45,7 +44,7 @@ function closeLoading() {
  * @description 请求基础配置 可直接使用访问自定义请求
  */
 const http = new Request({
-	baseURL: baseUrl + '/app-api',
+	baseURL: baseUrl + apiPath,
 	timeout: 8000,
 	method: 'GET',
 	header: {
@@ -103,7 +102,7 @@ http.interceptors.request.use(
 		config.header['Accept-Language'] = 'zh_CN'
 
     config.header['Accept'] = '*/*';
-    config.header['tenant-id'] = '155';
+    config.header['tenant-id'] = tenantId;
 		return config;
 	},
 	(error) => {

Kaikkia tiedostoja ei voida näyttää, sillä liian monta tiedostoa muuttui tässä diffissä