* [refac bug #57891] Set render cell js.

This commit is contained in:
wangyidong
2024-12-23 13:40:45 +08:00
committed by 孙广明
parent ac31c580bf
commit 9162b7f8a9
2 changed files with 44 additions and 0 deletions
+41
View File
@@ -2,3 +2,44 @@ window.waitDom('body.body-modal .toolbar', function()
{
$('.body-modal .toolbar a[data-load="modal"]').attr('data-toggle', 'modal').removeAttr('data-load');
})
window.renderCell = function(result, info)
{
const task = info.row.data;
if(info.col.name == 'name' && result)
{
if(typeof result[0] == 'object') result[0].props.className = 'overflow-hidden';
if(typeof task.delay != 'undefined' && task.delay && !['done', 'cancel', 'close'].includes(task.status))
{
result[result.length] = {html:'<span class="label danger-pale ml-1 flex-none nowrap">' + delayWarning.replace('%s', task.delay) + '</span>', className:'flex items-end', style:{flexDirection:"column"}};
}
}
if(info.col.name == 'deadline' && result[0])
{
if(['done', 'cancel', 'close'].includes(task.status)) return result;
const today = zui.formatDate(zui.createDate(), 'yyyy-MM-dd');
const yesterday = zui.formatDate(convertStringToDate(today) - 24 * 60 * 60 * 1000, 'yyyy-MM-dd');
if(result[0] == today)
{
result[0] = {html: '<span class="label warning-pale rounded-full size-sm">' + todayLabel + '</span>'};
}
else if(result[0] == yesterday)
{
result[0] = {html: '<span class="label danger-pale rounded-full size-sm">' + yesterdayLabel + '</span>'};
}
else if(result[0] < yesterday)
{
result[0] = {html: '<span class="label danger-pale rounded-full size-sm">' + result[0] + '</span>'};
}
}
return result;
}
function convertStringToDate(dateString)
{
dateString = dateString.split('-');
dateString = dateString[1] + '/' + dateString[2] + '/' + dateString[0];
return Date.parse(dateString);
}
+3
View File
@@ -12,6 +12,8 @@ namespace zin;
include($this->app->getModuleRoot() . 'ai/ui/promptmenu.html.php');
jsVar('delayWarning', $lang->task->delayWarning);
$isInModal = isInModal();
/* 初始化头部右上方工具栏。Init detail toolbar. */
@@ -126,6 +128,7 @@ if($task->children)
->control('dtable')
->className('ring')
->defaultNestedState(true)
->onRenderCell(jsRaw('window.renderCell'))
->cols(array_values($config->task->dtable->children->fieldList))
->userMap($users)
->data($children)