basicInfo.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433
  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 || '暂无' }}</span>
  64. </div>
  65. <div>
  66. <span class="mdi mdi-phone-outline"></span>
  67. <span>{{ baseInfo?.phone }}</span>
  68. </div>
  69. <div>
  70. <span class="mdi mdi-email-outline"></span>
  71. <span>{{ baseInfo?.email }}</span>
  72. </div>
  73. <div>
  74. <span class="mdi mdi-calendar-blank-outline"></span>
  75. <span>{{ baseInfo?.expTypeText }}</span>
  76. </div>
  77. <div>
  78. <span class="mdi mdi-school-outline"></span>
  79. <span>{{ baseInfo?.eduTypeText }}</span>
  80. </div>
  81. <!-- <div>
  82. <span class="mdi mdi-briefcase-outline"></span>
  83. <span>{{ baseInfo?.jobTypeText }}</span>
  84. </div> -->
  85. <div>
  86. <span class="mdi mdi-tag-outline"></span>
  87. <span>{{ baseInfo?.jobStatusText }}</span>
  88. </div>
  89. <div>
  90. <span class="mdi mdi-cake-variant-outline"></span>
  91. <span>{{ baseInfo?.birthdayText }}</span>
  92. </div>
  93. <div>
  94. <span class="mdi mdi-account-heart"></span>
  95. <span>{{ baseInfo?.maritalText }}</span>
  96. </div>
  97. <div>
  98. <span>{{ $t('resume.firstWorkTime') }}:</span>
  99. <span>{{ baseInfo?.firstWorkTimeText }}</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. options: {
  194. type: 'date',
  195. format: 'timestamp',
  196. placeholder: '出生日期 *',
  197. disabled: true,
  198. },
  199. },
  200. {
  201. type: 'text',
  202. key: 'phone',
  203. value: null,
  204. default: null,
  205. label: '电话号码',
  206. col: 6,
  207. outlined: true,
  208. disabled: true,
  209. slotName: 'phone',
  210. },
  211. {
  212. slotName: 'areaType',
  213. key: 'areaId',
  214. value: null,
  215. label: '所在城市 *',
  216. nameKey: 'areaName', // 展示出来id对应的内容
  217. col: 6,
  218. flexStyle: 'mr-3',
  219. rules: [v => !!v || '请选择所在城市']
  220. },
  221. {
  222. type: 'text',
  223. key: 'email',
  224. value: null,
  225. default: null,
  226. label: '常用邮箱 *',
  227. col: 6,
  228. outlined: true,
  229. rules: [v => !!v || '请输入常用邮箱']
  230. },
  231. {
  232. type: 'autocomplete',
  233. key: 'expType',
  234. value: null,
  235. default: null,
  236. label: '工作经验 *',
  237. col: 6,
  238. outlined: true,
  239. itemText: 'label',
  240. itemValue: 'value',
  241. dictTypeName: 'menduner_exp_type',
  242. rules: [v => !!v || '请选择工作经验'],
  243. items: []
  244. },
  245. {
  246. type: 'autocomplete',
  247. key: 'eduType',
  248. value: null,
  249. default: null,
  250. label: '最高学历 *',
  251. col: 6,
  252. outlined: true,
  253. itemText: 'label',
  254. itemValue: 'value',
  255. dictTypeName: 'menduner_education_type',
  256. rules: [v => !!v || '请选择最高学历'],
  257. items: []
  258. },
  259. {
  260. type: 'autocomplete',
  261. key: 'jobType',
  262. value: null,
  263. default: null,
  264. label: '求职类型 *',
  265. col: 6,
  266. outlined: true,
  267. itemText: 'label',
  268. itemValue: 'value',
  269. dictTypeName: 'menduner_job_type',
  270. rules: [v => !!v || '请选择求职类型'],
  271. items: []
  272. },
  273. {
  274. type: 'autocomplete',
  275. key: 'jobStatus',
  276. value: null,
  277. default: null,
  278. label: '求职状态 *',
  279. col: 6,
  280. outlined: true,
  281. itemText: 'label',
  282. itemValue: 'value',
  283. dictTypeName: 'menduner_job_status',
  284. rules: [v => !!v || '请选择求职状态'],
  285. items: []
  286. },
  287. {
  288. type: 'autocomplete',
  289. key: 'maritalStatus',
  290. value: null,
  291. default: null,
  292. label: '婚姻状况 *',
  293. col: 6,
  294. outlined: true,
  295. itemText: 'label',
  296. itemValue: 'value',
  297. dictTypeName: 'menduner_marital_status',
  298. rules: [v => !!v || '请选择婚姻状况'],
  299. items: []
  300. },
  301. {
  302. type: 'datePicker',
  303. key: 'firstWorkTime',
  304. value: null,
  305. default: null,
  306. col: 6,
  307. class: 'mb-3',
  308. options: {
  309. type: 'month',
  310. format: 'timestamp',
  311. placeholder: '首次工作时间 *',
  312. },
  313. rules: [v => !!v || '请选择首次工作时间']
  314. },
  315. ]
  316. })
  317. // 保存-基础信息
  318. const handleSave = async () => {
  319. const { valid } = await CtFormRef.value.formRef.validate()
  320. if (!valid) return
  321. const obj = {}
  322. formItems.value.options.forEach(e => {
  323. if (e.type === 'datepicker') obj[e.key] = getTimeStamp(e.value)
  324. else obj[e.key] = e.value
  325. })
  326. await saveResumeBasicInfo(obj)
  327. Snackbar.success(t('common.saveMsg'))
  328. isEdit.value = false
  329. // 获取当前登录账户信息
  330. if (baseInfo.value.userId) await userStore.getUserBaseInfos(baseInfo.value.userId)
  331. await getBasicInfo()
  332. }
  333. // 城市
  334. const setValue = (key, id, name) => {
  335. const item = formItems.value.options.find(e => e.key === key)
  336. if (item) {
  337. item.value = id
  338. item[item.nameKey] = name
  339. }
  340. }
  341. const handleArea = (list, name) => {
  342. if (!list.length) return
  343. const id = list[0]
  344. setValue('areaId', id, name)
  345. }
  346. // 获取字典内容
  347. const getDictData = async (dictTypeName) => {
  348. const item = formItems.value.options.find(e => e.dictTypeName === dictTypeName)
  349. if (item) {
  350. const { data } = await getDict(dictTypeName)
  351. item.items = data
  352. }
  353. }
  354. formItems.value.options.forEach((e, index) => {
  355. if ((index + 2) % 2 === 0) e.flexStyle = 'mr-3'
  356. if (e.dictTypeName) getDictData(e.dictTypeName) // 查字典set options
  357. // formItems回显
  358. const infoExist = baseInfo.value && Object.keys(baseInfo.value).length
  359. if (infoExist && baseInfo.value[e.key]) e.value = baseInfo.value[e.key]
  360. // 日期相关
  361. if (e.type === 'datepicker') e.value = timesTampChange(e.value).slice(0, 10)
  362. // 所在城市回显
  363. if (infoExist && e.nameKey) e[e.nameKey] = baseInfo.value[e.nameKey]
  364. })
  365. </script>
  366. <style lang="scss" scoped>
  367. .jobTypeCardBox {
  368. position: absolute;
  369. top: -22px;
  370. left: 0;
  371. }
  372. .avatarsBox {
  373. height: 80px;
  374. width: 80px;
  375. position: relative;
  376. cursor: pointer;
  377. margin: 32px;
  378. margin-right: 40px;
  379. .img {
  380. width: 100%;
  381. height: 100%;
  382. }
  383. .mdi {
  384. font-size: 42px;
  385. color: #fff;
  386. }
  387. div {
  388. position: absolute;
  389. top: 50%;
  390. left: 50%;
  391. transform: translate(-50%, -50%);
  392. border-radius: 50%;
  393. }
  394. }
  395. .listBox {
  396. display: flex;
  397. flex-wrap: wrap; /* 允许换行 */
  398. width: 100%; /* 设置容器宽度 */
  399. // height: 68px;
  400. overflow: hidden;
  401. color: #666;
  402. div {
  403. margin-right: 50px;
  404. span {
  405. height: 32px;
  406. line-height: 32px;
  407. }
  408. .mdi {
  409. font-size: 22px;
  410. margin-right: 8px;
  411. // margin-top: 2px;
  412. }
  413. }
  414. // border: 1px solid red; /* 可视化边界 */
  415. // .jobItems {
  416. // font-size: 14px;
  417. // margin-left: 12px;
  418. // cursor: pointer;
  419. // color: #666666;
  420. // font-family: 微软雅黑;
  421. // }
  422. }
  423. </style>