right.vue 8.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290
  1. <template>
  2. <div>
  3. <div class="accountBox d-flex mb-3 radius white-bgc flex-column">
  4. <div class="resume-header ml-3 mt-2">
  5. <div class="resume-title">{{ $t('points.wallet') }}</div>
  6. </div>
  7. <div class="d-flex" v-if="userAccount && Object.keys(userAccount).length">
  8. <div v-for="val in accountList" :key="val.title" class="accountItem cursor-pointer" @click="router.push({ path: '/recruit/personal/myWallet' })">
  9. <v-icon color="primary">{{ val.icon }}</v-icon>
  10. <div class="ml-1">
  11. <div class="title-text">{{ (userAccount[val.key] || 0) + val.desc }}</div>
  12. <div class="tip-text">{{ val.title }}</div>
  13. </div>
  14. </div>
  15. </div>
  16. <div v-else class="text-center font-size-14 mb-3">
  17. 请先登录
  18. </div>
  19. </div>
  20. <div class="resume d-flex">
  21. <div v-for="val in resumeList" :key="val.title" class="topping white-bgc radius" @click="resumeClick(val)">
  22. <v-icon color="primary">{{ val.icon }}</v-icon>
  23. <div class="ml-1">
  24. <div class="title-text">{{ val.title }}</div>
  25. <div class="tip-text">{{ val.desc }}</div>
  26. </div>
  27. </div>
  28. </div>
  29. <div class="attachment white-bgc radius mt-3">
  30. <div>
  31. <span class="title">{{ $t('resume.attachmentResume') }}</span>
  32. <span class="upload--text cursor-pointer" @click="openFileInput">
  33. {{ $t('common.upload') }}
  34. <input
  35. type="file"
  36. ref="fileInput"
  37. accept=".pdf, .doc, .docx"
  38. style="display: none;"
  39. @change="handleUploadFile"
  40. />
  41. </span>
  42. </div>
  43. <span class="more-text">{{ $t('resume.uploadUpToFiveCopies') }}</span>
  44. <div v-if="attachmentList.length">
  45. <div class="d-flex attachment-item my-2 cursor-pointer" v-for="k in attachmentList" :key="k.id">
  46. <v-icon color="primary">mdi-file-account</v-icon>
  47. <div class="file-name ellipsis ml-2">{{ k.title }}</div>
  48. <v-icon color="primary" @click="previewFile(k.url)">mdi-eye-outline</v-icon>
  49. <v-icon class="mx-2" color="primary" @click="handleDownload(k)">mdi-download-box-outline</v-icon>
  50. <v-icon color="error" @click="handleDelete(k)">mdi-trash-can-outline</v-icon>
  51. </div>
  52. </div>
  53. <div v-else class="more-text d-flex justify-center">暂无简历,请先上传</div>
  54. </div>
  55. <v-navigation-drawer
  56. v-model="showInterviewSchedule"
  57. style="height: 100vh; overflow: hidden;"
  58. temporary
  59. location="right"
  60. width="300"
  61. >
  62. <interviewSchedule :dataList="invitePageList" @handleMore="interviewScheduleMore()"></interviewSchedule>
  63. </v-navigation-drawer>
  64. </div>
  65. </template>
  66. <script setup>
  67. defineOptions({ name: 'personal-center-right'})
  68. import { ref } from 'vue'
  69. import { uploadFile } from '@/api/common'
  70. import { previewFile } from '@/utils'
  71. import { useRouter } from 'vue-router'
  72. import { useRoute } from 'vue-router'; const route = useRoute()
  73. import { getPersonResumeCv, savePersonResumeCv, deletePersonResumeCv } from '@/api/recruit/personal/resume'
  74. import { useI18n } from '@/hooks/web/useI18n'
  75. import { useUserStore } from '@/store/user'
  76. import Snackbar from '@/plugins/snackbar'
  77. import Confirm from '@/plugins/confirm'
  78. import interviewSchedule from './../components/interviewSchedule.vue'
  79. import { getUserInterviewInvitePage } from '@/api/recruit/personal/personalCenter'
  80. import { dealDictObjData } from '@/utils/position'
  81. const { t } = useI18n()
  82. const router = useRouter()
  83. const userStore = useUserStore()
  84. const accountList = [
  85. { icon: 'mdi-currency-cny', title: t('resume.accountWithdrawal'), desc: t('unit.rmb'), key: 'balance' },
  86. { icon: 'mdi-octagram-outline', title: t('resume.goldCoins'), desc: t('unit.ge'), key: 'point' }
  87. ]
  88. let userAccount = ref(JSON.parse(localStorage.getItem('userAccount')) || {}) // 账户信息
  89. userStore.$subscribe((mutation, state) => {
  90. userAccount.value = state.userAccount || {}
  91. })
  92. const resumeList = ref([
  93. // { icon: 'mdi-upload', title: t('resume.topResume'), desc: t('resume.increaseMoreExposure') },
  94. { name: 'refresh', icon: 'mdi-refresh', title: t('resume.refreshResume'), desc: t('resume.enhanceResumeActivity') },
  95. { name: 'interview', icon: 'mdi-account-multiple-check-outline', title: t('resume.interviewSchedule'), desc: '' },
  96. ])
  97. const showInterviewSchedule = ref(false)
  98. const resumeClick = async (val) => {
  99. if (val.name === 'interview') {
  100. await getUserInterviewInvitePageList() // 获取最新数据
  101. showInterviewSchedule.value = true
  102. }
  103. }
  104. // 获取附件
  105. const attachmentList = ref([])
  106. const getList = async () => {
  107. const data = await getPersonResumeCv()
  108. attachmentList.value = data
  109. }
  110. getList()
  111. // 选择文件
  112. const fileInput = ref()
  113. const clicked = ref(false)
  114. const openFileInput = () => {
  115. if (attachmentList.value.length >= 5) return Snackbar.warning(t('resume.uploadFiveCopies'))
  116. if (clicked.value) return
  117. clicked.value = true
  118. fileInput.value.click()
  119. clicked.value = false
  120. }
  121. // 上传附件
  122. const typeList = ['pdf', 'doc', 'docx']
  123. const handleUploadFile = async (e) => {
  124. const file = e.target.files[0]
  125. const size = file.size
  126. if (size / (1024*1024) > 10) {
  127. Snackbar.warning(t('common.fileSizeExceed'))
  128. return
  129. }
  130. const arr = file.name.split('.')
  131. if (typeList.indexOf(arr[arr.length - 1]) < 0) {
  132. Snackbar.warning(t('common.fileFormatIncorrect'))
  133. return
  134. }
  135. const formData = new FormData()
  136. formData.append('file', file)
  137. const { data } = await uploadFile(formData)
  138. if (!data) return
  139. Snackbar.success(t('common.uploadSucMsg'))
  140. await savePersonResumeCv({ title: file.name, url: data })
  141. getList()
  142. }
  143. // 删除
  144. const handleDelete = ({ id }) => {
  145. Confirm(t('common.confirmTitle'), t('resume.deleteAttachment')).then(async () => {
  146. await deletePersonResumeCv(id)
  147. Snackbar.success(t('common.delMsg'))
  148. getList()
  149. })
  150. }
  151. const getBlob = (url) => {
  152. return new Promise(resolve => {
  153. const xhr = new XMLHttpRequest()
  154. xhr.open('GET', url, true)
  155. xhr.responseType = 'blob'
  156. xhr.onload = () => {
  157. if (xhr.status === 200) resolve(xhr.response)
  158. }
  159. xhr.send()
  160. })
  161. }
  162. const saveAs = (blob, filename) => {
  163. var link = document.createElement('a')
  164. link.href = window.URL.createObjectURL(blob)
  165. link.download = filename
  166. link.click()
  167. }
  168. // 下载附件
  169. const handleDownload = (k) => {
  170. getBlob(k.url).then(blob => {
  171. saveAs(blob, k.title)
  172. })
  173. }
  174. // 面试日程
  175. const invitePageList = ref([])
  176. const getUserInterviewInvitePageList = async () => {
  177. const res = await getUserInterviewInvitePage()
  178. invitePageList.value = res?.list.map(e => {
  179. e.job = { ...e.job, ...dealDictObjData({}, e.job) }
  180. e.enterprise = { ...e.enterprise, ...dealDictObjData({}, e.enterprise)}
  181. return e
  182. }) || []
  183. // const interview = resumeList.value.find(f => f.name === 'interview')
  184. // if (interview) interview.desc = '有' + (res?.total || '0') + '个待面试'
  185. }
  186. // getUserInterviewInvitePageList()
  187. const interviewScheduleMore = () => {
  188. showInterviewSchedule.value = false
  189. const path = route.path
  190. router.push({ path, query: { showInterviewScheduleMore: true } })
  191. }
  192. </script>
  193. <style scoped lang="scss">
  194. .radius {
  195. border-radius: 8px;
  196. }
  197. .title {
  198. font-weight: 600;
  199. font-size: 17px;
  200. }
  201. .accountBox {
  202. width: 100%;
  203. .accountItem {
  204. display: flex;
  205. align-items: center;
  206. justify-content: center;
  207. width: 50%;
  208. height: 80px;
  209. padding: 0 12px;
  210. .tip-text {
  211. font-size: 13px;
  212. color: var(--color-666);
  213. }
  214. .title-text {
  215. font-weight: 600;
  216. font-size: 18px;
  217. &:hover {
  218. color: var(--v-primary-base);
  219. }
  220. }
  221. }
  222. }
  223. .resume {
  224. width: 100%;
  225. .topping {
  226. display: flex;
  227. align-items: center;
  228. justify-content: center;
  229. width: 50%;
  230. height: 90px;
  231. padding: 12px;
  232. margin-right: 12px;
  233. cursor: pointer;
  234. &:nth-child(2n) {
  235. margin-right: 0;
  236. }
  237. .tip-text {
  238. font-size: 12px;
  239. color: var(--color-666);
  240. }
  241. .title-text {
  242. font-weight: 600;
  243. &:hover {
  244. color: var(--v-primary-base);
  245. }
  246. }
  247. }
  248. }
  249. .attachment {
  250. padding: 12px;
  251. .more-text {
  252. font-size: 12px;
  253. color: var(--color-666);
  254. margin-left: 4px;
  255. }
  256. .upload--text {
  257. float: right;
  258. color: var(--v-primary-base);
  259. font-size: 12px;
  260. }
  261. .last-update {
  262. font-size: 12px;
  263. color: var(--color-666);
  264. }
  265. .attachment-item {
  266. color: #555;
  267. font-size: 14px;
  268. .file-name {
  269. width: 230px;
  270. &:hover {
  271. color: var(--v-primary-base);
  272. }
  273. }
  274. }
  275. }
  276. </style>