positions.vue 12 KB

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