| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415 |
- <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 class="staff-head">
- <span class="inline-block" :class="{'active': switchType === 'addNoRegister'}" @click="setSwitchType('addNoRegister')">添加未注册用户</span>
- <span class="inline-block" :class="{'active': switchType === 'addRegister'}" @click="setSwitchType('addRegister')">添加已注册用户</span>
- </div>
- <div class="staff-record" v-if="switchType == 'addNoRegister'" >
- <div class="list-content">
- <ul class="staff-adds">
- <li><span>姓名:</span><input type="text" v-model="newUserName" maxlength="10" placeholder="请输入用户名"></li>
- <!--<li style="overflow: visible;"><span>性别:</span>-->
- <!--<div class="sex-filter">-->
- <!--<div class="select-wrap" @click.stop="openChoose">{{sex === 'M' ? '男' : '女'}}<i class="iconfont icon-arrow-down"></i></div>-->
- <!--<ul class="select-list" v-if="showChooseSex">-->
- <!--<li v-show="sex != 'M'" @click="chooseSex('M')">男</li>-->
- <!--<li v-show="sex != 'F'" @click="chooseSex('F')">女</li>-->
- <!--</ul>-->
- <!--</div>-->
- <!--</li>-->
- <li><span>手机:</span><input type="text"
- v-model="newUserPhone"
- @change="checkPhone()"
- @input="checkPhone()"
- maxlength="11"
- placeholder="请输入手机"></li>
- <li><span>邮箱:</span><input type="text"
- v-model="newUserEmail"
- @change="checkEmail()"
- @input="checkEmail()"
- placeholder="请输入邮箱"></li>
- </ul>
- <div class="staff-footer">
- <div class="cancel handle" @click="cancelBind">取消</div>
- <div class="agree handle" @click="addNewUser">确定</div>
- </div>
- </div>
- </div>
- <div class="staff-record" v-if="switchType == 'addRegister'">
- <div class="search-content">
- <input type="text"
- v-model="searchKeyword"
- @click="addApply"
- placeholder="请输入UU号、手机或邮箱">
- <span @click="addApply"><i class="iconfont icon-sousuo"></i></span>
- </div>
- <div class="list-content" v-if="searchNoData">
- <div class="staff-list">
- <span>您查找的用户不存在!</span>
- </div>
- </div>
- <div class="list-content" v-else>
- <div v-if="showSearchUser">
- <div class="staff-list">
- <div class="list-item"><span>UU账号:</span><span v-text="newUserInfo.userUU">100000721</span></div>
- <div class="list-item"><span>姓名:</span><span v-text="newUserInfo.userName">张洪别</span></div>
- <!--<div class="list-item"><span>性别:</span><span v-text="newUserInfo.userSex === 'F' ? '女' : newUserInfo.userSex === 'M' ? '男' : '-'">男</span></div>-->
- <div class="list-item"><span>手机:</span><span v-text="newUserInfo.userTel">12345678901</span></div>
- <div class="list-item"><span>邮箱:</span><span v-text="newUserInfo.userEmail">12345678901</span></div>
- </div>
- <div class="staff-footer">
- <div class="cancel handle" @click="cancelBind">取消</div>
- <div class="agree handle" @click="sureBindNewUser()">确定绑定</div>
- </div>
- </div>
- <div class="staff-list" v-else-if="bindSelf">
- <span>不可对自己进行绑定!</span>
- </div>
- </div>
- </div>
- </div>
- <remind-box :title="remindText" :timeoutCount="timeoutCount"></remind-box>
- </div>
- </template>
- <script>
- import { RemindBox } from '~components/mobile/common'
- export default {
- data () {
- return {
- switchType: 'addNoRegister',
- newUserName: '',
- newUserPhone: '',
- newUserEmail: '',
- showChooseSex: false,
- sex: 'M',
- remindText: '',
- timeoutCount: 0,
- newPhoneCheck: false,
- newEmailCheck: true,
- showSearchUser: false,
- searchKeyword: '',
- newUserInfo: '',
- bindSelf: false,
- searchNoData: false
- }
- },
- components: {
- RemindBox
- },
- computed: {
- userInfo () {
- return this.$store.state.option.user.data
- }
- },
- mounted () {
- this.$nextTick(() => {
- window.addEventListener('click', () => {
- this.showChooseSex = false
- }, false)
- })
- },
- methods: {
- setSwitchType (type) {
- this.switchType = type
- },
- // openChoose () {
- // this.showChooseSex = !this.showChooseSex
- // },
- // chooseSex (info) {
- // this.sex = info
- // this.showChooseSex = false
- // },
- onRemind: function (str) {
- this.remindText = str
- this.timeoutCount ++
- },
- // 验证手机
- checkPhone () {
- if (!this.newUserPhone || this.newUserPhone === '') {
- this.newPhoneCheck = false
- this.onRemind('请输入手机号码')
- } else {
- if ((/^1\d{10}$/).test(this.newUserPhone)) {
- this.$http.get('/basic/user/telEnable', {params: {tel: this.newUserPhone}})
- .then(response => {
- if (response.data) {
- this.newPhoneCheck = true
- } else {
- this.newPhoneCheck = false
- this.onRemind('手机号码' + this.newUserPhone + '已被注册')
- }
- })
- } else {
- this.newPhoneCheck = false
- this.onRemind('请输入正确的手机号码')
- }
- }
- },
- // 验证邮箱
- checkEmail () {
- if (!this.newUserEmail || this.newUserEmail === '') {
- this.newEmailCheck = true
- } else {
- if ((/^\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$/).test(this.newUserEmail)) {
- this.$http.get('/basic/user/emailEnable', {params: {email: this.newUserEmail}})
- .then(response => {
- if (response.data) {
- this.newEmailCheck = true
- } else {
- this.newEmailCheck = false
- this.onRemind('邮箱' + this.newUserEmail + '已被注册')
- }
- })
- } else {
- this.newEmailCheck = false
- this.onRemind('请输入正确的邮箱')
- }
- }
- },
- // 绑定未注册用户
- addNewUser () {
- if (!this.newUserName || this.newUserName === '') {
- this.onRemind('请输入用户名')
- } else if (!this.newUserPhone || this.newUserPhone === '') {
- this.onRemind('请输入手机号码')
- this.newPhoneCheck = false
- } else {
- if (this.newEmailCheck && this.newPhoneCheck) {
- let params = {
- userName: this.newUserName,
- userTel: this.newUserPhone
- }
- if (this.newUserEmail) {
- params.userEmail = this.newUserEmail
- }
- this.$http.post('/basic/user', params)
- .then(response => {
- if (response) {
- this.onRemind('增加用户成功' + this.newUserName)
- this.$router.push('/mobile/user/staff')
- }
- }).catch(() => {
- this.onRemind('增加用户失败!')
- })
- } else {
- this.checkPhone()
- this.checkEmail()
- }
- }
- },
- // 取消绑定
- cancelBind () {
- this.$router.push('/mobile/user/staff')
- },
- // 搜索已注册用户
- addApply () {
- if (this.searchKeyword) {
- this.$http.get('/basic/user/searchUser', {params: {keyWord: this.searchKeyword}}).then(response => {
- if (response.data) {
- this.searchNoData = false
- if (response.data.userUU === this.userInfo.userUU) {
- // 不可自己绑定自己
- this.bindSelf = true
- this.showSearchUser = false
- } else {
- this.showSearchUser = true
- this.bindSelf = false
- this.newUserInfo = response.data
- }
- } else {
- // 未搜索到结果
- this.searchNoData = true
- this.showSearchUser = false
- this.bindSelf = false
- }
- }).catch(err => {
- if (err) {
- this.searchNoData = true
- this.showSearchUser = false
- this.bindSelf = false
- }
- })
- }
- },
- // 确定绑定已注册用户
- sureBindNewUser () {
- let isFlag = false
- if (this.newUserInfo.enterprises) {
- if (this.newUserInfo.enterprises.length) {
- this.newUserInfo.enterprises.forEach(item => {
- if (item.uu === this.user.data.enterprise.uu) {
- isFlag = true
- }
- })
- }
- }
- if (isFlag) {
- this.onRemind('该用户已绑定到当前企业,不可重复绑定!')
- } else {
- this.$http.get('/basic/user/bindUser', {params: {userUU: this.newUserInfo.userUU}})
- .then(response => {
- if (response) {
- this.onRemind('增加' + this.newUserInfo.userName + '用户成功')
- this.$router.push('/mobile/user/staff')
- }
- })
- }
- }
- }
- }
- </script>
- <style lang="scss" scoped>
- $base-color: #3f84f6;
- #mobile-staff-center {
- .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 {
- overflow: hidden;
- padding: .25rem 0;
- text-align: center;
- input {
- width: 6.9rem;
- border: 1px solid #376ff3;
- }
- }
- .list-content{
- margin: 0 auto;
- padding: 0 .20rem;
- .staff-adds {
- margin: 0.25rem auto 0;
- padding: 0 .24rem;
- width: 6.64rem;
- background-color: #ffffff;
- border-radius: .05rem;
- li{
- overflow: hidden;
- height: 1.18rem;
- line-height: 1.18rem;
- border-bottom: 1px solid #d9d9d9;
- list-style: none;
- span {
- display: inline-block;
- float: left;
- width: 1rem;
- font-size: .28rem;
- color: #3f84f6;
- }
- input{
- float: left;
- width: 4.85rem;
- border: none;
- outline: none;
- }
- div.sex-filter {
- float: left;
- position: relative;
- margin-top: .3rem;
- width: .73rem;
- height: .58rem;
- line-height: .58rem;
- border-radius: .05rem;
- border: solid 1px #b4b4b4;
- .select-wrap {
- width: .73rem;
- height: .58rem;
- text-align: center;
- i{
- font-size: .1rem;
- font-weight: bold;
- color: $base-color;
- }
- }
- ul.select-list{
- width: .73rem;
- position: absolute;
- left: -0.02rem;
- 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: center;
- padding: 0 .13rem;
- font-size: .28rem;
- height: .53rem;
- line-height: .53rem;
- }
- }
- }
- &:last-child {
- border-bottom: none;
- }
- }
- }
- .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 .2rem;
- background-color: #acaaab;
- }
- &:last-child{
- background-color: #3f84f6 ;
- }
- }
- }
- .staff-list {
- margin: 0 auto;
- padding: .35rem .24rem .15rem;
- width: 6.64rem;
- background-color: #ffffff;
- border-radius: .05rem;
- .list-item {
- overflow: hidden;
- margin-bottom: .1rem;
- span{
- float: left;
- font-size: .28rem;
- color: #3f84f6;
- &:first-child{
- width: 1.3rem;
- }
- &:last-child{
- width: 4.8rem;
- color: #666;
- }
- }
- }
- }
- }
- }
- }
- </style>
|