StaffList.vue 16 KB

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