basicInfo.vue 16 KB

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