jobIntention.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376
  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. const emit = defineEmits(['complete'])
  109. const isAdd = ref(false)
  110. const formPageRef = ref()
  111. const editId = ref(null)
  112. let query = reactive({})
  113. const items = ref({
  114. options: [
  115. {
  116. slotName: 'positionId',
  117. key: 'positionId',
  118. value: '',
  119. col: 6,
  120. label: '期望岗位 *',
  121. flexStyle: 'mr-3',
  122. valueKey: 'position',
  123. hideDetails: true,
  124. outlined: true,
  125. rules: [v => !!v || '请选择期望岗位']
  126. },
  127. {
  128. slotName: 'industryIdList',
  129. key: 'industryIdList',
  130. value: '',
  131. outlined: true,
  132. placeholder: '期望行业 *',
  133. col: 6,
  134. // rules: [v => !!v || '请选择期望行业']
  135. },
  136. {
  137. type: 'number',
  138. key: 'payFrom',
  139. value: '',
  140. col: 4,
  141. label: '最低薪资 *',
  142. suffix: '元',
  143. rules: [
  144. value => {
  145. if (value) return true
  146. return '请填写最低薪资'
  147. },
  148. value => {
  149. if (value >= 1) return true
  150. return '数额不得小于1'
  151. },
  152. value => {
  153. const payTo = items.value.options.find(e => e.key === 'payTo').value
  154. if (!payTo || (Number(value) < payTo ? Number(payTo) : 0)) return true
  155. return '应低于最高薪资'
  156. }
  157. ]
  158. },
  159. {
  160. type: 'number',
  161. key: 'payTo',
  162. value: '',
  163. col: 4,
  164. label: '最高薪资 *',
  165. flexStyle: 'mx-3',
  166. suffix: '元',
  167. rules: [
  168. value => {
  169. if (value) return true
  170. return '请填写最高薪资'
  171. },
  172. value => {
  173. if (value >= 1) return true
  174. return '数额不得小于1'
  175. },
  176. value => {
  177. const payFrom = items.value.options.find(e => e.key === 'payFrom').value
  178. if (!payFrom || (Number(value) > payFrom ? Number(payFrom) : 0)) return true
  179. return '应高于最低薪资'
  180. }
  181. ]
  182. },
  183. {
  184. type: 'autocomplete',
  185. key: 'jobType',
  186. value: null,
  187. label: '求职类型 *',
  188. outlined: true,
  189. itemText: 'label',
  190. col: 6,
  191. flexStyle: 'mr-3',
  192. itemValue: 'value',
  193. rules: [v => !!v || '请选择求职类型'],
  194. items: []
  195. },
  196. {
  197. type: 'cascade',
  198. key: 'workAreaId',
  199. value: null,
  200. default: null,
  201. label: '期望城市',
  202. itemText: 'name',
  203. itemValue: 'id',
  204. required: true,
  205. clearable: false,
  206. col: 6,
  207. items: [],
  208. },
  209. {
  210. slotName: 'interestedAreaIdList',
  211. key: 'interestedAreaIdList',
  212. value: '',
  213. placeholder: '其它感兴趣的城市'
  214. }
  215. ]
  216. })
  217. getDict('areaTreeData', null, 'areaTreeData').then(({ data }) => {
  218. data = data?.length && data || []
  219. if (!data?.length) return console.error('areaTreeData获取失败!')
  220. const chinaTreeData = data
  221. if (!chinaTreeData?.length) return console.error('chinaTreeData获取失败!')
  222. const item = items.value.options.find(e => e.key === 'workAreaId')
  223. if (item?.items) item.items = chinaTreeData
  224. })
  225. // 求职类型
  226. getDict('menduner_job_type').then(({ data }) => {
  227. data = data?.length && data || []
  228. items.value.options.find(e => e.key === 'jobType').items = data
  229. })
  230. // 获取求职意向
  231. const interestList = ref([])
  232. const getJobInterested = async () => {
  233. const data = await getResumeJobInterested()
  234. // 完成度展示
  235. emit('complete', { status: Boolean(data?.length), id: 'jobIntention' })
  236. if (!data.length) {
  237. interestList.value = []
  238. return
  239. }
  240. interestList.value = dealJobData(data)
  241. }
  242. getJobInterested()
  243. const setValue = (key, value) => {
  244. items.value.options.find(e => e.key === key).value = value
  245. }
  246. // 期望职位
  247. const handleJobClickItem = (list, name) => {
  248. if (!list.length) return
  249. query.positionId = list[0]
  250. setValue('positionId', name)
  251. }
  252. // 行业类型
  253. let currentSelect = reactive([])
  254. const handleIndustry = (list, arr) => {
  255. if (!list.length) return setValue('industryIdList', '')
  256. query.industryIdList = list
  257. currentSelect = arr
  258. // const str = arr.map(e => e.nameCn).join('、')
  259. // setValue('industryIdList', str)
  260. }
  261. const handleIndustryClear = (k) => {
  262. query.industryIdList = query.industryIdList.filter(i => i !== k.id)
  263. const index = currentSelect.findIndex(i => i.id === k.id)
  264. if (index !== -1) currentSelect.splice(index, 1)
  265. }
  266. // 其它感兴趣的城市
  267. let areaSelect = reactive([])
  268. const handleArea = (list, arr) => {
  269. if (!list.length) return setValue('interestedAreaIdList', '')
  270. query.interestedAreaIdList = list
  271. areaSelect = arr
  272. }
  273. const handleAreaClear = (k) => {
  274. query.interestedAreaIdList = query.interestedAreaIdList.filter(i => Number(i) !== Number(k.id))
  275. const index = areaSelect.findIndex(i => Number(i.id) === Number(k.id))
  276. if (index !== -1) areaSelect.splice(index, 1)
  277. }
  278. const resetForm = () => {
  279. items.value.options.forEach(e => {
  280. if (e.key === 'industryIdList') e.value = ''
  281. else e.value = null
  282. })
  283. editId.value = null
  284. query = {}
  285. currentSelect = []
  286. areaSelect = []
  287. }
  288. const arr = ['payFrom', 'payTo', 'jobType', 'workAreaId']
  289. const handleSave = async () => {
  290. const { valid } = await formPageRef.value.formRef.validate()
  291. if (!valid) return
  292. items.value.options.forEach(e => {
  293. if (arr.includes(e.key)) query[e.key] = e.value
  294. })
  295. if (!query.industryIdList || !query.industryIdList.length) return Snackbar.warning('请选择您的期望行业')
  296. if (editId.value) query.id = editId.value
  297. await saveResumeJobInterested(query)
  298. Snackbar.success('保存成功')
  299. isAdd.value = false
  300. resetForm()
  301. getJobInterested()
  302. }
  303. const handleEdit = async (item) => {
  304. editId.value = item.id
  305. items.value.options.forEach(e => {
  306. query[e.key] = item[e.key]
  307. if (e.valueKey) {
  308. e.value = item[e.valueKey]
  309. } else e.value = item[e.key]
  310. if (e.key === 'industryIdList') e.value = null
  311. if (e.key === 'interestedAreaIdList') {
  312. e.value = null
  313. query.interestedAreaIdList = item.interestedAreaIdList && item.interestedAreaIdList.length ? item.interestedAreaIdList : []
  314. }
  315. })
  316. currentSelect = item.industry
  317. areaSelect = item.interestedArea && item.interestedArea.length ? item.interestedArea : []
  318. isAdd.value = true
  319. }
  320. const handleDelete = ({ id }) => {
  321. Confirm('系统提示', '是否确认删除此项求职意向?').then(async () => {
  322. await deleteResumeJobInterested(id)
  323. Snackbar.success('删除成功!')
  324. getJobInterested()
  325. })
  326. }
  327. </script>
  328. <style scoped lang="scss">
  329. .jobTypeCardBox {
  330. position: absolute;
  331. top: -22px;
  332. left: 0;
  333. }
  334. .position-item {
  335. display: flex;
  336. justify-content: space-between;
  337. cursor: pointer;
  338. border-radius: 6px;
  339. line-height: 40px;
  340. font-size: 15px;
  341. &:hover {
  342. background-color: var(--color-f8);
  343. }
  344. span {
  345. font-size: 15px;
  346. }
  347. .grey-text {
  348. color: var(--color-999);
  349. }
  350. }
  351. .text-box {
  352. max-width: 200px;
  353. white-space: nowrap;
  354. text-overflow: ellipsis;
  355. overflow: hidden;
  356. }
  357. .line {
  358. color: #e0e0e0;
  359. margin: 0 10px;
  360. }
  361. </style>