田源
2024-04-07 2ac55ce0edf4870a29691b56bfad59f4830a11a2
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
/**
 * 流程跟踪,查看流程历史和当前的流程图
 */
layui.define(['layer','element','table'],function(exports){
    var ProcessHistory = function(){
        this.id = "vciWebProHistory";
        this.modelKey = "vciWebProHistory";
        this.businessBtmInProcess = "";
        this.businessOidsInProcess = "";//业务数据会有多个
        this.taskOidInProcess = "";
        this.executionId = "";
        this.backPath = configData.compatibility ? path : configData.processServicePath ;
        this.maxWidth = 1000;
        this.url={
            history:'processDefineController/getHistory',
            picture:'processDefineController/getProcessPic',
        };
    }
 
    ProcessHistory.prototype.getContent = function(){
        var that = this;
        if($webUtil.isNotNull(that.executionOid) && that.executionOid.indexOf(",") > -1){
            return '<div><span>只有单个任务的时候才能查看流程历史</div>';
        }
        return ['<div style="width:', that.maxWidth - 10, 'px;overflow:auto;"><table id="history_' , that.id , '" lay-filter="history_' , that.id , '" ></table>',
                '<img layer-pid="picture_' , that.id , '" lay-filter="picture_' , that.id , '" src=""  alt="流程图" style="width:', that.maxWidth - 10 ,'px;" /></div>'].join('');
    };
 
    ProcessHistory.prototype.init = function(){
        var that = this;
        var table = layui.table;
        if(that.historyColumns == null || that.historyColumns.length == 0){
            that.checkHistoryColumns();
        }
        table.render({
            elem:'#history_' + that.id,
            backPath: that.backPath,
            url:that.url.history,
            page:false,
            where:{
                executionId:that.executionId,
                showCurrentNode:true
            },
            cols:[that.historyColumns]
        });
        //显示流程图
        var url = "";
        if(layui.util.isNotNull(that.taskOidInProcess)){
            url = that.backPath + that.url.picture + "?taskOid=" + that.taskOidInProcess + "&" + TOKEN_KEY + "=" + $webUtil.getToken();
        }else{
            url = that.backPath + that.url.picture + "?executionId=" + that.executionId + "&" + TOKEN_KEY + "=" + $webUtil.getToken();
        }
        $("img[layer-pid='picture_" + that.id + "']").attr("src",url);
    };
    ProcessHistory.prototype.checkHistoryColumns = function(){
        var that = this;
        var table = layui.table;
        if(that.historyColumns==null || that.historyColumns.length==0){//如果其他地方想使用这个组件的时候,可以自定义列
            that.historyColumns = [table.getIndexColumn(),{
                field:'taskName',
                title:'任务名称',
                width:150
            },{
                field:'opinin',
                title:'执行操作',
                width:100
            },{
                field:'createTime',
                title:'任务开始时间',
                width:180
            },{
                field:'node',
                title:'审批意见',
                width:200
            },{
                field:'assigneeName',
                title:'执行人',
                width:120
            },{
                field:'endTime',
                title:'任务完成时间',
                width:180,
                templet:function(d){
                    if($webUtil.isNotNull(d.endTime)){
                        return d.endTime;
                    }else{
                        return "正在处理中";
                    }
                }
            }]
        }
    };
 
    var history = new ProcessHistory();
    exports('process/vciWebProHistory',history);
});