positions.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371
  1. <template>
  2. <div class="top">
  3. <div class="d-flex" v-if="positionCategory.length">
  4. <div class="font-weight-bold position-category-left">职位类别:</div>
  5. <div class="position-category-right">
  6. <span
  7. :class="['category-item', {'default-active': k.active}, {'font-weight-bold': k.active}]"
  8. v-for="k in positionCategory"
  9. :key="k.id"
  10. @click.stop="handleClickCategory(k)"
  11. >{{ k.id === -1 ? `${k.label}` : `${k.label} (${k.number})` }}</span>
  12. </div>
  13. </div>
  14. <div class="d-flex mt-1 justify-space-between">
  15. <conditionFilter v-if="show" ref="conditionFilterRef" :showFilterList="showFilterList" @reset="handleReset" @change="handleQueryChange"></conditionFilter>
  16. <div style="width: 220px;" class="mt-2">
  17. <v-text-field
  18. v-model="query.content"
  19. variant="outlined"
  20. label="查找职位关键字"
  21. hide-details
  22. color="primary"
  23. append-inner-icon="mdi-magnify"
  24. @click:append-inner="handleSearch('content', { values: query.content })"
  25. @keyup.enter="handleSearch('content', { values: query.content })"
  26. >
  27. </v-text-field>
  28. </div>
  29. </div>
  30. </div>
  31. <v-divider class="mt-5"></v-divider>
  32. <div class="bottom mt-4">
  33. <div v-if="list.length">
  34. <div
  35. v-for="(val, i) in list"
  36. :key="i"
  37. :class="['bottom-item', {'border-bottom-dashed': i !== list.length -1}, 'd-flex', 'justify-space-between', 'cursor-pointer']"
  38. @mouseenter="val.active = true"
  39. @mouseleave="val.active = false"
  40. >
  41. <div>
  42. <p v-if="val.job.name.includes('style')" :class="['name', {'default-active': val.active }]" v-html="val.job.name" @click.stop="handlePosition(val)"></p>
  43. <p v-else :class="['name', {'default-active': val.active }]" @click.stop="handlePosition(val)">{{ formatName(val.job.name) }}</p>
  44. <div style="line-height: 40px;">
  45. <span v-for="k in desc" :key="k.mdi">
  46. <span v-if="val.job[k.value] || k.value === 'areaName'" class="mr-5">
  47. <v-icon color="var(--color-666)" size="15">{{ k.mdi }}</v-icon>
  48. <span class="ml-1 tag-text">
  49. {{ k.value === 'areaName' ? !val.job.areaId ? '全国' : val.job.area?.str : val.job[k.value] }}
  50. </span>
  51. </span>
  52. </span>
  53. </div>
  54. </div>
  55. <div v-if="!val.active" class="text-right">
  56. <p v-if="!val.job.payFrom && !val.job.payTo" class="salary">面议</p>
  57. <p v-else class="salary">{{ val.job.payFrom ? val.job.payFrom + '-' : '' }}{{ val.job.payTo }}{{ val.job.payName ? '/' + val.job.payName : '' }}</p>
  58. <div class="update-time">{{ timesTampChange(val.job.updateTime) }} 刷新</div>
  59. </div>
  60. <div v-else class="account-info">
  61. <v-avatar :image="getUserAvatar(val.contact.avatar, val.contact.sex)"></v-avatar>
  62. <span class="account-label">{{ val.contact.name }}{{ val.contact.postNameCn ? ' · ' + val.contact.postNameCn : '' }}</span>
  63. <span>
  64. <v-btn class="half-button" color="primary" size="small" @click="toDetails(val)">立即沟通</v-btn>
  65. </span>
  66. </div>
  67. </div>
  68. <MPagination
  69. :total="total"
  70. :page="pageInfo.pageNo"
  71. :limit="pageInfo.pageSize"
  72. @handleChange="handleChangePage"
  73. ></MPagination>
  74. </div>
  75. <Empty v-else :elevation="false"></Empty>
  76. <!-- 快速登录 -->
  77. <loginPage v-if="showLogin" @loginSuccess="loginSuccess" @close="loginClose"></loginPage>
  78. </div>
  79. </template>
  80. <script setup>
  81. defineOptions({ name: 'recruitment-positions'})
  82. import { reactive, ref } from 'vue'
  83. import { useRoute, useRouter } from 'vue-router'
  84. import { timesTampChange } from '@/utils/date'
  85. import { getDict } from '@/hooks/web/useDictionaries'
  86. import { dealDictObjData } from '@/utils/position'
  87. import { prologue, defaultText } from '@/hooks/web/useIM'
  88. import { getUserAvatar } from '@/utils/avatar'
  89. import { getJobAdvertisedPositionCount, getJobAreaByEnterpriseId, getJobAdvertisedSearch } from '@/api/position'
  90. import MPagination from '@/components/CtPagination'
  91. import conditionFilter from '@/views/recruit/personal/position/components/conditionFilter'
  92. import loginPage from '@/views/common/loginDialog.vue'
  93. import { getToken } from '@/utils/auth'
  94. import Snackbar from '@/plugins/snackbar'
  95. import { checkPersonBaseInfo } from '@/utils/check'
  96. import dialogExtend from '@/plugins/dialogExtend'
  97. import { formatName } from '@/utils/getText'
  98. const props = defineProps({
  99. info: {
  100. type: Object,
  101. default: () => {}
  102. }
  103. })
  104. const total = ref(0)
  105. const pageInfo = ref({
  106. pageSize: 10,
  107. pageNo: 1
  108. })
  109. let query = reactive({})
  110. const route = useRoute(); const router = useRouter()
  111. let routeQuery = (route?.query && route.query && Object.keys(route?.query).length) ? route.query : null
  112. if (routeQuery?.content) query.content = routeQuery?.content || ''
  113. if (routeQuery) query = routeQuery
  114. // 职位详情
  115. const handlePosition = (val) => {
  116. window.open(`/recruit/personal/position/details/${val.job.id}`)
  117. }
  118. // 职位类型
  119. const positionList = ref([])
  120. const getDictData = async () => {
  121. const { data } = await getDict('positionData', {}, 'positionData')
  122. positionList.value = data
  123. }
  124. getDictData()
  125. const show = ref(false)
  126. const showFilterList = ref([
  127. { key: 'expType', isSingle: true },
  128. { key: 'eduType', isSingle: true },
  129. { key: 'payScope', isSingle: true },
  130. ])
  131. const getProvideData = (list) => {
  132. if (!list?.length) return show.value = true
  133. getDict('menduner_area_type', {}, 'areaList').then(({ data }) => {
  134. data = data?.length && data || []
  135. const arr = list.map(e => {
  136. const obj = data.find(k => k.id === Number(e.key))
  137. if (!obj) return
  138. return { label: obj.name, value: obj.id }
  139. }).filter(Boolean)
  140. if (arr?.length) showFilterList.value.unshift({ key: 'areaIds', isSingle: true, provideData: arr})
  141. show.value = true
  142. })
  143. }
  144. // 职位类别&工作地点
  145. const positionCategory = ref([])
  146. const getData = async () => {
  147. const data = await getJobAdvertisedPositionCount({ enterpriseId: props.info.enterprise.id })
  148. const areaList = await getJobAreaByEnterpriseId({ enterpriseId: props.info.enterprise.id })
  149. getProvideData(areaList)
  150. const list = data.map(val => {
  151. const value = positionList.value.find(e => Number(e.id) === Number(val.key))
  152. if (!value) return
  153. return { id: value.id, label: value.nameCn, number: val.value, active: false }
  154. }).filter(Boolean)
  155. positionCategory.value = [{ id: -1, label: '全部', active: true }, ...list]
  156. }
  157. const getPoAr = async () => {
  158. await getData()
  159. // 职位类别回显
  160. if (routeQuery?.positionId) {
  161. positionCategory.value.map(e => e.active = false)
  162. positionCategory.value.find(e => e.id === Number(routeQuery.positionId)).active = true
  163. }
  164. }
  165. getPoAr()
  166. // 职位类别选中
  167. const handleClickCategory = (k) => {
  168. positionCategory.value.map(e => e.active = false)
  169. k.active = !k.active
  170. handleSearch('positionId', { values: [k.id] })
  171. }
  172. const dealRouteQuery = () => {
  173. const arr = Object.keys(query).map(e => {
  174. if (Array.isArray(query[e]) && !query[e].length) {
  175. delete query[e]
  176. }
  177. if (!query[e]) delete query[e]
  178. if (e !== 'pageSize' && e !== 'pageNo' && e !== 'enterpriseId' && e !== 'key') return `${e}=${query[e]}`
  179. }).filter(Boolean)
  180. const str = ['key=recruitmentPositions', ...arr].join('&')
  181. if (str) router.replace(`${route.path}?${str}`)
  182. }
  183. const handleSearch = (key, { values = [] }) => {
  184. if (key) {
  185. if (values === -1 || !values || values[0] === -1 || !values.length) delete query[key]
  186. else if (['payScope', 'positionId'].includes(key)) query[key] = values?.length ? values[values.length-1] : '' // 单选且传递字符串
  187. else query[key] = values
  188. }
  189. dealRouteQuery()
  190. getPositionList(true)
  191. }
  192. // 职位列表
  193. const list = ref([])
  194. // 职位列表
  195. const getPositionList = async (isSearch) => {
  196. const queryParams = {
  197. ...query,
  198. ...pageInfo.value,
  199. enterpriseId: props.info.enterprise.id
  200. }
  201. delete queryParams.key
  202. for (const key in queryParams) {
  203. if (['expType', 'eduType'].includes(key) && queryParams[key] === '9999') delete queryParams[key]
  204. }
  205. if (isSearch) query.pageNo = 1
  206. const { list: arr, total: number } = await getJobAdvertisedSearch(queryParams)
  207. total.value = number
  208. list.value = arr.map(e => {
  209. e.active = false
  210. e.job = { ...e.job, ...dealDictObjData({}, e.job) }
  211. return e
  212. })
  213. }
  214. getPositionList()
  215. const handleChangePage = (index) => {
  216. pageInfo.value.pageNo = index
  217. getPositionList()
  218. }
  219. // 参数改变
  220. const handleQueryChange = (key, val) => { // val为字符串,数组的话用_下划线分隔
  221. pageInfo.value.pageNo = 1
  222. const values = val ? val.split('_') : []
  223. handleSearch(key, { values })
  224. }
  225. // 清空筛选条件
  226. const handleReset = async () => {
  227. pageInfo.value.pageNo = 1
  228. showFilterList.value.forEach(e => {
  229. delete query[e.key]
  230. })
  231. delete query['positionId']
  232. handleSearch(null, {})
  233. }
  234. // 城市、学历、工作经验
  235. const desc = [
  236. { mdi: 'mdi-map-marker-outline', value: 'areaName' },
  237. { mdi: 'mdi-school-outline', value: 'eduName' },
  238. { mdi: 'mdi-clock-time-ten-outline', value: 'expName' }
  239. ]
  240. let toDetailsInfo = {}
  241. // 沟通
  242. const toDetails = async (info) => {
  243. if (info) toDetailsInfo = info // 快速登录弹窗回调使用
  244. else info = toDetailsInfo
  245. if (!getToken()) {
  246. showLogin.value = true // 打开快速登录弹窗
  247. Snackbar.warning('您还未登录,请先登录后再试')
  248. //
  249. loginCloseWarningWord = '您已取消登录,无法对职位进行沟通' // 取消登录提示语
  250. nextFunc.value = toDetails // 登录成功后要执行的操作 (toDetails执行不成功,原因未找到)
  251. return
  252. }
  253. if (!checkPersonBaseInfo()) { // 强制填写个人信息
  254. dialogExtend('necessaryInfoDialog').then(() => {
  255. toDetails(toDetailsInfo)
  256. })
  257. return
  258. }
  259. const userId = info.contact.userId
  260. const enterpriseId = info.contact.enterpriseId
  261. const textObj = {
  262. text: defaultText,
  263. positionInfo: { ...info.job, enterprise: info.enterprise, contact: info.contact },
  264. }
  265. await prologue({userId, enterpriseId, text: JSON.stringify(textObj)})
  266. let url = `/recruit/personal/message?id=${info.job.id}`
  267. if (info.contact.enterpriseId) {
  268. url += `&enterprise=${info.contact.enterpriseId}`
  269. }
  270. window.open(url)
  271. }
  272. const showLogin = ref(false)
  273. const nextFunc = ref(null)
  274. let loginCloseWarningWord = ''
  275. // 快速登录
  276. const loginSuccess = () => {
  277. showLogin.value = false
  278. Snackbar.success('登录成功')
  279. if (nextFunc.value) nextFunc.value()
  280. }
  281. const loginClose = () => {
  282. showLogin.value = false
  283. Snackbar.warning(loginCloseWarningWord)
  284. }
  285. </script>
  286. <style scoped lang="scss">
  287. .bottom-item {
  288. width: 100%;
  289. height: 68px;
  290. margin-bottom: 12px;
  291. }
  292. .name {
  293. position: relative;
  294. max-width: 30vw;
  295. margin-right: 8px;
  296. overflow: hidden;
  297. text-overflow: ellipsis;
  298. white-space: nowrap;
  299. font-weight: 600;
  300. color: #0E100F;
  301. }
  302. .salary {
  303. font-size: 16px;
  304. font-weight: 700;
  305. color: var(--v-primary-base);
  306. line-height: 22px;
  307. flex: none;
  308. }
  309. .tag-text {
  310. color: var(--color-222);
  311. font-size: 14px;
  312. }
  313. .update-time {
  314. color: var(--color-666);
  315. font-size: 14px;
  316. line-height: 40px;
  317. }
  318. .account-info {
  319. line-height: 52px;
  320. .account-label {
  321. color: var(--color-666);
  322. font-size: 14px;
  323. font-weight: 600;
  324. margin: 0 10px;
  325. }
  326. }
  327. .position-category-left {
  328. width: 80px;
  329. }
  330. .position-category-right {
  331. flex: 1;
  332. }
  333. .category-item {
  334. display: inline-block;
  335. margin-right: 20px;
  336. font-size: 15px;
  337. color: var(--color-666);
  338. cursor: pointer;
  339. &:hover {
  340. color: var(--v-primary-base);
  341. }
  342. }
  343. :deep(.v-field__input) {
  344. height: 28px;
  345. padding: 0 0 0 10px;
  346. font-size: 12px;
  347. min-height: 28px;
  348. }
  349. </style>