jobIntention.vue 13 KB

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