Procházet zdrojové kódy

审批通过,限制一次

wsx před 9 měsíci
rodič
revize
eefec5769b

+ 2 - 0
src/main.js

@@ -39,6 +39,8 @@ import fileMain from '@/components/addDoc/index.vue';
 import './directives';
 import seekPage from '@/BIZComponents/seekPage';
 Vue.component('seekPage', seekPage);
+import clickOnce from './utils/clickOnce.js';
+Vue.directive('click-once', clickOnce);
 
 import Tooltip from './utils/tooltip'; // 引入封装的工具
 Vue.prototype.$tooltip = Tooltip;

+ 35 - 0
src/utils/clickOnce.js

@@ -0,0 +1,35 @@
+export default {
+  bind(el, binding, vnode) {
+    // 创建加载指示器元素
+    const loadingIndicator = document.createElement('i');
+    loadingIndicator.classList.add('loading-indicator', 'el-icon-loading'); // 假设使用 Element UI 的加载图标
+    el.appendChild(loadingIndicator);
+
+    // 隐藏加载指示器,默认不显示
+    loadingIndicator.style.display = 'none';
+
+    // 保存加载指示器引用
+    el._loadingIndicator = loadingIndicator;
+
+    // 添加点击事件监听器
+    el.addEventListener('click', () => {
+      // 显示加载指示器
+      loadingIndicator.style.display = 'inline-block';
+
+      // 禁用按钮
+      el.setAttribute('disabled', '');
+
+      // 假设这里有一个异步操作,完成后需要隐藏加载指示器和重新启用按钮
+      setTimeout(() => {
+        loadingIndicator.style.display = 'none';
+        el.removeAttribute('disabled'); // 重新启用按钮
+      }, 2000); // 模拟异步操作耗时2秒
+    });
+
+    // 清理事件监听器,防止内存泄漏
+    vnode.context.$once('hook:beforeDestroy', () => {
+      el.removeEventListener('click', () => {});
+      el.removeChild(loadingIndicator);
+    });
+  }
+};

+ 18 - 14
src/views/bpm/handleTask/components/materialPlan/submit.vue

@@ -28,7 +28,6 @@
       </el-form-item> -->
       <el-form-item
         label="审批建议"
-   
         style="margin-bottom: 20px"
         :rules="{
           required: true,
@@ -49,6 +48,7 @@
         type="success"
         size="mini"
         @click="handleAudit(1)"
+        v-click-once
         >通过
       </el-button>
 
@@ -80,7 +80,11 @@
     apspurchaseplan,
     cancel
   } from '@/api/bpm/components/apsMeterialPlan';
-  import { approveTaskWithVariables, rejectTask,cancelTask } from '@/api/bpm/task';
+  import {
+    approveTaskWithVariables,
+    rejectTask,
+    cancelTask
+  } from '@/api/bpm/task';
   import { listAllUserBind } from '@/api/system/organization';
 
   // 流程实例的详情页,可用于审批
@@ -128,19 +132,19 @@
 
         this._approveTaskWithVariables(status);
       },
-      rejectTask(status){
+      rejectTask(status) {
         rejectTask({
-            id: this.taskId,
-            reason: this.form.reason,
-            pass: false
-          }).then((res) => {
-            if (res.data.code != '-1') {
-              this.$emit('handleAudit', {
-                status,
-                title: '驳回'
-              });
-            }
-          });
+          id: this.taskId,
+          reason: this.form.reason,
+          pass: false
+        }).then((res) => {
+          if (res.data.code != '-1') {
+            this.$emit('handleAudit', {
+              status,
+              title: '驳回'
+            });
+          }
+        });
       },
       async _approveTaskWithVariables(status) {
         if (status == 1) {