lyh
2025-06-27 82b238214db913000a12fc037c5e0f101a7b9d73
src/views/flowable/workflow/dispatchFile/DispatchFileHandle.vue
@@ -119,8 +119,20 @@
            </a-col>
          </a-row>
          <div class="table-operator" style="text-align: right;">
            <a-button  @click="handleQueXiaoTask" type="primary" icon="close">取消</a-button>
            <a-button @click="submitForm">提 交</a-button>
            <a-button
            @click="handleQueXiaoTask"
            icon="close"
            :disabled="isSubmitting"
            :class="{'disabled-btn': isSubmitting}"
          >取消</a-button>
            <a-button
              @click="submitForm"
              type="primary"
              :disabled="isSubmitting"
              :loading="isSubmitting"
            >
              提 交
            </a-button>
          </div>
        </a-form-model>
      </div>
@@ -191,7 +203,8 @@
      },
      dictOptions: {},
      superFieldList: [],
      workflowSource: []
      workflowSource: [],
      isSubmitting: false,
    }
  },
  created() {
@@ -225,94 +238,133 @@
        alert('无法加载图片,请稍后再试。')
      }
    },
    handleQueXiaoTask(){
      this.visible = false
      this.routeReload()
    handleQueXiaoTask() {
      // 如果正在提交,阻止取消操作
      if (this.isSubmitting) return;
      this.visible = false;
      this.routeReload();
    },
    submitForm () {
    submitForm() {
      // 如果正在提交,阻止重复点击
      if (this.isSubmitting) return;
      // 开启全局禁选
      this.isSubmitting = true;
      document.body.classList.add('submitting');
      const that = this;
      if (that.selectShenpiData.taskDefKey ==='task_prepare'){
        // 触发表单验证-重新启动
      // 定义一个恢复状态的函数
      const resetState = () => {
        that.isSubmitting = false;
        document.body.classList.remove('submitting');
      };
      // 处理task_prepare分支
      if (that.selectShenpiData.taskDefKey === 'task_prepare') {
        this.form.validateFields((err, values) => {
          if (!err) {
            that.confirmLoading = true;
            let url=this.url.saveDispatchFile;
            let method = 'post';
            let flowTaskVo = {}
            flowTaskVo.comment =that.assignFileStream.approveContent;
            flowTaskVo.dataId = this.selectShenpiData.dataId
            flowTaskVo.instanceId = this.selectShenpiData.procInstId
            flowTaskVo.taskId = this.selectShenpiData.id
            console.log("表单提交数据",flowTaskVo)
            httpAction(url,flowTaskVo,method).then((res)=>{
              if(res.success){
          if (err) {
            resetState(); // 验证失败,恢复状态
            return;
          }
          that.confirmLoading = true;
          let url = that.url.saveDispatchFile;
          let method = 'post';
          let flowTaskVo = {
            comment: that.assignFileStream.approveContent,
            dataId: that.selectShenpiData.dataId,
            instanceId: that.selectShenpiData.procInstId,
            taskId: that.selectShenpiData.id
          };
          console.log("表单提交数据", flowTaskVo);
          httpAction(url, flowTaskVo, method)
            .then((res) => {
              if (res.success) {
                that.$message.success(res.message);
                that.visible = false
                //刷新表格
                that.$emit('searchReset')
              }else{
                that.visible = false;
                that.$emit('searchReset');
              } else {
                that.$message.warning(res.message);
              }
            }).finally(() => {
              that.confirmLoading = false;
            })
          }
        })
        //跳出方法
        return false;
      }else {
        if (!that.assignFileStream.status==null || that.assignFileStream.status===undefined){
          this.$message.warning('请选择处理类型!')
          return false;
            .catch((error) => {
              console.error(error);
              that.$message.error('提交失败');
            })
            .finally(() => {
              that.confirmLoading = false;
              resetState(); // 请求结束,恢复状态
            });
        });
      } else {
        // 处理其他任务分支
        // 先检查处理类型和意见
        if (!that.assignFileStream.status) {
          that.$message.warning('请选择处理类型!');
          resetState();
          return;
        }
      }
      if (!that.assignFileStream.approveContent==null || that.assignFileStream.approveContent===undefined) {
        this.$message.warning('请输入处理意见!')
        return false;
      }
      // 触发表单验证
      this.form.validateFields((err, values) => {
        if (!err) {
        if (!that.assignFileStream.approveContent) {
          that.$message.warning('请输入处理意见!');
          resetState();
          return;
        }
        // 进行表单验证
        this.form.validateFields((err, values) => {
          if (err) {
            resetState();
            return;
          }
          that.confirmLoading = true;
          let url=this.url.approve
          let url = that.url.approve;
          let method = 'post';
          let handle =that.assignFileStream.status === '1';
          let flowTaskVo = {}
          switch (that.selectShenpiData.taskDefKey){
          let handle = that.assignFileStream.status === '1';
          let flowTaskVo = {
            comment: that.assignFileStream.approveContent,
            dataId: that.selectShenpiData.dataId,
            taskId: that.selectShenpiData.id,
            userId: that.selectShenpiData.assignee,
            instanceId: that.selectShenpiData.procInstId,
            values: that.selectShenpiData.variables
          };
          switch (that.selectShenpiData.taskDefKey) {
            case "task_approve":
              flowTaskVo.ratify=handle;
              flowTaskVo.ratify = handle;
              break;
            case "task_cut":
              flowTaskVo.cut=handle;
              flowTaskVo.cut = handle;
              break;
            case "task_finalize":
              flowTaskVo.stereotype=handle;
              flowTaskVo.stereotype = handle;
              break;
          }
          if (that.selectShenpiData.taskDefKey ==='task_proofread'){
            flowTaskVo.proofreadStatus =that.assignFileStream.status;
          if (that.selectShenpiData.taskDefKey === 'task_proofread') {
            flowTaskVo.proofreadStatus = that.assignFileStream.status;
          }
          flowTaskVo.comment =that.assignFileStream.approveContent;
          flowTaskVo.dataId = this.selectShenpiData.dataId
          flowTaskVo.taskId = this.selectShenpiData.id
          flowTaskVo.userId = this.selectShenpiData.assignee
          flowTaskVo.instanceId = this.selectShenpiData.procInstId
          flowTaskVo.values = this.selectShenpiData.variables
          console.log("表单提交数据",flowTaskVo)
          httpAction(url,flowTaskVo,method).then((res)=>{
            if(res.success){
              that.$message.success(res.message);
              that.visible = false
              //刷新表格
              that.$emit('searchReset')
            }else{
              that.$message.warning(res.message);
            }
          }).finally(() => {
            that.confirmLoading = false;
          })
        }
      })
          console.log("表单提交数据", flowTaskVo);
          httpAction(url, flowTaskVo, method)
            .then((res) => {
              if (res.success) {
                that.$message.success(res.message);
                that.visible = false;
                that.$emit('searchReset');
              } else {
                that.$message.warning(res.message);
              }
            })
            .catch((error) => {
              console.error(error);
              that.$message.error('提交失败');
            })
            .finally(() => {
              that.confirmLoading = false;
              resetState();
            });
        });
      }
    },
    getAllApproveData(item) {
      console.log('selectShenpiData----->', this.selectShenpiData)
@@ -340,6 +392,45 @@
}
</script>
<style scoped>
/* 全局禁选样式 - 作用于整个页面 */
html.submitting,
html.submitting body {
  pointer-events: none !important;
  cursor: wait !important;
}
/* 蒙层效果增强 */
html.submitting::before {
  content: '';
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(255, 255, 255, 0.5);
  z-index: 9998;
}
/* 加载指示器 - 更明显的视觉反馈 */
html.submitting::after {
  content: '提交中...';
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: #1890ff;
  color: white;
  padding: 10px 20px;
  border-radius: 4px;
  z-index: 9999;
}
/* 禁用状态按钮样式 */
.disabled-btn {
  opacity: 0.6;
  cursor: not-allowed !important;
}
.shallow-hr {
  border: 0;
  height: 1px; /* 分界线的高度 */