index.vue 9.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294
  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 font-size-15 cursor-pointer color-primary clear" @click="handleClear">清空筛选条件</div>
  20. </div>
  21. <div class="text-center mt-3">
  22. <v-btn class="half-button" color="primary" @click="handleConfirm">搜 索</v-btn>
  23. </div>
  24. </div>
  25. </div>
  26. <div class="mt-10">
  27. <v-divider></v-divider>
  28. <CtTable
  29. :items="items"
  30. :headers="headers"
  31. :loading="loading"
  32. :elevation="0"
  33. :isTools="false"
  34. :showPage="true"
  35. :total="total"
  36. :page-info="query"
  37. itemKey="id"
  38. @pageHandleChange="handleChangePage"
  39. >
  40. <template #name="{ item }">
  41. <div class="d-flex align-center cursor-pointer" @click="handleToPersonDetail(item)">
  42. <v-badge
  43. v-if="item?.sex === '1' || item?.sex === '2'"
  44. bordered
  45. offset-y="6"
  46. :color="badgeColor(item)"
  47. :icon="badgeIcon(item)">
  48. <v-avatar size="40" :image="getUserAvatar(item.avatar, item.sex)"></v-avatar>
  49. </v-badge>
  50. <v-avatar v-else size="40" :image="getUserAvatar(item.avatar, item.sex)"></v-avatar>
  51. <span class="defaultLink ml-3 mt-2">{{ item?.name }}</span>
  52. </div>
  53. </template>
  54. <template #actions="{ item }">
  55. <v-btn color="primary" variant="text" @click="handleInvite(item)">邀请面试</v-btn>
  56. <v-btn color="primary" variant="text" @click="handleCommunicate(item)">立即沟通</v-btn>
  57. </template>
  58. </CtTable>
  59. </div>
  60. <CtDialog :visible="showInvite" :widthType="4" titleClass="text-h6" title="邀请面试" @close="showInvite = false" @submit="handleSubmit">
  61. <InvitePage v-if="showInvite" ref="inviteRef" :item-data="itemData" :position="positionList"></InvitePage>
  62. </CtDialog>
  63. <TipDialog :visible="showTip" icon="mdi-check-circle-outline" message="面试邀请发送成功" @close="showTip = false">
  64. <div class="color-primary text-decoration-underline cursor-pointer" @click="handleToInterviewManagement">点击到面试中查看。</div>
  65. </TipDialog>
  66. </template>
  67. <script setup>
  68. defineOptions({ name: 'searchRetrieval' })
  69. import { ref, computed } from 'vue'
  70. import CommonPage from '../components/common.vue'
  71. import Position from './components/position.vue'
  72. import { getPersonSearchPage } from '@/api/enterprise.js'
  73. import { dealDictArrayData } from '@/utils/position'
  74. import { timesTampChange } from '@/utils/date'
  75. import { talkToUser, defaultTextEnt } from '@/hooks/web/useIM'
  76. import { getUserAvatar } from '@/utils/avatar'
  77. import { getJobAdvertisedList } from '@/api/position'
  78. import Snackbar from '@/plugins/snackbar'
  79. import { saveInterviewInvite } from '@/api/recruit/enterprise/interview'
  80. import { useRouter } from 'vue-router'; const router = useRouter()
  81. import InvitePage from '@/views/recruit/enterprise/interviewManagement/components/invite'
  82. import { getDict } from '@/hooks/web/useDictionaries'
  83. const textItem = ref({
  84. type: 'text',
  85. width: 600,
  86. value: '',
  87. label: '输入关键字',
  88. clearable: true,
  89. appendInnerIcon: 'mdi-magnify'
  90. })
  91. const query = ref({
  92. pageNo: 1,
  93. pageSize: 10
  94. })
  95. const queryParams = ref({
  96. content: null,
  97. positionIds: [],
  98. areaIds: [],
  99. expType: '',
  100. eduType: ''
  101. })
  102. const selectItems = ref({
  103. value: null,
  104. itemText: 'name',
  105. itemValue: 'id',
  106. hideDetails: true,
  107. clearable: true,
  108. multiple: true,
  109. checkStrictly: true,
  110. collapseTags: true,
  111. placeholder: '地区',
  112. items: [],
  113. })
  114. getDict('areaTreeData', null, 'areaTreeData').then(res => {
  115. const data = res?.data?.length ? res.data : []
  116. if (data[0] && data[0].id === 10000) data[0].children = []
  117. selectItems.value.items = data
  118. })
  119. const total = ref(0)
  120. const items = ref([])
  121. const loading = ref(false)
  122. const headers = ref([
  123. { title: '姓名', key: 'name', sortable: false },
  124. { title: '求职状态', key: 'jobStatusName', sortable: false },
  125. { title: '工作年限', key: 'expName', sortable: false },
  126. { title: '最高学历', key: 'eduName', sortable: false },
  127. { title: '所在城市', key: 'areaName', sortable: false },
  128. { title: '户籍地', key: 'regName', sortable: false },
  129. { title: '婚姻状况', key: 'maritalStatusName', sortable: false },
  130. { title: '首次工作时间', key: 'firstWorkTime', sortable: false, value: item => timesTampChange(item.firstWorkTime, 'Y-M-D') },
  131. { title: '操作', key: 'actions', sortable: false }
  132. ])
  133. const getData = async () => {
  134. loading.value = true
  135. try {
  136. const res = await getPersonSearchPage(Object.assign(queryParams.value, query.value))
  137. if (!res.list.length) {
  138. items.value = []
  139. total.value = 0
  140. return
  141. }
  142. items.value = dealDictArrayData([], res.list).map(e => {
  143. e.regName = e.reg?.str ?? ''
  144. e.areaName = e.area?.str ?? '全国'
  145. return e
  146. })
  147. total.value = res.total
  148. } finally {
  149. loading.value = false
  150. }
  151. }
  152. // 分页
  153. const handleChangePage = (e) =>{
  154. query.value.pageNo = e
  155. getData()
  156. }
  157. const position = ref([])
  158. const handleSearch = (key, value) => {
  159. query.value.pageNo = 1
  160. queryParams.value[key] = value
  161. }
  162. const checkValue = (obj) => {
  163. return Object.values(obj).some(value => {
  164. return value !== null && value !== undefined && value !== '' && (Array.isArray(value) ? value.length > 0 : true)
  165. })
  166. }
  167. const handleConfirm = () => {
  168. const positionIds = position.value.map(k => k.id)
  169. queryParams.value.positionIds = positionIds || []
  170. query.value.pageNo = 1
  171. if (!checkValue(queryParams.value)) {
  172. Snackbar.warning('至少选择一个条件进行搜索')
  173. items.value = []
  174. total.value = 0
  175. return
  176. }
  177. getData()
  178. }
  179. // 清空筛选条件
  180. const clear = ref(false)
  181. const handleClear = () => {
  182. position.value = []
  183. queryParams.value = {
  184. content: null,
  185. positionIds: [],
  186. areaIds: [],
  187. expType: '',
  188. eduType: ''
  189. }
  190. query.value.pageNo = 1
  191. items.value = []
  192. total.value = 0
  193. clear.value = true
  194. }
  195. const handleClose = (item) => {
  196. position.value = position.value.filter(k => k.id !== item.id)
  197. }
  198. // 职位列表
  199. const jobNum = ref(0)
  200. const positionList = ref([])
  201. const getJobList = async () => {
  202. const { total, list } = await getJobAdvertisedList({ pageNo: 1, pageSize: 10, hasExpiredData: false, status: 0 })
  203. jobNum.value = total
  204. if (!list.length) {
  205. positionList.value = []
  206. jobNum.value = 0
  207. return
  208. }
  209. positionList.value = list.map(e => {
  210. const salary = e.payFrom && e.payTo ? `${e.payFrom ? e.payFrom + '-' : ''}${e.payTo}${e.payName ? '/' + e.payName : ''}` : '面议'
  211. return {
  212. label: `${e.name}_${e.areaName ? e.area?.str : '全国'} ${salary}`,
  213. value: e.id,
  214. data: e
  215. }
  216. })
  217. }
  218. getJobList()
  219. // 立即沟通
  220. const handleCommunicate = async (item) => {
  221. // // 企业必须有招聘中的职位才能发起沟通
  222. if (jobNum.value === 0) return Snackbar.warning('请先发布职位')
  223. const userId = item.userId
  224. if (!userId) return
  225. await talkToUser({userId, text: defaultTextEnt})
  226. let url = `/recruit/enterprise/chatTools?id=${userId}`
  227. router.push(url)
  228. }
  229. const showInvite = ref(false)
  230. const showTip = ref(false)
  231. const inviteRef = ref()
  232. const itemData = ref({})
  233. const handleInvite = (item) => {
  234. if (jobNum.value === 0) return Snackbar.warning('请先发布职位')
  235. itemData.value = item
  236. showInvite.value = true
  237. }
  238. // 发送面试邀请
  239. const handleSubmit = async () => {
  240. const { valid } = await inviteRef.value.CtFormRef.formRef.validate()
  241. if (!valid) {
  242. return
  243. }
  244. const query = inviteRef.value.getQuery()
  245. if (!query.time) {
  246. Snackbar.warning('时间不能为空')
  247. return
  248. }
  249. delete query.id
  250. await saveInterviewInvite(query)
  251. showInvite.value = false
  252. showTip.value = true
  253. }
  254. const handleToInterviewManagement = () => {
  255. router.push('/recruit/enterprise/interviewManagement')
  256. }
  257. // 人才详情
  258. const handleToPersonDetail = ({ userId, id }) => {
  259. if (!userId || !id) return
  260. window.open(`/recruit/enterprise/talentPool/details/${userId}?id=${id}`)
  261. }
  262. const badgeColor = computed(() => (item) => {
  263. return (item && item.sex) ? (item.sex === '1' ? '#1867c0' : 'error') : 'error'
  264. })
  265. const badgeIcon = computed(() => (item) => {
  266. return (item && item.sex) ? (item.sex === '1' ? 'mdi-gender-male' : 'mdi-gender-female') : 'mdi-gender-female'
  267. })
  268. </script>
  269. <style scoped lang="scss">
  270. .clear:hover {
  271. color: var(--v-primary-base);
  272. }
  273. </style>