Browse Source

优化网络

qinzhipeng_v 5 years ago
parent
commit
b98714c25f
2 changed files with 41 additions and 12 deletions
  1. 7 0
      src/App.vue
  2. 34 12
      src/views/ToConfigure/BusinessDirection/BusinessDirection.vue

+ 7 - 0
src/App.vue

@@ -14,6 +14,13 @@ const config = { appKey: 'omega6b172861f4' }
 export default {
   name: 'App',
   mounted() {
+    window.addEventListener('offline', () => {
+      // 网络由正常常到异常时触发
+      this.$message({ message: '网络异常,请检查网络!', type: 'error', duration: 2000, offset: 150 })
+    })
+    window.addEventListener('online', () => {
+      location.reload()
+    })
     getUserInfo()
       .then(res => {
         localStorage.setItem('realname', res.data.chineseName)

+ 34 - 12
src/views/ToConfigure/BusinessDirection/BusinessDirection.vue

@@ -1,17 +1,6 @@
 <template>
   <div>
-    <el-table
-      ref="moduleTable"
-      :data="moduleData"
-      style="width: 100%;margin-bottom: 20px;"
-      row-key="id"
-      border
-      :tree-props="{children: 'childModules', hasChildren: 'hasChildren'}"
-      header-align="center"
-      size="mini"
-      :header-cell-style="{ background: '#F2F3F6' }"
-      fit
-    >
+    <el-table ref="moduleTable" :data="moduleData" style="width: 100%;margin-bottom: 20px;" row-key="id" border :tree-props="{children: 'childModules', hasChildren: 'hasChildren'}" header-align="center" size="mini" :header-cell-style="{ background: '#F2F3F6' }" fit>
       <el-table-column v-if="false" prop="id" label="ID" width="180" align="center" />
       <el-table-column prop="moduleName" label="模块名称">
         <template slot="header">
@@ -28,6 +17,7 @@
         </template>
       </el-table-column>
     </el-table>
+
     <el-dialog :title="moduleTitle" :visible.sync="moduleDialog" width="30%" :before-close="() => {moduleDialog = false}">
       <el-form ref="moduleForm" :model="moduleForm">
         <template v-if="curcentModule === 'add'">
@@ -67,6 +57,10 @@
           是否要删除模块:<span style="color: #E6A23C">{{ moduleForm.moduleNames[0] }}</span>
         </el-col>
       </el-form>
+      <span slot="footer" class="dialog-footer">
+        <el-button @click="moduleDialog = false">取 消</el-button>
+        <el-button type="primary" @click="confirmModule('moduleForm')">确 定</el-button>
+      </span>
     </el-dialog>
   </div>
 </template>
@@ -116,6 +110,34 @@ export default {
       } else {
         this.moduleDialog = true
       }
+    },
+    addModuleForm() {
+      if (this.moduleForm.moduleNames.length <= 4) {
+        this.moduleForm.moduleNames.push(null)
+      }
+    },
+    confirmModule(formName) { // 模块操作确认
+      if (this.curcentModule === 'add') {
+        this.$refs[formName].validate((valid) => {
+          if (valid) {
+            this.addModule(this.moduleForm)
+          } else {
+            this.$message({ message: '填写格式不正确', type: 'error' })
+            return false
+          }
+        })
+      } else if (this.curcentModule === 'edit') {
+        this.$refs[formName].validate((valid) => {
+          if (valid) {
+            this.updataModule(this.moduleForm)
+          } else {
+            this.$message({ message: '填写格式不正确', type: 'error' })
+            return false
+          }
+        })
+      } else if (this.curcentModule === 'delete') {
+        this.deleteModule(this.moduleForm)
+      }
     }
   }