StaffList.vue 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543
  1. <template>
  2. <div class="seek">
  3. <div class="com-mobile-header mobile-center-header">
  4. <a @click="goLastPage"><i class="iconfont icon-fanhui"></i></a>
  5. <p>员工管理</p>
  6. <p class="en-name"><img :src="`/images/mobile/center/${user.data.enterprise.uu ? 'en' : 'self'}.png`" alt="">{{currentEnName}}</p>
  7. </div>
  8. <div class="mobile-fix-content mobile-centerfix-content" id="mobile-staff-center">
  9. <div class="staff-head">
  10. <span class="inline-block" :class="{'active': switchType === 'info'}" @click="setSwitchType('info')">员工信息</span>
  11. <span v-show="isAdmin" class="inline-block" :class="{'active': switchType === 'Audit'}" @click="setSwitchType('Audit')">审核绑定</span>
  12. </div>
  13. <div class="staff-record" v-if="switchType === 'info'">
  14. <div class="search-content clearfix">
  15. <div class="search">
  16. <input type="text" placeholder="人员姓名、电话号码、邮箱或UU" v-model="staffSearch" class="staff-search" @keyup.13="staffRecord()">
  17. <span @click="staffRecord()"><i class="iconfont icon-sousuo"></i></span>
  18. </div>
  19. <div class="search-filter">
  20. <div class="select-wrap" @click="showRoleEvent($event)"><strong v-text="role"></strong><i class="iconfont icon-arrow-down"></i></div>
  21. <ul class="select-list" v-if="showRole">
  22. <li @click="rolesEvent()">全部角色</li>
  23. <li v-for="item in roles" v-text="item.desc" @click="rolesEvent(item)">全部角色</li>
  24. </ul>
  25. </div>
  26. </div>
  27. <div class="list-content" v-if="staffDataList && staffDataList.length">
  28. <div class="bg" v-for="item in staffDataList">
  29. <div class="staff-list">
  30. <div class="list-item"><span>UU账号:</span><span v-text="item.userUU">100000721</span></div>
  31. <div class="list-item"><span>姓名:</span><span v-text="item.userName">张洪别</span></div>
  32. <div class="list-item"><span>性别:</span><span v-text="item.userSex === 'F' ? '女' : item.userSex === 'M' ? '男' : '-'">男</span></div>
  33. <div class="list-item"><span>手机号:</span><span v-text="item.userTel">12345678901</span></div>
  34. <div class="list-item"><span>邮箱:</span><span v-text="item.userEmail">12345678901</span></div>
  35. <div class="list-item"><span>角色:</span><span class="role" v-for="role in item.roles" v-text="role.desc ? role.desc.slice(0,2) : ''" v-bind:class="'bg' + role.color">普通</span></div>
  36. </div>
  37. <div class="list-footer">
  38. <div @click="goEdit(item)" class="edit handle" v-bind:class="{'no-allow': (item.userUU === userInfo.userUU)}"><i class="iconfont icon-edit"></i><span>编辑</span></div>
  39. <div @click="openDelete(item)" class="delete handle" v-bind:class="{'no-allow': (item.userUU === userInfo.userUU)}"><i class="iconfont icon-lajitong"></i><span>删除</span></div>
  40. </div>
  41. </div>
  42. </div>
  43. <empty-status :type="'collect'" :showLink="true" :text="'抱歉,没有相关信息'" v-else></empty-status>
  44. <pull-up :fixId="'mobile-staff-center'" :searchMore="fetching" :allPage="allPage" :page="page" @pullUpAction="onPullUpAction"></pull-up>
  45. <nuxt-link class="staff-add" :to="'/mobile/user/staff/add'"><i class="iconfont icon-add"></i>新增用户</nuxt-link>
  46. </div>
  47. <div class="staff-record" v-if="switchType === 'Audit'">
  48. <div class="search-content">
  49. <input type="text" placeholder="人员姓名、电话号码、邮箱或UU" v-model="auditSearch" @keyup.13="auditRecord()">
  50. <span @click="auditRecord()"><i class="iconfont icon-sousuo"></i></span>
  51. </div>
  52. <div class="list-content" v-if="AuditList && AuditList.length">
  53. <div class="bg" v-for="item in AuditList">
  54. <div class="staff-list">
  55. <div class="list-item"><span>用户名:</span><span v-text="item.user.vipName"></span></div>
  56. <div class="list-item"><span>UU账号:</span><span v-text="item.user.userUU">100000721</span></div>
  57. <div class="list-item"><span>手机号:</span><span v-text="item.user.mobile">12345678901</span></div>
  58. <div class="list-item"><span>邮箱:</span><span v-text="item.user.email">12345678901</span></div>
  59. </div>
  60. <div class="list-footer">
  61. <div class="edit handle" @click="agreeEvent(item, '1')"><i class="iconfont icon-check-circle"></i><span>同意</span></div>
  62. <div class="handle delete" @click="agreeEvent(item, '0')"><i class="iconfont icon-close-circle"></i><span>拒绝</span></div>
  63. </div>
  64. </div>
  65. </div>
  66. <empty-status :type="'collect'" :showLink="true" :text="'抱歉,没有相关信息'" v-else></empty-status>
  67. <pull-up :fixId="'mobile-staff-center'" :searchMore="fetch" :allPage="allPageAudit" :page="page" @pullUpAction="onPullUpAudit"></pull-up>
  68. </div>
  69. </div>
  70. <!--删除员工-->
  71. <div class="deleteKuang" v-if="showDelete">
  72. <div class="kuangContent">
  73. <div class="title">温馨提示</div>
  74. <div class="titleinfo">确定删除该用户吗?</div>
  75. <div class="K_btn">
  76. <div class="cancelBtn" @click="showDelete = false">取消</div>
  77. <div class="answerBtn" @click="sureDelete()">确定</div>
  78. </div>
  79. </div>
  80. </div>
  81. <remind-box :title="remindText" :timeoutCount="timeoutCount"></remind-box>
  82. </div>
  83. </template>
  84. <script>
  85. import { RemindBox, PullUp, EmptyStatus } from '~components/mobile/common'
  86. import { BaseFilter } from '~components/mobile/base'
  87. export default {
  88. layout: 'mobile',
  89. data () {
  90. return {
  91. remindText: '',
  92. timeoutCount: 0,
  93. page: 1,
  94. count: 10,
  95. staffSearch: '',
  96. staffDataList: [],
  97. auditSearch: '',
  98. AuditList: [],
  99. isChange: false,
  100. hasChange: false,
  101. switchType: 'info',
  102. showDelete: false,
  103. currentObject: '',
  104. role: '全部角色',
  105. roles: [],
  106. showRole: false
  107. }
  108. },
  109. components: {
  110. RemindBox,
  111. PullUp,
  112. EmptyStatus,
  113. BaseFilter
  114. },
  115. created () {
  116. this.auditRecord()
  117. },
  118. mounted () {
  119. // 获取角色
  120. this.$nextTick(() => {
  121. this.getRoles()
  122. })
  123. let _this = this
  124. _this.$nextTick(function () {
  125. window.addEventListener('scroll', function () {
  126. _this.scroll()
  127. }, false)
  128. document.body.onclick = () => {
  129. this.showRole = false
  130. }
  131. })
  132. },
  133. watch: {
  134. 'staffData': {
  135. handler: function (val) {
  136. if (this.isChange) {
  137. this.staffDataList = val.content
  138. this.isChange = false
  139. } else {
  140. this.staffDataList = [...this.staffDataList, ...val.content]
  141. }
  142. },
  143. immediate: true
  144. },
  145. 'auditBind': {
  146. handler: function (val) {
  147. if (this.hasChange) {
  148. this.AuditList = val.content
  149. this.hasChange = false
  150. } else {
  151. this.AuditList = [...this.AuditList, ...val.content]
  152. }
  153. },
  154. immediate: true
  155. }
  156. },
  157. computed: {
  158. staffData () {
  159. return this.$store.state.staff.infoList.info.data
  160. },
  161. fetching () {
  162. return this.$store.state.staff.infoList.info.fetching
  163. },
  164. allPage () {
  165. return Math.floor(this.staffData.totalElements / this.staffData.size) + Math.floor(this.staffData.totalElements % this.staffData.size > 0 ? 1 : 0)
  166. },
  167. auditBind () {
  168. console.log(this.$store.state.staff.infoList.audit.data, '213')
  169. return this.$store.state.staff.infoList.audit.data ? this.$store.state.staff.infoList.audit.data.content : {content: []}
  170. },
  171. fetch () {
  172. return this.$store.state.staff.infoList.audit.fetching
  173. },
  174. allPageAudit () {
  175. return Math.floor(this.auditBind.totalElements / this.auditBind.size) + Math.floor(this.auditBind.totalElements % this.auditBind.size > 0 ? 1 : 0)
  176. },
  177. userInfo () {
  178. return this.$store.state.option.user.data
  179. }
  180. },
  181. methods: {
  182. onRemind: function (str) {
  183. this.remindText = str
  184. this.timeoutCount++
  185. },
  186. setSwitchType (type) {
  187. this.switchType = type
  188. this.page = 1
  189. if ( type === 'info') {
  190. this.staffRecord()
  191. } else {
  192. this.auditRecord()
  193. }
  194. },
  195. // 获取角色信息
  196. getRoles () {
  197. this.$http.get('/account/role')
  198. .then(response => {
  199. if (response.data) {
  200. this.roles = response.data
  201. }
  202. })
  203. .catch(err => {
  204. console.log(err)
  205. })
  206. },
  207. staffList () {
  208. this.$store.dispatch('staff/loadStaffList', {count: this.count, page: this.page, enuu: this.userInfo.enterprise.uu})
  209. },
  210. onPullUpAction: function () {
  211. this.page++
  212. this.staffList()
  213. },
  214. goEdit (item) {
  215. this.$store.commit('staff/infoList/EDIT_DATA_SUCCESS', item)
  216. this.$router.push('/mobile/user/staff/edit')
  217. },
  218. // 删除员工
  219. openDelete (item) {
  220. this.currentObject = item
  221. this.showDelete = true
  222. },
  223. // 员工搜索
  224. staffRecord () {
  225. this.role = '全部角色'
  226. this.showRole = false
  227. this.$store.dispatch('staff/loadStaffList', {count: this.count, page: this.page, enuu: this.user.data.enterprise.uu, keyword: this.staffSearch})
  228. },
  229. // 打开选择
  230. showRoleEvent (e) {
  231. if (e) {
  232. e.stopPropagation()
  233. }
  234. this.showRole = !this.showRole
  235. },
  236. // 选择性搜索
  237. rolesEvent (type) {
  238. this.showRole = !this.showRole
  239. this.page = 1
  240. if (type) {
  241. this.role = type.desc
  242. let params = {
  243. count: this.count,
  244. page: this.page,
  245. enuu: this.user.data.enterprise.uu,
  246. keyword: this.staffSearch,
  247. roleId: type.id
  248. }
  249. this.$store.commit('infoList/REQUEST_INFO_LIST')
  250. this.$http.get('/basic/user/enterprise/keywordinfo', {params})
  251. .then(response => {
  252. this.$store.commit('staff/infoList/GET_INFO_LIST_SUCCESS', response.data ? response.data : {})
  253. }, err => {
  254. this.$store.commit('staff/infoList/GET_INFO_LIST_FAILURE', err)
  255. })
  256. } else {
  257. this.role = '全部角色'
  258. this.staffRecord()
  259. }
  260. },
  261. sureDelete () {
  262. this.$http.delete('/basic/user/' + this.currentObject.userUU)
  263. .then(response => {
  264. console.log(response.data)
  265. this.showDelete = false
  266. this.onRemind('用户' + this.currentObject.userUU + '删除成功')
  267. this.staffData()
  268. }).catch(data => {
  269. this.showDelete = false
  270. this.onRemind(data.response.data)
  271. })
  272. },
  273. // 申请绑定搜索
  274. auditRecord () {
  275. this.$store.dispatch('staff/loadBindAudit', {count: this.count, page: this.page, speaceUU: this.user.data.enterprise.uu, status: 311, keyword: this.auditSearch})
  276. },
  277. // 绑定下拉
  278. onPullUpAudit () {
  279. this.page++
  280. this.auditRecord()
  281. },
  282. // 申请绑定操作事件 (同意和拒绝)
  283. agreeEvent (type, flag) {
  284. this.$http.get(`/basic/enterprise/auditApply?id=${type.id}&status=${Number(flag)}&userUU=${type.userUU}`)
  285. this.auditSearch = null
  286. this.page = 1
  287. this.auditRecord()
  288. }
  289. }
  290. }
  291. </script>
  292. <style lang="scss">
  293. $base-color: #3f84f6;
  294. #mobile-staff-center {
  295. .staff-head {
  296. height: .82rem;
  297. line-height: .82rem;
  298. text-align: center;
  299. background: #fff;
  300. span {
  301. font-size: .29rem;
  302. &:first-child {
  303. margin-right: 2.6rem;
  304. }
  305. &.active {
  306. color: $base-color;
  307. border-bottom: 1px solid $base-color;
  308. }
  309. }
  310. }
  311. .staff-record {
  312. .search-content {
  313. padding: .25rem 0;
  314. text-align: center;
  315. input {
  316. width: 6.9rem;
  317. border: 1px solid #376ff3;
  318. }
  319. .staff-search {
  320. width: 5.31rem;
  321. }
  322. .search {
  323. float: left;
  324. }
  325. .search-filter {
  326. float: left;
  327. margin-left: .35rem;
  328. position: relative;
  329. .select-wrap {
  330. width: 1.45rem;
  331. height: .58rem;
  332. line-height: .58rem;
  333. background-color: #ffffff;
  334. border-radius: .06rem;
  335. border: solid 1px #b4b4b4;
  336. strong{
  337. font-weight: normal;
  338. }
  339. i{
  340. float:right;
  341. display:inline-block;
  342. font-size: .1rem;
  343. font-weight: bold;
  344. color: $base-color;
  345. }
  346. }
  347. ul.select-list{
  348. width: 1.45rem;
  349. position: absolute;
  350. left: 0rem;
  351. top: .59rem;
  352. border: solid 1px #b4b4b4;
  353. border-top: none;
  354. -webkit-box-shadow: 0 1px 5px 0 #aaa;
  355. box-shadow: 0 1px 5px 0 #aaa;
  356. border-radius: .04rem;
  357. li{
  358. background: #fff;
  359. text-align: left;
  360. padding: 0 .13rem;
  361. font-size: .28rem;
  362. height: .53rem;
  363. line-height: .53rem;
  364. }
  365. }
  366. }
  367. }
  368. .list-content{
  369. margin: 0 auto;
  370. padding: 0 .20rem;
  371. margin-bottom:1.2rem;
  372. div.bg{
  373. padding: .32rem .24rem 0 .24rem;
  374. margin-bottom: .25rem;
  375. width: 7.1rem;
  376. background: #fff;
  377. border-radius: .05rem;
  378. }
  379. .staff-list {
  380. width: 100%;
  381. .list-item {
  382. margin-bottom: .14rem;
  383. &:last-child{
  384. padding-bottom: 0;
  385. }
  386. span {
  387. display: inline-block;
  388. font-size: .28rem;
  389. &:first-child {
  390. width: 1.3rem;
  391. text-align: right;
  392. color: #3f84f6;
  393. }
  394. &:last-child {
  395. color: #666;
  396. }
  397. }
  398. span.role{
  399. display: inline-block;
  400. margin-right: .1rem;
  401. padding: 0 .05rem;
  402. height: .25rem;
  403. line-height: .25rem;
  404. text-align: center;
  405. font-size: .24rem;
  406. color: #fff;
  407. border-radius: .04rem;
  408. }
  409. span.role.bg1{
  410. background-color: #89aefa;
  411. }
  412. span.role.bg2{
  413. background-color: #01d9ce;
  414. }
  415. span.role.bg3{
  416. background-color: #01d9ce;
  417. }
  418. span.role.bg4{
  419. background-color: #ff6769;
  420. }
  421. span.role.bg5{
  422. background-color: #ff8050;
  423. }
  424. }
  425. }
  426. .list-footer {
  427. width: 100%;
  428. height: .8rem;
  429. line-height: .8rem;
  430. background: #fff;
  431. border-top: 1px solid #d9d9d9;
  432. div.handle{
  433. float: left;
  434. width: 50%;
  435. margin: 0 auto;
  436. text-align: center;
  437. span{
  438. font-size: .26rem;
  439. color: #333;
  440. }
  441. i.iconfont {
  442. margin-right: .06rem;
  443. font-size: .36rem;
  444. color: #333;
  445. }
  446. }
  447. div.edit{
  448. border-right: 1px solid #d9d9d9;
  449. }
  450. div.no-allow {
  451. color: #606168;
  452. cursor: not-allowed;
  453. }
  454. }
  455. }
  456. .staff-add {
  457. display: inline-block;
  458. position: fixed;
  459. bottom: 1.2rem;
  460. left: 50%;
  461. margin-left: -3.29rem;
  462. width: 6.59rem;
  463. height: .77rem;
  464. line-height: .77rem;
  465. text-align: center;
  466. font-size: .32rem;
  467. color: #fff;
  468. background-color: #3f84f6;
  469. border-radius: 0.08rem;
  470. i{
  471. margin-right: .1rem;
  472. font-size: .32rem;
  473. color: #fff;
  474. }
  475. }
  476. }
  477. }
  478. /*删除弹框*/
  479. .deleteKuang {
  480. position: fixed;
  481. background: rgba(0,0,0,0.5);
  482. top: 0;
  483. left: 0;
  484. right: 0;
  485. bottom: 0;
  486. z-index: 9999;
  487. .kuangContent {
  488. border-radius: 5px;
  489. background: #fff;
  490. width: 5rem;
  491. position: absolute;
  492. left: 50%;
  493. top: 50%;
  494. transform: translate3d(-50%, -50%, 0);
  495. overflow: hidden;
  496. .titleinfo {
  497. font-size: .3rem;
  498. color: #666;
  499. text-align: center;
  500. margin-top: 0.5rem;
  501. margin-bottom: 0.1rem;
  502. }
  503. .title {
  504. background: #5078cb;
  505. height: .7rem;
  506. line-height: .7rem;
  507. font-size: .3rem;
  508. color: #fff;
  509. text-align: center;
  510. }
  511. .info {
  512. color: #f00;
  513. text-align: center;
  514. }
  515. .K_btn {
  516. margin-top: 0.4rem;
  517. line-height: 0.7rem;
  518. height: 0.7rem;
  519. &::after{
  520. clear: both;
  521. display: block;
  522. content: ' ';
  523. visibility: hidden;
  524. zoom: 1;
  525. }
  526. div {
  527. float: left;
  528. width: 50%;
  529. font-size: 0.3rem;
  530. text-align: center;
  531. &.cancelBtn {
  532. background: #b4b5b9;
  533. color: #333;
  534. }
  535. &.answerBtn {
  536. background: #5078cb;
  537. color: #fff;
  538. }
  539. }
  540. }
  541. }
  542. }
  543. </style>