|
|
@@ -23,39 +23,62 @@
|
|
|
</ul>
|
|
|
</div>
|
|
|
</li>
|
|
|
- <li><span>手机号:</span><input type="text" v-model="newUserPhone" placeholder="请输入手机号"></li>
|
|
|
- <li><span>邮箱:</span><input type="text" v-model="newUserEmail" placeholder="请输入邮箱"></li>
|
|
|
+ <li><span>手机号:</span><input type="text"
|
|
|
+ v-model="newUserPhone"
|
|
|
+ @change="checkPhone()"
|
|
|
+ placeholder="请输入手机号"></li>
|
|
|
+ <li><span>邮箱:</span><input type="text"
|
|
|
+ v-model="newUserEmail"
|
|
|
+ @change="checkEmail()"
|
|
|
+ placeholder="请输入邮箱"></li>
|
|
|
</ul>
|
|
|
<div class="staff-footer">
|
|
|
- <div class="cancel handle">取消</div>
|
|
|
+ <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" placeholder="请输入UU号、手机号或邮箱">
|
|
|
- <span><i class="iconfont icon-sousuo"></i></span>
|
|
|
+ <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">
|
|
|
- <div class="staff-list">
|
|
|
- <div class="list-item"><span>UU账号:</span><span>100000721</span></div>
|
|
|
- <div class="list-item"><span>姓名:</span><span>张洪别</span></div>
|
|
|
- <div class="list-item"><span>性别:</span><span>男</span></div>
|
|
|
- <div class="list-item"><span>手机号:</span><span>12345678901</span></div>
|
|
|
- <div class="list-item"><span>邮箱:</span><span>12345678901</span></div>
|
|
|
+ <div class="list-content" v-if="showSearchUser">
|
|
|
+ <div v-if="bindUser">
|
|
|
+ <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-footer">
|
|
|
- <div class="cancel handle">取消</div>
|
|
|
- <div class="agree handle">确定绑定</div>
|
|
|
+ <div class="staff-list" v-if="reBindError">
|
|
|
+ <span>该用户已绑定到当前企业,不可重复绑定!</span>
|
|
|
+ </div>
|
|
|
+ <div class="staff-list" v-if="illegalError">
|
|
|
+ <span>不可对自己进行绑定!</span>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ <div class="list-content" v-else>
|
|
|
+ <div class="staff-list">
|
|
|
+ <span>您查找的用户不存在!</span>
|
|
|
</div>
|
|
|
</div>
|
|
|
</div>
|
|
|
</div>
|
|
|
+ <remind-box :title="remindText" :timeoutCount="timeoutCount"></remind-box>
|
|
|
</div>
|
|
|
</template>
|
|
|
<script>
|
|
|
- import { RemindBox, PullUp, EmptyStatus } from '~components/mobile/common'
|
|
|
+ import { RemindBox } from '~components/mobile/common'
|
|
|
export default {
|
|
|
data () {
|
|
|
return {
|
|
|
@@ -64,15 +87,26 @@
|
|
|
newUserPhone: '',
|
|
|
newUserEmail: '',
|
|
|
showChooseSex: false,
|
|
|
- sex: 'M'
|
|
|
+ sex: 'M',
|
|
|
+ remindText: '',
|
|
|
+ timeoutCount: 0,
|
|
|
+ newPhoneCheck: false,
|
|
|
+ newEmailCheck: false,
|
|
|
+ showSearchUser: true,
|
|
|
+ searchKeyword: '',
|
|
|
+ newUserInfo: '',
|
|
|
+ reBindError: false,
|
|
|
+ illegalError: false,
|
|
|
+ bindUser: false
|
|
|
}
|
|
|
},
|
|
|
components: {
|
|
|
- RemindBox,
|
|
|
- PullUp,
|
|
|
- EmptyStatus
|
|
|
+ RemindBox
|
|
|
},
|
|
|
computed: {
|
|
|
+ userInfo () {
|
|
|
+ return this.$store.state.option.user.data
|
|
|
+ }
|
|
|
},
|
|
|
methods: {
|
|
|
setSwitchType (type) {
|
|
|
@@ -85,10 +119,115 @@
|
|
|
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.onRemind('请输入邮箱')
|
|
|
+ this.newEmailCheck = false
|
|
|
+ } 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 () {
|
|
|
- this.$http.post('/basic/user', {userEmail: this.newUserEmail, userName: this.newUserName, userSex: this.sex, userTel: this.newUserPhone})
|
|
|
+ if (this.newEmailCheck && this.newPhoneCheck) {
|
|
|
+ this.$http.post('/basic/user', {userEmail: this.newUserEmail, userName: this.newUserName, userSex: this.sex, userTel: this.newUserPhone})
|
|
|
+ .then(response => {
|
|
|
+ if (response) {
|
|
|
+ this.onRemind('增加用户成功' + this.newUserName)
|
|
|
+ this.$router.push('/mobile/user/staff')
|
|
|
+ }
|
|
|
+ })
|
|
|
+ }
|
|
|
+ },
|
|
|
+ // 取消绑定
|
|
|
+ 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.showSearchUser = true
|
|
|
+ this.newUserInfo = response.data
|
|
|
+ this.bindUser = true
|
|
|
+ this.illegalError = false
|
|
|
+ this.reBindError = false
|
|
|
+ if (this.newUserInfo.userUU === this.userInfo.userUU) {
|
|
|
+ //不可自己绑定自己
|
|
|
+ this.illegalError = true
|
|
|
+ this.bindUser = false
|
|
|
+ } else {
|
|
|
+ for (var i = 0; i < this.newUserInfo.enterprises.length; i++) {
|
|
|
+ if (this.newUserInfo.enterprises[i].current) {
|
|
|
+ for (var j = 0; j < this.userInfo.enterprises.length; j++) {
|
|
|
+ //该用户已绑定到当前企业,不可重复绑定
|
|
|
+ if (this.newUserInfo.enterprises[i].uu === this.userInfo.enterprises[j].uu) {
|
|
|
+ this.reBindError = true
|
|
|
+ this.bindUser = false
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ // 未搜索到结果
|
|
|
+ this.showSearchUser = false
|
|
|
+ this.bindUser = false
|
|
|
+ this.reBindError = false
|
|
|
+ this.illegalError = false
|
|
|
+ }
|
|
|
+ })
|
|
|
+ }
|
|
|
+ },
|
|
|
+ // 确定绑定已注册用户
|
|
|
+ sureBindNewUser () {
|
|
|
+ this.$http.get('/basic/user/bindUser', {params: {userUU: this.newUserInfo.userUU}})
|
|
|
.then(response => {
|
|
|
- console.log(response)
|
|
|
+ if (response) {
|
|
|
+ this.onRemind('增加用户成功' + this.newUserInfo.userName)
|
|
|
+ this.$router.push('/mobile/user/staff')
|
|
|
+ }
|
|
|
})
|
|
|
}
|
|
|
}
|
|
|
@@ -224,6 +363,7 @@
|
|
|
border-radius: .05rem;
|
|
|
.list-item {
|
|
|
overflow: hidden;
|
|
|
+ margin-bottom: .1rem;
|
|
|
span{
|
|
|
float: left;
|
|
|
font-size: .28rem;
|