jobManagement.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617
  1. <template>
  2. <view class="job-management-page">
  3. <view class="fixed-header">
  4. <nav-bar title="职位管理" :backUrl="backUrl" goMy="/pages/my/index">
  5. <view slot="left" v-if="canClose" @click="handleToIndex">
  6. <u-icon name="close" color="#333"></u-icon>
  7. </view>
  8. </nav-bar>
  9. <!-- 标签页导航 - 使用uview的u-tabs组件 -->
  10. <view class="sticky-tabs">
  11. <u-tabs
  12. :list="tabs"
  13. :current="tabIndex"
  14. @change="tabChange"
  15. :is-scroll="false"
  16. :height="88"
  17. :font-size="24"
  18. active-color="rgba(1, 107, 246, 1)"
  19. inactive-color="rgba(102, 102, 102, 1)"
  20. :bar-width="60"
  21. :bar-height="4"
  22. :gutter="0"
  23. bg-color="#ffffff"
  24. ></u-tabs>
  25. </view>
  26. </view>
  27. <!-- 职位列表 -->
  28. <view class="job-list">
  29. <!-- 有数据时显示列表 -->
  30. <scroll-view
  31. scroll-y="true"
  32. style="width: 100%;height: 100%;"
  33. v-if="jobList.length > 0"
  34. @scrolltolower="loadMore"
  35. lower-threshold="50"
  36. >
  37. <view class="list">
  38. <view
  39. class="job-card"
  40. v-for="(job, index) in jobList"
  41. :key="index"
  42. @click="goNav('/my/order/pay?postPushId='+job.postPushId)"
  43. >
  44. <view class="job-card-content">
  45. <view class="job-header">
  46. <view class="job-title-section">
  47. <text class="job-title">{{job.stationName || job.ruleClassifyName}}</text>
  48. <view class="urgent-tag" v-if="job.isDue">急聘</view>
  49. </view>
  50. <view class="job-status" :class="job.status | statusClassName">
  51. {{job.status | statusText}}
  52. </view>
  53. </view>
  54. <view class="base-info">
  55. <text class="info-item color-clip">{{ job.city }}</text>
  56. <text class="info-item color-clip">{{ job.education }}</text>
  57. <text class="info-item color-clip">{{ job.experience }}</text>
  58. <text class="info-item color-clip">{{ job.salaryRange }}·{{ job.salaryTimes }}</text>
  59. </view>
  60. <view class="tags">
  61. <view class="tag" v-for="(tag, i) in job.positionTags" :key="i">{{ tag }}</view>
  62. </view>
  63. <view class="company-info flex align-center">
  64. <image :src="job.company.companyLogo ? job.company.companyLogo : '/static/logo.png'" class="logo"></image>
  65. <text class="company-name">{{ job.company.companyName }}</text>
  66. </view>
  67. <view class="buttons flex align-center">
  68. <view class="button primary" v-if="job.status == 5" @click.stop="handleOpenPosition('open', job)">开启岗位</view>
  69. <view class="button plain" v-if="job.status != 1" @click.stop="handleEditPosition(job)">{{ job.status == 2 ? '下架并编辑' : '编辑修改' }}</view>
  70. <view class="button info" v-if="job.status == 2" @click.stop="handleOpenPosition('close', job)">关闭职位</view>
  71. <view class="button info" v-else @click.stop="handleDeletePosition(job)">删除</view>
  72. </view>
  73. </view>
  74. </view>
  75. </view>
  76. </scroll-view>
  77. <!-- 空状态显示 -->
  78. <view class="empty-state" v-else>
  79. <view class="empty-illustration">
  80. <image src="../../static/images/index/Hrempty.svg" class="empty-image" mode="aspectFit" />
  81. </view>
  82. </view>
  83. </view>
  84. <!-- 底部发布按钮 -->
  85. <view class="button-section">
  86. <view class="submit-btn" @click="publishNewJob">发布新职位</view>
  87. </view>
  88. </view>
  89. </template>
  90. <script>
  91. import navBar from "@/components/nav-bar/index.vue";
  92. import empty from '@/components/empty.vue'
  93. export default {
  94. components: {
  95. navBar,
  96. },
  97. data() {
  98. return {
  99. tabIndex: 0,
  100. tabs: [
  101. { name: '全部', status: 0 },
  102. { name: '待审核', status: 1 },
  103. { name: '招聘中', status: 2 },
  104. { name: '已拒绝', status: 3 },
  105. // { name: '已取消', status: 4 },
  106. { name: '已关闭', status: 5 },
  107. // { name: '已拒绝', status: 6 }
  108. ],
  109. jobList: [],
  110. page: 1, // 当前页码
  111. limit: 10, // 每页条数
  112. count: 0, // 总条数
  113. companyId: '',
  114. isLoading: false, // 防止重复请求标记
  115. backUrl:'',
  116. status:'',
  117. canClose: false, // 判断页面是否是关闭,如果是从“完善招聘名片”页面进入,则是可以关闭,反之则不可以
  118. loading: false,
  119. }
  120. },
  121. filters: {
  122. statusText(value) {
  123. switch (value) {
  124. case 1: return '待审核'
  125. case 2: return '招聘中'
  126. case 3: return '已拒绝'
  127. case 4: return '已取消'
  128. case 5: return '已关闭'
  129. case 6: return '暂存'
  130. default: return '暂无数据'
  131. }
  132. },
  133. statusClassName(value) {
  134. switch (value) {
  135. case 1: return ''
  136. case 2: return 'primary'
  137. case 3: return 'info'
  138. case 4: return 'error'
  139. case 5: return 'error'
  140. default: return ''
  141. }
  142. }
  143. },
  144. onLoad(options) {
  145. if (options.type && options.type == 'canClose') {
  146. this.canClose = true
  147. }
  148. if(options.status){
  149. this.status=options.status
  150. }
  151. this.backUrl = options.backUrl;
  152. if(options.companyId){
  153. this.companyId=options.companyId;
  154. }
  155. // this.companyId = uni.getStorageSync('companyId');
  156. this.getJobList();
  157. this.setBodyHeight();
  158. },
  159. onShow() {
  160. this.getJobList();
  161. },
  162. methods: {
  163. // 获取职位列表(新增分页逻辑)
  164. getJobList() {
  165. if (this.isLoading) return; // 正在加载时,阻止重复请求
  166. this.isLoading = true;
  167. let data = {
  168. status: this.tabIndex == 0 ? '' : this.tabIndex,
  169. page: this.page,
  170. limit: this.limit,
  171. companyId: this.companyId
  172. }
  173. this.$Request.getT('/app/postPush/getMyPostPush', data).then(res => {
  174. if (res.code == 0) {
  175. if (this.page == 1) {
  176. this.jobList = []; // 第一页清空原有列表
  177. }
  178. // 拼接新数据
  179. res.data.records.forEach(ret => {
  180. ret.showpeop = false
  181. if (ret.status == 1) {
  182. ret.statusName = '待审核'
  183. } else if (ret.status == 2) {
  184. ret.statusName = '招聘中'
  185. } else if (ret.status == 3) {
  186. ret.statusName = '已拒绝'
  187. } else if (ret.status == 4) {
  188. ret.statusName = '已取消'
  189. } else if (ret.status == 5) {
  190. ret.statusName = '已关闭'
  191. }
  192. ret.positionTags = ret.positionTag.split(',')
  193. this.jobList.push(ret)
  194. })
  195. this.count = res.data.total; // 更新总条数
  196. }
  197. this.isLoading = false;
  198. uni.stopPullDownRefresh();
  199. }).catch(err => {
  200. this.isLoading = false;
  201. uni.hideLoading();
  202. uni.stopPullDownRefresh();
  203. })
  204. },
  205. // 触底加载下一页
  206. loadMore() {
  207. if (this.jobList.length >= this.count) {
  208. uni.showToast({ title: '已加载全部数据', icon: 'none' });
  209. return;
  210. }
  211. this.page++; // 页码+1
  212. this.getJobList(); // 请求下一页
  213. },
  214. // 切换标签页(重置分页)
  215. tabChange(e) {
  216. const index = typeof e === 'number' ? e : e.index
  217. this.tabIndex = index
  218. this.page = 1; // 切换标签时重置为第1页
  219. this.jobList = [];
  220. this.getJobList();
  221. },
  222. // 下拉刷新(可选,若需要下拉刷新可添加)
  223. onPullDownRefresh() {
  224. this.page = 1;
  225. this.getJobList();
  226. },
  227. // 原有方法保持不变...
  228. goBack() {
  229. uni.switchTab({
  230. url: '/pages/my/index'
  231. });
  232. },
  233. goNav(url) { uni.navigateTo({ url }); },
  234. // publishNewJob() { uni.navigateTo({ url: '/package/addJob/addJob' }); },
  235. publishNewJob() { uni.navigateTo({ url: `/pages/my/jobPosting?status=${this.status}&companyId=${this.companyId}` }); },
  236. setBodyHeight() { /* 原有逻辑不变 */ },
  237. // 跳转至首页
  238. handleToIndex() {
  239. uni.reLaunch({
  240. url: '/pages/index/index'
  241. })
  242. },
  243. // 开启职位
  244. handleOpenPosition(type, item) {
  245. uni.showModal({
  246. title: '提示',
  247. content: type == 'close' ? '关闭岗位后,该岗位不会再推荐给用户,是否关闭?' : '开启岗位后,该岗位会重新推荐给用户,是否开启?',
  248. complete: (ret) => {
  249. if (ret.confirm) {
  250. this.closePosition(item)
  251. }
  252. }
  253. })
  254. },
  255. // 开启关闭岗位
  256. closePosition(item, callback) {
  257. if (this.loading) return
  258. this.loading = true
  259. uni.showLoading({
  260. title: '处理中'
  261. })
  262. this.$Request.getT('/app/postPush/closeOrOpen', {
  263. postPushId: item.postPushId
  264. }).then(res => {
  265. if (res.code == 0) {
  266. uni.showToast({
  267. title: '操作成功',
  268. duration: 1500,
  269. complete: () => {
  270. this.page = 1
  271. this.getJobList()
  272. if (typeof callback == 'function') {
  273. callback()
  274. }
  275. }
  276. })
  277. } else {
  278. uni.showToast({
  279. title: res.msg,
  280. icon: 'none'
  281. })
  282. }
  283. }).finally(() => {
  284. uni.hideLoading()
  285. this.loading = false
  286. })
  287. },
  288. // 编辑职位
  289. handleEditPosition(item) {
  290. // 如果是招聘中,则是下架并编辑,需要先下架再编辑
  291. if (item.status == 2) {
  292. uni.showModal({
  293. content: '确认下架并编辑该岗位?',
  294. title: '提示',
  295. confirmColor: '#016BF6',
  296. success: (it) => {
  297. if (it.confirm) {
  298. this.closePosition(item, () => {
  299. uni.navigateTo({
  300. url: `/pages/my/jobPosting?postPushId=${item.postPushId}&type=update`
  301. })
  302. })
  303. }
  304. }
  305. })
  306. } else {
  307. uni.navigateTo({
  308. url: `/pages/my/jobPosting?postPushId=${item.postPushId}&type=update`
  309. })
  310. }
  311. },
  312. // 删除职位
  313. handleDeletePosition(item) {
  314. uni.showModal({
  315. content: '确认删除该岗位吗?',
  316. title: '提示',
  317. confirmColor: '#016BF6',
  318. success: (iet) => {
  319. if (iet.confirm) {
  320. this.deletePosition(item)
  321. }
  322. }
  323. })
  324. },
  325. // 删除职位
  326. deletePosition(item) {
  327. if (this.loading) return
  328. this.loading = true
  329. uni.showLoading({
  330. title: '处理中'
  331. })
  332. this.$Request.post('/app/postPush/deletePostPush', {
  333. postPushId: item.postPushId,
  334. }).then(res => {
  335. if (res.code == 0) {
  336. uni.showToast({
  337. title: '删除成功',
  338. duration: 1500
  339. })
  340. this.page = 1
  341. this.getJobList()
  342. } else {
  343. uni.showToast({
  344. title: res.msg,
  345. icon: 'none'
  346. })
  347. }
  348. }).finally(() => {
  349. uni.hideLoading()
  350. this.loading = false
  351. })
  352. }
  353. }
  354. }
  355. </script>
  356. <style lang="scss" scoped>
  357. /*
  358. sticky生效条件:
  359. 1、父元素不能overflow:hidden或者overflow:auto属性。(mescroll-body设置:sticky="true"即可, mescroll-uni本身没有设置overflow)
  360. 2、必须指定top、bottom、left、right4个值之一,否则只会处于相对定位
  361. 3、父元素的高度不能低于sticky元素的高度
  362. 4、sticky元素仅在其父元素内生效,所以父元素必须是 mescroll
  363. */
  364. .sticky-tabs {
  365. z-index: 990;
  366. // position: sticky;
  367. // top: var(--window-top);
  368. background-color: #fff;
  369. }
  370. page {
  371. background-color: #ffffff;
  372. }
  373. .job-management-page {
  374. background-color: #ffffff;
  375. display: flex;
  376. flex-direction: column;
  377. height: 100vh;
  378. font-family: DM Sans;
  379. box-sizing: border-box;
  380. }
  381. .fixed-header {
  382. background-color: #ffffff;
  383. }
  384. .job-list {
  385. padding: 20rpx 40rpx 0;
  386. flex: 1;
  387. display: flex;
  388. flex-direction: column;
  389. overflow: auto;
  390. .list {
  391. padding-bottom: 30rpx;
  392. }
  393. .job-card {
  394. background: #ffffff;
  395. border-radius: 12rpx;
  396. margin-bottom: 20rpx;
  397. padding: 16rpx 36rpx;
  398. border: 0.5px solid rgba(227, 231, 236, 1);
  399. .job-card-content {
  400. .job-header {
  401. display: flex;
  402. justify-content: space-between;
  403. align-items: flex-start;
  404. margin-bottom: 8rpx;
  405. .job-title-section {
  406. display: flex;
  407. align-items: center;
  408. flex: 1;
  409. .job-title {
  410. color: rgba(23, 23, 37, 1);
  411. font-family: DM Sans;
  412. font-size: 28rpx;
  413. font-weight: 400;
  414. line-height: 44rpx;
  415. letter-spacing: 0.5%;
  416. text-align: left;
  417. }
  418. .urgent-tag {
  419. border-radius: 8rpx;
  420. padding: 8rpx;
  421. margin-left: 20rpx;
  422. background: radial-gradient(87.28% 72.40% at 49% 66%,rgba(255, 160, 162, 0.2),rgba(255, 246, 247, 1));
  423. font-size: 20rpx;
  424. line-height: 1;
  425. color: rgba(237, 66, 69, 1);
  426. }
  427. }
  428. .job-status {
  429. color: rgba(1, 107, 246, 1);
  430. padding: 8rpx;
  431. font-size: 20rpx;
  432. line-height: 1;
  433. border-radius: 4px;
  434. &.primary {
  435. color: rgba(1, 107, 246, 1);
  436. background: rgba(1, 107, 246, 0.1);
  437. }
  438. &.info {
  439. color: rgba(153, 153, 153, 1);
  440. }
  441. &.error {
  442. color: rgba(144.88, 87.8, 191.25, 1);
  443. }
  444. }
  445. }
  446. .base-info {
  447. display: flex;
  448. flex-wrap: wrap;
  449. margin-bottom: 8rpx;
  450. .info-item {
  451. margin-right: 12rpx;
  452. }
  453. .color-clip {
  454. background: linear-gradient(90deg, rgba(13, 39, 247, 1), rgba(19, 193, 234, 1) 100%);
  455. -webkit-background-clip: text;
  456. -webkit-text-fill-color: transparent;
  457. background-clip: text;
  458. text-fill-color: transparent;
  459. font-size: 28rpx;
  460. font-weight: 400;
  461. line-height: 36rpx;
  462. }
  463. }
  464. .tags {
  465. display: flex;
  466. flex-wrap: wrap;
  467. .tag {
  468. padding: 8rpx;
  469. border-radius: 8rpx;
  470. background: rgba(153, 153, 153, 0.1);
  471. margin-right: 4px;
  472. margin-bottom: 4px;
  473. color: rgba(102, 102, 102, 1);
  474. font-size: 20rpx;
  475. font-weight: 400;
  476. line-height: 1;
  477. }
  478. }
  479. .company-info {
  480. .logo {
  481. display: block;
  482. width: 28rpx;
  483. height: 28rpx;
  484. border: 1px solid rgba(240, 240, 240, 1);
  485. border-radius: 28rpx;
  486. margin-right: 8rpx;
  487. }
  488. .company-name {
  489. flex: 1;
  490. width: 0;
  491. color: rgba(156, 164, 171, 1);
  492. font-size: 20rpx;
  493. font-weight: 400;
  494. line-height: 40rpx;
  495. overflow: hidden;
  496. text-overflow: ellipsis;
  497. white-space: nowrap;
  498. }
  499. }
  500. .buttons {
  501. margin-top: 12rpx;
  502. .button {
  503. height: 60rpx;
  504. padding: 16rpx 32rpx;
  505. box-sizing: border-box;
  506. border-radius: 60rpx;
  507. border: 1px solid #fff;
  508. font-size: 24rpx;
  509. font-weight: 500;
  510. line-height: 24rpx;
  511. margin-right: 16rpx;
  512. &.primary {
  513. color: #fff;
  514. background: rgba(1, 107, 246, 1);
  515. border-color: rgba(1, 107, 246, 1);
  516. }
  517. &.plain {
  518. color: rgba(1, 107, 246, 1);
  519. background-color: rgba(1, 107, 246, 0.1);
  520. border-color: rgba(1, 107, 246, 0.1);
  521. }
  522. &.info {
  523. color: #999;
  524. border-color: #E8E8E8;
  525. }
  526. }
  527. }
  528. }
  529. }
  530. }
  531. .empty-state {
  532. display: flex;
  533. // flex-direction: column;
  534. align-items: center;
  535. justify-content: center;
  536. padding: 40rpx;
  537. .empty-illustration {
  538. margin-bottom: 40rpx;
  539. .empty-image {
  540. width: 700rpx;
  541. height: 800rpx;
  542. }
  543. }
  544. .empty-text {
  545. color: rgba(120, 130, 138, 1);
  546. font-family: DM Sans;
  547. font-size: 28rpx;
  548. font-weight: 400;
  549. line-height: 36rpx;
  550. letter-spacing: 0.5%;
  551. text-align: center;
  552. }
  553. }
  554. .button-section {
  555. padding: 28rpx 40rpx;
  556. box-shadow: 0px -4px 16px 0px rgba(0, 0, 0, 0.04);
  557. }
  558. .submit-btn {
  559. flex-shrink: 0;
  560. border-radius: 999px;
  561. box-shadow: 0px -4px 16px 0px rgba(0, 0, 0, 0.04);
  562. background: linear-gradient(90deg, rgba(13, 39, 247, 1), rgba(19, 193, 234, 1) 100%);
  563. color: rgba(255, 255, 255, 1);
  564. font-family: DM Sans;
  565. font-size: 32rpx;
  566. font-weight: 400;
  567. line-height: 48rpx;
  568. display: flex;
  569. justify-content: center;
  570. align-items: center;
  571. padding: 16rpx 32rpx;
  572. box-sizing: border-box;
  573. }
  574. </style>