/**
|
* 待办事项--不包括流程--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);
|
});
|