页面树结构
转至元数据结尾
转至元数据起始
  • 无标签

7 评论

  1. 钟广友 发表:

    前端驳回(当前任务仅往前跳站)
    debugger
    var rtnData = this.confirmData;
    if (rtnData) {
        let targetTaskId = rtnData.taskId; //驳回到目标的任务id
        //调用跳站的API
        let curTaskInstanceOid = ``; //当前taskOid
        let that = this;
        // let targetTaskId = "Activity_199viea";
        curTaskInstanceOid = this.getAddinById('Grid1').getAll();
        if (curTaskInstanceOid && curTaskInstanceOid.length > 1) {
            curTaskInstanceOid = curTaskInstanceOid[0].oid;
            debugger
            // doJump();
            // this.dwf_axios.post(`/workflow/task-instance/jump`, param).then(function (res) {
            // })
            this.dwf_axios.post(`/workflow/task-instance/jump`, {
                taskInstanceOid: curTaskInstanceOid,
                username: this.user.userName,
                targetTaskId: targetTaskId,
            }).then(function (res) {
                res = res.data;
                console.log(res);
                if (!res.success) {
                    if (isPc) {
                        that.msgbox.error("跳站失败!");
                    }
                    else {
                        that.msgbox.fail("跳站失败!");
                    }
                } else {
                    that.msgbox.success("跳站成功!");
                }
            }).catch(function (error) {
                //TODO 请求失败,失败信息 error
                console.log(error);
                if (isPc) {
                    that.msgbox.error("提交失败!");
                }
                else {
                    that.msgbox.fail("提交失败!");
                }
            });
        } else {
            curTaskInstanceOid = null;
            this.msgbox.warning("驳回失败!");
        }
    } else {}
  2. 钟广友 发表:

    移动端已办任务打开(前端脚本)
    let isPc = this.env.url ? this.env.url.indexOf('app-web') > -1 : true;
    console.log(this.selectedObjs[0], this.user, this.env, isPc)
    
    let taskInstance = this.obj;
    if (this.selectedObjs && this.selectedObjs.length > 0) {
        taskInstance = this.selectedObjs[0];
    }
    
    let getView = (className, viewName) => {
        return this.dwf_axios.get(`meta/class/${className}/views/${viewName}/devices/actPc/type/${isPc ? 'PC' : 'Mobile'}`).then(function (res) {
            console.log('++++++++++++++++++getView+++++++++', res)
            if (!res.data.data) {
                let msg = isPc ? '电脑端' : '移动端';
                msgboxError(msg + '表单不存在');
            }
            return res.data;
        }).catch(function (error) {
            //TODO 请求失败,失败信息 error 
            console.log(error);
    
            msgboxError("获取表单失败")
        });
    }
    
    
    let wf = {};
    let that = this;
    let bindObj = {};
    let targetOid = taskInstance.targetOid;
    let targetClass = taskInstance.targetClass;
    let taskInstanceInfo = taskInstance.taskInstanceInfo;
    if (typeof taskInstanceInfo == 'string') {
        try {
            taskInstanceInfo = JSON.parse(taskInstanceInfo);
        } catch (error) {
            console.log(`event parse ${error}`)
        }
    }
    console.log(taskInstanceInfo, 'taskInstanceInfo')
    wf = {
        processDef: null,
        processIns: null,
        taskIns: taskInstance,
        variables: {
        },
    };
    
    // 0 如果有targeOid
    if (taskInstance.targetOid) {
        this.handleQueryData(
            {
                "targetClass": targetClass,
                "query": { query: `and obj.oid='${targetOid}'` }
            }
        ).then(res => {
            //TODO res为接口返回结果 
            console.log(res);
            if (res && res.length > 0) {
                bindObj = res[0];
                console.log('bindObj', bindObj);
                wf.variables._obj = bindObj
                // 1、如果有前处理操作,接受返回的参数,在前处理操作回调内调用doClaim
                // if (taskInstanceInfo["dwf.beforeTaskClaim"]) {
                //     invokeOpr(taskInstanceInfo["dwf.beforeTaskClaim"]);
                // }
                // // 2、没有前处理操作,直接doClaim
                // else {
                //     doClaim();
                // }
    
                // openNewForm(
                //     taskInstanceInfo["dwf.showFormStyle"],
                //     taskInstanceInfo["dwf.bindTargetClass"],
                //     taskInstanceInfo["dwf.defaultForm"]
                // );
                // 兼容v0.14发版之前使用移动端的客户
                // console.log('taskInstance.taskInstanceInfo = ',taskInstance.taskInstanceInfo);
                // debugger
    
                if (taskInstanceInfo["dwf.defaultFormType"] === "Mobile" && taskInstanceInfo["dwf.defaultMobileForm"] == undefined) {
                    openNewForm(
                        taskInstanceInfo["dwf.showFormStyle"],
                        taskInstanceInfo["dwf.bindTargetClass"],
                        taskInstanceInfo["dwf.defaultForm"]
                    );
                } else {
                    openNewForm(
                        taskInstanceInfo["dwf.showMobileFormStyle"],
                        taskInstanceInfo["dwf.bindTargetClass"],
                        taskInstanceInfo["dwf.defaultMobileForm"]
                    );
                }
            }
            else {
                // this.msgboxDialog.confirm("title标题", "请确认是否删除?",
                //     function () {
                //         console.log("确定按钮点击事件!");
                //     },
                //     function () {
                //         console.log("取消按钮点击事件!");
                //     });
                msgboxError("没有查询到关联的审批对象")
            }
        })
    }
    
    
    // 3、打开表单
    function openNewForm(opentype, bindTargetClass, viewName) {
        console.log('openNewForm',opentype, bindTargetClass, viewName, bindObj)
        if (!bindTargetClass || !viewName) return;
        let className = bindTargetClass.split("&")[0];
    
        getView(className, viewName);
    
        let param = {
            obj: bindObj,
            data: {
                wf: wf
            }
        }
        let commonargs = {
            needDialogDefaultOpr: false
        }
        switch (opentype) {
            case 'tab':
                let openParam = {
                // todo: 创建方式
                action: "create",
                targetClass: className,
                authority: viewName,
                displayName: '任务详情',
                viewName: viewName,
                };
                let args = {  
                    initScript:`return ${JSON.stringify(param)}`,
                    needDialogDefaultOpr: false,
                    displayType:'edit'
                }
                console.log('open tab', args)
                // that.openTab(openParam, openParam, args);  //应该参数重复了,by zgy 20230628
                that.openTab(openParam, args);
                break;
            case 'drawerR':
                console.log('open right drawer')
                that.openDrawer(className, viewName, 'right', commonargs, 'edit', param);
                break;
            case 'drawerL':
                console.log('open left drawer')
                that.openDrawer(className, viewName, 'left', commonargs, 'edit', param);
                break;
            case 'dialog':
            default:
                console.log('open dialog')
                that.openForm(className, viewName, commonargs,  'edit', param);
                break;
        }
    }
    console.log(this, '111')
    // 2、发送任务领取请求
    function doClaim () {
        console.log('do cliam', taskInstance, that.user.userId)
        claimTask(
            [{
                taskInstanceOid: taskInstance.oid,
            }], that.user.userId
        ).then((res) => {
            console.log("claimTask", res);
            if (!res.success) {
                msgboxError("任务领取失败")
                
                return;
            }
            // that.$Message.success("任务领取成功");
            // 打开新表单
    
            openNewForm(
                taskInstanceInfo["dwf.showFormStyle"],
                taskInstanceInfo["dwf.bindTargetClass"],
                taskInstanceInfo["dwf.defaultForm"]
            );
    
        });
    }
    
    function judgeNeedObj() {
        console.log(!taskInstance.targetOid, isPc)
        if (!taskInstance.targetOid) {
            msgboxError("没有tartgetOid")
            return false;
        }
        return true
    }
    
    function msgboxError(msg) {
        if (isPc) {
            that.msgbox.error(msg)
        }
        else {
            that.msgbox.fail(msg);
        }
    }
  3. 钟广友 发表:

    工作流发起(前端脚本)
    function wfm_startFun(){
        return "start!";
    }
    
    /**
     * 发起工作流脚本封装,by zgy,2023-03-27;
     */
    function wfm_inVokeLaunchProcess(that, processDefOBJ,bizOBJ,isDialog) {
        debugger
        let isPc = that.env.url ? that.env.url.indexOf('app-web') > -1 : true;
        let bindObj = bizOBJ;
        // console.log(that.selectedObjs[0], that.user, that.env, isPc)
        //流程发起方法封装
        let launchProcess = (param) => {
            return that.dwf_axios.post(`/workflow/process-instance/launch`, param).then(function (res) {
                return res.data;
            }).catch(function (error) {
                if (isPc) {
                    that.msgbox.error(`流程发起失败!error=${error.toString()}`);
                }
                else {
                    that.msgbox.fail(`流程发起失败!error=${error.toString()}`);
                }
            });
        }
        // if (that.selectedObjs.length == 0) return;
        let processDef = processDefOBJ;
        let wf = {
            processDef: processDef,
            processIns: {},
            taskIns: {},
        }
        if (processDef && processDef.beforeProcessStart) {
            invokeOpr(processDef.beforeProcessStart);
        }
        else {
            doLaunchProcess();
        }
        // 流程运行前处理操作
        function invokeOpr(event) {
            if (typeof event == 'string') {
                try {
                    event = JSON.parse(event);
                } catch (error) {
                    console.log(`event parse ${error}`)
                }
            }
            if (event && event.opr_path && event.opr_path != "") {
                console.log('wf ', wf)
                let resolve = (res) => {
                    console.log('--000000000--', res)
                    if (res.variables) wf.variables = res.variables;
                    if (res.taskIns) {
                        wf.taskIns = res.taskIns;
                    }
                    if (res.processDef) wf.processDef = res.processDef;
                    if (res.processIns) wf.processIns = res.processIns;
                    // if (res.obj) bindObj = res.obj; //不应该处理obj存储,by zgy,2023-03-27
                    //前处理后触发流程发起
                    doLaunchProcess();
                }
                that.executeOperation(event.opr_path, wf, resolve);
            }
            else {
                doLaunchProcess();
            }
        };
        function doLaunchProcess() {
            if(processDef.param == null || processDef.param == undefined){
                processDef.param = {}; //修正为 processDef.param = {}也行?
                processDef.param = {'mock':'mock' }; 
            }
            let variables = {
                _obj: {
                    type: "json",
                    value: JSON.stringify(bindObj),
                },
                _user: {
                    type: "json",
                    value: JSON.stringify(that.user),
                },
                _env: {
                    type: "json",
                    value: JSON.stringify(that.env),
                },
                _param: {
                    type: "json",
                    value: JSON.stringify(processDef ? processDef.param : {}),
                },
            };
            let param = {
                definitionOid: processDef.oid,
                name: processDef.name + format(new Date(), "-yyyy-MM-dd HH:mm"),
                initiator: that.user.userId,
                initiatorName: that.user.userName,
                variables: variables
            };
            bindObj && bindObj.oid
                ? (param.targetOid = bindObj.oid)
                : "";
            launchProcess([param]).then((re) => {
                console.log("re", re);
                if (re.success) {
                    that.msgbox.success("流程发起成功");
                    if(isDialog){
                        that.closeDialog();
                    }else{  
                        that.closeTab();
                    }
                    
                } else {
                    if (isPc) {
                        that.msgbox.error(re.message || "流程发起失败");
                    }
                    else {
                        that.msgbox.fail(re.message || "流程发起失败");
                    }
                }
            });
        }
        //流程实例化名格式化
        function format(time, fmt) {
            if (!(time instanceof Date) || isNaN(time.getTime())) return "";
            var o = {
                "M+": time.getMonth() + 1, //月份
                "d+": time.getDate(), //日
                "h+": time.getHours(), //小时
                "H+": time.getHours(), //小时
                "m+": time.getMinutes(), //分
                "s+": time.getSeconds(), //秒
                "q+": Math.floor((time.getMonth() + 3) / 3), //季度
                S: time.getMilliseconds(), //毫秒
            };
            if (/(y+)/.test(fmt)) {
                fmt = fmt.replace(
                    RegExp.$1,
                    (time.getFullYear() + "").substr(4 - RegExp.$1.length)
                );
            }
            for (var k in o) {
                if (new RegExp("(" + k + ")").test(fmt)) {
                    fmt = fmt.replace(
                        RegExp.$1,
                        RegExp.$1.length == 1
                            ? o[k]
                            : ("00" + o[k]).substr(("" + o[k]).length)
                    );
                }
            }
            return fmt;
        }
    }
    
    /**
     * 获取当前应用全局map对象,add by zgy,2023-04-01;
     */
    function getCurAppCacheMapData(){
        var appCacheData = null;
        var appDiv = document.querySelectorAll("div#app");
        if(appDiv && appDiv.length > 0){
            appCacheData = appDiv[0].appCacheData;
            if(appCacheData == null){
                appCacheData = new Map();
                // appCacheData.set(`a`,`a`);
                appDiv[0].appCacheData = appCacheData;
            }
        }
        return appCacheData;
    }
  4. 钟广友 发表:

    通过脚本发起流程示例(前端脚本)
    this.create(this.obj, 'VehicleUseApply',{showMessage:false}).then(newRtnObj => {
        debugger
        // var curProcessDefOBJ = getCurProcessDefOBJ();
        this.handleQueryData({
                "targetClass": "ProcessDefinition",
                "query": ` and obj.name = '分公司用车申请' `,
                "fresh": true
            }
        ).then(res => {
            debugger
            if(res && res.length == 1){
                var curProcessDefOBJ = res[0];
                if(curProcessDefOBJ.workflowInfo){
                    curProcessDefOBJ.workflowInfo = JSON.parse(curProcessDefOBJ.workflowInfo);  //注意转为json对象
                }
                if(curProcessDefOBJ.param){
                    curProcessDefOBJ.param = JSON.parse(curProcessDefOBJ.param);        //注意转为json对象
                }
        debugger
                wfm_inVokeLaunchProcess(this,curProcessDefOBJ/*流程模板*/,newRtnObj/*流程绑定的业务对象*/,true/*是否dialog弹窗*/)  //调用工作流的全局脚本封装,具体见"功能模型->全局操作"中"OPR1FAB0CCD58F06349947C9689BFAE4/工作流前端函数封装";
            }else{
                this.msgbox.warning("获取流程模板异常!");
            }
        });
    });
  5. 钟广友 发表:

    (流程中打开的)任务提交-前端脚本
    var operation1 = this.getAddinById('Operation1');  //任务提交触发脚本的按钮;
    operation1.args.disabled = true; //执行后按钮不可用,不能再次提交;
    this.validateForm().then(validateRes => {  //任务提前的表单必填项检查
        if (validateRes) {
            // var UserTaskExecutionControlMobile = this.getAddinById('UserTaskExecutionControlMobile10');
                        // //触发任务执行-审批事件
                        // UserTaskExecutionControlMobile.$el.getElementsByTagName('button')[0].click();  //改为通过脚本触发任务提交,by zgy,231016
                        var taskInstance = this.data.wf.taskIns;
                        let dataView1Obj = this.getAddinById('DataView1').getObj();
                        debugger
                        taskInstance.comments= dataView1Obj.comments;
                        taskInstance.approveState= dataView1Obj.approveState;
                        taskSubmit(this,this.obj,taskInstance);  //改为通过脚本触发任务提交,by zgy,231016
        }
        else {
            operation1.args.disabled = false;
        }
    });
    
    /**
     * 任务提交操作脚本封装,231016,by zgy
     */
    function taskSubmit(_this,curOBJ,taskInstance) {
        debugger
        // let taskInstance = _this.obj;
        // if (_this.selectedObjs && _this.selectedObjs.length > 0) {
        //     taskInstance = _this.selectedObjs[0];
        // }
        let wf = {
            processDef: {},
            processIns: {},
            taskIns: taskInstance,
        }
        let bindObj = curOBJ;
        // 审批人 同意
        // taskInstance.approver = "同意"
        console.log(taskInstance, _this.obj)
    
    
        let taskInstanceInfo = taskInstance.taskInstanceInfo;
        if (typeof taskInstanceInfo == 'string') {
            try {
                taskInstanceInfo = JSON.parse(taskInstanceInfo);
            } catch (error) {
                console.log(`event parse ${error}`)
            }
        }
        let isPc = _this.env.url ? _this.env.url.indexOf('app-web') > -1 : true;
        console.log(taskInstance, _this.env, isPc, _this.displayType)
    
        let that = _this;
    
        let commitTask = (param) => {
            return _this.dwf_axios.post(`/workflow/task-instance/commit`, param).then(function (res) {
                return res.data;
            }).catch(function (error) {
                //TODO 请求失败,失败信息 error 
                console.log(error);
                if (isPc) {
                    that.msgbox.error("提交失败!");
                }
                else {
                    that.msgbox.fail("提交失败!");
                }
            });
        }
    
        if (taskInstanceInfo["dwf.beforeTaskCommit"]) {
            invokeOpr(taskInstanceInfo["dwf.beforeTaskCommit"]);
        }
        else {
            dosubmit();
        }
    
        // 运行前处理操作
        function invokeOpr(event) {
            if (typeof event == 'string') {
                try {
                    event = JSON.parse(event);
                } catch (error) {
                    console.log(`event parse ${error}`)
                }
            }
            if (event && event.opr_path && event.opr_path != "") {
                console.log('wf ', wf)
                let resolve = (res) => {
                    console.log('--000000000--', res)
                    if (res.variables) wf.variables = res.variables;
                    if (res.taskIns) {
                        wf.taskIns = res.taskIns;
                    }
                    if (res.obj && res.obj.oid) {
                        bindObj = res.obj;
                    }
                    if (res.processDef) wf.processDef = res.processDef;
                    if (res.processIns) wf.processIns = res.processIns;
    
                    dosubmit();
    
                }
                that.executeOperation(event.opr_path, wf, resolve);
            }
            else {
                dosubmit();
            }
        };
    
        function dosubmit() {
            commitTask([{
                taskInstanceOid: taskInstance.oid,
                userId: that.user.userId,
                variables: getVariables()// _this.wf.variables,
            }]).then((res) => {
                console.log(res)
                if (!res.success) {
                    if (isPc) {
                        that.msgbox.error("提交失败!");
                    }
                    else {
                        that.msgbox.fail("提交失败!");
                    }
                } else {
                    that.msgbox.success("提交成功!");
                    if (isPc) {
                        //暂缓处理
    
                    }else {
                        //
                        that.commonBack(); //移动端:提交后关闭当前窗口
                        window.taskInstancemy_suppliesDoneTodo_isNeedFresh = true;//add by zhonggy,用于任务列表定时刷新(北方管道应用场景),221208                 debugger; 
                    }
                }
            });
        }
    
        function getVariables() {
            let vars = {};
            vars['_obj'] = { value: JSON.stringify(bindObj), type: 'json' };
            vars['_user'] = { value: JSON.stringify(that.user), type: 'json' };
            vars['_env'] = { value: JSON.stringify(that.env), type: 'json' };
            return vars;
        }
    }
  6. 钟广友 发表:

    (选中流程任务的)任务提交-前端脚本-参考
    let taskInstance = this.obj;
    if (this.selectedObjs && this.selectedObjs.length > 0) {
        taskInstance = this.selectedObjs[0];
    
    }
    let wf = {
        processDef: {},
        processIns: {},
        taskIns: taskInstance,
    }
    let bindObj = {};
        // 审批人 同意
    taskInstance.approver = "同意"
    console.log(taskInstance, this.obj)
    
    
    let taskInstanceInfo = taskInstance.taskInstanceInfo;
    if (typeof taskInstanceInfo == 'string') {
        try {
            taskInstanceInfo = JSON.parse(taskInstanceInfo);
        } catch (error) {
            console.log(`event parse ${error}`)
        }
    }
    let isPc =  this.env.url?  this.env.url.indexOf('app-web') > -1 : true;
    console.log(taskInstance, this.env, isPc, this.displayType)
    
    let that = this;
    
    let commitTask = (param) => {
        return this.dwf_axios.post(`/workflow/task-instance/commit`, param).then(function (res) {
         return res.data;  
        }).catch(function (error) { 
            //TODO 请求失败,失败信息 error 
            console.log(error); 
            if (isPc) {
                that.msgbox.error("提交失败!");
            }
            else {
                that.msgbox.fail("提交失败!");
            }
        });
    }
    
    if (taskInstanceInfo["dwf.beforeTaskCommit"]) {
        invokeOpr(taskInstanceInfo["dwf.beforeTaskCommit"]);
    }
    else {
        dosubmit();
    }
    
    
    
    
    
    // 运行前处理操作
    function invokeOpr(event) {
        if (typeof event == 'string') {
            try {
                event = JSON.parse(event);
            } catch (error) {
                console.log(`event parse ${error}`)
            }
        }
        if (event && event.opr_path && event.opr_path != "") {
            console.log('wf ', wf)
            let resolve = (res) => {
                console.log('--000000000--', res)
                if (res.variables) wf.variables = res.variables;
                if (res.taskIns) {
                    wf.taskIns = res.taskIns;
                }
                if (res.obj && res.obj.oid) { 
                    bindObj = res.obj;
                }
                if (res.processDef) wf.processDef = res.processDef;
                if (res.processIns) wf.processIns = res.processIns;
                
                dosubmit();
    
            }
            that.executeOperation(event.opr_path, wf, resolve);
        }
        else {
            dosubmit();
        }
    };
    
    function dosubmit() {
        commitTask([{
            taskInstanceOid: taskInstance.oid,
            userId: that.user.userId,
            variables: getVariables()// this.wf.variables,
        }]).then((res) => {
            console.log(res)
            if (!res.success) {
                if (isPc) {
                    that.msgbox.error("提交失败!");
                }
                else {
                    that.msgbox.fail("提交失败!");
                }
            } else {
                that.msgbox.success("提交成功!");
            }
        });
    }
    
    function getVariables(){
        let vars = {};
        vars['_obj'] ={value:JSON.stringify(bindObj), type:'json'};
        vars['_user'] ={value:JSON.stringify( that.user), type:'json'};
        vars['_env'] ={value:JSON.stringify(  that.env), type:'json'};
        return vars;
    }
  7. 钟广友 发表:

    工作流任务打开执行(前端脚本)
    var curTaskOid = this.getSourceAddin().cacheTaskOid;
    debugger
    if (curTaskOid) {
        this.handleQueryData(
            {
                "targetClass": "TaskInstance",
                "query": ` and obj.oid = '${curTaskOid}'`
            }
        ).then(res => {
            debugger
            openTask(this, res[0]);
        });
    }
    
    /**
     * 打开流程中任务脚本封装,by zgy,231016 
     */
    function openTask(_this, taskInstance) {
        let isPc = _this.env.url ? _this.env.url.indexOf('app-web') > -1 : true;
        // console.log(_this.selectedObjs[0], _this.user, _this.env, isPc)
        console.log(_this, '666')
        // init api
        let claimTask = (param, claimer) => {
            return _this.dwf_axios.post(`/workflow/task-instance/claim`, param).then(function (res) {
                return res.data;
            }).catch(function (error) {
                //TODO 请求失败,失败信息 error 
                console.log(error);
                msgboxError('领取失败')
            });
        }
    
        let getView = (className, viewName) => {
            return _this.dwf_axios.get(`meta/class/${className}/views/${viewName}/devices/actPc/type/${isPc ? 'PC' : 'Mobile'}`).then(function (res) {
                console.log('++++++++++++++++++getView+++++++++', res)
                if (!res.data.data) {
                    let msg = isPc ? '电脑端' : '移动端';
                    msgboxError(msg + '表单不存在');
                }
                return res.data;
            }).catch(function (error) {
                //TODO 请求失败,失败信息 error 
                console.log(error);
    
                msgboxError("获取表单失败")
            });
        }
    
    
        let wf = {};
        let that = _this;
        let bindObj = {};
        let targetOid = taskInstance.targetOid;
        let targetClass = taskInstance.targetClass;
        let taskInstanceInfo = taskInstance.taskInstanceInfo;
        if (typeof taskInstanceInfo == 'string') {
            try {
                taskInstanceInfo = JSON.parse(taskInstanceInfo);
            } catch (error) {
                console.log(`event parse ${error}`)
            }
        }
        console.log(taskInstanceInfo, 'taskInstanceInfo')
        wf = {
            processDef: null,
            processIns: null,
            taskIns: taskInstance,
            variables: {
            },
        };
    
        // 0 如果有targeOid
        if (taskInstance.targetOid) {
            _this.handleQueryData(
                {
                    "targetClass": targetClass,
                    "query": { query: `and obj.oid='${targetOid}'` }
                }
            ).then(res => {
                //TODO res为接口返回结果 
                // console.log(res); 
                if (res && res.length > 0) {
                    bindObj = res[0];
                    console.log('bindObj', bindObj);
                    wf.variables._obj = bindObj
    
                    // 1、如果有前处理操作,接受返回的参数,在前处理操作回调内调用doClaim
                    if (taskInstanceInfo["dwf.beforeTaskClaim"]) {
                        invokeOpr(taskInstanceInfo["dwf.beforeTaskClaim"]);
                    }
                    // 2、没有前处理操作,直接doClaim
                    else {
                        doClaim();
                    }
                }
                else {
                    msgboxError("没有查询到对象")
    
                }
            });
        }
        // 0 如果没有targeOid
        else {
            // 有前处理脚本
            if (taskInstanceInfo["dwf.beforeTaskClaim"]) {
                invokeOpr(taskInstanceInfo["dwf.beforeTaskClaim"]);
            }
            // 没有前处理脚本 报错
            else {
                judgeNeedObj();
            }
        }
    
    
    
        // 1、运行前处理操作
        function invokeOpr(event) {
            if (typeof event == 'string') {
                try {
                    event = JSON.parse(event);
                    console.log(event, event.opr_path)
                } catch (error) {
                    console.log(`event parse ${error}`)
                }
            }
            if (event && event.opr_path && event.opr_path != "") {
                console.log('wf ', wf)
                let resolve = (res) => {
                    console.log('--000000000--', res)
                    if (res.variables) wf.variables = res.variables;
                    if (res.taskIns) {
                        wf.taskIns = res.taskIns;
                    }
                    if (res.obj && res.obj.oid) {
                        bindObj = res.obj;
                    }
                    else {
                        if (!judgeNeedObj()) {
                            return;
                        }
                    }
                    if (res.processDef) wf.processDef = res.processDef;
                    if (res.processIns) wf.processIns = res.processIns;
    
                    doClaim();
    
                }
                that.executeOperation(event.opr_path, wf, resolve);
            }
            else {
                if (!judgeNeedObj()) return;
                doClaim();
            }
        };
    
        // 3、打开表单
        function openNewForm(opentype, bindTargetClass, viewName) {
            console.log('openNewForm', opentype, bindTargetClass, viewName, bindObj, '00000000000000000000000')
            console.log(opentype, '111111111111111111111111111')
            if (!bindTargetClass || !viewName) return;
            let className = bindTargetClass.split("&")[0];
    
            getView(className, viewName);
    
            let param = {
                obj: bindObj,
                data: {
                    wf: wf
                }
            }
            let commonargs = {
                needDialogDefaultOpr: false
            }
            switch (opentype) {
                case 'tab':
                    let openParam = {
                        // todo: 创建方式
                        action: "create",
                        targetClass: className,
                        authority: viewName,
                        displayName: '详情',
                        viewName: viewName,
                    };
                    let args = {
                        initScript: `return ${JSON.stringify(param)}`,
                        needDialogDefaultOpr: false,
                        displayType: 'edit'
                    }
                    console.log('open tab', args)
                    // console.log(that,'2222222222222222222222222222222222222')
                    that.openTab(openParam, args);
                    break;
                case 'drawerR':
                    console.log('open right drawer')
                    that.openDrawer(className, viewName, 'right', commonargs, 'edit', param);
                    break;
                case 'drawerL':
                    console.log('open left drawer')
                    that.openDrawer(className, viewName, 'left', commonargs, 'edit', param);
                    break;
                case 'dialog':
                default:
                    console.log('open dialog')
                    that.openForm(className, viewName, commonargs, 'edit', param);
                    break;
            }
        }
        console.log(_this, '111')
        // 2、发送任务领取请求
        function doClaim() {
            console.log('do cliam', taskInstance, that.user.userId)
            claimTask(
                [{
                    taskInstanceOid: taskInstance.oid,
                    username: that.user.userName
                }], that.user.userId
            ).then((res) => {
                console.log("claimTask", res);
                if (!res.success) {
                    msgboxError("任务领取失败")
    
                    return;
                }
                // that.$Message.success("任务领取成功");
                // 打开新表单
    
                openNewForm(
                    taskInstanceInfo["dwf.showFormStyle"],
                    taskInstanceInfo["dwf.bindTargetClass"],
                    taskInstanceInfo["dwf.defaultForm"]
                );
    
            });
        }
    
        function judgeNeedObj() {
            console.log(!taskInstance.targetOid, isPc)
            if (!taskInstance.targetOid) {
                msgboxError("没有tartgetOid")
                return false;
            }
            return true
        }
    
        function msgboxError(msg) {
            if (isPc) {
                that.msgbox.error(msg)
            }
            else {
                that.msgbox.fail(msg);
            }
        }
    }