basicInfo.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490
  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="getUserAvatar(baseInfo?.avatar, baseInfo?.sex)">
  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="items" 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: 600;color: var(--color-666);">{{ 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 || $t('common.currentlyUnavailable') }}</span>
  64. </div>
  65. <div>
  66. <span class="mdi mdi-phone-outline"></span>
  67. <span>{{ baseInfo?.phone || $t('common.currentlyUnavailable') }}</span>
  68. </div>
  69. <div>
  70. <span class="mdi mdi-email-outline"></span>
  71. <span>{{ baseInfo?.email || $t('common.currentlyUnavailable') }}</span>
  72. </div>
  73. <div>
  74. <span class="mdi mdi-calendar-blank-outline"></span>
  75. <span>{{ baseInfo?.expTypeText || $t('common.currentlyUnavailable') }}</span>
  76. </div>
  77. <div>
  78. <span class="mdi mdi-school-outline"></span>
  79. <span>{{ baseInfo?.eduTypeText || $t('common.currentlyUnavailable') }}</span>
  80. </div>
  81. <!-- <div>
  82. <span class="mdi mdi-briefcase-outline"></span>
  83. <span>{{ baseInfo?.jobTypeText || $t('common.currentlyUnavailable') }}</span>
  84. </div> -->
  85. <div>
  86. <span class="mdi mdi-tag-outline"></span>
  87. <span>{{ baseInfo?.jobStatusText || $t('common.currentlyUnavailable') }}</span>
  88. </div>
  89. <div>
  90. <span class="mdi mdi-cake-variant-outline"></span>
  91. <span>{{ baseInfo?.birthdayText || $t('common.currentlyUnavailable') }}</span>
  92. </div>
  93. <div>
  94. <span class="mdi mdi-account-heart"></span>
  95. <span>{{ baseInfo?.maritalText || $t('common.currentlyUnavailable') }}</span>
  96. </div>
  97. <div>
  98. <span>{{ $t('resume.firstWorkTime') }}:</span>
  99. <span>{{ baseInfo?.firstWorkTimeText || $t('common.currentlyUnavailable') }}</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 { getDict } from '@/hooks/web/useDictionaries'
  120. import { cityToProvince } from '@/utils/areaDeal'
  121. import { getTimeStamp, timesTampChange } from '@/utils/date'
  122. import { updatePersonAvatar, saveResumeBasicInfo } from '@/api/recruit/personal/resume'
  123. import { useUserStore } from '@/store/user'
  124. import { uploadFile } from '@/api/common'
  125. import { getUserAvatar } from '@/utils/avatar'
  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. const key = localStorage.getItem('baseInfo')
  139. if (!key || !Object.keys(key).length) return
  140. baseInfo.value = JSON.parse(key) // 人才信息
  141. }
  142. getBasicInfo()
  143. // 选择文件
  144. const fileInput = ref()
  145. const clicked = ref(false)
  146. const openFileInput = () => {
  147. if (clicked.value) return
  148. clicked.value = true
  149. fileInput.value.click()
  150. clicked.value = false
  151. }
  152. // 上传头像
  153. const handleUploadFile = async (e) => {
  154. const file = e.target.files[0]
  155. if (!file) return
  156. const formData = new FormData()
  157. formData.append('file', file)
  158. const { data } = await uploadFile(formData)
  159. if (!data) return
  160. Snackbar.success(t('common.uploadSucMsg'))
  161. await updatePersonAvatar(data)
  162. await userStore.getUserBaseInfos(baseInfo.value.userId)
  163. getBasicInfo()
  164. }
  165. const items = ref({
  166. options: [
  167. {
  168. type: 'text',
  169. key: 'name',
  170. value: null,
  171. default: null,
  172. label: '姓名 *',
  173. col: 6,
  174. outlined: true,
  175. rules: [v => !!v || '请输入姓名']
  176. },
  177. {
  178. type: 'ifRadio',
  179. key: 'sex',
  180. value: '0', // '1' ? '男' : '女'
  181. default: 0,
  182. label: '性别',
  183. col: 6,
  184. width: 70,
  185. dictTypeName: 'system_user_sex',
  186. items: [],
  187. },
  188. {
  189. type: 'datePicker',
  190. key: 'birthday',
  191. value: null,
  192. default: null,
  193. col: 6,
  194. class: 'mb-3',
  195. rules: [v => !!v || '请选择出生日期'],
  196. options: {
  197. type: 'date',
  198. format: 'timestamp',
  199. placeholder: '出生日期 *',
  200. clearable: false,
  201. // disabled: true,
  202. },
  203. },
  204. {
  205. type: 'phoneNumber',
  206. key: 'phone',
  207. value: null,
  208. default: null,
  209. label: '电话号码',
  210. col: 6,
  211. outlined: true,
  212. rules: [v => !!v || '请填写手机号码']
  213. // disabled: true,
  214. // slotName: 'phone',
  215. },
  216. // {
  217. // slotName: 'areaType',
  218. // key: 'areaId',
  219. // value: null,
  220. // label: '所在城市 *',
  221. // nameKey: 'areaName', // 展示出来id对应的内容
  222. // col: 6,
  223. // flexStyle: 'mr-3',
  224. // rules: [v => !!v || '请选择所在城市']
  225. // },
  226. {
  227. type: 'text',
  228. key: 'email',
  229. value: null,
  230. default: null,
  231. label: '常用邮箱 *',
  232. col: 6,
  233. outlined: true,
  234. rules: [v => !!v || '请输入常用邮箱']
  235. },
  236. {
  237. type: 'autocomplete',
  238. key: 'expType',
  239. value: null,
  240. default: null,
  241. label: '工作经验 *',
  242. col: 6,
  243. outlined: true,
  244. itemText: 'label',
  245. itemValue: 'value',
  246. dictTypeName: 'menduner_exp_type',
  247. rules: [v => !!v || '请选择工作经验'],
  248. items: []
  249. },
  250. {
  251. type: 'autocomplete',
  252. key: 'eduType',
  253. value: null,
  254. default: null,
  255. label: '最高学历 *',
  256. col: 6,
  257. outlined: true,
  258. itemText: 'label',
  259. itemValue: 'value',
  260. dictTypeName: 'menduner_education_type',
  261. rules: [v => !!v || '请选择最高学历'],
  262. items: []
  263. },
  264. {
  265. type: 'autocomplete',
  266. key: 'jobType',
  267. value: null,
  268. default: null,
  269. label: '求职类型 *',
  270. col: 6,
  271. outlined: true,
  272. itemText: 'label',
  273. itemValue: 'value',
  274. dictTypeName: 'menduner_job_type',
  275. rules: [v => !!v || '请选择求职类型'],
  276. items: []
  277. },
  278. {
  279. type: 'autocomplete',
  280. key: 'jobStatus',
  281. value: null,
  282. default: null,
  283. label: '求职状态 *',
  284. col: 6,
  285. outlined: true,
  286. itemText: 'label',
  287. itemValue: 'value',
  288. dictTypeName: 'menduner_job_status',
  289. rules: [v => !!v || '请选择求职状态'],
  290. items: []
  291. },
  292. {
  293. type: 'autocomplete',
  294. key: 'maritalStatus',
  295. value: null,
  296. default: null,
  297. label: '婚姻状况 *',
  298. col: 6,
  299. outlined: true,
  300. itemText: 'label',
  301. itemValue: 'value',
  302. dictTypeName: 'menduner_marital_status',
  303. rules: [v => !!v || '请选择婚姻状况'],
  304. items: []
  305. },
  306. {
  307. type: 'autocomplete',
  308. key: 'workAreaProvinceId',
  309. value: null,
  310. label: '所在城市:省 *',
  311. outlined: true,
  312. itemText: 'name',
  313. itemValue: 'id',
  314. returnSelect: true,
  315. noParam: true,
  316. col: 6,
  317. flexStyle: 'mr-3',
  318. rules: [v => !!v || '请选择所在城市:省'],
  319. items: [],
  320. change: null
  321. },
  322. {
  323. type: 'autocomplete',
  324. key: 'areaId',
  325. value: null,
  326. label: '所在城市:市 *',
  327. outlined: true,
  328. itemText: 'name',
  329. itemValue: 'id',
  330. col: 6,
  331. rules: [v => !!v || '请选择所在城市:市'],
  332. items: [],
  333. change: null
  334. },
  335. {
  336. type: 'datePicker',
  337. key: 'firstWorkTime',
  338. value: null,
  339. default: null,
  340. col: 6,
  341. class: 'mb-3',
  342. options: {
  343. type: 'month',
  344. format: 'timestamp',
  345. placeholder: '首次工作时间 *',
  346. },
  347. rules: [v => !!v || '请选择首次工作时间']
  348. },
  349. ]
  350. })
  351. // 保存-基础信息
  352. const handleSave = async () => {
  353. const { valid } = await CtFormRef.value.formRef.validate()
  354. if (!valid) return
  355. const obj = {}
  356. items.value.options.forEach(e => {
  357. if (e.type === 'datepicker') obj[e.key] = getTimeStamp(e.value)
  358. else obj[e.key] = e.value
  359. })
  360. await saveResumeBasicInfo(obj)
  361. Snackbar.success(t('common.saveMsg'))
  362. isEdit.value = false
  363. // 获取当前登录账户信息
  364. // if (baseInfo.value.userId) await userStore.getUserBaseInfos(baseInfo.value.userId)
  365. await userStore.getUserBaseInfos(baseInfo.value.userId || null)
  366. getBasicInfo()
  367. }
  368. // 获取字典内容
  369. const getDictData = async (dictTypeName) => {
  370. const item = items.value.options.find(e => e.dictTypeName === dictTypeName)
  371. if (item) {
  372. const { data } = await getDict(dictTypeName)
  373. item.items = data
  374. }
  375. }
  376. let workAreaId = ''
  377. const deal = async () => {
  378. if (workAreaId) { // 省份回显
  379. const province = items.value.options.find(pv => pv.key === 'workAreaProvinceId')
  380. if (province) {
  381. const dealReturnObj = await cityToProvince(workAreaId, {}, province.items || [])
  382. const city = items.value.options.find(pv => pv.key === 'areaId')
  383. if (city) city.items = dealReturnObj.cityList || []
  384. province.value = dealReturnObj.pid || ''
  385. }
  386. }
  387. }
  388. items.value.options.forEach((e, index) => {
  389. if ((index + 2) % 2 === 0) e.flexStyle = 'mr-3'
  390. if (e.dictTypeName) getDictData(e.dictTypeName) // 查字典set options
  391. // formItems回显
  392. const infoExist = baseInfo.value && Object.keys(baseInfo.value).length
  393. if (infoExist && baseInfo.value[e.key]) e.value = baseInfo.value[e.key]
  394. // 日期相关
  395. if (e.type === 'datepicker') e.value = timesTampChange(e.value, 'Y-M-D')
  396. // 所在城市回显
  397. // if (infoExist && e.nameKey) e[e.nameKey] = baseInfo.value[e.nameKey]
  398. if (infoExist && e.key === 'areaId' && baseInfo.value[e.key]) {
  399. workAreaId = baseInfo.value[e.key]
  400. deal()
  401. }
  402. })
  403. const provinceChange = (value, val, obj) => {
  404. const item = items.value.options.find(e => e.key === 'areaId')
  405. if (!item) return
  406. item.items = obj.children || []
  407. item.value = null
  408. }
  409. getDict('areaTreeData', null, 'areaTreeData').then(({ data }) => {
  410. data = data?.length && data || []
  411. if (!data?.length) return console.error('areaTreeData获取失败!')
  412. //
  413. const china = data.find(e => e.id === '1')
  414. const chinaTreeData = china?.children?.length ? china.children : []
  415. //
  416. if (!chinaTreeData?.length) return console.error('chinaTreeData获取失败!')
  417. const item = items.value.options.find(e => e.key === 'workAreaProvinceId')
  418. if (item?.items) {
  419. item.items = chinaTreeData
  420. item.change = provinceChange
  421. }
  422. })
  423. </script>
  424. <style lang="scss" scoped>
  425. .jobTypeCardBox {
  426. position: absolute;
  427. top: -22px;
  428. left: 0;
  429. }
  430. .avatarsBox {
  431. height: 80px;
  432. width: 80px;
  433. position: relative;
  434. cursor: pointer;
  435. margin: 32px;
  436. margin-right: 40px;
  437. .img {
  438. width: 100%;
  439. height: 100%;
  440. }
  441. .mdi {
  442. font-size: 42px;
  443. color: #fff;
  444. }
  445. div {
  446. position: absolute;
  447. top: 50%;
  448. left: 50%;
  449. transform: translate(-50%, -50%);
  450. border-radius: 50%;
  451. }
  452. }
  453. .listBox {
  454. display: flex;
  455. flex-wrap: wrap; /* 允许换行 */
  456. width: 100%; /* 设置容器宽度 */
  457. // height: 68px;
  458. overflow: hidden;
  459. color: var(--color-666);
  460. div {
  461. margin-right: 50px;
  462. span {
  463. height: 32px;
  464. line-height: 32px;
  465. }
  466. .mdi {
  467. font-size: 22px;
  468. margin-right: 8px;
  469. // margin-top: 2px;
  470. }
  471. }
  472. // border: 1px solid red; /* 可视化边界 */
  473. // .jobItems {
  474. // font-size: 14px;
  475. // margin-left: 12px;
  476. // cursor: pointer;
  477. // color: var(--color-666);
  478. // font-family: 微软雅黑;
  479. // }
  480. }
  481. </style>