Ldc
2024-04-07 0652600959e5e3b5796fb6e8da129704ca95347a
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
/**
 * 待办事项--不包括流程--2021-2-22增加前端查询的方式
 * Created by weidy on 2018/5/2.
 */
 
layui.define(['layer','carousel'],function(exports){
 
    var Task = function(){
        this.id ='vciBaseTaskPortlet';
        this.backPath = configData.compatibility?path:configData.frameworkPath
        this.urlConfig = {
            listMyTask:'homeTaskController/listMyHomeTask'
        };
        this.countByServer = false;
        this.moduleKey = "vciBaseTaskPortlet";
        this.items = [];
    };
    Task.prototype.getContent = function(){
        var that = this;
        return '<div class="layui-carousel layui-vci-undotask"  id="' + that.id + '"></div>';
    };
    Task.prototype.init = function(){
        var that = this;
        $webUtil.copyConfig(that,that.moduleKey);
        if(this.items.length == 0){
            $webUtil.get(that.urlConfig.listMyTask,{},function(result){
                if(!result.success){
                    return false;
                }
                that.items = result.data;
                var carousel = layui.carousel;
                //自己加条目,而不是由carousel加
                var html = "<div carousel-item>";
                layui.each(that.items,function(_index,record){
                    if(_index%6==0){
                        //4的整数倍
                        html += '<ul class="layui-row layui-col-space10 ' + (_index == 0?'layui-this':'') + '">';
                    }
                    //添加本功能
                    html += '<li class="layui-col-xs6"><a href="javascript:;" class="vciTaskPortlet_task"  data-id="' + record.oid + '"><h3>'  + record.name + '</h3><p style="text-align: center"><cite>' + (that.countByServer?record.count:'0') + '</cite></p></a></li>';
                    if(_index%6==5 || _index == that.items.length-1){
                        html += '</ul>';
                    }
                });
                html += '</div>';
                $("#" + that.id).html(html);
                carousel.render({
                    elem:'#' + that.id,
                    width:'100%',
                    autoplay:false,
                    arrow:'none',
                    indicator:'inside'
                });
                that.bindButtonListener();
                if(!that.countByServer){
                    //是前端查询
                    layui.each(that.items,function(_index,record){
                        $webUtil.get(record.countUrl,{},function (result) {
                            if(result.success){
                                $('#' + that.id).find('a[data-id="' + record.oid + '"]').find('cite').html(result.obj);
                            }else{
                                $('#' + that.id).find('a[data-id="' + record.oid + '"]').find('cite').html(0);
                            }
                        },function (err,xhr) {
                            $webUtil.showDebugMsg(err);
                        },configData['serviceName']);
                    });
                }
            },function(xhr,err){
 
            },that.backPath,false);
        }
    };
 
    Task.prototype.bindButtonListener = function(){
        var that = this;
        $(".vciTaskPortlet_task").click(function(){
            var oid = $(this).attr("data-id");
            layui.each(that.items,function(_index,record){
                if(record.oid == oid){
                    var menuObj = {
                        id:record.id,
                        text : record.name,
                        url : record.uiUrl
                    };
                    portal.showTabByMenu(record.id,menuObj);
                    return false;
                }
            });
        });
    };
    var task = new Task();
   exports('portal/vciBaseTaskPortlet',task);
});