item.vue 9.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372
  1. <template>
  2. <view>
  3. <view v-for="(val, index) in items" :key="index" :is-shadow="true" @tap.stop="handleDetail(val)" class="mList default-border">
  4. <!-- 基本信息 -->
  5. <view class="d-flex align-center">
  6. <view class="user-avatar">
  7. <image class="user-avatar-img" :src="getUserAvatar(val.person?.avatar, val.person?.sex)" mode="scaleToFill"></image>
  8. <image class="user-avatar-sex" :src="val?.person?.sex ? val?.person?.sex === '1' ? '/static/img/man.png' : '/static/img/female.png' : ''" alt="" mode="scaleToFill" />
  9. </view>
  10. <view style="flex: 1; margin-left: 10px;">
  11. <view class="d-flex justify-space-between align-center">
  12. <view class="font-size-18 default-text-color">{{ val.person?.name }}</view>
  13. <view v-if="current !== 4">
  14. <span v-if="current === 0" :style="{'color': val.status && val.status === '0' ? '#fb8c00' : '#00B760'}">
  15. {{ val.status && val.status === '0' ? '未查看' : '已查看' }}
  16. </span>
  17. <span v-else class="color-999">{{ val.status ? statusList.find(i => i.value === val.status)?.label : '' }}</span>
  18. </view>
  19. </view>
  20. <view class="ss-m-t-10">
  21. <span
  22. class="color-999"
  23. v-for="(key, index) in desc"
  24. :key="index"
  25. >
  26. {{ val.person?.[key] }}
  27. <span v-if="index !== desc.length - 1 && val.person?.[key]" class="ss-m-x-10">|</span>
  28. </span>
  29. </view>
  30. </view>
  31. </view>
  32. <view class="ss-m-t-15 color-999">
  33. <view>
  34. 投递职位:
  35. <image v-if="val.jobFairId" src="/static/svg/jobFair.svg" style="width: 15px; height: 15px;"></image>
  36. {{ formatName(val.job?.name) }}
  37. </view>
  38. <view>操作时间:{{ timesTampChange(val.createTime) }}</view>
  39. </view>
  40. <view class="sub-li-bottom ss-m-t-20">
  41. <view class="sub-li-bottom-item color-primary" @tap.stop="handlePreview(val)">查看/下载附件</view>
  42. <view
  43. class="sub-li-bottom-item d-flex align-center justify-center"
  44. @tap.stop="handleLoadMore(val)"
  45. :style="{'color': !actionItems(val)?.length ? '#ccc' : '#00B760'}"
  46. >
  47. <view>更多操作</view>
  48. <uni-icons type="list" class="ss-m-l-10" size="20" :color="!actionItems(val)?.length ? '#ccc' : '#00B760'"></uni-icons>
  49. </view>
  50. </view>
  51. </view>
  52. <!-- 更多操作 -->
  53. <uni-popup ref="popup" type="bottom" :mask-click="true">
  54. <view class="actions" v-if="itemData && Object.keys(itemData).length">
  55. <view
  56. class="action-item"
  57. v-for="(val, index) in actionItems(itemData)"
  58. :key="index"
  59. @tap.stop="val.click(itemData)"
  60. >{{ val.title }}</view>
  61. </view>
  62. <button class="big-cancel-button" @tap.stop="handleClosePopup">取消</button>
  63. </uni-popup>
  64. </view>
  65. </template>
  66. <script setup>
  67. import { ref } from 'vue'
  68. import { timesTampChange } from '@/utils/date'
  69. import { getUserAvatar } from '@/utils/avatar'
  70. import { formatName } from '@/utils/getText'
  71. import { preview } from '@/utils/preview'
  72. import { getDict } from '@/hooks/useDictionaries'
  73. import { userStore } from '@/store/user'
  74. import { defaultText, talkToUser } from '@/hooks/useIM'
  75. import { joinToTalentPool, joinEliminate, personCvUnfitCancel, personEntryByEnterprise, hireJobCvRelSettlement, personJobCvLook } from '@/api/resume'
  76. const emit = defineEmits(['refresh'])
  77. const props = defineProps({ items: Array, current: [Number, String] })
  78. const user = userStore()
  79. const statusList = ref([])
  80. getDict('menduner_interview_invite_status').then(({ data }) => {
  81. statusList.value = data.data || []
  82. })
  83. const desc = ['jobStatusName', 'eduName', 'expName']
  84. const popup = ref()
  85. const itemData = ref({})
  86. // 查看在线简历
  87. const handleDetail = async (val) => {
  88. if (!val.userId || !val.id) {
  89. uni.showToast({ title: '用户ID不存在', icon: 'none' })
  90. return
  91. }
  92. try {
  93. const {data } = await personJobCvLook(val.id)
  94. if (data) emit('refresh')
  95. } catch {}
  96. uni.navigateTo({
  97. url: `/pagesB/personnelDetails/index?id=${val.userId}&type=1`
  98. })
  99. }
  100. // 查看附件
  101. const handlePreview = async (val) => {
  102. if (!val.userId || !val.id) {
  103. uni.showToast({ title: '用户ID不存在', icon: 'none' })
  104. return
  105. }
  106. try {
  107. const {data } = await personJobCvLook(val.id)
  108. if (data) emit('refresh')
  109. } catch {}
  110. if (!val.url) {
  111. uni.showToast({ title: '附件地址不存在', icon: 'none' })
  112. return
  113. }
  114. preview(val.url)
  115. }
  116. // 更多操作
  117. const handleLoadMore = (val) => {
  118. if (!actionItems(val).length) {
  119. itemData.value = {}
  120. uni.showToast({ title: '暂无更多操作', icon: 'none' })
  121. return
  122. }
  123. itemData.value = val
  124. popup.value.open()
  125. }
  126. // 关闭操作弹窗
  127. const handleClosePopup = () => {
  128. popup.value.close()
  129. itemData.value = {}
  130. }
  131. // 加入储备
  132. const handleJoinToTalentPool = async (item) => {
  133. if (!item.userId) {
  134. uni.showToast({ title: '用户ID不存在', icon: 'none' })
  135. return
  136. }
  137. try {
  138. await joinToTalentPool(item.userId)
  139. uni.showToast({ title: '加入成功', icon: 'none' })
  140. handleClosePopup()
  141. emit('refresh')
  142. } catch {
  143. handleClosePopup()
  144. }
  145. }
  146. // 邀请面试
  147. const handleInterviewInvite = (item) => {
  148. if (item?.job?.status === '1') {
  149. uni.showToast({ title: '职位已关闭', icon: 'none' })
  150. return
  151. }
  152. uni.navigateTo({
  153. url: `/pagesB/InviteInterview/index?id=${item.userId}&jobId=${item.job.id}`
  154. })
  155. handleClosePopup()
  156. }
  157. // 不合适
  158. const handleEliminate = async (item) => {
  159. if (!item.userId) {
  160. uni.showToast({ title: '用户ID不存在', icon: 'none' })
  161. return
  162. }
  163. const query = {
  164. bizId: item.id,
  165. jobId: item.job.id,
  166. userId: item.userId,
  167. type: props.current === 0 ? '0' : '1' // 投递简历0 已邀约1
  168. }
  169. // 招聘会职位则带id
  170. if (item?.jobFairId) query.jobFairId = item.jobFairId
  171. try {
  172. await joinEliminate(query)
  173. uni.showToast({ title: '操作成功', icon: 'none' })
  174. handleClosePopup()
  175. emit('refresh')
  176. } catch {
  177. handleClosePopup()
  178. }
  179. }
  180. // 取消不合适
  181. const handleCancelEliminate = async (item) => {
  182. if (!item.id) {
  183. uni.showToast({ title: 'ID不存在', icon: 'none' })
  184. return
  185. }
  186. try {
  187. await personCvUnfitCancel(item.id)
  188. uni.showToast({ title: '操作成功', icon: 'none' })
  189. handleClosePopup()
  190. emit('refresh')
  191. } catch {
  192. handleClosePopup()
  193. }
  194. }
  195. // 立即沟通
  196. const handleToCommunicate = async (item) => {
  197. if (item?.job?.status === '1') {
  198. uni.showToast({ title: '职位已关闭', icon: 'none' })
  199. return
  200. }
  201. const userId = item.userId
  202. if (!userId) return
  203. const channel = await talkToUser({ userId, text: defaultText })
  204. const query = {
  205. id: userId,
  206. name: item?.person?.name || item?.person?.phone,
  207. channelID: channel.channelID,
  208. channelType: channel.channelType,
  209. avatar: item?.person?.avatar,
  210. sex: item?.person?.sex,
  211. }
  212. const queryStr = Object.keys(query).reduce((r, v) => {
  213. if (!query[v]) {
  214. return r
  215. }
  216. return r += `${v}=${encodeURIComponent(query[v])}&`
  217. }, '?')
  218. uni.navigateTo({
  219. url: `/pagesA/chart/index${queryStr.slice(0, -1)}`
  220. })
  221. handleClosePopup()
  222. }
  223. // 结算
  224. const handleSettlement = async (item) => {
  225. if (!item.id) {
  226. uni.showToast({ title: 'ID不存在', icon: 'none' })
  227. return
  228. }
  229. try {
  230. await hireJobCvRelSettlement(item.id)
  231. uni.showToast({ title: '操作成功', icon: 'none' })
  232. handleClosePopup()
  233. emit('refresh')
  234. // 更新账户信息
  235. setTimeout(async () => {
  236. await user.getAccountInfo()
  237. }, 2000)
  238. } catch {
  239. handleClosePopup()
  240. }
  241. }
  242. // 入职
  243. const handleEnterByEnterprise = async (item) => {
  244. console.log(item, '====入职====')
  245. if (!item.id) {
  246. uni.showToast({ title: 'ID不存在', icon: 'none' })
  247. return
  248. }
  249. try {
  250. await personEntryByEnterprise(item.id)
  251. uni.showToast({ title: '操作成功', icon: 'none' })
  252. handleClosePopup()
  253. emit('refresh')
  254. } catch {
  255. handleClosePopup()
  256. }
  257. }
  258. const actionItems = (item) => {
  259. const arr = []
  260. if (props.current === 0) arr.push({ title: '邀请面试', click: handleInterviewInvite }, { title: '立即沟通', click: handleToCommunicate })
  261. if ([0, 1].includes(props.current)) arr.push({ title: '不合适', click: handleEliminate })
  262. if (props.current === 4) arr.push({ title: '取消不合适', click: handleCancelEliminate })
  263. if (props.current === 2 && item?.job?.hire) arr.push({ title: '结算', click: handleSettlement })
  264. if (props.current === 1 && ['3', '4'].includes(item.status)) arr.push({ title: '入职', click: handleEnterByEnterprise })
  265. // 面试后才能够加入储备
  266. if ([1, 2, 3].includes(props.current) && !item.inTalentPool) arr.push({ title: '加入储备', click: handleJoinToTalentPool })
  267. return arr
  268. }
  269. </script>
  270. <style scoped lang="scss">
  271. .mList {
  272. border-radius: 12px;
  273. box-shadow: 1px 2px 12px rgba(0, 0, 0, 0.17);
  274. margin: 0 30rpx 20rpx 30rpx;
  275. padding: 30rpx;
  276. background-color: #fff;
  277. font-size: 28rpx;
  278. &:first-child {
  279. margin-top: 20rpx;
  280. }
  281. }
  282. .user-avatar {
  283. position: relative;
  284. &-img {
  285. width: 45px;
  286. height: 45px;
  287. border-radius: 50%;
  288. }
  289. &-sex {
  290. position: absolute;
  291. right: 0;
  292. bottom: 2px;
  293. width: 20px;
  294. height: 20px;
  295. background-color: #fff;
  296. border-radius: 50%;
  297. }
  298. }
  299. .action {
  300. font-size: 28rpx;
  301. &-item {
  302. text-align: center;
  303. width: 90vw;
  304. border-bottom: 1px solid #eee;
  305. height:44px;
  306. line-height: 44px;
  307. margin: 0 auto;
  308. color: #00B760;
  309. background-color: #fff !important;
  310. &:first-child {
  311. border-radius: 5px 5px 0 0;
  312. }
  313. &:last-child {
  314. border-radius: 0 0 5px 5px;
  315. border-bottom: none;
  316. }
  317. }
  318. }
  319. .big-cancel-button {
  320. width: 90vw;
  321. height:44px;
  322. line-height: 44px;
  323. margin: 10px auto;
  324. color: #fe574a;
  325. background-color: #fff !important;
  326. font-size: 28rpx;
  327. }
  328. .sub-li-bottom {
  329. display: flex;
  330. justify-content: space-between;
  331. // align-items: flex-end;
  332. margin-top: 10px;
  333. font-size: 13px;
  334. &-item {
  335. width: 50%;
  336. height: 35px;
  337. line-height: 35px;
  338. text-align: center;
  339. margin-right: 15px;
  340. background-color: #f7f8fa;
  341. border-radius: 4px;
  342. &:nth-child(2) {
  343. margin-right: 0;
  344. }
  345. }
  346. }
  347. </style>