myCompany.vue 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691
  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. export default {
  133. components: {
  134. navBar,
  135. cModal
  136. },
  137. data() {
  138. return {
  139. companyInfo: {
  140. isNo: true,
  141. },
  142. isAdmin: false,
  143. companyId: '',
  144. loading: false,
  145. showAuditModal: false,
  146. auditChecked: false, // 是否设置成管理员
  147. showLeaveModal: false,
  148. auditList: [],
  149. updating: false,
  150. currentAuditItem: {}, // 当前被审核人
  151. showChangeModal: false, // 变更弹窗
  152. disabled: false,
  153. timer: null,
  154. countdown: 60,
  155. getting: false,
  156. verifyCode: '',
  157. phoneNum: '', // 输入手机号
  158. changePhoneNum: '', // 被变更手机号
  159. userPhoneNum: '', // 当前登录人手机号
  160. };
  161. },
  162. filters: {
  163. statusText(status) {
  164. switch (status) {
  165. case 1:
  166. return '请审核'
  167. case 2:
  168. return '已通过'
  169. case 3:
  170. return '已拒绝'
  171. default:
  172. return ''
  173. }
  174. }
  175. },
  176. watch: {
  177. showAuditModal(nValue) {
  178. if (!nValue) {
  179. this.auditChecked = false
  180. }
  181. },
  182. showChangeModal(nValue) {
  183. if (!nValue) {
  184. // 关闭弹窗时清除选择的手机号
  185. this.changePhoneNum = ''
  186. this.verifyCode = ''
  187. this.phoneNum = ''
  188. this.clearCountdownTimer()
  189. }
  190. }
  191. },
  192. onLoad() {
  193. // /app/user/selectUserById
  194. this.getCompanyStatus()
  195. },
  196. onUnload() {
  197. this.clearCountdownTimer()
  198. },
  199. methods: {
  200. getStatusClass(status) {
  201. switch (status) {
  202. case 1:
  203. return 'btn'; // 待审核
  204. case 2:
  205. return ''; // 已通过
  206. case 3:
  207. return 'info'; // 已拒绝
  208. default:
  209. return '';
  210. }
  211. },
  212. getCompanyStatus() {
  213. uni.showLoading({ title: '加载中' })
  214. this.loading = true
  215. this.$Request.get("/app/company/selectCompanyByUserId")
  216. .then((res) => {
  217. this.loading = false
  218. uni.hideLoading()
  219. if (res.code == 0 && res.data) {
  220. this.companyInfo = res.data
  221. this.companyId = res.data.companyId
  222. this.userPhoneNum = res.data.phone
  223. this.auditList = res.data.companyUserVos || []
  224. if (res.data.companyUser?.isAdmin == 1) {
  225. this.isAdmin = true
  226. }
  227. } else {
  228. this.companyInfo = {
  229. isNo: true,
  230. };
  231. }
  232. }).catch(err => {
  233. this.loading = false
  234. uni.hideLoading()
  235. });
  236. },
  237. // 审核账号
  238. handleAudit(item) {
  239. if (item.status != 1) return
  240. this.showAuditModal = true
  241. this.currentAuditItem = item
  242. },
  243. handleCloseModal() {
  244. this.showAuditModal = false
  245. this.showLeaveModal = false
  246. },
  247. // 审核账号
  248. auditAccount(status) {
  249. if (this.updating) return
  250. this.updating = true
  251. uni.showLoading({ title: '处理中' })
  252. this.$Request.getT('/app/company/auditCompanyUser', {
  253. companyId: this.companyId,
  254. auditedUserId: this.currentAuditItem.userId,
  255. isAdmin: this.auditChecked ? 1: 0,
  256. status
  257. }).then(res => {
  258. if (res.code == 0) {
  259. this.$queue.showToast('操作成功')
  260. this.showAuditModal = false
  261. this.getCompanyStatus()
  262. } else {
  263. this.$queue.showToast(res.msg || '操作成功')
  264. }
  265. this.updating = false
  266. uni.hideLoading()
  267. }).catch(() => {
  268. this.$queue.showToast('失败了,请重试')
  269. this.updating = false
  270. uni.hideLoading()
  271. })
  272. },
  273. // 审核拒绝
  274. handleRejest() {
  275. this.auditAccount(3)
  276. },
  277. // 审核通过
  278. handlePass() {
  279. this.auditAccount(2)
  280. },
  281. // 确定离开
  282. handleLeave() {
  283. if (this.updating) return
  284. this.updating = true
  285. uni.showLoading({ title: '处理中' })
  286. this.$Request.getT('/app/company/deleteCompany', {
  287. companyId: this.companyId
  288. }).then(res => {
  289. if (res.code == 0) {
  290. this.showLeaveModal = false
  291. this.logout()
  292. } else {
  293. this.$queue.showToast(res.msg || '出错了,请稍后再试')
  294. }
  295. this.updating = false
  296. uni.hideLoading()
  297. }).catch(() => {
  298. this.$queue.showToast('出错了,请稍后再试')
  299. this.updating = false
  300. uni.hideLoading()
  301. })
  302. // /sqx_fast/app/company/deleteCompany
  303. },
  304. // 去变更
  305. handleChange() {
  306. this.showLeaveModal = false
  307. this.showChangeModal = true
  308. },
  309. // 获取验证码
  310. getVerifyCode() {
  311. if (!this.phoneNum) {
  312. uni.showToast({
  313. title: '请输入手机号',
  314. icon: 'none'
  315. })
  316. return
  317. }
  318. if (!/^1[3-9]\d{9}$/.test(this.phoneNum)) {
  319. uni.showToast({
  320. title: '请输入正确的手机号',
  321. icon: 'none'
  322. })
  323. return
  324. }
  325. if (this.disabled || this.getting) return
  326. uni.showLoading({ title: '正在发送验证码' })
  327. this.getting = true
  328. this.$Request
  329. .getT('/app/Login/sendMsg/' + this.phoneNum + '/bind')
  330. .then((res) => {
  331. if (res.code === 0) {
  332. this.startCountdown()
  333. } else {
  334. uni.showModal({
  335. showCancel: false,
  336. title: '短信发送失败',
  337. content: res.msg ? res.msg : '请一分钟后再获取验证码',
  338. });
  339. }
  340. })
  341. .finally(() => {
  342. this.getting = false
  343. uni.hideLoading();
  344. })
  345. },
  346. startCountdown() {
  347. this.disabled = true
  348. this.timer = setInterval(() => {
  349. this.countdown--
  350. if (this.countdown <= 0) {
  351. this.clearCountdownTimer()
  352. }
  353. }, 1000)
  354. },
  355. clearCountdownTimer() {
  356. if (this.timer) {
  357. clearInterval(this.timer)
  358. this.timer = null // 重置定时器实例
  359. this.countdown = 60
  360. this.disabled = false
  361. }
  362. },
  363. // 变更选择的账号
  364. changeSelectAccount(item) {
  365. this.changePhoneNum = item.phone
  366. this.showChangeModal = true
  367. },
  368. // 提交变更
  369. submitChangeAccount() {
  370. if (this.updating) return
  371. this.updating = true
  372. if (!this.phoneNum) {
  373. uni.showToast({
  374. title: '请输入手机号',
  375. icon: 'none'
  376. })
  377. return
  378. }
  379. if (!this.verifyCode) {
  380. uni.showToast({
  381. title: '请输入验证码',
  382. icon: 'none'
  383. })
  384. return
  385. }
  386. uni.showLoading({ title: '处理中' })
  387. this.$Request.postJson('/app/company/giveCompany', {
  388. phone: this.changePhoneNum || this.userPhoneNum,
  389. msg: this.verifyCode,
  390. givePhone: this.phoneNum
  391. }).then(res => {
  392. if (res.code == 0) {
  393. this.showChangeModal = false
  394. this.logout()
  395. } else {
  396. this.$queue.showToast(res.msg || '出错了,请稍后再试')
  397. }
  398. }).finally(() => {
  399. uni.hideLoading()
  400. this.updating = false
  401. })
  402. },
  403. logout() {
  404. uni.showToast({
  405. title: '操作成功',
  406. icon: 'none',
  407. })
  408. setTimeout(() => {
  409. this.$queue.toLogin()
  410. this.$queue.logout()
  411. }, 1500)
  412. }
  413. }
  414. }
  415. </script>
  416. <style lang="scss" scoped>
  417. .my-company-page {
  418. display: flex;
  419. flex-direction: column;
  420. height: 100vh;
  421. background: linear-gradient(90.00deg, rgba(13, 39, 247, 1), rgba(19, 193, 234, 1) 100%);
  422. background-size: 100% 40%;
  423. background-position: center top;
  424. background-repeat: no-repeat;
  425. font-family: DM Sans;
  426. font-style: Regular;
  427. }
  428. /* 头部区域 */
  429. .header-section {
  430. text-align: center;
  431. }
  432. .illustration-area {
  433. .company-illustration {
  434. display: block;
  435. width: 280rpx;
  436. height: 180rpx;
  437. margin: 0 auto;
  438. }
  439. }
  440. // 管理员端
  441. .admin-container {
  442. flex: 1;
  443. .company-name {
  444. font-weight: 500;
  445. line-height: 44rpx;
  446. color: #fff;
  447. text-align: center;
  448. margin: 20rpx 40rpx;
  449. }
  450. .buttons {
  451. padding: 0 40rpx 28rpx;
  452. gap: 20rpx;
  453. .button {
  454. flex: 1;
  455. height: 80rpx;
  456. border-radius: 40rpx;
  457. background: rgba(255, 255, 255, 0.2);
  458. font-size: 32rpx;
  459. font-weight: 400;
  460. text-align: center;
  461. color: #fff;
  462. line-height: 80rpx;
  463. }
  464. }
  465. .list-wrapper {
  466. border-radius: 20rpx 20rpx 0 0;
  467. background-color: #fff;
  468. }
  469. .scroll-view {
  470. height: calc(100vh - 470rpx);
  471. overflow-y: auto;
  472. }
  473. .list {
  474. padding: 40rpx;
  475. .list-title {
  476. font-size: 32rpx;
  477. font-weight: 500;
  478. line-height: 56rpx;
  479. color: rgba(51, 51, 51, 1);
  480. }
  481. .account-item {
  482. padding: 32rpx 32rpx 28rpx 0;
  483. .title {
  484. color: rgba(51, 51, 51, 1);
  485. font-size: 30rpx;
  486. font-weight: 400;
  487. line-height: 44rpx;
  488. .badge {
  489. box-sizing: border-box;
  490. border: 1px solid rgba(1, 107, 246, 1);
  491. border-radius: 3px;
  492. background: rgba(1, 107, 246, 0.1);
  493. font-size: 20rpx;
  494. font-weight: 400;
  495. line-height: 24rpx;
  496. color: rgba(1, 107, 246, 1);
  497. margin-left: 16rpx;
  498. padding: 6rpx 12rpx;
  499. }
  500. }
  501. .sub-title {
  502. color: rgba(153, 153, 153, 1);
  503. font-size: 24rpx;
  504. font-weight: 400;
  505. line-height: 28rpx;
  506. margin-top: 10rpx;
  507. }
  508. .status-text {
  509. height: 54rpx;
  510. padding: 12rpx 24rpx;
  511. border-radius: 30rpx;
  512. font-size: 24rpx;
  513. font-weight: 400;
  514. line-height: 28rpx;
  515. color: rgba(1, 107, 246, 1);
  516. box-sizing: border-box;
  517. &.info {
  518. color: rgba(153, 153, 153, 1);
  519. }
  520. &.btn {
  521. color: #fff;
  522. background-color: #016BF6;
  523. }
  524. }
  525. .bottom-button {
  526. height: 44rpx;
  527. text-align: center;
  528. border-radius: 2px;
  529. background: rgba(1, 107, 246, 0.1);
  530. font-size: 24rpx;
  531. line-height: 44rpx;
  532. color: rgba(1, 107, 246, 1);
  533. margin-top: 10rpx;
  534. }
  535. }
  536. }
  537. }
  538. // 非管理员端
  539. .un-admin-container {
  540. .company-name {
  541. margin: 40rpx 40rpx 60rpx;
  542. color: rgba(255, 255, 255, 1);
  543. font-size: 28rpx;
  544. font-weight: 500;
  545. line-height: 44rpx;
  546. text-align: center;
  547. }
  548. .content-wrapper {
  549. border-radius: 20rpx 20rpx 0 0;
  550. background-color: #fff;
  551. padding: 52rpx 76rpx;
  552. .info-list {
  553. .info-item {
  554. color: rgba(153, 153, 153, 1);
  555. font-size: 24rpx;
  556. font-weight: 400;
  557. line-height: 32rpx;
  558. margin-bottom: 12rpx;
  559. text {
  560. padding-right: 48rpx;
  561. }
  562. }
  563. }
  564. .buttons {
  565. margin-top: 40rpx;
  566. .button {
  567. width: 100%;
  568. height: 40px;
  569. box-sizing: border-box;
  570. border: 1px solid rgba(1, 107, 246, 1);
  571. border-radius: 40px;
  572. background: rgba(255, 255, 255, 1);
  573. text-align: center;
  574. line-height: 38px;
  575. font-size: 16px;
  576. font-weight: 400;
  577. margin-bottom: 40rpx;
  578. &.plain {
  579. color: rgba(1, 107, 246, 1);
  580. }
  581. &.primary {
  582. color: #fff;
  583. background: rgba(1, 107, 246, 1);
  584. }
  585. }
  586. }
  587. }
  588. }
  589. // 审核弹窗
  590. .audit-modal {
  591. min-height: 180rpx;
  592. .title {
  593. color: rgba(51, 51, 51, 1);
  594. font-size: 30rpx;
  595. font-weight: 400;
  596. line-height: 44rpx;
  597. margin-top: 48rpx;
  598. .badge {
  599. box-sizing: border-box;
  600. border: 1px solid rgba(1, 107, 246, 1);
  601. border-radius: 3px;
  602. background: rgba(1, 107, 246, 0.1);
  603. font-size: 20rpx;
  604. font-weight: 400;
  605. line-height: 24rpx;
  606. color: rgba(1, 107, 246, 1);
  607. margin-left: 16rpx;
  608. padding: 6rpx 12rpx;
  609. }
  610. }
  611. .sub-title {
  612. color: rgba(153, 153, 153, 1);
  613. font-size: 24rpx;
  614. font-weight: 400;
  615. line-height: 28rpx;
  616. margin-top: 10rpx;
  617. }
  618. .check-bar {
  619. font-size: 24rpx;
  620. margin-top: 50rpx;
  621. ::v-deep .u-checkbox__label {
  622. margin-right: 20rpx;
  623. }
  624. .tip {
  625. padding-bottom: 5px;
  626. }
  627. }
  628. }
  629. // 更换账号弹窗
  630. .input-wrapper {
  631. box-sizing: border-box;
  632. border: 1px solid rgba(242, 242, 242, 1);
  633. border-radius: 6px;
  634. background: rgba(250, 250, 250, 1);
  635. margin-bottom: 16rpx;
  636. padding: 10rpx 24rpx;
  637. font-size: 28rpx;
  638. line-height: 60rpx;
  639. input {
  640. height: 60rpx;
  641. font-size: 28rpx;
  642. color: #1f2c37;
  643. }
  644. .placeholder {
  645. color: rgba(158, 161, 168, 1);
  646. }
  647. .verify-input {
  648. width: 300rpx;
  649. }
  650. .verify-btn {
  651. color: rgba(1, 107, 246, 1);
  652. }
  653. }
  654. </style>