index.js 9.68 KB
import { getWorkFlowImage } from "@/api/jsydsyqFlow.js";
import { popupDialog } from "@/utils/popup.js";
import {
  leftMenu,
  stepExpandInfo,
  record,
  completeTask,
  getNextLinkInfo,
} from "@/api/fqsq.js";
export default {
  data () {
    return {
      //是否开启材料分屏
      splitScreen: false,
      //设置表单组件是否刷选值
      fresh: 10,
      //左侧菜单数据集合
      unitData: [],
      //顶部左侧按钮集合
      leftButtonList: [],
      //顶部右侧按钮集合
      rightButtonList: [],
      //批量按钮名称
      batchButtonName: '',
    }
  },
  mounted () {
    this.flowInitParam();
    this.loadBdcdylist();
  },
  methods: {
    //读取申请单元信息
    loadBdcdylist () {
      var formdata = new FormData();
      formdata.append("bsmSlsq", this.bsmSlsq);
      formdata.append("bestepid", this.bestepid);
      leftMenu(formdata).then((res) => {
        if (res.code === 200) {
          if (res.result) {
            this.unitData = res.result;
            this.currentSelectProps = res.result[0];
            this.judgeBatchShow();
            if (this.showBatch) {
              //满足批量查封/批量抵押按钮出现 即先展示批量表单
              this.unitClick(-1);
            } else {
              //默认选择单元列表第一个
              this.unitClick(0);
            }
          }
        }
      });
    },
    //批量按钮判断
    judgeBatchShow () {
      this.showBatch = false;
      let qllx = this.$route.query.sqywbm.substring(0, 3);
      if (this.unitData.length > 1) {
        switch (qllx) {
          case 'B39':
            this.showBatch = true;
            this.batchButtonName = '批量查封';
            break;
          case 'A37':
            this.showBatch = true;
            this.batchButtonName = '批量抵押';
            break;
        }
      }
    },
    //加载流程初始参数
    flowInitParam () {
      var formdata = new FormData();
      formdata.append("bsmSlsq", this.bsmSlsq);
      formdata.append("bestepid", this.bestepid);
      stepExpandInfo(formdata).then((res) => {
        if (res.code === 200) {
          this.leftButtonList = res.result.button;
          this.rightButtonList = res.result.operation;
        }
      });
    },
    //流程环节操作按钮
    operation (item) {
      //按钮 B0:选择不动产单元 B1:流程图 B2:材料分屏 B3:材料导入 B4:登记簿 B5:证书预览 B6:打印申请书 B7:证书领取 B8:楼盘表 B9:登簿
      //操作按钮 登簿:record  转件:transfer  退回:back  退出:signout
      let that = this;
      switch (item.value) {
        case "B0":
          this.isDialog = true;
          break;
        case "B1":
          getWorkFlowImage(this.bsmSlsq, this.$route.query.bestepid).then(res => {
            let { result } = res
            popupDialog("流程图", "workflow/components/processViewer", {
              xml: result.xml,
              finishedInfo: {
                finishedTaskSet: result.finishedTaskSet,
                unfinishedTaskSet: result.unfinishedTaskSet,
                rejectedTaskSet: result.rejectedTaskSet,
                finishedSequenceFlowSet: result.finishedSequenceFlowSet
              },
              allCommentList: result.historyTaskList
            })
          })
          break;
        case "B2": //材料分屏按钮
          this.splitScreen = this.splitScreen ? false : true;
          this.$store.dispatch("app/settScreen", this.splitScreen);
          if (this.splitScreen) {
            //如果当前选项卡为材料信息内容,递减到上一个选项卡内容
            if (this.tabName == this.clxxTab.value) {
              this.tabName = this.tabList[this.clxxIndex - 1].value;
              this.getFromRouter(this.tabList[this.clxxIndex - 1].value);
            }
            //删除材料信息选项卡数据
            this.tabList.splice(this.clxxIndex, 1);
          } else {
            //新增材料信息选项卡数据
            this.tabList.splice(this.clxxIndex, 0, this.clxxTab);
          }
          break;
        case "B4":
          popupDialog("登记簿详情", "registerBook/djbFrame", this.currentSelectProps, '80%')
          break;
        case "B5":
          popupDialog("证书预览", "workflow/components/zsyl", {
            bsmSlsq: this.bsmSlsq,
            entryType: '1'
          }, '800px')
          break;
        case "B7":
          this.$popup("证书领取", "workflow/components/zslq", {
            formData: { bsmSlsq: this.$route.query.bsmSlsq }
          })
          break;
        case "back": //退回按钮
          popupDialog("退回", "workflow/components/th", {
            bsmSlsq: this.bsmSlsq,
            bestepid: this.bestepid
          }, '30%', "200px", true)
          break;
        case "transfer": //转件按钮
          getNextLinkInfo({
            bsmSlsq: this.bsmSlsq,
            bestepid: this.bestepid,
          }).then((res) => {
            if (res.code === 200) {
              if (res.result) {
                this.sendToNext(res.result);
              } else {
                this.sendToEnd();
              }
            }
          });
          break;
        case "stop": //终止按钮
          popupDialog("终止", "workflow/components/stop", {
            bsmSlsq: this.bsmSlsq,
            bestepid: this.bestepid,
          }, '30%', "330px", true)
          break;
        case "signout":
          window.close();
          //取消认领
          unClaimTask(this.bsmSlsq, this.bestepid)
          break;
        case "B9":
          var formdata = new FormData();
          formdata.append("bsmSlsq", this.bsmSlsq);
          formdata.append("bestepid", this.bestepid);
          this.$confirm("请确认是否登簿", "提示", {
            iconClass: "el-icon-question", //自定义图标样式
            confirmButtonText: "确认", //确认按钮文字更换
            cancelButtonText: "取消", //取消按钮文字更换
            showClose: true, //是否显示右上角关闭按钮
            type: "warning", //提示类型  success/info/warning/error
          }).then(function () {
            record(formdata).then((res) => {
              if (res.code === 200) {
                if (res.result.length === 1) {
                  res.result[0].state ? that.$alert("登簿成功!") : that.$alert(res.result[0].msg);;
                }
                else {
                  that.$alert('<div>' + res.result[0].ywh + ',' + res.result[0].msg + '</div>', '登簿明细', {
                    dangerouslyUseHTMLString: true
                  });
                }
              } else {
                that.$alert(res.message);
              }
            });
          });
          break;
      }
    },
    //发送下一个环节
    sendToNext (obj) {
      const h = this.$createElement;
      this.$msgbox({
        title: "您确定转出吗?1",
        message: h("div", { style: "margin: auto" }, [
          h("span", null, "下个环节名称:"),
          h("i", { style: "color: teal" }, obj.taskName),
          h("div", null, ""),
          h("span", null, "下个环节经办人: "),
          h("i", { style: "color: teal" }, obj.usernames.join(",")),
        ]),
        showCancelButton: true,
        beforeClose: (action, instance, done) => {
          if (action === "confirm") {
            instance.confirmButtonLoading = true;
            instance.confirmButtonText = "执行中...";
            completeTask({
              bsmSlsq: this.bsmSlsq,
              shyj: "this.bestepid",
              stepform: JSON.stringify(this.tabList),
            }).then((res) => {
              if (res.code === 200) {
                instance.confirmButtonLoading = false;
                this.$message.success("转件成功");
                window.opener.location.reload(); //刷新父窗口
                window.close();
                this.$emit("input", false);
              } else {
                instance.confirmButtonLoading = false;
                instance.confirmButtonText = "确定";
                this.$message.error(res.message);
              }
            });
          } else {
            done();
          }
        },
      }).then((action) => {
        this.$message({
          type: "info",
          message: "action: " + action,
        });
      });
    },
    sendToEnd () {
      let that = this
      const h = this.$createElement;
      this.$msgbox({
        title: "您确定转出吗?2",
        message: "此环节为流程结束环节,转出后流程将结束",
        showCancelButton: true,
        beforeClose: (action, instance, done) => {
          console.log(action, 'actionaction');
          if (action === "confirm") {
            instance.confirmButtonLoading = true;
            instance.confirmButtonText = "执行中...";
            completeTask({
              bsmSlsq: this.bsmSlsq,
              shyj: "this.bestepid",
              stepform: JSON.stringify(this.tabList),
            }).then((res) => {
              if (res.code === 200) {
                instance.confirmButtonLoading = false;
                that.$message.success("转件成功");
                localStorage.setItem('transfer', true)
                window.opener.location.reload(); //刷新父窗口
                window.close();
                that.$emit("input", false);
              } else {
                instance.confirmButtonLoading = false;
                instance.confirmButtonText = "确定";
                this.$message.error(res.message);
              }
            })
          } else {
            done();
          }
        },
      }).then((action) => {
        this.$message({
          type: "info",
          message: "action: " + action
        })
      })
    }
  }
}