basicInfo.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439
  1. <template>
  2. <div class="resume-box">
  3. <div class="resume-header">
  4. <div class="resume-title">{{ $t('resume.basicInfo') }}</div>
  5. <v-btn v-if="!isEdit" variant="text" color="primary" prepend-icon="mdi-square-edit-outline" @click="isEdit = true">{{ $t('common.edit') }}</v-btn>
  6. </div>
  7. <div class="d-flex align-center">
  8. <!-- 头像 -->
  9. <div class="avatarsBox" @mouseover="showIcon = true" @mouseleave="showIcon = false">
  10. <v-badge
  11. bordered
  12. offset-x="-25"
  13. offset-y="33"
  14. :color="baseInfo?.sex ? (baseInfo?.sex === '1' ? '#1867c0' : 'error') : 'error'"
  15. :icon="baseInfo?.sex ? (baseInfo?.sex === '1' ? 'mdi-gender-male' : 'mdi-gender-female') : 'mdi-gender-female'">
  16. <v-avatar size=80 :image="baseInfo.avatar || 'https://minio.citupro.com/dev/menduner/7.png'">
  17. </v-avatar>
  18. <div v-show="showIcon" @click="openFileInput" v-bind="$attrs" class="mdi mdi-camera-outline">
  19. <input
  20. type="file"
  21. ref="fileInput"
  22. accept="image/png, image/jpg, image/jpeg"
  23. style="display: none;"
  24. @change="handleUploadFile"
  25. />
  26. </div>
  27. </v-badge>
  28. </div>
  29. <!-- 基础信息 -->
  30. <div style="flex: 1;" class="mr-8 mt-5">
  31. <!-- 编辑 -->
  32. <div v-if="isEdit">
  33. <CtForm ref="CtFormRef" :items="formItems" style="width: 100%;">
  34. <template v-slot:phone>
  35. <v-btn variant="text" class="ml-2" color="primary">{{ $t('common.change') }}</v-btn>
  36. </template>
  37. <template #areaType="{ item }">
  38. <v-menu :close-delay="1" :open-delay="0" v-bind="$attrs">
  39. <template v-slot:activator="{ props }">
  40. <textUI
  41. v-model="item[item.nameKey]"
  42. :item="item"
  43. v-bind="props"
  44. style="position: relative;"
  45. ></textUI>
  46. </template>
  47. <areaType :isIntType="false" :select="[baseInfo?.areaId].filter(Boolean)" @handleAreaClick="handleArea" class="jobTypeCardBox" isSingle></areaType>
  48. </v-menu>
  49. </template>
  50. </CtForm>
  51. <div class="text-end">
  52. <v-btn class="half-button mr-3" variant="tonal" @click="isEdit = false">{{ $t('common.cancel') }}</v-btn>
  53. <v-btn color="primary" class="half-button" @click="handleSave">{{ $t('common.save') }}</v-btn>
  54. </div>
  55. </div>
  56. <!-- 展示 -->
  57. <div v-else>
  58. <span style="font-size: 20px; font-weight: 500;">{{ baseInfo.name }}</span>
  59. <div class="mt-3 d-flex">
  60. <div class="listBox" :style="{ height: isExpand ? 'auto' : '68px' }">
  61. <div>
  62. <span class="mdi mdi-map-marker-outline"></span>
  63. <span>{{ baseInfo.areaName || '暂无' }}</span>
  64. </div>
  65. <div>
  66. <span class="mdi mdi-phone-outline"></span>
  67. <span>{{ baseInfo.phone }}</span>
  68. </div>
  69. <div>
  70. <span class="mdi mdi-email-outline"></span>
  71. <span>{{ baseInfo.email }}</span>
  72. </div>
  73. <div>
  74. <span class="mdi mdi-calendar-blank-outline"></span>
  75. <span>{{ baseInfo.expTypeText }}</span>
  76. </div>
  77. <div>
  78. <span class="mdi mdi-school-outline"></span>
  79. <span>{{ baseInfo.eduTypeText }}</span>
  80. </div>
  81. <!-- <div>
  82. <span class="mdi mdi-briefcase-outline"></span>
  83. <span>{{ baseInfo.jobTypeText }}</span>
  84. </div> -->
  85. <div>
  86. <span class="mdi mdi-tag-outline"></span>
  87. <span>{{ baseInfo.jobStatusText }}</span>
  88. </div>
  89. <div>
  90. <span class="mdi mdi-cake-variant-outline"></span>
  91. <span>{{ baseInfo.birthdayText }}</span>
  92. </div>
  93. <div>
  94. <span class="mdi mdi-account-heart"></span>
  95. <span>{{ baseInfo.maritalText }}</span>
  96. </div>
  97. <div>
  98. <span>{{ $t('resume.firstWorkTime') }}:</span>
  99. <span>{{ baseInfo.firstWorkTimeText }}</span>
  100. </div>
  101. </div>
  102. <div class="ml-3">
  103. <v-btn variant="text" color="primary" v-if="isExpand" @click="isExpand = false">{{ $t('resume.retract') }}</v-btn>
  104. <v-btn variant="text" color="primary" v-else @click="isExpand = true">{{ $t('resume.expand') }}</v-btn>
  105. </div>
  106. </div>
  107. <div class="mt-4">
  108. <span style="font-size: 15px;">个人画像:</span>
  109. <v-chip size="small" label v-for="(k, i) in welfareList.slice(0, 8)" :key="i" class="mr-2" color="primary">{{ k }}</v-chip>
  110. </div>
  111. </div>
  112. </div>
  113. </div>
  114. </div>
  115. </template>
  116. <script setup>
  117. import CtForm from '@/components/CtForm'
  118. import Snackbar from '@/plugins/snackbar'
  119. import areaType from '@/components/AreaSelect'
  120. import textUI from '@/components/FormUI/TextInput'
  121. import { getDict } from '@/hooks/web/useDictionaries'
  122. import { getTimeStamp, timesTampChange } from '@/utils/date'
  123. import { saveResumeBasicInfo } from '@/api/resume'
  124. import { useUserStore } from '@/store/user'
  125. import { uploadFile } from '@/api/common'
  126. import { useI18n } from '@/hooks/web/useI18n'
  127. import { ref } from 'vue';
  128. defineOptions({name: 'resume-components-basicInfo'})
  129. const { t } = useI18n()
  130. const userStore = useUserStore()
  131. const CtFormRef = ref()
  132. const isEdit = ref(false)
  133. const showIcon = ref(false)
  134. const isExpand = ref(false)
  135. const welfareList = ref(['热情活泼', '理性冷静', '富有创新', '热爱生活', '有幽默感'])
  136. let baseInfo = ref({})
  137. const getBasicInfo = () => { // 获取基础信息
  138. baseInfo.value = JSON.parse(localStorage.getItem('baseInfo')) // 人才信息
  139. }
  140. getBasicInfo()
  141. // 选择文件
  142. const fileInput = ref()
  143. const clicked = ref(false)
  144. const openFileInput = () => {
  145. if (clicked.value) return
  146. clicked.value = true
  147. fileInput.value.click()
  148. clicked.value = false
  149. }
  150. // 上传头像
  151. const handleUploadFile = async (e) => {
  152. const file = e.target.files[0]
  153. const formData = new FormData()
  154. formData.append('file', file)
  155. const { data } = await uploadFile(formData)
  156. if (!data) return
  157. Snackbar.success(t('common.uploadSucMsg'))
  158. // 保存信息
  159. await saveResumeBasicInfo({ ...baseInfo.value, avatar: data })
  160. await userStore.getUserBaseInfos(baseInfo.value.userId)
  161. getBasicInfo()
  162. }
  163. const formItems = ref({
  164. options: [
  165. {
  166. type: 'text',
  167. key: 'name',
  168. value: null,
  169. default: null,
  170. label: '姓名 *',
  171. col: 6,
  172. outlined: true,
  173. rules: [v => !!v || '请输入姓名']
  174. },
  175. {
  176. type: 'ifRadio',
  177. key: 'sex',
  178. value: '0', // '1' ? '男' : '女'
  179. default: 0,
  180. label: '性别',
  181. col: 6,
  182. width: 70,
  183. dictTypeName: 'system_user_sex',
  184. items: [],
  185. },
  186. {
  187. type: 'datePicker',
  188. key: 'birthday',
  189. value: null,
  190. default: null,
  191. col: 6,
  192. class: 'mb-3',
  193. options: {
  194. type: 'date',
  195. format: 'timestamp',
  196. placeholder: '出生日期 *',
  197. disabled: true,
  198. },
  199. },
  200. {
  201. type: 'text',
  202. key: 'phone',
  203. value: null,
  204. default: null,
  205. label: '电话号码',
  206. col: 6,
  207. outlined: true,
  208. disabled: true,
  209. slotName: 'phone',
  210. },
  211. {
  212. slotName: 'areaType',
  213. key: 'areaId',
  214. value: null,
  215. label: '所在城市 *',
  216. nameKey: 'areaName', // 展示出来id对应的内容
  217. col: 6,
  218. flexStyle: 'mr-3',
  219. rules: [v => !!v || '请选择所在城市']
  220. },
  221. {
  222. type: 'text',
  223. key: 'email',
  224. value: null,
  225. default: null,
  226. label: '常用邮箱 *',
  227. col: 6,
  228. outlined: true,
  229. rules: [v => !!v || '请输入常用邮箱']
  230. },
  231. {
  232. type: 'autocomplete',
  233. key: 'expType',
  234. value: null,
  235. default: null,
  236. label: '工作经验 *',
  237. col: 6,
  238. outlined: true,
  239. itemText: 'label',
  240. itemValue: 'value',
  241. dictTypeName: 'menduner_exp_type',
  242. rules: [v => !!v || '请选择工作经验'],
  243. items: []
  244. },
  245. {
  246. type: 'autocomplete',
  247. key: 'eduType',
  248. value: null,
  249. default: null,
  250. label: '最高学历 *',
  251. col: 6,
  252. outlined: true,
  253. itemText: 'label',
  254. itemValue: 'value',
  255. dictTypeName: 'menduner_education_type',
  256. rules: [v => !!v || '请选择最高学历'],
  257. items: []
  258. },
  259. {
  260. type: 'autocomplete',
  261. key: 'jobType',
  262. value: null,
  263. default: null,
  264. label: '求职类型 *',
  265. col: 6,
  266. outlined: true,
  267. itemText: 'label',
  268. itemValue: 'value',
  269. dictTypeName: 'menduner_job_type',
  270. rules: [v => !!v || '请选择求职类型'],
  271. items: []
  272. },
  273. {
  274. type: 'autocomplete',
  275. key: 'jobStatus',
  276. value: null,
  277. default: null,
  278. label: '求职状态 *',
  279. col: 6,
  280. outlined: true,
  281. itemText: 'label',
  282. itemValue: 'value',
  283. rules: [v => !!v || '请选择求职状态'],
  284. items: [
  285. { label: '离职-随时到岗', value: '0' },
  286. { label: '在职-月内到岗', value: '1' },
  287. { label: '在职-考虑机会', value: '2' },
  288. { label: '在职-暂不考虑', value: '3' }
  289. ]
  290. },
  291. {
  292. type: 'autocomplete',
  293. key: 'maritalStatus',
  294. value: null,
  295. default: null,
  296. label: '婚姻状况 *',
  297. col: 6,
  298. outlined: true,
  299. itemText: 'label',
  300. itemValue: 'value',
  301. rules: [v => !!v || '请选择婚姻状况'],
  302. items: [
  303. { label: '未婚', value: '0' },
  304. { label: '已婚', value: '1' },
  305. { label: '离异', value: '2' },
  306. { label: '保密', value: '3' }
  307. ]
  308. },
  309. {
  310. type: 'datePicker',
  311. key: 'firstWorkTime',
  312. value: null,
  313. default: null,
  314. col: 6,
  315. class: 'mb-3',
  316. options: {
  317. type: 'month',
  318. format: 'timestamp',
  319. placeholder: '首次工作时间 *',
  320. },
  321. rules: [v => !!v || '请选择首次工作时间']
  322. },
  323. ]
  324. })
  325. // 保存-基础信息
  326. const handleSave = async () => {
  327. const { valid } = await CtFormRef.value.formRef.validate()
  328. if (!valid) return
  329. const obj = {}
  330. formItems.value.options.forEach(e => {
  331. if (e.type === 'datepicker') obj[e.key] = getTimeStamp(e.value)
  332. else obj[e.key] = e.value
  333. })
  334. await saveResumeBasicInfo(obj)
  335. Snackbar.success(t('common.saveMsg'))
  336. isEdit.value = false
  337. // 获取当前登录账户信息
  338. await userStore.getUserBaseInfos(baseInfo.value.userId)
  339. await getBasicInfo()
  340. }
  341. // 城市
  342. const setValue = (key, id, name) => {
  343. const item = formItems.value.options.find(e => e.key === key)
  344. if (item) {
  345. item.value = id
  346. item[item.nameKey] = name
  347. }
  348. }
  349. const handleArea = (list, name) => {
  350. if (!list.length) return
  351. const id = list[0]
  352. setValue('areaId', id, name)
  353. }
  354. // 获取字典内容
  355. const getDictData = async (dictTypeName) => {
  356. const item = formItems.value.options.find(e => e.dictTypeName === dictTypeName)
  357. if (item) {
  358. const { data } = await getDict(dictTypeName)
  359. item.items = data
  360. }
  361. }
  362. formItems.value.options.forEach((e, index) => {
  363. if ((index + 2) % 2 === 0) e.flexStyle = 'mr-3'
  364. if (e.dictTypeName) getDictData(e.dictTypeName) // 查字典set options
  365. // formItems回显
  366. if (baseInfo.value[e.key]) e.value = baseInfo.value[e.key]
  367. // 日期相关
  368. if (e.type === 'datepicker') e.value = timesTampChange(e.value).slice(0, 10)
  369. // 所在城市回显
  370. if (e.nameKey) e[e.nameKey] = baseInfo.value[e.nameKey]
  371. })
  372. </script>
  373. <style lang="scss" scoped>
  374. .jobTypeCardBox {
  375. position: absolute;
  376. top: -22px;
  377. left: 0;
  378. }
  379. .avatarsBox {
  380. height: 80px;
  381. width: 80px;
  382. position: relative;
  383. cursor: pointer;
  384. margin: 32px;
  385. margin-right: 40px;
  386. .img {
  387. width: 100%;
  388. height: 100%;
  389. }
  390. .mdi {
  391. font-size: 42px;
  392. color: #fff;
  393. }
  394. div {
  395. position: absolute;
  396. top: 50%;
  397. left: 50%;
  398. transform: translate(-50%, -50%);
  399. border-radius: 50%;
  400. }
  401. }
  402. .listBox {
  403. display: flex;
  404. flex-wrap: wrap; /* 允许换行 */
  405. width: 100%; /* 设置容器宽度 */
  406. // height: 68px;
  407. overflow: hidden;
  408. div {
  409. margin-right: 50px;
  410. span {
  411. height: 32px;
  412. line-height: 32px;
  413. }
  414. .mdi {
  415. font-size: 22px;
  416. margin-right: 8px;
  417. // margin-top: 2px;
  418. }
  419. }
  420. // border: 1px solid red; /* 可视化边界 */
  421. // .jobItems {
  422. // font-size: 14px;
  423. // margin-left: 12px;
  424. // cursor: pointer;
  425. // color: #666666;
  426. // font-family: 微软雅黑;
  427. // }
  428. }
  429. </style>