jobIntention.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390
  1. <template>
  2. <div class="resume-box elevation-2 mb-3" id="jobIntention">
  3. <div class="resume-header mb-3">
  4. <div class="resume-title">{{ $t('resume.jobIntention') }}</div>
  5. <v-btn v-if="!isAdd" variant="text" color="primary" prepend-icon="mdi-plus-box" @click="isAdd = true">{{ $t('common.add') }}</v-btn>
  6. </div>
  7. <div v-if="!isAdd">
  8. <div v-if="interestList.length">
  9. <div
  10. :class="['position-item', 'mx-n2', 'px-2']"
  11. v-for="(k, i) in interestList"
  12. :key="i"
  13. @mouseenter="k.active = true"
  14. @mouseleave="k.active = false"
  15. >
  16. <div class="d-flex">
  17. <div>{{ k.position }}</div>
  18. <div class="line">|</div>
  19. <div v-if="!k.payFrom && !k.payTo">面议</div>
  20. <div v-else>{{k.payFrom ? k.payFrom + '-' : ''}}{{k.payTo}}</div>
  21. <div class="line">|</div>
  22. <div class="grey-text text-box">{{ k.industry && k.industry.length ? k.industry.map(e => e.nameCn).join('、') : '' }}</div>
  23. <div class="line" v-if="k.industry.length && k.jobTypeName">|</div>
  24. <div class="grey-text">{{ k.jobTypeName }}</div>
  25. <div class="line" v-if="k.jobTypeName && k.workArea">|</div>
  26. <div class="grey-text ellipsis" style="max-width: 160px;">
  27. {{ k.interestedArea && k.interestedArea.length ? k.workArea + ',' + k.interestedArea.map(e => e.name).join(',') : k.workArea }}
  28. </div>
  29. </div>
  30. <div class="float-right" v-if="k.active">
  31. <v-btn variant="text" color="primary" prepend-icon="mdi-square-edit-outline" @click="handleEdit(k)">{{ $t('common.edit') }}</v-btn>
  32. <v-btn variant="text" color="primary" prepend-icon="mdi-trash-can-outline" @click="handleDelete(k)">{{ $t('common.delete') }}</v-btn>
  33. </div>
  34. </div>
  35. </div>
  36. <div v-else class="resumeNoDataText">{{ $t('resume.dataDefaultPrompt') }}{{ $t('resume.jobIntention') }}...</div>
  37. </div>
  38. <div v-if="isAdd" class="mt-2">
  39. <CtForm ref="formPageRef" :items="items" style="width: 100%;">
  40. <!-- 期望岗位 -->
  41. <template #positionId="{ item }">
  42. <v-menu :close-delay="1" :open-delay="0" v-bind="$attrs">
  43. <template v-slot:activator="{ props }">
  44. <textUI
  45. :modelValue="item.value"
  46. :item="item"
  47. v-bind="props"
  48. style="position: relative;"
  49. ></textUI>
  50. </template>
  51. <jobTypeCard class="jobTypeCardBox" :select="[query.positionId].filter(Boolean)" :isSingle="true" @handleJobClick="handleJobClickItem"></jobTypeCard>
  52. </v-menu>
  53. </template>
  54. <!-- 期望行业 -->
  55. <template #industryIdList="{ item }">
  56. <v-menu :close-delay="1" :open-delay="0" v-bind="$attrs" :close-on-content-click="false">
  57. <template v-slot:activator="{ props }">
  58. <textUI
  59. v-model="item.value"
  60. :item="item"
  61. v-bind="props"
  62. >
  63. <template #default>
  64. <v-chip v-for="k in currentSelect" :key="k.id" class="mr-1" closable @click:close="handleIndustryClear(k)">{{ k.nameCn }}</v-chip>
  65. </template>
  66. </textUI>
  67. </template>
  68. <industryTypeCard :select="query.industryIdList" :currentData="currentSelect" showSelect @handleClickIndustry="handleIndustry"></industryTypeCard>
  69. </v-menu>
  70. </template>
  71. <!-- 其它感兴趣的城市 -->
  72. <template #interestedAreaIdList="{ item }">
  73. <v-menu :close-delay="1" :open-delay="0" v-bind="$attrs" :close-on-content-click="false">
  74. <template v-slot:activator="{ props }">
  75. <TextInput
  76. v-model="item.value"
  77. :item="item"
  78. v-bind="props"
  79. style="position: relative;"
  80. >
  81. <template #default>
  82. <v-chip v-for="k in areaSelect" :key="k.id" class="mr-1" closable @click:close="handleAreaClear(k)">{{ k.name }}</v-chip>
  83. </template>
  84. </TextInput>
  85. </template>
  86. <AreaSelect :select="query.interestedAreaIdList" :currentData="areaSelect" :limit="false" showSelect @handleClick="handleArea"></AreaSelect>
  87. </v-menu>
  88. </template>
  89. </CtForm>
  90. <div class="text-end">
  91. <v-btn class="half-button mr-3" variant="tonal" @click="isAdd = false; resetForm()">{{ $t('common.cancel') }}</v-btn>
  92. <v-btn color="primary" class="half-button" @click="handleSave">{{ $t('common.save') }}</v-btn>
  93. </div>
  94. </div>
  95. </div>
  96. </template>
  97. <script setup name="jobIntention">
  98. import { ref, reactive } from 'vue'
  99. import CtForm from '@/components/CtForm'
  100. import textUI from '@/components/FormUI/TextInput'
  101. import jobTypeCard from '@/components/jobTypeCard'
  102. import industryTypeCard from '@/components/industryTypeCard'
  103. import Snackbar from '@/plugins/snackbar'
  104. import Confirm from '@/plugins/confirm'
  105. import { saveResumeJobInterested, getResumeJobInterested, deleteResumeJobInterested } from '@/api/recruit/personal/resume'
  106. import { dealJobData } from './dict'
  107. import { getDict } from '@/hooks/web/useDictionaries'
  108. import { cityToProvince } from '@/utils/areaDeal'
  109. const emit = defineEmits(['complete'])
  110. const isAdd = ref(false)
  111. const formPageRef = ref()
  112. const editId = ref(null)
  113. let query = reactive({})
  114. const items = ref({
  115. options: [
  116. {
  117. slotName: 'positionId',
  118. key: 'positionId',
  119. value: '',
  120. col: 6,
  121. label: '期望岗位 *',
  122. flexStyle: 'mr-3',
  123. valueKey: 'position',
  124. hideDetails: true,
  125. outlined: true,
  126. rules: [v => !!v || '请选择期望岗位']
  127. },
  128. {
  129. slotName: 'industryIdList',
  130. key: 'industryIdList',
  131. value: '',
  132. outlined: true,
  133. placeholder: '期望行业 *',
  134. col: 6,
  135. // rules: [v => !!v || '请选择期望行业']
  136. },
  137. {
  138. type: 'number',
  139. key: 'payFrom',
  140. value: null,
  141. label: '期望薪资(最低要求) *',
  142. col: 4,
  143. suffix: '元',
  144. outlined: true,
  145. rules: [v => !!v || '请输入薪资最低要求']
  146. },
  147. {
  148. type: 'number',
  149. key: 'payTo',
  150. value: null,
  151. label: '期望薪资(最高要求) *',
  152. col: 4,
  153. suffix: '元',
  154. outlined: true,
  155. flexStyle: 'mx-3',
  156. rules: [v => !!v || '请输入薪资最高要求']
  157. },
  158. {
  159. type: 'autocomplete',
  160. key: 'jobType',
  161. value: null,
  162. label: '求职类型 *',
  163. outlined: true,
  164. itemText: 'label',
  165. col: 4,
  166. itemValue: 'value',
  167. rules: [v => !!v || '请选择求职类型'],
  168. items: [
  169. { label: '全职', value: '0' },
  170. { label: '兼职', value: '1' },
  171. { label: '临时', value: '2' },
  172. { label: '实习', value: '3' }
  173. ]
  174. },
  175. {
  176. type: 'autocomplete',
  177. key: 'workAreaProvinceId',
  178. value: null,
  179. label: '工作城市:省 *',
  180. outlined: true,
  181. itemText: 'name',
  182. itemValue: 'id',
  183. returnSelect: true,
  184. col: 6,
  185. flexStyle: 'mr-3',
  186. rules: [v => !!v || '请选择工作城市:省'],
  187. items: [],
  188. change: null
  189. },
  190. {
  191. type: 'autocomplete',
  192. key: 'workAreaId',
  193. value: null,
  194. label: '工作城市:市 *',
  195. outlined: true,
  196. itemText: 'name',
  197. itemValue: 'id',
  198. col: 6,
  199. rules: [v => !!v || '请选择工作城市:市'],
  200. items: [],
  201. change: null
  202. },
  203. {
  204. slotName: 'interestedAreaIdList',
  205. key: 'interestedAreaIdList',
  206. value: '',
  207. placeholder: '其它感兴趣的城市'
  208. // label: '其它感兴趣的城市'
  209. }
  210. ]
  211. })
  212. const provinceChange = (value, val, obj) => {
  213. const item = items.value.options.find(e => e.key === 'workAreaId')
  214. if (!item) return
  215. item.items = obj.children || []
  216. item.value = null
  217. }
  218. getDict('areaTreeData', null, 'areaTreeData').then(({ data }) => {
  219. data = data?.length && data || []
  220. if (!data?.length) return console.error('areaTreeData获取失败!')
  221. //
  222. // const china = data.find(e => e.id === '1')
  223. // const chinaTreeData = china?.children?.length ? china.children : []
  224. const chinaTreeData = data
  225. //
  226. if (!chinaTreeData?.length) return console.error('chinaTreeData获取失败!')
  227. const item = items.value.options.find(e => e.key === 'workAreaProvinceId')
  228. if (item?.items) {
  229. item.items = chinaTreeData
  230. item.change = provinceChange
  231. }
  232. })
  233. // 获取求职意向
  234. const interestList = ref([])
  235. const getJobInterested = async () => {
  236. const data = await getResumeJobInterested()
  237. // 完成度展示
  238. emit('complete', { status: Boolean(data?.length), id: 'jobIntention' })
  239. if (!data.length) {
  240. interestList.value = []
  241. return
  242. }
  243. interestList.value = dealJobData(data)
  244. }
  245. getJobInterested()
  246. const setValue = (key, value) => {
  247. items.value.options.find(e => e.key === key).value = value
  248. }
  249. // 期望职位
  250. const handleJobClickItem = (list, name) => {
  251. if (!list.length) return
  252. query.positionId = list[0]
  253. setValue('positionId', name)
  254. }
  255. // 行业类型
  256. let currentSelect = reactive([])
  257. const handleIndustry = (list, arr) => {
  258. if (!list.length) return setValue('industryIdList', '')
  259. query.industryIdList = list
  260. currentSelect = arr
  261. // const str = arr.map(e => e.nameCn).join('、')
  262. // setValue('industryIdList', str)
  263. }
  264. const handleIndustryClear = (k) => {
  265. query.industryIdList = query.industryIdList.filter(i => i !== k.id)
  266. const index = currentSelect.findIndex(i => i.id === k.id)
  267. if (index !== -1) currentSelect.splice(index, 1)
  268. console.log(k, 'industry', query.industryIdList, currentSelect)
  269. }
  270. // 其它感兴趣的城市
  271. let areaSelect = reactive([])
  272. const handleArea = (list, arr) => {
  273. if (!list.length) return setValue('interestedAreaIdList', '')
  274. query.interestedAreaIdList = list
  275. areaSelect = arr
  276. }
  277. const handleAreaClear = (k) => {
  278. query.interestedAreaIdList = query.interestedAreaIdList.filter(i => i !== k.id)
  279. const index = areaSelect.findIndex(i => i.id === k.id)
  280. if (index !== -1) areaSelect.splice(index, 1)
  281. }
  282. const resetForm = () => {
  283. items.value.options.forEach(e => {
  284. if (e.key === 'industryIdList') e.value = ''
  285. else e.value = null
  286. })
  287. editId.value = null
  288. query = {}
  289. currentSelect = []
  290. areaSelect = []
  291. }
  292. const arr = ['payFrom', 'payTo', 'jobType', 'workAreaId']
  293. const handleSave = async () => {
  294. const { valid } = await formPageRef.value.formRef.validate()
  295. if (!valid) return
  296. items.value.options.forEach(e => {
  297. if (arr.includes(e.key)) query[e.key] = e.value
  298. })
  299. if (!query.industryIdList || !query.industryIdList.length) return Snackbar.warning('请选择您的期望行业')
  300. if (editId.value) query.id = editId.value
  301. await saveResumeJobInterested(query)
  302. Snackbar.success('保存成功')
  303. isAdd.value = false
  304. resetForm()
  305. getJobInterested()
  306. }
  307. const handleEdit = async (item) => {
  308. editId.value = item.id
  309. let workAreaId = ''
  310. items.value.options.forEach(e => {
  311. query[e.key] = item[e.key]
  312. if (e.valueKey) {
  313. e.value = item[e.valueKey]
  314. } else e.value = item[e.key]
  315. if (e.key === 'industryIdList') e.value = null
  316. if (e.key === 'interestedAreaIdList') {
  317. e.value = null
  318. query.interestedAreaIdList = item.interestedAreaIdList && item.interestedAreaIdList.length ? item.interestedAreaIdList : []
  319. }
  320. if (e.key === 'workAreaId' && item[e.key]) workAreaId = item[e.key]
  321. })
  322. if (workAreaId) { // 省份回显
  323. const province = items.value.options.find(pv => pv.key === 'workAreaProvinceId')
  324. if (province) {
  325. const dealReturnObj = await cityToProvince(workAreaId, {}, province.items || [])
  326. const city = items.value.options.find(pv => pv.key === 'workAreaId')
  327. if (city) city.items = dealReturnObj.cityList || []
  328. province.value = dealReturnObj.pid || ''
  329. }
  330. }
  331. currentSelect = item.industry
  332. areaSelect = item.interestedArea && item.interestedArea.length ? item.interestedArea : []
  333. isAdd.value = true
  334. }
  335. const handleDelete = ({ id }) => {
  336. Confirm('系统提示', '是否确认删除此项求职意向?').then(async () => {
  337. await deleteResumeJobInterested(id)
  338. Snackbar.success('删除成功!')
  339. getJobInterested()
  340. })
  341. }
  342. </script>
  343. <style scoped lang="scss">
  344. .jobTypeCardBox {
  345. position: absolute;
  346. top: -22px;
  347. left: 0;
  348. }
  349. .position-item {
  350. display: flex;
  351. justify-content: space-between;
  352. cursor: pointer;
  353. border-radius: 6px;
  354. line-height: 40px;
  355. font-size: 15px;
  356. &:hover {
  357. background-color: var(--color-f8);
  358. }
  359. span {
  360. font-size: 15px;
  361. }
  362. .grey-text {
  363. color: var(--color-999);
  364. }
  365. }
  366. .text-box {
  367. max-width: 200px;
  368. white-space: nowrap;
  369. text-overflow: ellipsis;
  370. overflow: hidden;
  371. }
  372. .line {
  373. color: #e0e0e0;
  374. margin: 0 10px;
  375. }
  376. </style>