right.vue 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207
  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 v-if="val.key === 'balance'" class="title-text">{{ (userAccount[val.key] && userAccount[val.key] > 0 ? (userAccount[val.key] / 100.0).toFixed(2) : 0) + val.desc }}</div>
  12. <div v-else class="title-text">{{ (userAccount[val.key] || 0) + val.desc }}</div>
  13. <div class="tip-text">{{ val.title }}</div>
  14. </div>
  15. </div>
  16. </div>
  17. <div v-else class="text-center font-size-14 mb-3">
  18. 请先登录
  19. </div>
  20. </div>
  21. <div class="resume d-flex">
  22. <div v-for="val in resumeList" :key="val.title" class="topping white-bgc radius" @click="resumeClick(val)">
  23. <v-icon color="primary">{{ val.icon }}</v-icon>
  24. <div class="ml-1">
  25. <div class="title-text">{{ val.title }}</div>
  26. <div class="tip-text">{{ val.desc }}</div>
  27. </div>
  28. </div>
  29. </div>
  30. <div class="attachment white-bgc radius mt-3">
  31. <div>
  32. <span class="title">{{ $t('resume.attachmentResume') }}</span>
  33. <span class="upload--text cursor-pointer" @click="openFileInput">
  34. {{ $t('common.upload') }}
  35. <File ref="uploadFile" @success="handleUploadResume"></File>
  36. </span>
  37. </div>
  38. <span class="more-text">{{ $t('resume.uploadUpToFiveCopies') }}</span>
  39. <div v-if="attachmentList.length">
  40. <div class="d-flex attachment-item my-2" v-for="k in attachmentList" :key="k.id">
  41. <v-icon color="primary">mdi-file-account</v-icon>
  42. <div class="file-name ellipsis ml-2">{{ k.title }}</div>
  43. <span class="cursor-pointer color-primary" @click="previewFile(k.url)">预览</span>
  44. <span class="cursor-pointer mx-2 color-primary" @click="handleDownload(k)">下载</span>
  45. <span class="cursor-pointer color-error" @click="handleDelete(k)">删除</span>
  46. </div>
  47. </div>
  48. <div v-else class="more-text d-flex justify-center">暂无简历,请先上传</div>
  49. </div>
  50. </div>
  51. </template>
  52. <script setup>
  53. defineOptions({ name: 'personal-center-right'})
  54. import { ref } from 'vue'
  55. import { previewFile } from '@/utils'
  56. import { useRouter } from 'vue-router'
  57. import { getPersonResumeCv, savePersonResumeCv, deletePersonResumeCv } from '@/api/recruit/personal/resume'
  58. import { useI18n } from '@/hooks/web/useI18n'
  59. import { useUserStore } from '@/store/user'
  60. import Snackbar from '@/plugins/snackbar'
  61. import Confirm from '@/plugins/confirm'
  62. import { getBlob, saveAs } from '@/utils'
  63. const { t } = useI18n()
  64. const router = useRouter()
  65. const userStore = useUserStore()
  66. const accountList = [
  67. { icon: 'mdi-currency-cny', title: t('enterprise.account.accountBalances'), desc: t('unit.rmb'), key: 'balance' },
  68. { icon: 'mdi-octagram-outline', title: t('resume.goldCoins'), desc: t('unit.ge'), key: 'point' }
  69. ]
  70. let userAccount = ref(JSON.parse(localStorage.getItem('userAccount')) || {}) // 账户信息
  71. userStore.$subscribe((mutation, state) => {
  72. userAccount.value = state.userAccount || {}
  73. })
  74. const resumeList = ref([
  75. { name: 'refresh', icon: 'mdi-refresh', title: t('resume.refreshResume'), desc: t('resume.enhanceResumeActivity') },
  76. { name: 'order', icon: 'mdi-clipboard-list-outline', title: '我的订单', desc: '交易订单' },
  77. ])
  78. const resumeClick = async (val) => {
  79. if (val.name === 'order') router.push('/recruit/personal/tradeOrder')
  80. }
  81. // 获取附件
  82. const attachmentList = ref([])
  83. const getList = async () => {
  84. const data = await getPersonResumeCv()
  85. attachmentList.value = data
  86. }
  87. getList()
  88. // 选择文件
  89. const uploadFile = ref()
  90. const openFileInput = () => {
  91. if (attachmentList.value.length >= 5) return Snackbar.warning(t('resume.uploadFiveCopies'))
  92. uploadFile.value.trigger()
  93. }
  94. // 上传附件
  95. const handleUploadResume = async (url, title) => {
  96. if (!url || !title) return
  97. Snackbar.success(t('common.uploadSucMsg'))
  98. await savePersonResumeCv({ title, url })
  99. getList()
  100. }
  101. // 删除
  102. const handleDelete = ({ id }) => {
  103. Confirm(t('common.confirmTitle'), t('resume.deleteAttachment')).then(async () => {
  104. await deletePersonResumeCv(id)
  105. Snackbar.success(t('common.delMsg'))
  106. getList()
  107. })
  108. }
  109. // 下载附件
  110. const handleDownload = (k) => {
  111. getBlob(k.url).then(blob => {
  112. saveAs(blob, k.title)
  113. })
  114. }
  115. </script>
  116. <style scoped lang="scss">
  117. .radius {
  118. border-radius: 8px;
  119. }
  120. .title {
  121. font-weight: 600;
  122. font-size: 17px;
  123. }
  124. .accountBox {
  125. width: 100%;
  126. .accountItem {
  127. display: flex;
  128. align-items: center;
  129. justify-content: center;
  130. width: 50%;
  131. height: 80px;
  132. padding: 0 12px;
  133. .tip-text {
  134. font-size: 13px;
  135. color: var(--color-666);
  136. }
  137. .title-text {
  138. font-weight: 600;
  139. font-size: 18px;
  140. &:hover {
  141. color: var(--v-primary-base);
  142. }
  143. }
  144. }
  145. }
  146. .resume {
  147. width: 100%;
  148. .topping {
  149. display: flex;
  150. align-items: center;
  151. justify-content: center;
  152. width: 50%;
  153. height: 90px;
  154. padding: 12px;
  155. margin-right: 12px;
  156. cursor: pointer;
  157. &:nth-child(2n) {
  158. margin-right: 0;
  159. }
  160. .tip-text {
  161. font-size: 12px;
  162. color: var(--color-666);
  163. }
  164. .title-text {
  165. font-weight: 600;
  166. &:hover {
  167. color: var(--v-primary-base);
  168. }
  169. }
  170. }
  171. }
  172. .attachment {
  173. padding: 12px;
  174. .more-text {
  175. font-size: 12px;
  176. color: var(--color-666);
  177. margin-left: 4px;
  178. }
  179. .upload--text {
  180. float: right;
  181. color: var(--v-primary-base);
  182. font-size: 12px;
  183. }
  184. .last-update {
  185. font-size: 12px;
  186. color: var(--color-666);
  187. }
  188. .attachment-item {
  189. color: #555;
  190. font-size: 14px;
  191. .file-name {
  192. width: 219px;
  193. }
  194. }
  195. }
  196. </style>