Преглед изворни кода

预装箱单添加节流函数

jbb пре 2 година
родитељ
комит
3499d53cfe
3 измењених фајлова са 22 додато и 1 уклоњено
  1. 18 0
      src/api/document/throttle.js
  2. 2 0
      src/main.js
  3. 2 1
      src/views/advance-packingList/addAdpackingDrawer.vue

+ 18 - 0
src/api/document/throttle.js

@@ -0,0 +1,18 @@
+export default {
+    install(Vue) {
+        Vue.directive('preventReClick', {
+            inserted(el, binding) {
+                el.addEventListener('click', () => {
+                    const events = el.style.pointerEvents
+                    if (events == "") {
+                        el.style.pointerEvents = 'none'
+                        setTimeout(() => {
+                            el.style.pointerEvents = "";
+                        }, binding.value || 1000);
+                    }
+
+                })
+            }
+        })
+    }
+}

+ 2 - 0
src/main.js

@@ -44,6 +44,7 @@ import '@/assets/less/JAreaLinkage.less'
 import VueAreaLinkage from 'vue-area-linkage'
 import '@/components/jeecg/JVxeTable/install'
 import '@/components/JVxeCells/install'
+import preventReClick from '@api/document/throttle.js'
 
 // 表单验证
 import { rules } from '@/utils/rules'
@@ -64,6 +65,7 @@ Vue.use(preview)
 Vue.use(vueBus)
 Vue.use(JeecgComponents)
 Vue.use(VueAreaLinkage)
+Vue.use(preventReClick)
 // Vue.prototype.$echarts = echarts // 全局echarts
 Vue.config.productionTip = false
 

+ 2 - 1
src/views/advance-packingList/addAdpackingDrawer.vue

@@ -165,7 +165,7 @@
         <a-popconfirm title="确定放弃编辑?" @confirm="handleCancel" okText="确定" cancelText="取消">
           <a-button :style="{ marginRight: '8px' }">取消</a-button>
         </a-popconfirm>
-        <a-button type="primary" @click="myHandSave" :loading="btnLoading">
+        <a-button type="primary" @click="myHandSave" :loading="btnLoading" v-preventReClick="2000">
           保存
         </a-button>
         <a-button type="primary" @click="myHandSubmit" style="margin-left: 8px">
@@ -643,6 +643,7 @@ export default {
           newObj.push_status = 0;
       }
       if(this.editDecide === 'edit'){
+        throttle
         editById(newObj).then(res => {
           this.btnLoading = true
           if (res.success) {