basicInfo.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413
  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'"></v-avatar>
  17. <div v-show="showIcon" class="mdi mdi-camera-outline"></div>
  18. </v-badge>
  19. </div>
  20. <!-- 基础信息 -->
  21. <div style="flex: 1;" class="mr-8 mt-5">
  22. <!-- 编辑 -->
  23. <div v-if="isEdit">
  24. <CtForm ref="CtFormRef" :items="formItems" style="width: 100%;">
  25. <template v-slot:phone>
  26. <v-btn variant="text" class="ml-2" color="primary">{{ $t('common.change') }}</v-btn>
  27. </template>
  28. <template #areaType="{ item }">
  29. <v-menu :close-delay="1" :open-delay="0" v-bind="$attrs">
  30. <template v-slot:activator="{ props }">
  31. <textUI
  32. v-model="item[item.nameKey]"
  33. :item="item"
  34. v-bind="props"
  35. style="position: relative;"
  36. ></textUI>
  37. </template>
  38. <areaType :isIntType="false" :select="[baseInfo?.areaId].filter(Boolean)" @handleAreaClick="handleArea" class="jobTypeCardBox" isSingle></areaType>
  39. </v-menu>
  40. </template>
  41. </CtForm>
  42. <div class="text-end">
  43. <v-btn class="half-button mr-3" variant="tonal" @click="isEdit = false">{{ $t('common.cancel') }}</v-btn>
  44. <v-btn color="primary" class="half-button" @click="handleSave">{{ $t('common.save') }}</v-btn>
  45. </div>
  46. </div>
  47. <!-- 展示 -->
  48. <div v-else>
  49. <span style="font-size: 20px; font-weight: 500;">{{ baseInfo.name }}</span>
  50. <div class="mt-3 d-flex">
  51. <div class="listBox" :style="{ height: isExpand ? 'auto' : '68px' }">
  52. <div>
  53. <span class="mdi mdi-map-marker-outline"></span>
  54. <span>{{ baseInfo.areaName || '暂无' }}</span>
  55. </div>
  56. <div>
  57. <span class="mdi mdi-phone-outline"></span>
  58. <span>{{ baseInfo.phone }}</span>
  59. </div>
  60. <div>
  61. <span class="mdi mdi-email-outline"></span>
  62. <span>{{ baseInfo.email }}</span>
  63. </div>
  64. <div>
  65. <span class="mdi mdi-calendar-blank-outline"></span>
  66. <span>{{ baseInfo.expTypeText }}</span>
  67. </div>
  68. <div>
  69. <span class="mdi mdi-school-outline"></span>
  70. <span>{{ baseInfo.eduTypeText }}</span>
  71. </div>
  72. <!-- <div>
  73. <span class="mdi mdi-briefcase-outline"></span>
  74. <span>{{ baseInfo.jobTypeText }}</span>
  75. </div> -->
  76. <div>
  77. <span class="mdi mdi-tag-outline"></span>
  78. <span>{{ baseInfo.jobStatusText }}</span>
  79. </div>
  80. <div>
  81. <span class="mdi mdi-cake-variant-outline"></span>
  82. <span>{{ baseInfo.birthdayText }}</span>
  83. </div>
  84. <div>
  85. <span class="mdi mdi-account-heart"></span>
  86. <span>{{ baseInfo.maritalText }}</span>
  87. </div>
  88. <div>
  89. <span>{{ $t('resume.firstWorkTime') }}:</span>
  90. <span>{{ baseInfo.firstWorkTimeText }}</span>
  91. </div>
  92. </div>
  93. <div class="ml-3">
  94. <v-btn variant="text" color="primary" v-if="isExpand" @click="isExpand = false">{{ $t('resume.retract') }}</v-btn>
  95. <v-btn variant="text" color="primary" v-else @click="isExpand = true">{{ $t('resume.expand') }}</v-btn>
  96. </div>
  97. </div>
  98. <div class="mt-4">
  99. <span style="font-size: 15px;">个人画像:</span>
  100. <v-chip size="small" label v-for="(k, i) in welfareList.slice(0, 8)" :key="i" class="mr-2" color="primary">{{ k }}</v-chip>
  101. </div>
  102. </div>
  103. </div>
  104. </div>
  105. </div>
  106. </template>
  107. <script setup>
  108. import CtForm from '@/components/CtForm'
  109. import Snackbar from '@/plugins/snackbar'
  110. import areaType from '@/components/AreaSelect'
  111. import textUI from '@/components/FormUI/TextInput'
  112. import { getDict } from '@/hooks/web/useDictionaries'
  113. import { getTimeStamp, timesTampChange } from '@/utils/date'
  114. import { saveResumeBasicInfo } from '@/api/resume'
  115. import { useUserStore } from '@/store/user'
  116. import { ref } from 'vue';
  117. defineOptions({name: 'resume-components-basicInfo'})
  118. const userStore = useUserStore()
  119. const CtFormRef = ref()
  120. const isEdit = ref(false)
  121. const showIcon = ref(false)
  122. const isExpand = ref(false)
  123. const welfareList = ref(['热情活泼', '理性冷静', '富有创新', '热爱生活', '有幽默感'])
  124. let baseInfo = ref({})
  125. const getBasicInfo = () => { // 获取基础信息
  126. baseInfo.value = JSON.parse(localStorage.getItem('baseInfo')) // 人才信息
  127. }
  128. getBasicInfo()
  129. const formItems = ref({
  130. options: [
  131. {
  132. type: 'text',
  133. key: 'name',
  134. value: null,
  135. default: null,
  136. label: '姓名 *',
  137. col: 6,
  138. outlined: true,
  139. rules: [v => !!v || '请输入姓名']
  140. },
  141. {
  142. type: 'ifRadio',
  143. key: 'sex',
  144. value: '0', // '1' ? '男' : '女'
  145. default: 0,
  146. label: '性别',
  147. col: 6,
  148. width: 70,
  149. dictTypeName: 'system_user_sex',
  150. items: [],
  151. },
  152. {
  153. type: 'datePicker',
  154. key: 'birthday',
  155. value: null,
  156. default: null,
  157. col: 6,
  158. class: 'mb-3',
  159. options: {
  160. type: 'date',
  161. format: 'timestamp',
  162. placeholder: '出生日期 *',
  163. disabled: true,
  164. },
  165. },
  166. {
  167. type: 'text',
  168. key: 'phone',
  169. value: null,
  170. default: null,
  171. label: '电话号码',
  172. col: 6,
  173. outlined: true,
  174. disabled: true,
  175. slotName: 'phone',
  176. },
  177. {
  178. // type: 'autocomplete',
  179. // key: 'areaId',
  180. // value: null,
  181. // default: null,
  182. // label: '所在城市 *',
  183. // col: 6,
  184. // outlined: true,
  185. // itemText: 'label',
  186. // itemValue: 'value',
  187. // rules: [v => !!v || '请选择所在城市'],
  188. // items: [{ label: '广州', value: '440100'}]
  189. slotName: 'areaType',
  190. key: 'areaId',
  191. value: null,
  192. label: '所在城市 *',
  193. nameKey: 'areaName', // 展示出来id对应的内容
  194. col: 6,
  195. flexStyle: 'mr-3',
  196. rules: [v => !!v || '请选择所在城市']
  197. },
  198. {
  199. type: 'text',
  200. key: 'email',
  201. value: null,
  202. default: null,
  203. label: '常用邮箱 *',
  204. col: 6,
  205. outlined: true,
  206. rules: [v => !!v || '请输入常用邮箱']
  207. },
  208. {
  209. type: 'autocomplete',
  210. key: 'expType',
  211. value: null,
  212. default: null,
  213. label: '工作经验 *',
  214. col: 6,
  215. outlined: true,
  216. itemText: 'label',
  217. itemValue: 'value',
  218. dictTypeName: 'menduner_exp_type',
  219. rules: [v => !!v || '请选择工作经验'],
  220. items: []
  221. },
  222. {
  223. type: 'autocomplete',
  224. key: 'eduType',
  225. value: null,
  226. default: null,
  227. label: '最高学历 *',
  228. col: 6,
  229. outlined: true,
  230. itemText: 'label',
  231. itemValue: 'value',
  232. dictTypeName: 'menduner_education_type',
  233. rules: [v => !!v || '请选择最高学历'],
  234. items: []
  235. },
  236. {
  237. type: 'autocomplete',
  238. key: 'jobType',
  239. value: null,
  240. default: null,
  241. label: '求职类型 *',
  242. col: 6,
  243. outlined: true,
  244. itemText: 'label',
  245. itemValue: 'value',
  246. dictTypeName: 'menduner_job_type',
  247. rules: [v => !!v || '请选择求职类型'],
  248. items: []
  249. },
  250. {
  251. type: 'autocomplete',
  252. key: 'jobStatus',
  253. value: null,
  254. default: null,
  255. label: '求职状态 *',
  256. col: 6,
  257. outlined: true,
  258. itemText: 'label',
  259. itemValue: 'value',
  260. rules: [v => !!v || '请选择求职状态'],
  261. items: [
  262. { label: '离职-随时到岗 ', value: '0' },
  263. { label: '在职-月内到岗', value: '1' },
  264. { label: '在职-考虑机会', value: '2' },
  265. { label: '在职-暂不考虑', value: '3' }
  266. ]
  267. },
  268. {
  269. type: 'autocomplete',
  270. key: 'maritalStatus',
  271. value: null,
  272. default: null,
  273. label: '婚姻状况 *',
  274. col: 6,
  275. outlined: true,
  276. itemText: 'label',
  277. itemValue: 'value',
  278. rules: [v => !!v || '请选择婚姻状况'],
  279. items: [
  280. { label: '未婚 ', value: '0' },
  281. { label: '已婚', value: '1' },
  282. { label: '离异', value: '2' },
  283. { label: '保密', value: '3' }
  284. ]
  285. },
  286. {
  287. type: 'datePicker',
  288. key: 'firstWorkTime',
  289. value: null,
  290. default: null,
  291. col: 6,
  292. class: 'mb-3',
  293. options: {
  294. type: 'month',
  295. format: 'timestamp',
  296. placeholder: '首次工作时间 *',
  297. },
  298. rules: [v => !!v || '请选择首次工作时间']
  299. },
  300. ]
  301. })
  302. // 保存-基础信息
  303. const handleSave = async () => {
  304. const { valid } = await CtFormRef.value.formRef.validate()
  305. if (!valid) return
  306. const obj = {}
  307. formItems.value.options.forEach(e => {
  308. // if (e.nameKey) obj[e.nameKey] = e.nameKey
  309. if (e.type === 'datepicker') obj[e.key] = getTimeStamp(e.value)
  310. else obj[e.key] = e.value
  311. })
  312. await saveResumeBasicInfo(obj)
  313. Snackbar.success('保存成功!')
  314. isEdit.value = false
  315. // 获取当前登录账户信息
  316. await userStore.getUserBaseInfos(baseInfo.value.userId)
  317. await getBasicInfo()
  318. }
  319. // 城市
  320. const setValue = (key, id, name) => {
  321. const item = formItems.value.options.find(e => e.key === key)
  322. if (item) {
  323. item.value = id
  324. item[item.nameKey] = name
  325. }
  326. }
  327. const handleArea = (list, name) => {
  328. if (!list.length) return
  329. const id = list[0]
  330. setValue('areaId', id, name)
  331. }
  332. // 获取字典内容
  333. const getDictData = async (dictTypeName) => {
  334. const item = formItems.value.options.find(e => e.dictTypeName === dictTypeName)
  335. if (item) {
  336. const { data } = await getDict(dictTypeName)
  337. item.items = data
  338. }
  339. }
  340. formItems.value.options.forEach((e, index) => {
  341. if ((index + 2) % 2 === 0) e.flexStyle = 'mr-3'
  342. if (e.dictTypeName) getDictData(e.dictTypeName) // 查字典set options
  343. // formItems回显
  344. if (baseInfo.value[e.key]) e.value = baseInfo.value[e.key]
  345. // 日期相关
  346. if (e.type === 'datepicker') e.value = timesTampChange(e.value).slice(0, 10)
  347. })
  348. </script>
  349. <style lang="scss" scoped>
  350. .jobTypeCardBox {
  351. position: absolute;
  352. top: -22px;
  353. left: 0;
  354. }
  355. .avatarsBox {
  356. height: 80px;
  357. width: 80px;
  358. position: relative;
  359. cursor: pointer;
  360. margin: 32px;
  361. margin-right: 40px;
  362. .img {
  363. width: 100%;
  364. height: 100%;
  365. }
  366. .mdi {
  367. font-size: 42px;
  368. color: #fff;
  369. }
  370. div {
  371. position: absolute;
  372. top: 50%;
  373. left: 50%;
  374. transform: translate(-50%, -50%);
  375. border-radius: 50%;
  376. }
  377. }
  378. .listBox {
  379. display: flex;
  380. flex-wrap: wrap; /* 允许换行 */
  381. width: 100%; /* 设置容器宽度 */
  382. // height: 68px;
  383. overflow: hidden;
  384. div {
  385. margin-right: 50px;
  386. span {
  387. height: 32px;
  388. line-height: 32px;
  389. }
  390. .mdi {
  391. font-size: 22px;
  392. margin-right: 8px;
  393. // margin-top: 2px;
  394. }
  395. }
  396. // border: 1px solid red; /* 可视化边界 */
  397. // .jobItems {
  398. // font-size: 14px;
  399. // margin-left: 12px;
  400. // cursor: pointer;
  401. // color: #666666;
  402. // font-family: 微软雅黑;
  403. // }
  404. }
  405. </style>