leguwork_public/scripts/card_list_timeline.js
2021-04-02 10:30:40 +08:00

219 lines
5.5 KiB
JavaScript

function showCardTimeline(listid){
// console.log('==========');
// console.log(listid);
var html = T( $('#tmpl-card_timeline').html() );
$('body').append( html );
$('#cardListTimelineMask').fadeIn(100).css('width',$(document).width());
// $('.card-details-title').text('项目集成');
// $.get('?app=api&apiact=finishcount&boardid='+DATA.boardid,function(txt){
$.get('./?app=api&apiact=getsettingcardinfo&boardid=' + DATA.boardid + '&cardtitle='+ 'hearderleft',function(text){
// console.log(text);
var j = JSON.parse(text);
// console.log(j);
var cardid = Object.keys(j)[0];
cardData = j[cardid];
// console.log(cardData);
if (cardData){
html = cardData['description'];
} else {
html = "添加标题为<pre>__setting.hearderleft 的卡片</pre>"
}
html += listid;
// $('#cardListTimelineData').append(html);
var calendarEl = document.getElementById('cardListTimelineData');
var calendar = new FullCalendar.Calendar(calendarEl, {
plugins: ['interaction', 'resourceTimeline'],
schedulerLicenseKey: 'GPL-My-Project-Is-Open-Source',
timeZone: '+8',
locale: 'zh-cn',
defaultView: 'resourceTimelineMonth',
aspectRatio: 2.4,
header: {
left: 'prev,next',
// center: 'title',
center: 'title',
right: 'resourceTimelineDay,resourceTimelineWeek,resourceTimelineMonth'
},
editable: false,
resourceLabelText: '单子',
// resourceGroupField: 'group',
resourceAreaWidth: "300px",
resources: './?app=api&apiact=get_timeline_list_card&list=' + listid,
// resources11: [
// {"id":"5cd52386c5363","title":"<p>fasd</p>"},{"id":"3qCRNfNDywDcvfhxJ","group":"\u7f8e\u672f1\u90e8","title":"\u9648\u9752"},{"id":"5aeab9d8e8ab3","group":"\u6d4b\u8bd5\u90e8","title":"\u5218\u601d\u79cb"},{"id":"5aebf6e46df68","group":"H5\u5ba2\u6237\u7aef","title":"\u675c\u6052\u665f"},{"id":"5aeff82ec323d","group":"\u670d\u52a1\u7aef","title":"\u5f90\u671d"},{"id":"5b42d28a3df35","group":"UI\u7ec4","title":"\u738b\u4f73\u4f1f"},
// ],
resourceRender: function(renderInfo) {
// console.log("==-==-=");
// console.log(renderInfo);
var labels = renderInfo.resource.extendedProps.labels;
var board = DATA.boards[ DATA.boardid];
// console.log(labels);
// console.log(board.labels);
var html = `<div class="minicard-labels">`;
labels.forEach(function (ele) {
var label = getLabelsData(ele,board.labels);
html += ` <span class="minicard-label card-label-${label.color}" title="${label.name}">${label.name}</span> `;
});
if(renderInfo.resource.extendedProps.isyanqi){
html += ` <span class="minicard-label card-label-legured" title="延期">延期</span> `;
}
html += `</div>`;
// $(info.el).data('id',info.event.extendedProps.id);
$(renderInfo.el).children('div').append(html);
},
events: './?app=api&apiact=get_timeline_list_card_events&list=' + listid,
// events11: [
// {allDay: true,
// boardid: "5bbdbf66031d2",
// end: "2019-05-11",
// resourceId: "5cd52386c5363",
// start: "2019-05-09",
// title: "地牢冒险",
// isyanqi: "延期了",
// url: "./?app=list&boardid=5bbdbf66031d2#cardid=5c63af7623239"}
// ],
eventRender: function(info) {
// console.log("==-==-=");
// console.log(info);
$(info.el).data('id',info.event.extendedProps.cardid);
$(info.el).addClass('card-list-timeline-event-open');
if (info.event.extendedProps.isyanqi){
var txt = rtime2txt(yqrt);
if (txt){
var yqtxt = `<span class="minicard-label card-label-legured" title="延期">延期${txt}</span>`;
}
// var yqtxt = `<span class="minicard-label card-label-legured" title="延期">延期${info.event.extendedProps.yanqiday}天 ${info.event.extendedProps.yanqiRt}</span>`;
$(info.el).prepend(yqtxt);
}
// var tooltip = new Tooltip(info.el, {
// title: info.event.extendedProps.description,
// placement: 'top',
// trigger: 'hover',
// container: 'body'
// });
}
// events: function(info,success,failure){
// console.log('==========');
// console.log(info);
// success(function () {
// return [
// {allDay: true,
// boardid: "5bbdbf66031d2",
// end: "2019-05-11",
// resourceId: "5cd52386c5363",
// start: "2019-05-09",
// title: "地牢冒险",
// url: "./?app=list&boardid=5bbdbf66031d2#cardid=5c63af7623239"}
// ]
// });
//
// },
});
calendar.render();
// setTimeout(function () {
// $('.fc-expander').click();
// }, 100);
})
}
function closeCardListTimeline(){
$('#cardListTimelineMask').remove();
$('#cardListTimeline').remove();
}
function getLabelsData(labelsId,labels){
var res = '';
labels.forEach(function (ele) {
if (ele._id == labelsId){
res = ele
}
});
return res
}
// 时间转字符串 天 小时 分钟
function rtime2txt(rt) {
var txt = '';
// 天
if (rt > 24*3600){
txt = parseInt(rt/(24*3600)) + '天';
// 小时
}else if (rt > 3600){
txt = parseInt(rt/3600) + '小时'
// 分钟
}else if(rt > 60){
txt = parseInt(rt/60) + '分钟'
}else {
txt = rt + '秒'
}
return txt
}
$(function(){
$('body').on("click","#cardListTimelineMask",function(){
closeCardListTimeline();
});
$('body').on("click","#cardTimelineClose",function(){
closeCardListTimeline();
});
$('body').on('click','.card-list-timeline-event-open',function () {
showCard( $(this).data('id') );
// closeCardListTimeline();
});
$('body').on('click','#cardListTimeline',function () {
closeCardInfo();
})
});