jobIntention.vue 11 KB

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