basicInfo.vue 15 KB

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