myCompany.vue 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694
  1. <template>
  2. <view class="my-company-page flex flex-direction">
  3. <!-- 自定义导航栏 -->
  4. <nav-bar title="我的公司" color="#fff"></nav-bar>
  5. <!-- 头部渐变背景区域 -->
  6. <view class="header-section">
  7. <!-- 插画区域 -->
  8. <view class="illustration-area">
  9. <image src="/static/images/gongsi.svg" class="company-illustration" mode="aspectFit" />
  10. </view>
  11. </view>
  12. <template v-if="!loading">
  13. <!-- 管理员端 -->
  14. <view class="admin-container" v-if="isAdmin">
  15. <view class="company-name">{{ companyInfo.companyAllName }}</view>
  16. <view class="buttons flex">
  17. <view class="button" @click="showLeaveModal = true">离开公司</view>
  18. <view class="button" @click="showChangeModal = true">变更账号</view>
  19. </view>
  20. <view class="list-wrapper">
  21. <scroll-view scroll-y="true" class="scroll-view">
  22. <view class="list">
  23. <view class="list-title">账号审核列表</view>
  24. <view class="account-item" v-for="(item, index) in auditList" :key="index">
  25. <view class="account-info flex justify-between">
  26. <view class="account-info-l">
  27. <view class="title flex align-center">
  28. <text>{{ item.userName }}/{{ item.phone }}</text>
  29. <view class="badge" v-if="item.isAdmin">管理员</view>
  30. </view>
  31. <view class="sub-title">提交时间:{{ item.createTime }}</view>
  32. <view class="sub-title">{{ item.hrPosition || '--' }}</view>
  33. </view>
  34. <view class="status-text" :class="getStatusClass(item.status)" @click="handleAudit(item)">{{ item.status | statusText }}</view>
  35. </view>
  36. <view class="bottom-button" v-if="item.status == 2" @click="changeSelectAccount(item)">变更账号</view>
  37. </view>
  38. </view>
  39. </scroll-view>
  40. </view>
  41. </view>
  42. <!-- 非管理员端 -->
  43. <view class="un-admin-container" v-else>
  44. <view class="company-name">{{ companyInfo.companyAllName }}</view>
  45. <view class="content-wrapper">
  46. <view class="info-list">
  47. <view class="info-item">
  48. <text>公司规模</text>
  49. <text>{{ companyInfo.companyPeople || '--' }}</text>
  50. </view>
  51. <view class="info-item">
  52. <text>融资阶段</text>
  53. <text>{{ companyInfo.companyDevelop || '--' }}</text>
  54. </view>
  55. <view class="info-item">
  56. <text>所属行业</text>
  57. <text>{{ companyInfo.companyScope || '--' }}</text>
  58. </view>
  59. </view>
  60. <view class="buttons">
  61. <view class="button plain" @click="showLeaveModal = true">离开公司</view>
  62. <view class="button primary" @click="showChangeModal = true">变更账号</view>
  63. </view>
  64. </view>
  65. </view>
  66. </template>
  67. <!-- 审核 -->
  68. <c-modal
  69. :value="showAuditModal"
  70. :maskCloseAble="true"
  71. title="审核"
  72. cancel-button-text="拒绝"
  73. confirm-button-text="通过"
  74. @cancel="handleRejest"
  75. @confirm="handlePass"
  76. @close="handleCloseModal"
  77. >
  78. <view class="audit-modal">
  79. <view>请审核账号是否为您公司的员工</view>
  80. <view class="account-info flex">
  81. <view class="account-info-l">
  82. <view class="title flex align-center">
  83. <text>王先生/18828000000</text>
  84. </view>
  85. <view class="sub-title">提交时间:2021.09.22 09:55</view>
  86. <view class="sub-title">总监</view>
  87. </view>
  88. </view>
  89. <view class="check-bar flex align-center">
  90. <u-checkbox v-model="auditChecked" label-size="24">通过并设置为管理员</u-checkbox>
  91. <view class="tip">仅能设置2个管理员</view>
  92. </view>
  93. </view>
  94. </c-modal>
  95. <!-- 离开公司 -->
  96. <c-modal
  97. :value="showLeaveModal"
  98. :maskCloseAble="true"
  99. title="温馨提示"
  100. cancel-button-text="确定离开"
  101. confirm-button-text="去变更"
  102. @cancel="handleLeave"
  103. @confirm="handleChange"
  104. @close="handleCloseModal"
  105. >
  106. <view class="audit-modal">
  107. <view>您是企业的超级管理员</view>
  108. <view>如若需要保留数据请取消,并变更账号</view>
  109. <view>如您确定离开公司,公司及其相关所有数据均会删除,请确认!</view>
  110. </view>
  111. </c-modal>
  112. <!-- 变更账号 -->
  113. <c-modal
  114. :value="showChangeModal"
  115. title="请填写您需要变更的账号"
  116. @cancel="showChangeModal = false"
  117. @confirm="submitChangeAccount"
  118. >
  119. <view class="input-wrapper" style="margin-top: 30px">
  120. <input v-model="phoneNum" type="number" placeholder="请输入要变更的手机号码" maxlength="11" placeholder-class="placeholder" />
  121. </view>
  122. <view class="input-wrapper flex align-center justify-between" style="margin-bottom: 30px;">
  123. <input v-model="verifyCode" type="number" placeholder="输入验证码" maxlength="6" class="verify-input" placeholder-class="placeholder" />
  124. <view class="verify-btn" @click="getVerifyCode">{{ disabled ? `${countdown}s` : '获取验证码' }}</view>
  125. </view>
  126. </c-modal>
  127. </view>
  128. </template>
  129. <script>
  130. import navBar from '@/components/nav-bar/index.vue'
  131. import cModal from '@/components/c-modal.vue'
  132. import { logoutJP } from '@/utils/login'
  133. export default {
  134. components: {
  135. navBar,
  136. cModal
  137. },
  138. data() {
  139. return {
  140. companyInfo: {
  141. isNo: true,
  142. },
  143. isAdmin: false,
  144. companyId: '',
  145. loading: false,
  146. showAuditModal: false,
  147. auditChecked: false, // 是否设置成管理员
  148. showLeaveModal: false,
  149. auditList: [],
  150. updating: false,
  151. currentAuditItem: {}, // 当前被审核人
  152. showChangeModal: false, // 变更弹窗
  153. disabled: false,
  154. timer: null,
  155. countdown: 60,
  156. getting: false,
  157. verifyCode: '',
  158. phoneNum: '', // 输入手机号
  159. changePhoneNum: '', // 被变更手机号
  160. userPhoneNum: '', // 当前登录人手机号
  161. };
  162. },
  163. filters: {
  164. statusText(status) {
  165. switch (status) {
  166. case 1:
  167. return '请审核'
  168. case 2:
  169. return '已通过'
  170. case 3:
  171. return '已拒绝'
  172. default:
  173. return ''
  174. }
  175. }
  176. },
  177. watch: {
  178. showAuditModal(nValue) {
  179. if (!nValue) {
  180. this.auditChecked = false
  181. }
  182. },
  183. showChangeModal(nValue) {
  184. if (!nValue) {
  185. // 关闭弹窗时清除选择的手机号
  186. this.changePhoneNum = ''
  187. this.verifyCode = ''
  188. this.phoneNum = ''
  189. this.clearCountdownTimer()
  190. }
  191. }
  192. },
  193. onLoad() {
  194. // /app/user/selectUserById
  195. this.getCompanyStatus()
  196. },
  197. onUnload() {
  198. this.clearCountdownTimer()
  199. },
  200. methods: {
  201. getStatusClass(status) {
  202. switch (status) {
  203. case 1:
  204. return 'btn'; // 待审核
  205. case 2:
  206. return ''; // 已通过
  207. case 3:
  208. return 'info'; // 已拒绝
  209. default:
  210. return '';
  211. }
  212. },
  213. getCompanyStatus() {
  214. uni.showLoading({ title: '加载中' })
  215. this.loading = true
  216. this.$Request.get("/app/company/selectCompanyByUserId")
  217. .then((res) => {
  218. this.loading = false
  219. uni.hideLoading()
  220. if (res.code == 0 && res.data) {
  221. this.companyInfo = res.data
  222. this.companyId = res.data.companyId
  223. this.userPhoneNum = res.data.phone
  224. this.auditList = res.data.companyUserVos || []
  225. if (res.data.companyUser?.isAdmin == 1) {
  226. this.isAdmin = true
  227. }
  228. } else {
  229. this.companyInfo = {
  230. isNo: true,
  231. };
  232. }
  233. }).catch(err => {
  234. this.loading = false
  235. uni.hideLoading()
  236. });
  237. },
  238. // 审核账号
  239. handleAudit(item) {
  240. if (item.status != 1) return
  241. this.showAuditModal = true
  242. this.currentAuditItem = item
  243. },
  244. handleCloseModal() {
  245. this.showAuditModal = false
  246. this.showLeaveModal = false
  247. },
  248. // 审核账号
  249. auditAccount(status) {
  250. if (this.updating) return
  251. this.updating = true
  252. uni.showLoading({ title: '处理中' })
  253. this.$Request.getT('/app/company/auditCompanyUser', {
  254. companyId: this.companyId,
  255. auditedUserId: this.currentAuditItem.userId,
  256. isAdmin: this.auditChecked ? 1: 0,
  257. status
  258. }).then(res => {
  259. if (res.code == 0) {
  260. this.$queue.showToast('操作成功')
  261. this.showAuditModal = false
  262. this.getCompanyStatus()
  263. } else {
  264. this.$queue.showToast(res.msg || '操作成功')
  265. }
  266. this.updating = false
  267. uni.hideLoading()
  268. }).catch(() => {
  269. this.$queue.showToast('失败了,请重试')
  270. this.updating = false
  271. uni.hideLoading()
  272. })
  273. },
  274. // 审核拒绝
  275. handleRejest() {
  276. this.auditAccount(3)
  277. },
  278. // 审核通过
  279. handlePass() {
  280. this.auditAccount(2)
  281. },
  282. // 确定离开
  283. handleLeave() {
  284. if (this.updating) return
  285. this.updating = true
  286. uni.showLoading({ title: '处理中' })
  287. this.$Request.getT('/app/company/deleteCompany', {
  288. companyId: this.companyId
  289. }).then(res => {
  290. if (res.code == 0) {
  291. this.showLeaveModal = false
  292. this.logout()
  293. } else {
  294. this.$queue.showToast(res.msg || '出错了,请稍后再试')
  295. }
  296. this.updating = false
  297. uni.hideLoading()
  298. }).catch(() => {
  299. this.$queue.showToast('出错了,请稍后再试')
  300. this.updating = false
  301. uni.hideLoading()
  302. })
  303. // /sqx_fast/app/company/deleteCompany
  304. },
  305. // 去变更
  306. handleChange() {
  307. this.showLeaveModal = false
  308. this.showChangeModal = true
  309. },
  310. // 获取验证码
  311. getVerifyCode() {
  312. if (!this.phoneNum) {
  313. uni.showToast({
  314. title: '请输入手机号',
  315. icon: 'none'
  316. })
  317. return
  318. }
  319. if (!/^1[3-9]\d{9}$/.test(this.phoneNum)) {
  320. uni.showToast({
  321. title: '请输入正确的手机号',
  322. icon: 'none'
  323. })
  324. return
  325. }
  326. if (this.disabled || this.getting) return
  327. uni.showLoading({ title: '正在发送验证码' })
  328. this.getting = true
  329. this.$Request
  330. .getT('/app/Login/sendMsg/' + this.phoneNum + '/bind')
  331. .then((res) => {
  332. if (res.code === 0) {
  333. this.startCountdown()
  334. } else {
  335. uni.showModal({
  336. showCancel: false,
  337. title: '短信发送失败',
  338. content: res.msg ? res.msg : '请一分钟后再获取验证码',
  339. });
  340. }
  341. })
  342. .finally(() => {
  343. this.getting = false
  344. uni.hideLoading();
  345. })
  346. },
  347. startCountdown() {
  348. this.disabled = true
  349. this.timer = setInterval(() => {
  350. this.countdown--
  351. if (this.countdown <= 0) {
  352. this.clearCountdownTimer()
  353. }
  354. }, 1000)
  355. },
  356. clearCountdownTimer() {
  357. if (this.timer) {
  358. clearInterval(this.timer)
  359. this.timer = null // 重置定时器实例
  360. this.countdown = 60
  361. this.disabled = false
  362. }
  363. },
  364. // 变更选择的账号
  365. changeSelectAccount(item) {
  366. this.changePhoneNum = item.phone
  367. this.showChangeModal = true
  368. },
  369. // 提交变更
  370. submitChangeAccount() {
  371. if (this.updating) return
  372. this.updating = true
  373. if (!this.phoneNum) {
  374. uni.showToast({
  375. title: '请输入手机号',
  376. icon: 'none'
  377. })
  378. return
  379. }
  380. if (!this.verifyCode) {
  381. uni.showToast({
  382. title: '请输入验证码',
  383. icon: 'none'
  384. })
  385. return
  386. }
  387. uni.showLoading({ title: '处理中' })
  388. this.$Request.postJson('/app/company/giveCompany', {
  389. phone: this.changePhoneNum || this.userPhoneNum,
  390. msg: this.verifyCode,
  391. givePhone: this.phoneNum
  392. }).then(res => {
  393. if (res.code == 0) {
  394. this.showChangeModal = false
  395. this.logout()
  396. } else {
  397. this.$queue.showToast(res.msg || '出错了,请稍后再试')
  398. }
  399. }).finally(() => {
  400. uni.hideLoading()
  401. this.updating = false
  402. })
  403. },
  404. logout() {
  405. uni.showToast({
  406. title: '操作成功',
  407. icon: 'none',
  408. })
  409. setTimeout(() => {
  410. // 退出极光推送
  411. logoutJP()
  412. this.$queue.toLogin()
  413. this.$queue.logout()
  414. }, 1500)
  415. }
  416. }
  417. }
  418. </script>
  419. <style lang="scss" scoped>
  420. .my-company-page {
  421. display: flex;
  422. flex-direction: column;
  423. height: 100vh;
  424. background: linear-gradient(90.00deg, rgba(13, 39, 247, 1), rgba(19, 193, 234, 1) 100%);
  425. background-size: 100% 40%;
  426. background-position: center top;
  427. background-repeat: no-repeat;
  428. font-family: DM Sans;
  429. font-style: Regular;
  430. }
  431. /* 头部区域 */
  432. .header-section {
  433. text-align: center;
  434. }
  435. .illustration-area {
  436. .company-illustration {
  437. display: block;
  438. width: 280rpx;
  439. height: 180rpx;
  440. margin: 0 auto;
  441. }
  442. }
  443. // 管理员端
  444. .admin-container {
  445. flex: 1;
  446. .company-name {
  447. font-weight: 500;
  448. line-height: 44rpx;
  449. color: #fff;
  450. text-align: center;
  451. margin: 20rpx 40rpx;
  452. }
  453. .buttons {
  454. padding: 0 40rpx 28rpx;
  455. gap: 20rpx;
  456. .button {
  457. flex: 1;
  458. height: 80rpx;
  459. border-radius: 40rpx;
  460. background: rgba(255, 255, 255, 0.2);
  461. font-size: 32rpx;
  462. font-weight: 400;
  463. text-align: center;
  464. color: #fff;
  465. line-height: 80rpx;
  466. }
  467. }
  468. .list-wrapper {
  469. border-radius: 20rpx 20rpx 0 0;
  470. background-color: #fff;
  471. }
  472. .scroll-view {
  473. height: calc(100vh - 470rpx);
  474. overflow-y: auto;
  475. }
  476. .list {
  477. padding: 40rpx;
  478. .list-title {
  479. font-size: 32rpx;
  480. font-weight: 500;
  481. line-height: 56rpx;
  482. color: rgba(51, 51, 51, 1);
  483. }
  484. .account-item {
  485. padding: 32rpx 32rpx 28rpx 0;
  486. .title {
  487. color: rgba(51, 51, 51, 1);
  488. font-size: 30rpx;
  489. font-weight: 400;
  490. line-height: 44rpx;
  491. .badge {
  492. box-sizing: border-box;
  493. border: 1px solid rgba(1, 107, 246, 1);
  494. border-radius: 3px;
  495. background: rgba(1, 107, 246, 0.1);
  496. font-size: 20rpx;
  497. font-weight: 400;
  498. line-height: 24rpx;
  499. color: rgba(1, 107, 246, 1);
  500. margin-left: 16rpx;
  501. padding: 6rpx 12rpx;
  502. }
  503. }
  504. .sub-title {
  505. color: rgba(153, 153, 153, 1);
  506. font-size: 24rpx;
  507. font-weight: 400;
  508. line-height: 28rpx;
  509. margin-top: 10rpx;
  510. }
  511. .status-text {
  512. height: 54rpx;
  513. padding: 12rpx 24rpx;
  514. border-radius: 30rpx;
  515. font-size: 24rpx;
  516. font-weight: 400;
  517. line-height: 28rpx;
  518. color: rgba(1, 107, 246, 1);
  519. box-sizing: border-box;
  520. &.info {
  521. color: rgba(153, 153, 153, 1);
  522. }
  523. &.btn {
  524. color: #fff;
  525. background-color: #016BF6;
  526. }
  527. }
  528. .bottom-button {
  529. height: 44rpx;
  530. text-align: center;
  531. border-radius: 2px;
  532. background: rgba(1, 107, 246, 0.1);
  533. font-size: 24rpx;
  534. line-height: 44rpx;
  535. color: rgba(1, 107, 246, 1);
  536. margin-top: 10rpx;
  537. }
  538. }
  539. }
  540. }
  541. // 非管理员端
  542. .un-admin-container {
  543. .company-name {
  544. margin: 40rpx 40rpx 60rpx;
  545. color: rgba(255, 255, 255, 1);
  546. font-size: 28rpx;
  547. font-weight: 500;
  548. line-height: 44rpx;
  549. text-align: center;
  550. }
  551. .content-wrapper {
  552. border-radius: 20rpx 20rpx 0 0;
  553. background-color: #fff;
  554. padding: 52rpx 76rpx;
  555. .info-list {
  556. .info-item {
  557. color: rgba(153, 153, 153, 1);
  558. font-size: 24rpx;
  559. font-weight: 400;
  560. line-height: 32rpx;
  561. margin-bottom: 12rpx;
  562. text {
  563. padding-right: 48rpx;
  564. }
  565. }
  566. }
  567. .buttons {
  568. margin-top: 40rpx;
  569. .button {
  570. width: 100%;
  571. height: 40px;
  572. box-sizing: border-box;
  573. border: 1px solid rgba(1, 107, 246, 1);
  574. border-radius: 40px;
  575. background: rgba(255, 255, 255, 1);
  576. text-align: center;
  577. line-height: 38px;
  578. font-size: 16px;
  579. font-weight: 400;
  580. margin-bottom: 40rpx;
  581. &.plain {
  582. color: rgba(1, 107, 246, 1);
  583. }
  584. &.primary {
  585. color: #fff;
  586. background: rgba(1, 107, 246, 1);
  587. }
  588. }
  589. }
  590. }
  591. }
  592. // 审核弹窗
  593. .audit-modal {
  594. min-height: 180rpx;
  595. .title {
  596. color: rgba(51, 51, 51, 1);
  597. font-size: 30rpx;
  598. font-weight: 400;
  599. line-height: 44rpx;
  600. margin-top: 48rpx;
  601. .badge {
  602. box-sizing: border-box;
  603. border: 1px solid rgba(1, 107, 246, 1);
  604. border-radius: 3px;
  605. background: rgba(1, 107, 246, 0.1);
  606. font-size: 20rpx;
  607. font-weight: 400;
  608. line-height: 24rpx;
  609. color: rgba(1, 107, 246, 1);
  610. margin-left: 16rpx;
  611. padding: 6rpx 12rpx;
  612. }
  613. }
  614. .sub-title {
  615. color: rgba(153, 153, 153, 1);
  616. font-size: 24rpx;
  617. font-weight: 400;
  618. line-height: 28rpx;
  619. margin-top: 10rpx;
  620. }
  621. .check-bar {
  622. font-size: 24rpx;
  623. margin-top: 50rpx;
  624. ::v-deep .u-checkbox__label {
  625. margin-right: 20rpx;
  626. }
  627. .tip {
  628. padding-bottom: 5px;
  629. }
  630. }
  631. }
  632. // 更换账号弹窗
  633. .input-wrapper {
  634. box-sizing: border-box;
  635. border: 1px solid rgba(242, 242, 242, 1);
  636. border-radius: 6px;
  637. background: rgba(250, 250, 250, 1);
  638. margin-bottom: 16rpx;
  639. padding: 10rpx 24rpx;
  640. font-size: 28rpx;
  641. line-height: 60rpx;
  642. input {
  643. height: 60rpx;
  644. font-size: 28rpx;
  645. color: #1f2c37;
  646. }
  647. .placeholder {
  648. color: rgba(158, 161, 168, 1);
  649. }
  650. .verify-input {
  651. width: 300rpx;
  652. }
  653. .verify-btn {
  654. color: rgba(1, 107, 246, 1);
  655. }
  656. }
  657. </style>