田源
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
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
/**
 * 流程的待办事项挂件,首页里使用的,与选项卡里的区别在于这里的表格的分页数据相对较少
 * Created by weidy on 2018/5/2.
 */
 
layui.define(['layer','table'],function(exports){
 
    var UndoTask = function(){
        this.moduleKey = "vciWebProUndoTaskPortlet";
        this.taskCenterUrl='USEJS:/process/vciWebProUndoTask';//待办任务中心的数据
        this.url= {
            task: 'processDefineController/getMyUndoTask'
        };
        this.limit = 10;
        this.id = '';
    };
    UndoTask.prototype.getContent = function(){
        var that = this;
        return '<table id="table_vciProcessUndoTask_' + that.id + '" lay-filter="' + that.id +'"></table><div  id="toolbar_vciProcessUndoTask_' + that.id + '" style="display:none"></div>';
    };
    UndoTask.prototype.getTableColumns = function(){
        var that =this;
        var table = layui.table;
        var cols = [table.getIndexColumn(),{
            field:'name',
            title:'任务名称',
            width:450,
            templet:'<div><a name="processname" dataIndex="{{d.LAY_INDEX}}" lay-event="gotodo" href="javascript:;" style="text-decoration:underline;color:blue;">{{d.name}}</a></div>'
        },{
            field:'createtime',
            title:'上一步处理时间',
            width:150,
            templet:function(d){
                if(d.createtime !=null){
                    return layui.util.toDateString(d.createtime,'yyyy-MM-dd HH:mm');
                }else{
                    return "";
                }
            }
        },{
            field:'description',
            title:'描述',
            width:130
        },{
            field:'creator_name',
            title:'上一步操作人',
            width:100
        },{
            field: 'executionid',
            title: '所属流程模板',
            width: 150,
            templet: function (d) {
                if($webUtil.isNotNull(d.executionid) && d.executionid.indexOf(".") > -1){
                    return d.executionid.substring(0,d.executionid.indexOf("."));
                }else{
                    return d.executionid;
                }
            }
        },{
            field:'options',
            title:'操作',
            fixed:'right',
            width:60,
            toolbar:'#toolbar_vciProcessUndoTask_' + that.id
        }];
        return cols;
    };
    UndoTask.prototype.getToolbarHtml = function(){
        var that =this;
        var html = "";
        html += '<a class="layui-btn layui-btn-intable " lay-event="gotodo">执行</a>';//去处理
       // html += '<a class="layui-btn layui-btn-primary" lay-event="viewdata">查看数据</a>';//查看数据
        return html;
    };
    UndoTask.prototype.init = function(){
        var that = this;
        $webUtil.copyConfig(that,that.moduleKey);
        var table = layui.table;
        //先初始化工具栏的html--之前使用的script标签在IE8上是无效的,所以修改为DIV
        document.getElementById("toolbar_vciProcessUndoTask_" + that.id).innerHTML = that.getToolbarHtml();
        //初始化列表
        table.render({
            elem:'#table_vciProcessUndoTask_' + that.id ,
            id:'table_vciProcessUndoTask_' + that.id ,
            url:that.url.task,
            backPath:(configData.compatibility ? path : configData.processServicePath),
            page:{
                limit:that.limit,
                page:1
            },
            //height:600,
            cols:[that.getTableColumns()],
            done:function(res,curr,count){
                //不清楚工具栏的监听是否在表格加载完成之前有影响,因此只能在加载完成后添加监听
                table.on('tool(' + that.id + ')',function(obj){
                    var data = obj.data;//当前选择行的数据
                    var layEvent = obj.event;//点的是什么按钮
                    if(layEvent == 'gotodo'){
                        //直接弹出窗口
                         that.doProcess(data);
                    }else if(layEvent == 'viewdata'){
                        that.viewData(data);
                    }
                });
                /*$('a[name="processname"]',$('#table_vciProcessUndoTask_' + that.id).parent()).on('click',function(){
                    var table = layui.table;
                    var allData = table.getData('table_vciProcessUndoTask_' + that.id);
                    if(allData&& allData.length > 0){
                        var thisDataRowIndex = $(this).attr("dataIndex");
                        var thisRowData = null;
                        layui.each(allData,function(_index,_item){
                            if(_item.LAY_TABLE_INDEX == (thisDataRowIndex*1 - 1)){
                                thisRowData = _item;
                                return true;
                            }
                        });
                        if(thisRowData!=null){
                            that.doProcess(thisRowData);
                        }
                    }
                });*/
            }
        });
 
    };
    UndoTask.prototype.doProcess=function(data){
        var that = this;
        var table = layui.table;
        if(data&&data.oid){
            layui.use('process/vciWebProExecuteTask',function(){
                var executeTask = layui['process/vciWebProExecuteTask'];
                executeTask.init();
                var task = data;
                task.taskOid = data.oid;
                task.taskName = data.name;
                task.executionId=data.executionid
                var taskInfo = [task];
                executeTask.showExecuteWindow(taskInfo,{
                    fullScreen:true
                },function(finish){
                    if(finish){
                        table.reload('table_vciProcessUndoTask_' + that.id);
                    }
                });
            });
        }
    };
    UndoTask.prototype.viewData = function(data){
        var that = this;
    };
    UndoTask.prototype.getCenterObject = function(){//获取跳转到中心的相关对象
        var that = this;
        return {
            text:'我的待办任务',
            id:that.id,
            bsUrl:that.taskCenterUrl
        };
    };
    var task = new UndoTask();
   exports('portal/vciWebProUndoTaskPortlet',task);
});