basicInfo.vue 10 KB

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