Browse Source

绑定企业判断重复

huangb 7 years ago
parent
commit
81ee3b0959
2 changed files with 19 additions and 13 deletions
  1. 19 6
      components/mobile/staffManagement/StaffAdd.vue
  2. 0 7
      pages/mobile/user/staff/add.vue

+ 19 - 6
components/mobile/staffManagement/StaffAdd.vue

@@ -60,7 +60,7 @@
             </div>
             <div class="staff-footer">
               <div class="cancel handle" @click="cancelBind">取消</div>
-              <div class="agree handle" @click="sureBindNewUser">确定绑定</div>
+              <div class="agree handle" @click="sureBindNewUser()">确定绑定</div>
             </div>
           </div>
           <div class="staff-list" v-if="reBindError">
@@ -108,6 +108,7 @@
     },
     computed: {
       userInfo () {
+        console.log(this.$store.state.option.user.data)
         return this.$store.state.option.user.data
       }
     },
@@ -246,13 +247,25 @@
       },
       // 确定绑定已注册用户
       sureBindNewUser () {
-        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')
+        let isFlag = false
+        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')
+              }
+            })
+        }
       }
     }
   }

+ 0 - 7
pages/mobile/user/staff/add.vue

@@ -14,13 +14,6 @@
     data () {
       return {
       }
-    },
-    fetch ({ store }) {
-      return Promise.all([
-        store.dispatch('staff/loadStaffList', { count: 10, page: 1, enuu: store.state.option.user.data.enterprise.uu})
-      ])
-    },
-    methods: {
     }
   }
 </script>