sunlupeng 1 rok pred
rodič
commit
73b700805a
3 zmenil súbory, kde vykonal 43 pridanie a 35 odobranie
  1. 16 21
      src/mayout/index.vue
  2. 1 1
      src/utils/request.js
  3. 26 13
      src/views/index.vue

+ 16 - 21
src/mayout/index.vue

@@ -64,25 +64,12 @@
           </el-form-item>
           <el-button size="small" type="primary" style="text-align: center;width: 100%;margin-top: 10px;"
             @click="submitForm('ruleForm')">
-            {{ corpTitle }}
+            <span v-if="!loading"> {{ corpTitle }}</span>
+            <span v-else> {{ corpTitle }}中...</span>
           </el-button>
         </el-form>
       </el-dialog>
     </el-dialog>
-    <el-dialog width="30%" :title="corpTitle + '企业/团队'" :visible.sync="joinOrCreateVisible" append-to-body>
-      <el-form :model="form" :rules="rules" ref="ruleForm" label-position="top" label-width="80px" size="small">
-        <el-form-item label="企业/团队名称" prop="name" v-if="corpTitle == '创建'">
-          <el-input v-model="form.name" placeholder='请输入你的企业/团队名称'></el-input>
-        </el-form-item>
-        <el-form-item label="邀请码" prop="tenantId" v-if="corpTitle == '加入'">
-          <el-input v-model="form.url" placeholder='请输入你的邀请码'></el-input>
-        </el-form-item>
-        <el-button size="small" type="primary" style="text-align: center;width: 100%;margin-top: 10px;"
-          @click="submitForm('ruleForm')">
-          {{ corpTitle }}
-        </el-button>
-      </el-form>
-    </el-dialog>
   </div>
 </template>
 
@@ -100,6 +87,7 @@ export default {
   },
   data() {
     return {
+      loading: false,
       showMyTeam: null,
       myTeamList: [],
       showJoinTeam: null,
@@ -154,7 +142,7 @@ export default {
         setTenantId(val.id)
         setTimeout(() => {
           location.reload()
-        }, 2000)
+        }, 1500)
         .catch(() => {});
       })
       .catch(() => {});
@@ -166,23 +154,30 @@ export default {
     submitForm(formName) {
       this.$refs[formName].validate((valid) => {
         if (valid) {
+          this.loading = true;
           console.log(this.form);
           if (this.corpTitle == '创建') {
             createTenant({ status: 0, name: this.form.name }).then(response => {
               this.$modal.msgSuccess("创建成功");
+              this.loading = false;
+              this.joinOrCreateVisible = false;
+              this.getOwnJoinTenantList();
+              this.getOwnCreateTenantList();  
             });
-
+            
           }
           else {
             joinTenant({ tenantId: this.form.tenantId }).then(response => {
               this.$modal.msgSuccess("加入成功");
+              this.loading = false;
+              this.joinOrCreateVisible = false;
+              this.getOwnJoinTenantList();
+              this.getOwnCreateTenantList();  
             });
+           
           }
-          this.joinOrCreateVisible = false;
-          this.getOwnJoinTenantList();
-          this.getOwnCreateTenantList();
-
         } else {
+          this.loading = false;
           console.log('error submit!!');
           return false;
         }

+ 1 - 1
src/utils/request.js

@@ -26,7 +26,7 @@ const service = axios.create({
   // axios中请求配置有baseURL选项,表示请求URL公共部分
   baseURL: process.env.VUE_APP_BASE_API + '/admin-api/', // 此处的 /admin-api/ 地址,原因是后端的基础路径为 /admin-api/
   // 超时
-  timeout: 30000,
+  timeout: 40000,
   // 禁用 Cookie 等信息
   withCredentials: false,
 })

+ 26 - 13
src/views/index.vue

@@ -101,7 +101,8 @@
           </el-form-item>
           <el-button size="small" type="primary" style="text-align: center;width: 100%;margin-top: 10px;"
             @click="submitForm('ruleForm')">
-            {{ corpTitle }}
+            <span v-if="!loading"> {{ corpTitle }}</span>
+            <span v-else> {{ corpTitle }}中...</span>
           </el-button>
         </el-form>
     </el-dialog>
@@ -190,6 +191,7 @@ export default {
   },
   data() {
     return {
+      loading: false,
       corpTitle: '',
       form: {
         type:1,
@@ -304,32 +306,43 @@ export default {
     submitForm(formName) {
       this.$refs[formName].validate((valid) => {
         if (valid) {
+          this.loading = true;
           console.log(this.form);
           if(this.corpTitle=='创建'){
             createTenant({status:0,name:this.form.name}).then(response => {
-              this.$modal.msgSuccess("创建成功");
-              this.form= {
-                type:1,
-                name: '',
-                tenantId: '',
-              };
               this.joinOrCreateVisible = false;
+              this.$modal.msgSuccess("创建成功");
+              let data = response.data;
+              store.dispatch("ChangeTenant", data).then(() => {
+                setTenantId(data.id)
+                setTimeout(() => {
+                  location.reload()
+                }, 1500)
+                .catch(() => {});
+              })
+              .catch(() => {});
+              
             });
           }
           else{
             joinTenant({accountMode:1,corpId:this.form.tenantId}).then(response => {
-              this.$modal.msgSuccess("加入成功");
-              this.form= {
-                type:1,
-                name: '',
-                tenantId: '',
-              };
               this.joinOrCreateVisible = false;
+              this.$modal.msgSuccess("加入成功");
+              let data = response.data;
+              store.dispatch("ChangeTenant", data).then(() => {
+                setTenantId(data.id)
+                setTimeout(() => {
+                  location.reload()
+                }, 1500)
+                .catch(() => {});
+              })
+              .catch(() => {});
             });
           }
           
         } else {
           console.log('error submit!!');
+          this.loading = false;
           return false;
         }
       });