index.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385
  1. <template>
  2. <div class="mt-4">
  3. <div class="d-flex justify-center">
  4. <TextInput v-model="queryParams.content" :item="textItem" @enter="handleConfirm" @appendInnerClick="handleConfirm"></TextInput>
  5. </div>
  6. <div>
  7. <Position :isClear="clear" @clear="clear = false" :selectData="position" @select="val => position = val"></Position>
  8. <div class="font-size-15 d-flex align-center color-666">
  9. <span>地&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;区:</span>
  10. <cascade v-model="queryParams.areaIds" :item="selectItems" @change="val => handleSearch('areaIds', val)" style="width: 300px;"></cascade>
  11. </div>
  12. <CommonPage :isClear="clear" @clear="clear = false" class="my-3" dictType="menduner_education_type" title="最高学历" @select="val => handleSearch('eduType', val)"></CommonPage>
  13. <CommonPage :isClear="clear" @clear="clear = false" dictType="menduner_exp_type" title="工作经验" @select="val => handleSearch('expType', val)"></CommonPage>
  14. <v-divider class="mt-1 mb-3"></v-divider>
  15. <div>
  16. <div>
  17. <v-chip v-for="k in position" :key="k.id" label class="mr-3" closable @click:close="handleClose(k)">{{ k.nameCn }}</v-chip>
  18. </div>
  19. <div class="text-end">
  20. <v-btn color="primary" variant="text" @click="handleClear">清空筛选条件</v-btn>
  21. </div>
  22. </div>
  23. <div class="text-center mt-3">
  24. <v-btn class="half-button" color="primary" @click="handleConfirm">搜 索</v-btn>
  25. </div>
  26. </div>
  27. </div>
  28. <div class="mt-10" v-loading="loading">
  29. <v-divider></v-divider>
  30. <div class="py-3">
  31. <v-card
  32. v-for="item in items"
  33. :key="item.id"
  34. elevation="5"
  35. class="mb-3"
  36. :subtitle="item.subTitle"
  37. :title="item?.name"
  38. >
  39. <template #prepend>
  40. <v-badge
  41. v-if="item?.sex === '1' || item?.sex === '2'"
  42. class="mr-3 cursor-pointer"
  43. bordered
  44. offset-y="6"
  45. :color="badgeColor(item)"
  46. :icon="badgeIcon(item)"
  47. @click="handleToPersonDetail(item)"
  48. >
  49. <v-avatar size="48" :image="getUserAvatar(item.avatar, item.sex)"></v-avatar>
  50. </v-badge>
  51. <v-avatar v-else class="mr-3 cursor-pointer" size="48" :image="getUserAvatar(item.avatar, item.sex)" @click="handleToPersonDetail(item)"></v-avatar>
  52. </template>
  53. <template #append>
  54. <v-btn color="primary" variant="text" @click="handleInvite(item)">邀请面试</v-btn>
  55. <v-btn color="primary" variant="text" @click="handleCommunicate(item)">立即沟通</v-btn>
  56. </template>
  57. <template #title>
  58. <span class="cursor-pointer defaultLink" @click="handleToPersonDetail(item)">
  59. {{ item.name }}
  60. </span>
  61. </template>
  62. <template #subtitle>
  63. <div class="d-flex">
  64. <div class="mr-10">{{ item.subTitle }}</div>
  65. <div class="mr-10">首次工作时间: {{ timesTampChange(item.firstWorkTime, 'Y-M-D') }}</div>
  66. <div v-if="item.interestedList?.length" class="mr-10 d-flex flex-wrap">
  67. <div>求职意向:</div>
  68. <div
  69. v-for="(interested, index) in item.interestedList"
  70. :key="interested.id"
  71. >
  72. <span :class="{'mx-3': index}">{{ (index ? '|' : '') }}</span>
  73. <span>{{ positionData.find(e => e.id === interested.positionId)?.nameCn ?? '暂无' }}</span>
  74. </div>
  75. </div>
  76. </div>
  77. </template>
  78. <div class="px-5 pb-8">
  79. <div v-if="item?.workList?.length">
  80. <div class="second-title">工作经验</div>
  81. <v-timeline density="compact" align="start" side="end" truncate-line="both">
  82. <v-timeline-item v-for="(j, i) in item.workList" :key="i" dot-color="primary" size="small">
  83. <div v-if="j.show" class="timeline-item mt-1">
  84. <div v-ellipse-tooltip style="width: 20%;">
  85. <span>{{ j.startTimeStr }}</span>
  86. <span v-if="j.endTimeStr"> - {{ j.endTimeStr }}</span>
  87. <span v-if="j.year"> ({{ j.year }})</span>
  88. </div>
  89. <div v-ellipse-tooltip class="timeline-item-name mx-3">{{ formatName(j.enterpriseName) || '' }}</div>
  90. <div v-ellipse-tooltip class="timeline-item-name">{{ formatName(j.positionName) || '' }}</div>
  91. </div>
  92. </v-timeline-item>
  93. </v-timeline>
  94. </div>
  95. </div>
  96. </v-card>
  97. </div>
  98. <CtPagination :total="total" :page="query.pageNo" :limit="query.pageSize" @handleChange="handleChangePage"></CtPagination>
  99. </div>
  100. <CtDialog :visible="showInvite" :widthType="4" titleClass="text-h6" title="邀请面试" @close="showInvite = false" @submit="handleSubmit">
  101. <InvitePage v-if="showInvite" ref="inviteRef" :item-data="itemData" :position="positionList"></InvitePage>
  102. </CtDialog>
  103. <TipDialog :visible="showTip" icon="mdi-check-circle-outline" message="面试邀请发送成功" @close="showTip = false">
  104. <div class="color-primary text-decoration-underline cursor-pointer" @click="handleToInterviewManagement">点击到面试中查看。</div>
  105. </TipDialog>
  106. </template>
  107. <script setup>
  108. defineOptions({ name: 'searchRetrieval' })
  109. import { ref, computed } from 'vue'
  110. import CommonPage from '../components/common.vue'
  111. import Position from './components/position.vue'
  112. import { getPersonSearchPage } from '@/api/enterprise.js'
  113. import { dealDictArrayData } from '@/utils/position'
  114. import { timesTampChange } from '@/utils/date'
  115. import { talkToUser, defaultTextEnt } from '@/hooks/web/useIM'
  116. import { getUserAvatar } from '@/utils/avatar'
  117. import { getJobAdvertisedList } from '@/api/position'
  118. import Snackbar from '@/plugins/snackbar'
  119. import { saveInterviewInvite } from '@/api/recruit/enterprise/interview'
  120. import { useRouter } from 'vue-router'; const router = useRouter()
  121. import InvitePage from '@/views/recruit/enterprise/interviewManagement/components/invite'
  122. import { getDict } from '@/hooks/web/useDictionaries'
  123. import { getTimeDifferenceInChinese } from '@/utils/date'
  124. import { formatName } from '@/utils/getText'
  125. const textItem = ref({
  126. type: 'text',
  127. width: 600,
  128. value: '',
  129. label: '输入关键字',
  130. clearable: true,
  131. appendInnerIcon: 'mdi-magnify'
  132. })
  133. const query = ref({
  134. pageNo: 1,
  135. pageSize: 5
  136. })
  137. const queryParams = ref({
  138. content: null,
  139. positionIds: [],
  140. areaIds: [],
  141. expType: '',
  142. eduType: ''
  143. })
  144. const selectItems = ref({
  145. value: null,
  146. itemText: 'name',
  147. itemValue: 'id',
  148. hideDetails: true,
  149. clearable: true,
  150. multiple: true,
  151. checkStrictly: true,
  152. collapseTags: true,
  153. placeholder: '地区',
  154. items: [],
  155. })
  156. const positionData = ref([])
  157. getDict('areaTreeData', null, 'areaTreeData').then(res => {
  158. const data = res?.data?.length ? res.data : []
  159. if (data[0] && data[0].id === 10000) data[0].children = []
  160. selectItems.value.items = data
  161. })
  162. getDict('positionData', {}, 'positionData').then(({ data }) => {
  163. positionData.value = data
  164. })
  165. const total = ref(0)
  166. const items = ref([])
  167. const loading = ref(false)
  168. // const headers = ref([
  169. // { title: '姓名', key: 'name', sortable: false },
  170. // { title: '求职状态', key: 'jobStatusName', sortable: false },
  171. // { title: '工作年限', key: 'expName', sortable: false },
  172. // { title: '最高学历', key: 'eduName', sortable: false },
  173. // { title: '所在城市', key: 'areaName', sortable: false },
  174. // { title: '户籍地', key: 'regName', sortable: false },
  175. // { title: '婚姻状况', key: 'maritalStatusName', sortable: false },
  176. // { title: '首次工作时间', key: 'firstWorkTime', sortable: false, value: item => timesTampChange(item.firstWorkTime, 'Y-M-D') },
  177. // { title: '操作', key: 'actions', sortable: false }
  178. // ])
  179. const getData = async () => {
  180. loading.value = true
  181. try {
  182. const res = await getPersonSearchPage(Object.assign(queryParams.value, query.value))
  183. if (!res?.list?.length) {
  184. items.value = []
  185. total.value = 0
  186. return
  187. }
  188. items.value = dealDictArrayData([], res.list).map(e => {
  189. e.regName = e.reg?.str ?? ''
  190. e.areaName = e.area?.str ?? '暂无'
  191. e.subTitle = [e.jobStatusName, e.expName ? e.expName + '工作经验' : null, e.eduName, e.maritalStatusName].filter(k => k).join(' | ')
  192. if (e.workList?.length) {
  193. e.workList.forEach(exp => {
  194. exp.startTimeStr = exp.startTime ? timesTampChange(exp.startTime, 'Y-M') : '未填写工作时间'
  195. exp.endTimeStr = exp.startTime ? exp.endTime ? timesTampChange(exp.endTime, 'Y-M') : '至今' : ''
  196. exp.year = exp.endTimeStr ? getTimeDifferenceInChinese(exp.startTime, exp.endTime) : ''
  197. // 未填写工作经验内容,不展示
  198. exp.show = Boolean(exp.year) || Boolean(exp.enterpriseName) || Boolean(exp.positionName)
  199. })
  200. }
  201. return e
  202. })
  203. total.value = res.total
  204. } finally {
  205. loading.value = false
  206. }
  207. }
  208. // 分页
  209. const handleChangePage = (e) =>{
  210. query.value.pageNo = e
  211. getData()
  212. }
  213. const position = ref([])
  214. const handleSearch = (key, value) => {
  215. query.value.pageNo = 1
  216. queryParams.value[key] = value
  217. }
  218. const checkValue = (obj) => {
  219. return Object.values(obj).some(value => {
  220. return value !== null && value !== undefined && value !== '' && (Array.isArray(value) ? value.length > 0 : true)
  221. })
  222. }
  223. const handleConfirm = () => {
  224. const positionIds = position.value.map(k => k.id)
  225. queryParams.value.positionIds = positionIds || []
  226. query.value.pageNo = 1
  227. if (!checkValue(queryParams.value)) {
  228. Snackbar.warning('至少选择一个条件进行搜索')
  229. items.value = []
  230. total.value = 0
  231. return
  232. }
  233. getData()
  234. }
  235. // 清空筛选条件
  236. const clear = ref(false)
  237. const handleClear = () => {
  238. position.value = []
  239. queryParams.value = {
  240. content: null,
  241. positionIds: [],
  242. areaIds: [],
  243. expType: '',
  244. eduType: ''
  245. }
  246. query.value.pageNo = 1
  247. items.value = []
  248. total.value = 0
  249. clear.value = true
  250. }
  251. const handleClose = (item) => {
  252. position.value = position.value.filter(k => k.id !== item.id)
  253. }
  254. // 职位列表
  255. const jobNum = ref(0)
  256. const positionList = ref([])
  257. const getJobList = async () => {
  258. const { total, list } = await getJobAdvertisedList({ pageNo: 1, pageSize: 10, hasExpiredData: false, status: 0 })
  259. jobNum.value = total
  260. if (!list?.length) {
  261. positionList.value = []
  262. jobNum.value = 0
  263. return
  264. }
  265. positionList.value = list.map(e => {
  266. const salary = e.payFrom && e.payTo ? `${e.payFrom ? e.payFrom + '-' : ''}${e.payTo}${e.payName ? '/' + e.payName : ''}` : '面议'
  267. return {
  268. label: `${e.name}_${e.areaName ? e.area?.str : '全国'} ${salary}`,
  269. value: e.id,
  270. data: e
  271. }
  272. })
  273. }
  274. getJobList()
  275. // 立即沟通
  276. const handleCommunicate = async (item) => {
  277. // // 企业必须有招聘中的职位才能发起沟通
  278. if (jobNum.value === 0) return Snackbar.warning('请先发布职位')
  279. const userId = item.userId
  280. if (!userId) return
  281. await talkToUser({userId, text: defaultTextEnt})
  282. let url = `/recruit/enterprise/chatTools?id=${userId}`
  283. router.push(url)
  284. }
  285. const showInvite = ref(false)
  286. const showTip = ref(false)
  287. const inviteRef = ref()
  288. const itemData = ref({})
  289. const handleInvite = (item) => {
  290. if (jobNum.value === 0) return Snackbar.warning('请先发布职位')
  291. itemData.value = item
  292. showInvite.value = true
  293. }
  294. // 发送面试邀请
  295. const handleSubmit = async () => {
  296. const { valid } = await inviteRef.value.CtFormRef.formRef.validate()
  297. if (!valid) {
  298. return
  299. }
  300. const query = inviteRef.value.getQuery()
  301. if (!query.time) {
  302. Snackbar.warning('时间不能为空')
  303. return
  304. }
  305. delete query.id
  306. await saveInterviewInvite(query)
  307. showInvite.value = false
  308. showTip.value = true
  309. }
  310. const handleToInterviewManagement = () => {
  311. router.push('/recruit/enterprise/interviewManagement')
  312. }
  313. // 人才详情
  314. const handleToPersonDetail = ({ userId }) => {
  315. if (!userId) return
  316. window.open(`/recruit/enterprise/talentPool/details/${userId}`)
  317. }
  318. const badgeColor = computed(() => (item) => {
  319. return (item && item.sex) ? (item.sex === '1' ? '#1867c0' : 'error') : 'error'
  320. })
  321. const badgeIcon = computed(() => (item) => {
  322. return (item && item.sex) ? (item.sex === '1' ? 'mdi-gender-male' : 'mdi-gender-female') : 'mdi-gender-female'
  323. })
  324. </script>
  325. <style scoped lang="scss">
  326. .clear:hover {
  327. color: var(--v-primary-base);
  328. }
  329. .second-title {
  330. color: var(--color-666);
  331. font-size: 15px;
  332. }
  333. .timeline-item {
  334. display: flex;
  335. align-items: center;
  336. justify-content: space-between;
  337. width: 100%;
  338. color: var(--color-666);
  339. font-size: 13px;
  340. .timeline-item-name {
  341. width: 40%;
  342. }
  343. }
  344. :deep(.v-timeline-item__body) {
  345. width: 100%;
  346. }
  347. :deep(.v-timeline--vertical.v-timeline) {
  348. row-gap: 0;
  349. }
  350. :deep(.v-timeline-divider__dot--size-small) {
  351. width: 10px !important;
  352. height: 10px !important;
  353. margin-top: 10px !important;
  354. }
  355. :deep(.v-timeline-divider__inner-dot) {
  356. width: 10px !important;
  357. height: 10px !important;
  358. }
  359. </style>