luohairen
2024-12-17 ba61d95e7367745913a0c85d45416578d8d66e31
src/views/flowable/task/myProcess/send/index.vue
@@ -9,11 +9,22 @@
        <!--表单信息-->
        <el-tab-pane label="表单信息" name="1">
          <!--初始化流程加载表单信息-->
          <el-col :span="16" :offset="4">
            <v-form-render :form-data="formRenderData" ref="vFormRef"/>
            <div style="margin-left:15%;margin-bottom: 20px;font-size: 14px;">
              <el-button type="primary" @click="submitForm">提 交</el-button>
              <el-button type="primary" @click="resetForm">重 置</el-button>
          <el-col :span="16" :offset="4" v-if="formDataList && formDataList.length > 0">
            <div v-for="(formDataObj, index) in formDataList" :key="index" class="form-warp" style="position: relative">
              <div v-if="!formDataObj.current" style="position: absolute; top: 2px; right: 2px">
                <el-button type="danger" @click="openRejectTask(formDataObj.beforeNodeDefId)">驳回</el-button>
              </div>
              <div v-if="formDataObj.current" style="margin-bottom: 15px;color: #409eff">当前阶段:<span style="color: red">{{formDataObj.beforeNodeName}}</span></div>
              <div v-else style="margin-bottom: 15px;color: #409eff">前置阶段:<span style="color: #d5904b">{{formDataObj.beforeNodeName}}</span></div>
              <v-form-render  :form-data="formDataObj.formJson" :ref="'form' + index"/>
            </div>
<!--            <v-form-render :form-data="formRenderData" ref="vFormRef"/>-->
            <div style="display: flex;justify-content: center; align-items: center; margin: 20px 0">
              <el-button type="primary" @click="submitForm">确认并提交</el-button>
              <el-button type="primary" disabled @click="submitForm">协同办理(功能开发中)</el-button>
              <el-button type="primary" disabled @click="submitForm">转交他人办理(功能开发中)</el-button>
<!--              <el-button type="primary" @click="resetForm">重 置</el-button>-->
            </div>
          </el-col>
        </el-tab-pane>
@@ -32,6 +43,28 @@
        </span>
      </el-dialog>
    </el-card>
    <el-dialog
      :title="`驳回:` + rejectForm.projectName"
      :visible.sync="rejectShow"
      width="950px"
      :destroy-on-close="true"
      :close-on-click-modal="false"
      >
      <div>
        <el-input
          type="textarea"
          :rows="3"
          placeholder="审核建议"
          v-model="rejectForm.auditOpinion">
        </el-input>
      </div>
      <div>
        <el-button type="danger" size="small" @click="rejectTask">驳回</el-button>
      </div>
    </el-dialog>
  </div>
</template>
@@ -43,6 +76,7 @@
import {getNextFlowNodeByStart} from "@/api/flowable/todo";
import FlowUser from '@/components/flow/User'
import FlowRole from '@/components/flow/Role'
import {rejectTask} from "@/api/projectProcess/projectProcess";
export default {
  name: "Record",
@@ -54,6 +88,9 @@
  props: {},
  data() {
    return {
      rejectShow: false,
      goBackParams: {},
      formDataList: [],  // 表单列表
      taskId: '',
      processName: '',
      // 模型xml数据
@@ -68,6 +105,7 @@
      deployId: "",  // 流程定义编号
      procDefId: "",  // 流程实例编号
      formRenderData: {},
      formRenderDataList: [],
      variables: [], // 流程变量数据
      taskTitle: null,
      taskOpen: false,
@@ -77,19 +115,36 @@
      checkValues: null, // 选中任务接收人员数据
      formData: {}, // 填写的表单数据,
      multiInstanceVars: '', // 会签节点
      formJson: {} // 表单json
      formJson: {}, // 表单json
      rejectForm: {
        auditOpinion: '', // 审核意见
        taskId: '',
        rejectedTaskDefKey: ''  // 被驳回的任务key
      }
    };
  },
  created() {
  mounted() {
    this.processName = this.$route.query && this.$route.query.processName;
    this.deployId = this.$route.query && this.$route.query.deployId;
    this.taskId = this.$route.query && this.$route.query.taskId;
    // 初始化表单
    this.procDefId  = this.$route.query && this.$route.query.procDefId;
    this.goBackParams  = this.$route.query && this.$route.query.goBackParams;
    // this.getNextFlowNodeByStart(this.deployId);
    this.getFlowFormData(this.taskId);
  },
  methods: {
    rejectTask() {
      rejectTask(this.rejectForm).then(res => {
        this.rejectShow = false
        this.$message.success("驳回成功")
      })
    },
    openRejectTask(rejectedTaskDefKey) {
      this.rejectForm.rejectedTaskDefKey = rejectedTaskDefKey;
      this.rejectForm.taskId = this.taskId;
      this.rejectShow = true
    },
    handleClick(tab, event) {
      if (tab.name === '2'){
        flowXmlAndNode({deployId:this.deployId}).then(res => {
@@ -101,38 +156,59 @@
    getFlowFormData(taskId) {
      const params = {taskId: taskId}
      flowTaskForm(params).then(res => {
        if (res.data.formJson) {
          // 回显表单
          this.$refs.vFormRef.setFormJson(res.data.formJson);
          this.formJson = res.data.formJson;
        this.formDataList = res.data
        if (this.formDataList && this.formDataList.length > 0) {
          this.$nextTick(() => {
            // 加载表单填写的数据
            this.$refs.vFormRef.setFormData(res.data);
            // this.$nextTick(() => {
            //   // 表单禁用
            //   this.$refs.vFormRef.disableForm();
            // })
            this.formDataList.forEach((formDataObj, index) => {
              console.log("表单数据列表", formDataObj.formJson)
              let that = this
              console.log(eval("that.$refs.form" +index)[0])
              eval("that.$refs.form" +index)[0].setFormJson(formDataObj.formJsonObj.formJson);
              eval("that.$refs.form" +index)[0].setFormData(formDataObj.formJsonObj);
            })
            this.formJson = this.formDataList[0].formJsonObj.formJson
          })
        } else {
          this.$nextTick(() => {
            // 回显数据
            this.$refs.vFormRef.setFormJson(res.data);
            this.formJson = res.data;
          })
        }
        // if (res.data.formJson) {
        //   // 回显表单
        //   this.$refs.vFormRef.setFormJson(res.data.formJson);
        //   this.formJson = res.data.formJson;
        //   this.$nextTick(() => {
        //     // 加载表单填写的数据
        //     this.$refs.vFormRef.setFormData(res.data);
        //     // this.$nextTick(() => {
        //     //   // 表单禁用
        //     //   this.$refs.vFormRef.disableForm();
        //     // })
        //   })
        // } else {
        //   this.$nextTick(() => {
        //     // 回显数据
        //     this.$refs.vFormRef.setFormJson(res.data);
        //     this.formJson = res.data;
        //   })
        // }
      }).catch(res => {
        console.log("报错了:", res)
        this.goBack();
      })
    },
    /** 返回页面 */
    goBack() {
      // 关闭当前标签页并返回上个页面
      const obj = { path: "/task/process", query: { t: Date.now()} };
      this.$tab.closeOpenPage(obj);
      this.$router.push({
        path: '/projectFlow/detail',
        query: {
          projectId: this.goBackParams.projectId,
          processDefId: this.goBackParams.processDefId
        }
      })
    },
    /** 申请流程表单数据提交 */
    submitForm() {
      this.$refs.vFormRef.getFormData().then(formData => {
      let that = this
      eval("that.$refs.form" +0)[0].getFormData().then(formData => {
        // 根据当前任务或者流程设计配置的下一步节点 todo 暂时未涉及到考虑网关、表达式和多节点情况
        getNextFlowNodeByStart({deploymentId: this.deployId, variables: formData}).then(res => {
          const data = res.data;
@@ -274,4 +350,13 @@
.my-label {
  background: #E1F3D8;
}
.form-warp {
  padding: 20px;
  margin-bottom: 20px;
  box-shadow:
    inset 0 -3em 3em rgba(0, 0, 0, 0.1),
    0 0 0 2px rgb(239, 239, 239),
    0.3em 0.3em 1em rgba(0, 0, 0, 0.3);
}
</style>