duy 2 年之前
父節點
當前提交
0772467b27
共有 3 個文件被更改,包括 20 次插入2 次删除
  1. 3 1
      src/main.js
  2. 16 0
      src/util/preventClick.js
  3. 1 1
      src/views/exctab/ElementIdentification/index.vue

+ 3 - 1
src/main.js

@@ -33,7 +33,9 @@ import tenantPackage from './views/system/tenantpackage';
 
 //iconfont
 import "@/styles/icon/index.scss"
-
+//自定义指令按钮
+import preventClick from './util/preventClick'
+Vue.use(preventClick)
 // 注册全局crud驱动
 window.$crudCommon = crudCommon;
 // 加载Vue拓展

+ 16 - 0
src/util/preventClick.js

@@ -0,0 +1,16 @@
+export default {
+       install(Vue) {
+         Vue.directive('preventClick', {
+           inserted(button, bind) {
+            button.addEventListener('click', () => {
+             if (!button.disabled) {
+                 button.disabled = true;
+                setTimeout(() => {
+                  button.disabled = false
+             }, 3*1000)
+                }
+              })
+         }
+          })
+        }
+     }

+ 1 - 1
src/views/exctab/ElementIdentification/index.vue

@@ -663,7 +663,7 @@
           </div>
         <span slot="footer" class="dialog-footer">
           <el-button @click="eleDialog = false">取 消</el-button>
-          <el-button type="primary" @click.once="submitEleDialog" >确 定</el-button>
+          <el-button type="primary" @click="submitEleDialog" v-preventClick >确 定</el-button>
         </span>
       </el-dialog>
     </div>