123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740 |
- <template>
- <div class="seek">
- <div class="com-mobile-header mobile-center-header">
- <a @click="goLastPage"><i class="iconfont icon-fanhui"></i></a>
- <p>员工管理</p>
- <p class="en-name"><img :src="`/images/mobile/center/${user.data.enterprise.uu ? 'en' : 'self'}.png`" alt="">{{currentEnName}}</p>
- </div>
-
- <div class="mobile-fix-content mobile-centerfix-content" id="mobile-staff-center">
-
- <div v-if="activeTab === 0">
- <div class="staff-head" v-show="isAdmin">
- <span class="inline-block" :class="{'active': switchType === 'info'}" @click="setSwitchType('info')">员工信息</span>
- <span class="inline-block" :class="{'active': switchType === 'Audit'}" @click="setSwitchType('Audit')">审核绑定</span>
- </div>
- <div class="staff-record" v-if="switchType === 'info'">
- <div class="search-content clearfix">
- <div class="search">
- <input type="text" placeholder="人员姓名、手机、邮箱" v-model="staffSearch" class="staff-search" @keyup.13="staffRecord()">
- <span @click="staffRecord()"><i class="iconfont icon-sousuo"></i></span>
- </div>
- <div class="search-filter">
- <div class="select-wrap" @click="showRoleEvent($event)"><strong v-text="role"></strong><i class="iconfont icon-arrow-down"></i></div>
- <ul class="select-list" v-if="showRole">
- <li @click="rolesEvent()">全部角色</li>
- <li v-for="item in rolesList" v-text="item.desc" @click="rolesEvent(item)">全部角色</li>
- </ul>
- </div>
- </div>
- <div class="list-content" v-if="staffDataList && staffDataList.length">
- <div class="bg" v-for="item in staffDataList">
- <div class="staff-list">
-
- <div class="list-item"><span>姓名:</span><span v-text="item.userName">张洪别</span></div>
-
- <div class="list-item"><span>手机:</span><span v-text="item.userTel">12345678901</span></div>
- <div class="list-item"><span>邮箱:</span><span v-text="item.userEmail">12345678901</span></div>
- <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>
- </div>
- <div class="list-footer">
- <div @click="goEdit(item)" class="edit handle"><i class="iconfont icon-edit"></i><span>角色分配</span></div>
- <div @click="openDelete(item)" class="delete handle"><i class="iconfont icon-lajitong"></i><span>删除</span></div>
- </div>
- </div>
- </div>
- <empty-status :type="'collect'" :showLink="true" :text="'抱歉,没有相关信息'" v-else></empty-status>
- <pull-up :fixId="'mobile-staff-center'" :isValid="activeTab == 0 && switchType === 'info'" :searchMore="fetching" :allPage="allPage" :page="page" @pullUpAction="onPullUpAction"></pull-up>
- </div>
- <div class="staff-record" v-if="switchType === 'Audit'">
- <div class="search-content">
- <input type="text" placeholder="人员姓名、手机、邮箱" v-model="auditSearch" @keyup.13="searchAudit()">
- <span @click="searchAudit()"><i class="iconfont icon-sousuo"></i></span>
- </div>
- <div class="list-content" v-if="AuditList && AuditList.length">
- <div class="bg" v-for="item in AuditList">
- <div class="staff-list">
- <div class="list-item"><span>用户名:</span><span v-text="item.user.vipName"></span></div>
-
- <div class="list-item"><span>手机:</span><span v-text="item.user.mobile">12345678901</span></div>
- <div class="list-item"><span>邮箱:</span><span v-text="item.user.email">12345678901</span></div>
- </div>
- <div class="list-footer">
- <div class="edit handle" @click="agreeEvent(item, '1')"><i class="iconfont icon-check-circle"></i><span>同意</span></div>
- <div class="handle delete" @click="agreeEvent(item, '0')"><i class="iconfont icon-close-circle"></i><span>拒绝</span></div>
- </div>
- </div>
- </div>
- <empty-status :type="'collect'" :showLink="true" :text="'抱歉,没有相关信息'" v-else></empty-status>
- <pull-up :fixId="'mobile-staff-center'" :isValid="switchType === 'Audit'" :searchMore="fetch" :allPage="allPageAudit" :page="page" @pullUpAction="onPullUpAudit"></pull-up>
- </div>
- </div>
-
- <div v-if="activeTab === 1">
- <div v-for="(role, index) in rolesList">
- <div class="staff-role">
- <div class="staff-header"><span :class="'active_0' + role.color"><b></b>{{role.desc}}</span></div>
- <div class="staff-content">
- <label class="radio-label clearfix" >
- <input type="checkbox" :id="role.id" :checked="role.checked" @change="checkRole(role, index)"/>
- <label :for="role.id" v-bind:class="{'margin0': role.color === '4' || role.color === '2'}"></label>
- <p class="staff-des">{{role.duty}}</p>
- </label>
- </div>
- </div>
- </div>
- <div class="staff-footer" v-if="rolesList || rolesList.length > 0">
- <div class="cancel handle" @click="cancelBind">取消</div>
- <div class="agree handle" @click="sureEdit">确定</div>
- </div>
- </div>
- </div>
- <nuxt-link v-if="activeTab === 0 && switchType === 'info'" class="staff-add" :to="'/mobile/user/staff/add'"><i class="iconfont icon-add"></i>新增用户</nuxt-link>
-
- <div class="deleteKuang" v-if="showDelete">
- <div class="kuangContent">
- <div class="title">温馨提示</div>
- <div class="titleinfo">确定删除该用户吗?</div>
- <div class="K_btn">
- <div class="cancelBtn" @click="showDelete = false">取消</div>
- <div class="answerBtn" @click="sureDelete()">确定</div>
- </div>
- </div>
- </div>
- <remind-box :title="remindText" :timeoutCount="timeoutCount"></remind-box>
- </div>
- </template>
- <script>
- import { RemindBox, PullUp, EmptyStatus } from '~components/mobile/common'
- import { BaseFilter } from '~components/mobile/base'
- export default {
- layout: 'mobile',
- data () {
- return {
- remindText: '',
- timeoutCount: 0,
- page: 1,
- count: 10,
- staffSearch: '',
- staffDataList: [],
- auditSearch: '',
- AuditList: [],
- isChange: false,
- hasChange: false,
- switchType: 'info',
- showDelete: false,
- currentObject: '',
- activeTab: 0,
- checked: false,
- rolesList: [],
- currentStaff: [],
- role: '全部角色',
- showRole: false
- }
- },
- components: {
- RemindBox,
- PullUp,
- EmptyStatus,
- BaseFilter
- },
- mounted () {
-
- this.$nextTick(() => {
- this.getRoles()
- })
- let _this = this
- _this.$nextTick(function () {
- window.addEventListener('scroll', function () {
- _this.scroll()
- }, false)
- document.body.onclick = () => {
- this.showRole = false
- }
- })
- },
- watch: {
- 'staffData': {
- handler: function (val) {
- if (this.isChange) {
- this.staffDataList = []
- this.isChange = false
- }
- if (val && val.content) {
- this.staffDataList = [...this.staffDataList, ...val.content]
- }
- },
- immediate: true
- },
- 'auditBind': {
- handler: function (val) {
- if (this.hasChange) {
- this.AuditList = []
- this.hasChange = false
- }
- if (val && val.content) {
- this.AuditList = [...this.AuditList, ...val.content]
- }
- }
- }
- },
- computed: {
- staffData () {
- return this.$store.state.staff.infoList.info.data
- },
- fetching () {
- return this.$store.state.staff.infoList.info.fetching
- },
- allPage () {
- return Math.floor(this.staffData.totalElements / this.staffData.size) + Math.floor(this.staffData.totalElements % this.staffData.size > 0 ? 1 : 0)
- },
- auditBind () {
- return this.$store.state.staff.infoList.audit.data
- },
- fetch () {
- return this.$store.state.staff.infoList.audit.fetching
- },
- allPageAudit () {
- return Math.floor(this.auditBind.totalElements / this.auditBind.size) + Math.floor(this.auditBind.totalElements % this.auditBind.size > 0 ? 1 : 0)
- },
- userInfo () {
- return this.$store.state.option.user.data
- }
- },
- methods: {
- setRemindText: function (str) {
- this.remindText = str
- this.timeoutCount++
- },
- setSwitchType (type) {
- this.staffSearch = ''
- this.auditSearch = ''
- this.switchType = type
- this.page = 1
- if ( type === 'info') {
- this.isChange = true
- this.staffRecord()
- } else {
- this.hasChange = true
- this.auditRecord()
- }
- },
- staffList () {
- this.$store.dispatch('staff/loadStaffList', {count: this.count, page: this.page, enuu: this.userInfo.enterprise.uu})
- },
-
- onPullUpAction: function () {
- this.page++
- this.staffList()
- },
-
- staffRecord () {
- this.showRole = false
- this.rolesEvent()
- },
-
- openDelete (item) {
- if (this.isAdmin) {
- if (item.userUU === this.userInfo.userUU) {
- this.setRemindText('自己不可修改自己')
- } else {
- this.currentObject = item
- this.showDelete = true
- }
- } else {
- this.setRemindText('您不是管理员不可修改')
- }
- },
-
- sureDelete () {
- this.$http.delete('/basic/user/' + this.currentObject.userUU)
- .then(response => {
-
- this.showDelete = false
- this.setRemindText('用户' + this.currentObject.userUU + '删除成功')
- this.page = 1
- this.isChange = true
- this.staffList()
- }).catch(data => {
- this.showDelete = false
- this.setRemindText(data.response.data)
- })
- },
-
- showRoleEvent (e) {
- if (e) {
- e.stopPropagation()
- }
- this.showRole = !this.showRole
- },
-
- rolesEvent (type) {
- this.isChange = true
- this.showRole = false
- this.role = type ? type.desc : '全部角色'
- this.page = 1
- if (!type && !this.staffSearch) {
- this.$store.dispatch('staff/loadStaffList', {count: this.count, page: this.page, enuu: this.user.data.enterprise.uu, keyword: this.staffSearch})
- } else {
- let params = {
- count: this.count,
- page: this.page,
- enuu: this.user.data.enterprise.uu,
- keyword: this.staffSearch,
- roleId: type ? type.id : null
- }
- this.isChange = true
- this.$store.commit('staff/infoList/REQUEST_INFO_LIST')
- this.$http.get('/basic/user/enterprise/keywordinfo', {params})
- .then(response => {
- this.$store.commit('staff/infoList/GET_INFO_LIST_SUCCESS', response.data ? response.data : {})
- }, err => {
- this.$store.commit('staff/infoList/GET_INFO_LIST_FAILURE', err)
- })
- }
- },
-
- getRoles () {
- this.$http.get('/btob/account/role')
- .then(response => {
- if (response.data) {
- this.rolesList = response.data
- }
- })
- },
-
- goEdit (item) {
- if (item.userUU === this.userInfo.userUU) {
- this.setRemindText('自己不可修改自己')
- } else {
- this.authorityInterceptor('/basic/user/updaterole', () => {
- let currentData = item
- this.currentStaff = this.baseUtils.deepCopy(currentData)
- this.activeTab = 1
- for (let j = 0; j < this.rolesList.length; j++) {
- for (let i = 0; i < this.currentStaff.roles.length; i++) {
-
- if (this.currentStaff.roles[i].id === this.rolesList[j].id) {
- this.rolesList[j].checked = true
- break
- } else {
- this.rolesList[j].checked = false
- }
- }
- }
- })
- }
- },
-
- checkRole (role) {
- role.checked = !role.checked
- },
-
- cancelBind () {
- this.activeTab = 0
- },
-
- sureEdit () {
- this.currentStaff.roles = []
- for (var i = 0 ; i< this.rolesList.length; i++) {
- if (this.rolesList[i].checked) {
- this.currentStaff.roles.push(this.rolesList[i])
- }
- }
- this.$http.put(`/basic/user/updaterole`, this.currentStaff)
- .then(() => {
- this.setRemindText('角色编辑成功')
- this.activeTab = 0
- this.page = 1
- this.isChange = true
- this.staffList()
- })
- },
-
- auditRecord () {
- this.$store.dispatch('staff/loadBindAudit', {count: this.count, page: this.page, speaceUU: this.user.data.enterprise.uu, status: 311, keyword: this.auditSearch})
- },
- searchAudit () {
- this.hasChange = true
- this.page = 1
- this.auditRecord()
- },
-
- onPullUpAudit () {
- this.page++
- this.auditRecord()
- },
-
- agreeEvent (type, flag) {
- this.$http.get(`/basic/enterprise/auditApply?id=${type.id}&status=${Number(flag)}&userUU=${type.userUU}`)
- .then(() => {
- this.setRemindText('操作成功!')
- this.auditSearch = ''
- this.page = 1
- this.searchAudit()
- })
- }
- }
- }
- </script>
- <style lang="scss">
- $base-color: #3f84f6;
- #mobile-staff-center {
- padding-bottom: .5rem;
- margin: 0 auto;
- .staff-head {
- height: .82rem;
- line-height: .82rem;
- text-align: center;
- background: #fff;
- span {
- font-size: .29rem;
- &:last-child {
- margin-left: 2.6rem;
- }
- &.active {
- color: $base-color;
- border-bottom: 1px solid $base-color;
- }
- }
- }
- .staff-record {
- .search-content {
- padding: .25rem 0;
- text-align: center;
- input {
- width: 6.9rem;
- border: 1px solid #376ff3;
- }
- .staff-search {
- width: 5.31rem;
- }
- .search {
- float: left;
- }
- .search-filter {
- float: left;
- margin-left: .35rem;
- position: relative;
- .select-wrap {
- width: 1.45rem;
- height: .58rem;
- line-height: .58rem;
- background-color: #ffffff;
- border-radius: .06rem;
- border: solid 1px #b4b4b4;
- strong{
- font-weight: normal;
- }
- i{
- float:right;
- display:inline-block;
- font-size: .1rem;
- font-weight: bold;
- color: $base-color;
- }
- }
- ul.select-list{
- width: 1.45rem;
- position: absolute;
- left: 0rem;
- top: .59rem;
- border: solid 1px #b4b4b4;
- border-top: none;
- -webkit-box-shadow: 0 1px 5px 0 #aaa;
- box-shadow: 0 1px 5px 0 #aaa;
- border-radius: .04rem;
- li{
- background: #fff;
- text-align: left;
- padding: 0 .13rem;
- font-size: .28rem;
- height: .53rem;
- line-height: .53rem;
- }
- }
- }
- }
- .list-content{
- margin: 0 auto;
- padding: 0 .20rem;
- margin-bottom:1.2rem;
- div.bg{
- padding: .32rem .24rem 0 .24rem;
- margin-bottom: .25rem;
- width: 7.1rem;
- background: #fff;
- border-radius: .05rem;
- &:last-child {
- margin-bottom: 1.5rem;
- }
- }
- .staff-list {
- width: 100%;
- .list-item {
- margin-bottom: .14rem;
- &:last-child{
- padding-bottom: 0;
- }
- span {
- display: inline-block;
- font-size: .28rem;
- &:first-child {
- width: 1.3rem;
- text-align: right;
- color: #3f84f6;
- }
- &:last-child {
- color: #666;
- }
- }
- span.role{
- display: inline-block;
- margin-right: .1rem;
- padding: 0 .05rem;
- height: .25rem;
- line-height: .25rem;
- text-align: center;
- font-size: .24rem;
- color: #fff;
- border-radius: .04rem;
- }
- span.role.bg1{
- background-color: #89aefa;
- }
- span.role.bg2{
- background-color: #01d9ce;
- }
- span.role.bg3{
- background-color: #01d9ce;
- }
- span.role.bg4{
- background-color: #ff6769;
- }
- span.role.bg5{
- background-color: #ff8050;
- }
- }
- }
- .list-footer {
- width: 100%;
- height: .8rem;
- line-height: .8rem;
- background: #fff;
- border-top: 1px solid #d9d9d9;
- div.handle{
- float: left;
- width: 50%;
- margin: 0 auto;
- text-align: center;
- span{
- font-size: .26rem;
- color: #333;
- }
- i.iconfont {
- margin-right: .06rem;
- font-size: .36rem;
- color: #333;
- }
- }
- div.edit{
- border-right: 1px solid #d9d9d9;
- }
- div.no-allow {
- color: #606168;
- cursor: not-allowed;
- }
- }
- }
- }
- /*编辑角色*/
- .staff-role{
- margin: .2rem auto 0;
- padding: 0 .24rem;
- width: 7.1rem;
- height: 1.72rem;
- background-color: #fff;
- border-radius: .05rem;
- .staff-header {
- height: .5rem;
- line-height: .5rem;
- text-align: left;
- border-bottom: 1px solid #d9d9d9;
- span {
- font-size: .28rem;
- color: #333;
- b{
- display: inline-block;
- margin-right: .05rem;
- width: .05rem;
- height: .18rem;
- background-color: #3f84f6;
- }
- }
- span.active_02 b{
- background-color: #8aaefc;
- }
- span.active_03 b{
- background-color: #09d7cd;
- }
- span.active_04 b{
- background-color: #ff676a;
- }
- span.active_05 b{
- background-color: #fc9b68;
- }
- }
- .staff-content {
- padding-top: .25rem;
- .radio-label {
- background-size: contain;
- vertical-align: middle;
- input{
- float: left;
- display: none;
- margin: .18rem .1rem 0 0;
- width: .36rem;
- height: .36rem;
- border: solid 2px #999999;
- }
- label {
- float: left;
- margin: .18rem .1rem 0 0;
- width: .36rem;
- height: .36rem;
- border-radius: 50%;
- background: url(/images/mobile/center/user/car-noChecked.png) no-repeat;
- background-size: contain;
- vertical-align: middle;
- }
- label.margin0 {
- margin: 0.05rem .1rem 0 0;
- }
- input:checked + label {
- background-image: url(/images/mobile/center/user/car-checked.png);
- }
- input.checked + label {
- background-image: url(/images/mobile/center/user/car-checked.png);
- }
- }
- .staff-des{
- float: left;
- width: 6rem;
- line-height: .42rem;
- font-weight: normal;
- font-size: .28rem;
- color: #666666;
- }
- }
- }
- .staff-footer{
- overflow: hidden;
- margin-top: .6rem;
- div.handle{
- float: left;
- width: 3.24rem;
- height: .77rem;
- line-height: .77rem;
- font-size: .32rem;
- color: #fff;
- text-align: center;
- border-radius: .08rem;
- &:first-child{
- margin: 0 .28rem 0 .35rem;
- background-color: #acaaab;
- }
- &:last-child{
- background-color: #3f84f6;
- }
- }
- }
- }
- .staff-add {
- display: inline-block;
- position: fixed;
- bottom: 1.2rem;
- left: 50%;
- margin-left: -3.29rem;
- width: 6.59rem;
- height: .77rem;
- line-height: .77rem;
- text-align: center;
- font-size: .32rem;
- color: #fff;
- background-color: #3f84f6;
- border-radius: 0.08rem;
- i{
- margin-right: .1rem;
- font-size: .32rem;
- color: #fff;
- }
- }
- /*删除弹框*/
- .deleteKuang {
- position: fixed;
- background: rgba(0,0,0,0.5);
- top: 0;
- left: 0;
- right: 0;
- bottom: 0;
- z-index: 9999;
- .kuangContent {
- border-radius: 5px;
- background: #fff;
- width: 5rem;
- position: absolute;
- left: 50%;
- top: 50%;
- transform: translate3d(-50%, -50%, 0);
- overflow: hidden;
- .titleinfo {
- font-size: .3rem;
- color: #666;
- text-align: center;
- margin-top: 0.5rem;
- margin-bottom: 0.1rem;
- }
- .title {
- background: #5078cb;
- height: .7rem;
- line-height: .7rem;
- font-size: .3rem;
- color: #fff;
- text-align: center;
- }
- .info {
- color: #f00;
- text-align: center;
- }
- .K_btn {
- margin-top: 0.4rem;
- line-height: 0.7rem;
- height: 0.7rem;
- &::after{
- clear: both;
- display: block;
- content: ' ';
- visibility: hidden;
- zoom: 1;
- }
- div {
- float: left;
- width: 50%;
- font-size: 0.3rem;
- text-align: center;
- &.cancelBtn {
- background: #b4b5b9;
- color: #333;
- }
- &.answerBtn {
- background: #5078cb;
- color: #fff;
- }
- }
- }
- }
- }
- </style>
|