Переглянути джерело

解决触发多次的问题

Jeremy 2 роки тому
батько
коміт
caf0d4372a

+ 41 - 13
VinnoManagementSystem/src/views/organizationManage/organizationList.vue

@@ -53,7 +53,11 @@
             <el-option
               v-for="item in stateTypes"
               :key="item"
-              :label="$t('organization.' + item.replace(/^\S/, s => s.toLowerCase()))"
+              :label="
+                $t(
+                  'organization.' + item.replace(/^\S/, (s) => s.toLowerCase())
+                )
+              "
               :value="item"
             />
           </el-select>
@@ -173,22 +177,29 @@
             >
             <!-- 更多 -->
             <el-divider direction="vertical"></el-divider>
-            <el-dropdown>
+            <el-dropdown @command="handleCommand">
               <el-button type="text" size="small"
-                >{{$t('more')}}<el-icon class="el-icon--right"
+                >{{ $t("more")
+                }}<el-icon class="el-icon--right"
                   ><el-icon-arrow-down /></el-icon
               ></el-button>
               <template #dropdown>
                 <el-dropdown-menu>
-                  <el-dropdown-item @click="table_saveUser(scope.row)">{{
-                    $t("organization.setDirector")
-                  }}</el-dropdown-item>
-                  <el-dropdown-item @click="table_Setting(scope.row, 0)">{{
-                    $t("organization.setting0")
-                  }}</el-dropdown-item>
-                  <el-dropdown-item @click="table_Setting(scope.row, 1)">{{
-                    $t("organization.setting1")
-                  }}</el-dropdown-item>
+                  <el-dropdown-item
+                    command="table_saveUser"
+                    @click="table_saveUser(scope.row)"
+                    >{{ $t("organization.setDirector") }}</el-dropdown-item
+                  >
+                  <el-dropdown-item
+                    command="table_Setting0"
+                    @click="table_Setting(scope.row, 0)"
+                    >{{ $t("organization.setting0") }}</el-dropdown-item
+                  >
+                  <el-dropdown-item
+                    command="table_Setting1"
+                    @click="table_Setting(scope.row, 1)"
+                    >{{ $t("organization.setting1") }}</el-dropdown-item
+                  >
                 </el-dropdown-menu>
               </template>
             </el-dropdown>
@@ -254,6 +265,7 @@ export default {
       selection: [],
       confirmDel: this.$t("organization.confirmDelete"),
       organizationCode: "",
+      command: true,
     };
   },
   methods: {
@@ -275,6 +287,9 @@ export default {
         this.$refs.saveDialog.open();
       });
     },
+    handleCommand() {
+      this.command = true;
+    },
     //编辑
     table_edit(row) {
       this.dialog.show = true;
@@ -282,8 +297,18 @@ export default {
         this.$refs.saveDialog.open(true).setData(row);
       });
     },
+    canCommand() {
+      if (!this.command) {
+        return false;
+      }
+      this.command = false;
+      return true;
+    },
     //配置
     table_Setting(row, type) {
+      if (!this.canCommand()) {
+        return;
+      }
       this.dialog.showSetting = true;
       this.$nextTick(() => {
         this.$refs.saveSetting.open(type).setData(row);
@@ -319,9 +344,12 @@ export default {
     },
     //分配责任人
     table_saveUser(row) {
+      if (!this.canCommand()) {
+        return;
+      }
       this.dialog.showUser = true;
       this.organizationCode = row.OrganizationCode;
-        console.log(row)
+      this.command = false;
       this.$nextTick(() => {
         var director = "";
         if (row.Directors.length == 1) {