basicInfo.vue 15 KB

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