StaffList.vue 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538
  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. mounted () {
  116. // 获取角色
  117. this.$nextTick(() => {
  118. this.getRoles()
  119. })
  120. let _this = this
  121. _this.$nextTick(function () {
  122. window.addEventListener('scroll', function () {
  123. _this.scroll()
  124. }, false)
  125. document.body.onclick = () => {
  126. this.showRole = false
  127. }
  128. })
  129. },
  130. watch: {
  131. 'staffData': {
  132. handler: function (val) {
  133. if (this.isChange) {
  134. this.staffDataList = val.content
  135. this.isChange = false
  136. } else {
  137. this.staffDataList = [...this.staffDataList, ...val.content]
  138. }
  139. },
  140. immediate: true
  141. },
  142. 'auditBind': {
  143. handler: function (val) {
  144. if (this.hasChange) {
  145. this.AuditList = val.content
  146. this.hasChange = false
  147. } else {
  148. this.AuditList = [...this.AuditList, ...val.content]
  149. }
  150. }
  151. }
  152. },
  153. computed: {
  154. staffData () {
  155. return this.$store.state.staff.infoList.info.data
  156. },
  157. fetching () {
  158. return this.$store.state.staff.infoList.info.fetching
  159. },
  160. allPage () {
  161. return Math.floor(this.staffData.totalElements / this.staffData.size) + Math.floor(this.staffData.totalElements % this.staffData.size > 0 ? 1 : 0)
  162. },
  163. auditBind () {
  164. return this.$store.state.staff.infoList.audit.data || {content:[]}
  165. },
  166. fetch () {
  167. return this.$store.state.staff.infoList.audit.fetching
  168. },
  169. allPageAudit () {
  170. return Math.floor(this.auditBind.totalElements / this.auditBind.size) + Math.floor(this.auditBind.totalElements % this.auditBind.size > 0 ? 1 : 0)
  171. },
  172. userInfo () {
  173. return this.$store.state.option.user.data
  174. }
  175. },
  176. methods: {
  177. onRemind: function (str) {
  178. this.remindText = str
  179. this.timeoutCount++
  180. },
  181. setSwitchType (type) {
  182. this.switchType = type
  183. this.page = 1
  184. if ( type === 'info') {
  185. this.staffRecord()
  186. } else {
  187. this.auditRecord()
  188. }
  189. },
  190. // 获取角色信息
  191. getRoles () {
  192. this.$http.get('/account/role')
  193. .then(response => {
  194. if (response.data) {
  195. this.roles = response.data
  196. }
  197. })
  198. .catch(err => {
  199. console.log(err)
  200. })
  201. },
  202. staffList () {
  203. this.$store.dispatch('staff/loadStaffList', {count: this.count, page: this.page, enuu: this.userInfo.enterprise.uu})
  204. },
  205. onPullUpAction: function () {
  206. this.page++
  207. this.staffList()
  208. },
  209. goEdit (item) {
  210. this.$store.commit('staff/infoList/EDIT_DATA_SUCCESS', item)
  211. this.$router.push('/mobile/user/staff/edit')
  212. },
  213. // 删除员工
  214. openDelete (item) {
  215. this.currentObject = item
  216. this.showDelete = true
  217. },
  218. // 员工搜索
  219. staffRecord () {
  220. this.role = '全部角色'
  221. this.showRole = false
  222. this.$store.dispatch('staff/loadStaffList', {count: this.count, page: this.page, enuu: this.user.data.enterprise.uu, keyword: this.staffSearch})
  223. },
  224. // 打开选择
  225. showRoleEvent (e) {
  226. if (e) {
  227. e.stopPropagation()
  228. }
  229. this.showRole = !this.showRole
  230. },
  231. // 选择性搜索
  232. rolesEvent (type) {
  233. this.showRole = !this.showRole
  234. this.page = 1
  235. if (type) {
  236. this.role = type.desc
  237. let params = {
  238. count: this.count,
  239. page: this.page,
  240. enuu: this.user.data.enterprise.uu,
  241. keyword: this.staffSearch,
  242. roleId: type.id
  243. }
  244. this.$store.commit('infoList/REQUEST_INFO_LIST')
  245. this.$http.get('/basic/user/enterprise/keywordinfo', {params})
  246. .then(response => {
  247. this.$store.commit('staff/infoList/GET_INFO_LIST_SUCCESS', response.data ? response.data : {})
  248. }, err => {
  249. this.$store.commit('staff/infoList/GET_INFO_LIST_FAILURE', err)
  250. })
  251. } else {
  252. this.role = '全部角色'
  253. this.staffRecord()
  254. }
  255. },
  256. sureDelete () {
  257. this.$http.delete('/basic/user/' + this.currentObject.userUU)
  258. .then(response => {
  259. console.log(response.data)
  260. this.showDelete = false
  261. this.onRemind('用户' + this.currentObject.userUU + '删除成功')
  262. this.staffData()
  263. }).catch(data => {
  264. this.showDelete = false
  265. this.onRemind(data.response.data)
  266. })
  267. },
  268. // 申请绑定搜索
  269. auditRecord () {
  270. this.$store.dispatch('staff/loadBindAudit', {count: this.count, page: this.page, speaceUU: this.user.data.enterprise.uu, status: 311, keyword: this.auditSearch})
  271. },
  272. // 绑定下拉
  273. onPullUpAudit () {
  274. this.page++
  275. this.auditRecord()
  276. },
  277. // 申请绑定操作事件 (同意和拒绝)
  278. agreeEvent (type, flag) {
  279. this.$http.get(`/basic/enterprise/auditApply?id=${type.id}&status=${Number(flag)}&userUU=${type.userUU}`)
  280. this.auditSearch = null
  281. this.page = 1
  282. this.auditRecord()
  283. }
  284. }
  285. }
  286. </script>
  287. <style lang="scss">
  288. $base-color: #3f84f6;
  289. #mobile-staff-center {
  290. .staff-head {
  291. height: .82rem;
  292. line-height: .82rem;
  293. text-align: center;
  294. background: #fff;
  295. span {
  296. font-size: .29rem;
  297. &:first-child {
  298. margin-right: 2.6rem;
  299. }
  300. &.active {
  301. color: $base-color;
  302. border-bottom: 1px solid $base-color;
  303. }
  304. }
  305. }
  306. .staff-record {
  307. .search-content {
  308. padding: .25rem 0;
  309. text-align: center;
  310. input {
  311. width: 6.9rem;
  312. border: 1px solid #376ff3;
  313. }
  314. .staff-search {
  315. width: 5.31rem;
  316. }
  317. .search {
  318. float: left;
  319. }
  320. .search-filter {
  321. float: left;
  322. margin-left: .35rem;
  323. position: relative;
  324. .select-wrap {
  325. width: 1.45rem;
  326. height: .58rem;
  327. line-height: .58rem;
  328. background-color: #ffffff;
  329. border-radius: .06rem;
  330. border: solid 1px #b4b4b4;
  331. strong{
  332. font-weight: normal;
  333. }
  334. i{
  335. float:right;
  336. display:inline-block;
  337. font-size: .1rem;
  338. font-weight: bold;
  339. color: $base-color;
  340. }
  341. }
  342. ul.select-list{
  343. width: 1.45rem;
  344. position: absolute;
  345. left: 0rem;
  346. top: .59rem;
  347. border: solid 1px #b4b4b4;
  348. border-top: none;
  349. -webkit-box-shadow: 0 1px 5px 0 #aaa;
  350. box-shadow: 0 1px 5px 0 #aaa;
  351. border-radius: .04rem;
  352. li{
  353. background: #fff;
  354. text-align: left;
  355. padding: 0 .13rem;
  356. font-size: .28rem;
  357. height: .53rem;
  358. line-height: .53rem;
  359. }
  360. }
  361. }
  362. }
  363. .list-content{
  364. margin: 0 auto;
  365. padding: 0 .20rem;
  366. margin-bottom:1.2rem;
  367. div.bg{
  368. padding: .32rem .24rem 0 .24rem;
  369. margin-bottom: .25rem;
  370. width: 7.1rem;
  371. background: #fff;
  372. border-radius: .05rem;
  373. }
  374. .staff-list {
  375. width: 100%;
  376. .list-item {
  377. margin-bottom: .14rem;
  378. &:last-child{
  379. padding-bottom: 0;
  380. }
  381. span {
  382. display: inline-block;
  383. font-size: .28rem;
  384. &:first-child {
  385. width: 1.3rem;
  386. text-align: right;
  387. color: #3f84f6;
  388. }
  389. &:last-child {
  390. color: #666;
  391. }
  392. }
  393. span.role{
  394. display: inline-block;
  395. margin-right: .1rem;
  396. padding: 0 .05rem;
  397. height: .25rem;
  398. line-height: .25rem;
  399. text-align: center;
  400. font-size: .24rem;
  401. color: #fff;
  402. border-radius: .04rem;
  403. }
  404. span.role.bg1{
  405. background-color: #89aefa;
  406. }
  407. span.role.bg2{
  408. background-color: #01d9ce;
  409. }
  410. span.role.bg3{
  411. background-color: #01d9ce;
  412. }
  413. span.role.bg4{
  414. background-color: #ff6769;
  415. }
  416. span.role.bg5{
  417. background-color: #ff8050;
  418. }
  419. }
  420. }
  421. .list-footer {
  422. width: 100%;
  423. height: .8rem;
  424. line-height: .8rem;
  425. background: #fff;
  426. border-top: 1px solid #d9d9d9;
  427. div.handle{
  428. float: left;
  429. width: 50%;
  430. margin: 0 auto;
  431. text-align: center;
  432. span{
  433. font-size: .26rem;
  434. color: #333;
  435. }
  436. i.iconfont {
  437. margin-right: .06rem;
  438. font-size: .36rem;
  439. color: #333;
  440. }
  441. }
  442. div.edit{
  443. border-right: 1px solid #d9d9d9;
  444. }
  445. div.no-allow {
  446. color: #606168;
  447. cursor: not-allowed;
  448. }
  449. }
  450. }
  451. .staff-add {
  452. display: inline-block;
  453. position: fixed;
  454. bottom: 1.2rem;
  455. left: 50%;
  456. margin-left: -3.29rem;
  457. width: 6.59rem;
  458. height: .77rem;
  459. line-height: .77rem;
  460. text-align: center;
  461. font-size: .32rem;
  462. color: #fff;
  463. background-color: #3f84f6;
  464. border-radius: 0.08rem;
  465. i{
  466. margin-right: .1rem;
  467. font-size: .32rem;
  468. color: #fff;
  469. }
  470. }
  471. }
  472. }
  473. /*删除弹框*/
  474. .deleteKuang {
  475. position: fixed;
  476. background: rgba(0,0,0,0.5);
  477. top: 0;
  478. left: 0;
  479. right: 0;
  480. bottom: 0;
  481. z-index: 9999;
  482. .kuangContent {
  483. border-radius: 5px;
  484. background: #fff;
  485. width: 5rem;
  486. position: absolute;
  487. left: 50%;
  488. top: 50%;
  489. transform: translate3d(-50%, -50%, 0);
  490. overflow: hidden;
  491. .titleinfo {
  492. font-size: .3rem;
  493. color: #666;
  494. text-align: center;
  495. margin-top: 0.5rem;
  496. margin-bottom: 0.1rem;
  497. }
  498. .title {
  499. background: #5078cb;
  500. height: .7rem;
  501. line-height: .7rem;
  502. font-size: .3rem;
  503. color: #fff;
  504. text-align: center;
  505. }
  506. .info {
  507. color: #f00;
  508. text-align: center;
  509. }
  510. .K_btn {
  511. margin-top: 0.4rem;
  512. line-height: 0.7rem;
  513. height: 0.7rem;
  514. &::after{
  515. clear: both;
  516. display: block;
  517. content: ' ';
  518. visibility: hidden;
  519. zoom: 1;
  520. }
  521. div {
  522. float: left;
  523. width: 50%;
  524. font-size: 0.3rem;
  525. text-align: center;
  526. &.cancelBtn {
  527. background: #b4b5b9;
  528. color: #333;
  529. }
  530. &.answerBtn {
  531. background: #5078cb;
  532. color: #fff;
  533. }
  534. }
  535. }
  536. }
  537. }
  538. </style>