basicInfo.vue 15 KB

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