jobIntention.vue 11 KB

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