basicInfo.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434
  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="formItems" 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: #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 areaType from '@/components/AreaSelect'
  120. import textUI from '@/components/FormUI/TextInput'
  121. import { getDict } from '@/hooks/web/useDictionaries'
  122. import { getTimeStamp, timesTampChange } from '@/utils/date'
  123. import { saveResumeBasicInfo } from '@/api/resume'
  124. import { useUserStore } from '@/store/user'
  125. import { uploadFile } from '@/api/common'
  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. baseInfo.value = JSON.parse(localStorage.getItem('baseInfo')) || {} // 人才信息
  139. }
  140. getBasicInfo()
  141. // 选择文件
  142. const fileInput = ref()
  143. const clicked = ref(false)
  144. const openFileInput = () => {
  145. if (clicked.value) return
  146. clicked.value = true
  147. fileInput.value.click()
  148. clicked.value = false
  149. }
  150. // 上传头像
  151. const handleUploadFile = async (e) => {
  152. const file = e.target.files[0]
  153. const formData = new FormData()
  154. formData.append('file', file)
  155. const { data } = await uploadFile(formData)
  156. if (!data) return
  157. Snackbar.success(t('common.uploadSucMsg'))
  158. // 保存信息
  159. await saveResumeBasicInfo({ ...baseInfo.value, avatar: data })
  160. if (baseInfo.value.userId) await userStore.getUserBaseInfos(baseInfo.value.userId)
  161. getBasicInfo()
  162. }
  163. const formItems = 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. // disabled: true,
  211. // slotName: 'phone',
  212. },
  213. {
  214. slotName: 'areaType',
  215. key: 'areaId',
  216. value: null,
  217. label: '所在城市 *',
  218. nameKey: 'areaName', // 展示出来id对应的内容
  219. col: 6,
  220. flexStyle: 'mr-3',
  221. rules: [v => !!v || '请选择所在城市']
  222. },
  223. {
  224. type: 'text',
  225. key: 'email',
  226. value: null,
  227. default: null,
  228. label: '常用邮箱 *',
  229. col: 6,
  230. outlined: true,
  231. rules: [v => !!v || '请输入常用邮箱']
  232. },
  233. {
  234. type: 'autocomplete',
  235. key: 'expType',
  236. value: null,
  237. default: null,
  238. label: '工作经验 *',
  239. col: 6,
  240. outlined: true,
  241. itemText: 'label',
  242. itemValue: 'value',
  243. dictTypeName: 'menduner_exp_type',
  244. rules: [v => !!v || '请选择工作经验'],
  245. items: []
  246. },
  247. {
  248. type: 'autocomplete',
  249. key: 'eduType',
  250. value: null,
  251. default: null,
  252. label: '最高学历 *',
  253. col: 6,
  254. outlined: true,
  255. itemText: 'label',
  256. itemValue: 'value',
  257. dictTypeName: 'menduner_education_type',
  258. rules: [v => !!v || '请选择最高学历'],
  259. items: []
  260. },
  261. {
  262. type: 'autocomplete',
  263. key: 'jobType',
  264. value: null,
  265. default: null,
  266. label: '求职类型 *',
  267. col: 6,
  268. outlined: true,
  269. itemText: 'label',
  270. itemValue: 'value',
  271. dictTypeName: 'menduner_job_type',
  272. rules: [v => !!v || '请选择求职类型'],
  273. items: []
  274. },
  275. {
  276. type: 'autocomplete',
  277. key: 'jobStatus',
  278. value: null,
  279. default: null,
  280. label: '求职状态 *',
  281. col: 6,
  282. outlined: true,
  283. itemText: 'label',
  284. itemValue: 'value',
  285. dictTypeName: 'menduner_job_status',
  286. rules: [v => !!v || '请选择求职状态'],
  287. items: []
  288. },
  289. {
  290. type: 'autocomplete',
  291. key: 'maritalStatus',
  292. value: null,
  293. default: null,
  294. label: '婚姻状况 *',
  295. col: 6,
  296. outlined: true,
  297. itemText: 'label',
  298. itemValue: 'value',
  299. dictTypeName: 'menduner_marital_status',
  300. rules: [v => !!v || '请选择婚姻状况'],
  301. items: []
  302. },
  303. {
  304. type: 'datePicker',
  305. key: 'firstWorkTime',
  306. value: null,
  307. default: null,
  308. col: 6,
  309. class: 'mb-3',
  310. options: {
  311. type: 'month',
  312. format: 'timestamp',
  313. placeholder: '首次工作时间 *',
  314. },
  315. rules: [v => !!v || '请选择首次工作时间']
  316. },
  317. ]
  318. })
  319. // 保存-基础信息
  320. const handleSave = async () => {
  321. const { valid } = await CtFormRef.value.formRef.validate()
  322. if (!valid) return
  323. const obj = {}
  324. formItems.value.options.forEach(e => {
  325. if (e.type === 'datepicker') obj[e.key] = getTimeStamp(e.value)
  326. else obj[e.key] = e.value
  327. })
  328. await saveResumeBasicInfo(obj)
  329. Snackbar.success(t('common.saveMsg'))
  330. isEdit.value = false
  331. // 获取当前登录账户信息
  332. if (baseInfo.value.userId) await userStore.getUserBaseInfos(baseInfo.value.userId)
  333. await getBasicInfo()
  334. }
  335. // 城市
  336. const setValue = (key, id, name) => {
  337. const item = formItems.value.options.find(e => e.key === key)
  338. if (item) {
  339. item.value = id
  340. item[item.nameKey] = name
  341. }
  342. }
  343. const handleArea = (list, name) => {
  344. if (!list.length) return
  345. const id = list[0]
  346. setValue('areaId', id, name)
  347. }
  348. // 获取字典内容
  349. const getDictData = async (dictTypeName) => {
  350. const item = formItems.value.options.find(e => e.dictTypeName === dictTypeName)
  351. if (item) {
  352. const { data } = await getDict(dictTypeName)
  353. item.items = data
  354. }
  355. }
  356. formItems.value.options.forEach((e, index) => {
  357. if ((index + 2) % 2 === 0) e.flexStyle = 'mr-3'
  358. if (e.dictTypeName) getDictData(e.dictTypeName) // 查字典set options
  359. // formItems回显
  360. const infoExist = baseInfo.value && Object.keys(baseInfo.value).length
  361. if (infoExist && baseInfo.value[e.key]) e.value = baseInfo.value[e.key]
  362. // 日期相关
  363. if (e.type === 'datepicker') e.value = timesTampChange(e.value).slice(0, 10)
  364. // 所在城市回显
  365. if (infoExist && e.nameKey) e[e.nameKey] = baseInfo.value[e.nameKey]
  366. })
  367. </script>
  368. <style lang="scss" scoped>
  369. .jobTypeCardBox {
  370. position: absolute;
  371. top: -22px;
  372. left: 0;
  373. }
  374. .avatarsBox {
  375. height: 80px;
  376. width: 80px;
  377. position: relative;
  378. cursor: pointer;
  379. margin: 32px;
  380. margin-right: 40px;
  381. .img {
  382. width: 100%;
  383. height: 100%;
  384. }
  385. .mdi {
  386. font-size: 42px;
  387. color: #fff;
  388. }
  389. div {
  390. position: absolute;
  391. top: 50%;
  392. left: 50%;
  393. transform: translate(-50%, -50%);
  394. border-radius: 50%;
  395. }
  396. }
  397. .listBox {
  398. display: flex;
  399. flex-wrap: wrap; /* 允许换行 */
  400. width: 100%; /* 设置容器宽度 */
  401. // height: 68px;
  402. overflow: hidden;
  403. color: #666;
  404. div {
  405. margin-right: 50px;
  406. span {
  407. height: 32px;
  408. line-height: 32px;
  409. }
  410. .mdi {
  411. font-size: 22px;
  412. margin-right: 8px;
  413. // margin-top: 2px;
  414. }
  415. }
  416. // border: 1px solid red; /* 可视化边界 */
  417. // .jobItems {
  418. // font-size: 14px;
  419. // margin-left: 12px;
  420. // cursor: pointer;
  421. // color: #666666;
  422. // font-family: 微软雅黑;
  423. // }
  424. }
  425. </style>