jobIntention.vue 8.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300
  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%;"></CtForm>
  40. <div class="text-end">
  41. <v-btn class="half-button mr-3" variant="tonal" @click="isAdd = false; resetForm()">{{ $t('common.cancel') }}</v-btn>
  42. <v-btn color="primary" class="half-button" @click="handleSave">{{ $t('common.save') }}</v-btn>
  43. </div>
  44. </div>
  45. </div>
  46. </template>
  47. <script setup name="jobIntention">
  48. import { ref, reactive } from 'vue'
  49. import CtForm from '@/components/CtForm'
  50. import Snackbar from '@/plugins/snackbar'
  51. import Confirm from '@/plugins/confirm'
  52. import { saveResumeJobInterested, getResumeJobInterested, deleteResumeJobInterested } from '@/api/recruit/personal/resume'
  53. import { dealJobData } from './dict'
  54. import { getDict } from '@/hooks/web/useDictionaries'
  55. const emit = defineEmits(['complete'])
  56. const isAdd = ref(false)
  57. const formPageRef = ref()
  58. const editId = ref(null)
  59. let query = reactive({})
  60. const items = ref({
  61. options: [
  62. {
  63. type: 'cascade',
  64. key: 'positionId',
  65. value: null,
  66. default: null,
  67. label: '期望岗位',
  68. itemText: 'nameCn',
  69. itemValue: 'id',
  70. required: true,
  71. clearable: false,
  72. col: 6,
  73. flexStyle: 'mr-3',
  74. rules: [v => !!v || '请选择期望岗位'],
  75. items: [],
  76. },
  77. {
  78. type: 'cascade',
  79. key: 'industryIdList',
  80. value: [],
  81. default: [],
  82. label: '期望行业',
  83. itemText: 'nameCn',
  84. itemValue: 'id',
  85. required: true,
  86. collapseTags: true,
  87. clearable: false,
  88. multiple: true,
  89. col: 6,
  90. rules: [v => !!v || '请选择期望行业'],
  91. items: [],
  92. },
  93. {
  94. type: 'number',
  95. key: 'payFrom',
  96. value: '',
  97. col: 6,
  98. label: '最低薪资 *',
  99. flexStyle: 'mr-3',
  100. suffix: '元',
  101. rules: [
  102. value => {
  103. if (value) return true
  104. return '请填写最低薪资'
  105. },
  106. value => {
  107. if (value >= 1) return true
  108. return '数额不得小于1'
  109. },
  110. value => {
  111. const payTo = items.value.options.find(e => e.key === 'payTo').value
  112. if (!payTo || (Number(value) < payTo ? Number(payTo) : 0)) return true
  113. return '应低于最高薪资'
  114. }
  115. ]
  116. },
  117. {
  118. type: 'number',
  119. key: 'payTo',
  120. value: '',
  121. col: 6,
  122. label: '最高薪资 *',
  123. suffix: '元',
  124. rules: [
  125. value => {
  126. if (value) return true
  127. return '请填写最高薪资'
  128. },
  129. value => {
  130. if (value >= 1) return true
  131. return '数额不得小于1'
  132. },
  133. value => {
  134. const payFrom = items.value.options.find(e => e.key === 'payFrom').value
  135. if (!payFrom || (Number(value) > payFrom ? Number(payFrom) : 0)) return true
  136. return '应高于最低薪资'
  137. }
  138. ]
  139. },
  140. {
  141. type: 'autocomplete',
  142. key: 'jobType',
  143. value: null,
  144. label: '求职类型 *',
  145. outlined: true,
  146. itemText: 'label',
  147. col: 6,
  148. flexStyle: 'mr-3',
  149. itemValue: 'value',
  150. rules: [v => !!v || '请选择求职类型'],
  151. items: []
  152. },
  153. {
  154. type: 'cascade',
  155. key: 'workAreaId',
  156. value: null,
  157. default: null,
  158. label: '期望城市',
  159. itemText: 'name',
  160. itemValue: 'id',
  161. required: true,
  162. clearable: false,
  163. checkStrictly: true,
  164. col: 6,
  165. items: [],
  166. },
  167. {
  168. type: 'cascade',
  169. key: 'interestedAreaIdList',
  170. value: [],
  171. label: '其它感兴趣的城市',
  172. itemText: 'name',
  173. itemValue: 'id',
  174. collapseTags: true,
  175. checkStrictly: true,
  176. clearable: false,
  177. multiple: true,
  178. items: []
  179. }
  180. ]
  181. })
  182. // 期望城市、其它感兴趣的城市
  183. getDict('areaTreeData', null, 'areaTreeData').then(({ data }) => {
  184. data = data?.length && data || []
  185. items.value.options.find(e => e.key === 'workAreaId').items = data
  186. items.value.options.find(e => e.key === 'interestedAreaIdList').items = data
  187. })
  188. // 求职类型
  189. getDict('menduner_job_type').then(({ data }) => {
  190. data = data?.length && data || []
  191. items.value.options.find(e => e.key === 'jobType').items = data
  192. })
  193. // 岗位tree
  194. getDict('positionTreeData', null, 'positionTreeData').then(({ data }) => {
  195. data = data?.length && data || []
  196. items.value.options.find(e => e.key === 'positionId').items = data
  197. })
  198. // 期望行业
  199. getDict('industryTreeData', null, 'industryTreeData').then(({ data }) => {
  200. data = data?.length && data || []
  201. items.value.options.find(e => e.key === 'industryIdList').items = data
  202. })
  203. // 获取求职意向
  204. const interestList = ref([])
  205. const getJobInterested = async () => {
  206. const data = await getResumeJobInterested()
  207. // 完成度展示
  208. emit('complete', { status: Boolean(data?.length), id: 'jobIntention' })
  209. if (!data.length) {
  210. interestList.value = []
  211. return
  212. }
  213. interestList.value = dealJobData(data)
  214. }
  215. getJobInterested()
  216. const resetForm = () => {
  217. items.value.options.forEach(e => {
  218. if (e.key === 'industryIdList') e.value = []
  219. else e.value = null
  220. })
  221. editId.value = null
  222. query = {}
  223. }
  224. const handleSave = async () => {
  225. const { valid } = await formPageRef.value.formRef.validate()
  226. if (!valid) return
  227. items.value.options.forEach(e => {
  228. query[e.key] = e.value
  229. })
  230. if (editId.value) query.id = editId.value
  231. await saveResumeJobInterested(query)
  232. Snackbar.success('保存成功')
  233. isAdd.value = false
  234. resetForm()
  235. getJobInterested()
  236. }
  237. const handleEdit = async (item) => {
  238. editId.value = item.id
  239. items.value.options.forEach(e => {
  240. query[e.key] = item[e.key]
  241. e.value = item[e.key]
  242. if (e.key === 'interestedAreaIdList') {
  243. e.value = item[e.key] && item[e.key].length ? item[e.key].map(e => Number(e)) : []
  244. }
  245. })
  246. isAdd.value = true
  247. }
  248. const handleDelete = ({ id }) => {
  249. Confirm('系统提示', '是否确认删除此项求职意向?').then(async () => {
  250. await deleteResumeJobInterested(id)
  251. Snackbar.success('删除成功!')
  252. getJobInterested()
  253. })
  254. }
  255. </script>
  256. <style scoped lang="scss">
  257. .jobTypeCardBox {
  258. position: absolute;
  259. top: -22px;
  260. left: 0;
  261. }
  262. .position-item {
  263. display: flex;
  264. justify-content: space-between;
  265. cursor: pointer;
  266. border-radius: 6px;
  267. line-height: 40px;
  268. font-size: 15px;
  269. &:hover {
  270. background-color: var(--color-f8);
  271. }
  272. span {
  273. font-size: 15px;
  274. }
  275. .grey-text {
  276. color: var(--color-999);
  277. }
  278. }
  279. .text-box {
  280. max-width: 300px;
  281. white-space: nowrap;
  282. text-overflow: ellipsis;
  283. overflow: hidden;
  284. }
  285. .line {
  286. color: #e0e0e0;
  287. margin: 0 10px;
  288. }
  289. </style>