/**
* 待办事项--不包括流程--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 '
';
};
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 = "";
layui.each(that.items,function(_index,record){
if(_index%6==0){
//4的整数倍
html += '
';
}
});
html += '
';
$("#" + 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);
});