diff --git a/module/task/js/view.ui.js b/module/task/js/view.ui.js index 5657c9b1d8..8bb620c3df 100644 --- a/module/task/js/view.ui.js +++ b/module/task/js/view.ui.js @@ -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:'' + delayWarning.replace('%s', task.delay) + '', 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: '' + todayLabel + ''}; + } + else if(result[0] == yesterday) + { + result[0] = {html: '' + yesterdayLabel + ''}; + } + else if(result[0] < yesterday) + { + result[0] = {html: '' + result[0] + ''}; + } + } + return result; +} + +function convertStringToDate(dateString) +{ + dateString = dateString.split('-'); + dateString = dateString[1] + '/' + dateString[2] + '/' + dateString[0]; + + return Date.parse(dateString); +} diff --git a/module/task/ui/view.html.php b/module/task/ui/view.html.php index 799c0af270..4220a9b88c 100644 --- a/module/task/ui/view.html.php +++ b/module/task/ui/view.html.php @@ -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)