jobIntention.vue 8.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292
  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">|</div>
  23. <div class="grey-text">{{ k.jobTypeName }}</div>
  24. <div class="line">|</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="{ 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].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/resume'
  95. import { dealJobData } from './dict'
  96. const isAdd = ref(false)
  97. const formPageRef = ref()
  98. const editId = ref(null)
  99. let query = reactive({})
  100. const items = ref({
  101. options: [
  102. {
  103. slotName: 'positionId',
  104. key: 'positionId',
  105. value: '',
  106. col: 6,
  107. label: '期望岗位 *',
  108. flexStyle: 'mr-3',
  109. valueKey: 'position',
  110. hideDetails: true,
  111. outlined: true,
  112. rules: [v => !!v || '请选择期望岗位']
  113. },
  114. {
  115. slotName: 'industryIdList',
  116. key: 'industryIdList',
  117. value: '不限',
  118. outlined: true,
  119. label: '期望行业 *',
  120. col: 6,
  121. rules: [v => !!v || '请选择期望行业']
  122. },
  123. {
  124. type: 'number',
  125. key: 'payFrom',
  126. value: null,
  127. label: '期望薪资(最低要求) *',
  128. col: 6,
  129. flexStyle: 'mr-3',
  130. outlined: true,
  131. rules: [v => !!v || '请输入薪资最低要求']
  132. },
  133. {
  134. type: 'number',
  135. key: 'payTo',
  136. value: null,
  137. label: '期望薪资(最高要求) *',
  138. col: 6,
  139. outlined: true,
  140. rules: [v => !!v || '请输入薪资最高要求']
  141. },
  142. {
  143. slotName: 'workAreaId',
  144. key: 'workAreaId',
  145. value: null,
  146. label: '工作城市 *',
  147. valueKey: 'workArea',
  148. col: 6,
  149. flexStyle: 'mr-3',
  150. rules: [v => !!v || '请选择工作城市']
  151. },
  152. {
  153. type: 'autocomplete',
  154. key: 'jobType',
  155. value: null,
  156. label: '求职类型 *',
  157. outlined: true,
  158. itemText: 'label',
  159. col: 6,
  160. itemValue: 'value',
  161. rules: [v => !!v || '请选择求职类型'],
  162. items: [
  163. { label: '全职', value: '0' },
  164. { label: '兼职', value: '1' },
  165. { label: '临时', value: '2' },
  166. { label: '实习', value: '3' }
  167. ]
  168. }
  169. ]
  170. })
  171. // 获取求职意向
  172. const interestList = ref([])
  173. const getJobInterested = async () => {
  174. const data = await getResumeJobInterested()
  175. if (!data.length) return
  176. interestList.value = data
  177. interestList.value = dealJobData(data)
  178. }
  179. getJobInterested()
  180. const setValue = (key, value) => {
  181. items.value.options.find(e => e.key === key).value = value
  182. }
  183. // 期望职位
  184. const handleJobClickItem = (list, name) => {
  185. if (!list.length) return
  186. query.positionId = list[0]
  187. setValue('positionId', name)
  188. }
  189. // 行业类型
  190. let currentSelect = reactive([])
  191. const handleIndustry = (list, arr) => {
  192. if (!list.length) return setValue('industryIdList', '不限')
  193. query.industryIdList = list
  194. currentSelect = arr
  195. const str = arr.map(e => e.nameCn).join('、')
  196. setValue('industryIdList', str)
  197. }
  198. // 工作城市
  199. const handleArea = (list, name) => {
  200. if (!list.length) return
  201. query.workAreaId = list[0]
  202. setValue('workAreaId', name)
  203. }
  204. const resetForm = () => {
  205. items.value.options.forEach(e => {
  206. if (e.key === 'industryIdList') e.value = '不限'
  207. else e.value = null
  208. })
  209. editId.value = null
  210. query = {}
  211. currentSelect = []
  212. }
  213. const arr = ['payFrom', 'payTo', 'jobType']
  214. const handleSave = async () => {
  215. const { valid } = await formPageRef.value.formRef.validate()
  216. if (!valid) return
  217. items.value.options.forEach(e => {
  218. if (arr.includes(e.key)) query[e.key] = e.value
  219. })
  220. if (editId.value) query.id = editId.value
  221. await saveResumeJobInterested(query)
  222. Snackbar.success('保存成功')
  223. isAdd.value = false
  224. resetForm()
  225. getJobInterested()
  226. }
  227. const handleEdit = (item) => {
  228. editId.value = item.id
  229. items.value.options.forEach(e => {
  230. query[e.key] = item[e.key]
  231. if (e.valueKey) {
  232. e.value = item[e.valueKey]
  233. } else e.value = item[e.key]
  234. if (e.key === 'industryIdList') e.value = item.industry.map(e => e.nameCn).join('、')
  235. })
  236. currentSelect = item.industry
  237. isAdd.value = true
  238. }
  239. const handleDelete = ({ id }) => {
  240. Confirm('系统提示', '是否确认删除此项求职意向?').then(async () => {
  241. await deleteResumeJobInterested(id)
  242. Snackbar.success('删除成功!')
  243. getJobInterested()
  244. })
  245. }
  246. </script>
  247. <style scoped lang="scss">
  248. .jobTypeCardBox {
  249. position: absolute;
  250. top: -22px;
  251. left: 0;
  252. }
  253. .position-item {
  254. display: flex;
  255. justify-content: space-between;
  256. cursor: pointer;
  257. border-radius: 6px;
  258. line-height: 40px;
  259. font-size: 15px;
  260. &:hover {
  261. background-color: var(--color-f8);
  262. }
  263. span {
  264. font-size: 15px;
  265. }
  266. .grey-text {
  267. color: var(--color-999);
  268. }
  269. }
  270. .text-box {
  271. max-width: 200px;
  272. white-space: nowrap;
  273. text-overflow: ellipsis;
  274. overflow: hidden;
  275. }
  276. .line {
  277. color: #e0e0e0;
  278. margin: 0 10px;
  279. }
  280. </style>