* Code for execution dtable.

This commit is contained in:
Yagami
2023-02-09 14:10:27 +08:00
parent 1a9c76cfaf
commit d47e5a06f7
4 changed files with 334 additions and 66 deletions
+20 -25
View File
@@ -184,94 +184,89 @@ else
$config->execution->datatable->defaultField = array('id', 'name', 'project', 'PM', 'status', 'progress', 'begin', 'end', 'estimate', 'consumed', 'left', 'burn');
}
$config->execution->datatable->fieldList['id']['title'] = 'idAB';
$config->execution->datatable->fieldList['id']['fixed'] = 'left';
$config->execution->datatable->fieldList['id']['width'] = '70';
$config->execution->datatable->fieldList['id']['required'] = 'yes';
$config->execution->datatable->fieldList['id']['sortType'] = true;
$config->execution->datatable->fieldList['name']['title'] = 'execName';
$config->execution->datatable->fieldList['name']['fixed'] = 'left';
$config->execution->datatable->fieldList['name']['width'] = 'auto';
$config->execution->datatable->fieldList['name']['required'] = 'yes';
$config->execution->datatable->fieldList['project']['title'] = 'project';
$config->execution->datatable->fieldList['project']['fixed'] = 'no';
$config->execution->datatable->fieldList['project']['width'] = '128';
$config->execution->datatable->fieldList['project']['required'] = 'no';
$config->execution->datatable->fieldList['name']['name'] = 'name';
$config->execution->datatable->fieldList['name']['title'] = $lang->execution->name;
$config->execution->datatable->fieldList['name']['width'] = 356;
$config->execution->datatable->fieldList['name']['type'] = 'html';
$config->execution->datatable->fieldList['name']['flex'] = 1;
$config->execution->datatable->fieldList['name']['fixed'] = 'left';
$config->execution->datatable->fieldList['name']['nestedToggle'] = true;
$config->execution->datatable->fieldList['name']['checkbox'] = true;
$config->execution->datatable->fieldList['name']['iconRender'] = true;
$config->execution->datatable->fieldList['name']['sortType'] = true;
$config->execution->datatable->fieldList['name']['required'] = 'yes';
if(!isset($config->setCode) or $config->setCode == 1)
{
$config->execution->datatable->fieldList['code']['title'] = 'execCode';
$config->execution->datatable->fieldList['code']['fixed'] = 'no';
$config->execution->datatable->fieldList['code']['width'] = '95';
$config->execution->datatable->fieldList['code']['width'] = '120';
$config->execution->datatable->fieldList['code']['fixed'] = 'left';
$config->execution->datatable->fieldList['code']['required'] = 'no';
}
$config->execution->datatable->fieldList['project']['title'] = 'project';
$config->execution->datatable->fieldList['project']['width'] = '200';
$config->execution->datatable->fieldList['project']['required'] = 'no';
$config->execution->datatable->fieldList['status']['title'] = 'execStatus';
$config->execution->datatable->fieldList['status']['fixed'] = 'no';
$config->execution->datatable->fieldList['status']['type'] = 'status';
$config->execution->datatable->fieldList['status']['width'] = '100';
$config->execution->datatable->fieldList['status']['required'] = 'no';
$config->execution->datatable->fieldList['PM']['title'] = 'owner';
$config->execution->datatable->fieldList['PM']['fixed'] = 'no';
$config->execution->datatable->fieldList['PM']['width'] = '70';
$config->execution->datatable->fieldList['PM']['required'] = 'no';
$config->execution->datatable->fieldList['openedDate']['title'] = 'openedDate';
$config->execution->datatable->fieldList['openedDate']['fixed'] = 'no';
$config->execution->datatable->fieldList['openedDate']['width'] = '85';
$config->execution->datatable->fieldList['openedDate']['required'] = 'no';
$config->execution->datatable->fieldList['begin']['title'] = 'begin';
$config->execution->datatable->fieldList['begin']['fixed'] = 'no';
$config->execution->datatable->fieldList['begin']['width'] = '100';
$config->execution->datatable->fieldList['begin']['required'] = 'no';
$config->execution->datatable->fieldList['end']['title'] = 'end';
$config->execution->datatable->fieldList['end']['fixed'] = 'no';
$config->execution->datatable->fieldList['end']['width'] = '90';
$config->execution->datatable->fieldList['end']['required'] = 'no';
$config->execution->datatable->fieldList['realBegan']['title'] = 'realBegan';
$config->execution->datatable->fieldList['realBegan']['fixed'] = 'no';
$config->execution->datatable->fieldList['realBegan']['width'] = '90';
$config->execution->datatable->fieldList['realBegan']['required'] = 'no';
$config->execution->datatable->fieldList['realBegan']['sort'] = 'no';
$config->execution->datatable->fieldList['realEnd']['title'] = 'realEnd';
$config->execution->datatable->fieldList['realEnd']['fixed'] = 'no';
$config->execution->datatable->fieldList['realEnd']['width'] = '90';
$config->execution->datatable->fieldList['realEnd']['required'] = 'no';
$config->execution->datatable->fieldList['realEnd']['sort'] = 'no';
$config->execution->datatable->fieldList['estimate']['title'] = 'estimate';
$config->execution->datatable->fieldList['estimate']['fixed'] = 'no';
$config->execution->datatable->fieldList['estimate']['width'] = '70';
$config->execution->datatable->fieldList['estimate']['required'] = 'no';
$config->execution->datatable->fieldList['estimate']['sort'] = 'no';
$config->execution->datatable->fieldList['consumed']['title'] = 'consumed';
$config->execution->datatable->fieldList['consumed']['fixed'] = 'no';
$config->execution->datatable->fieldList['consumed']['width'] = '75';
$config->execution->datatable->fieldList['consumed']['required'] = 'no';
$config->execution->datatable->fieldList['consumed']['sort'] = 'no';
$config->execution->datatable->fieldList['left']['title'] = 'left';
$config->execution->datatable->fieldList['left']['fixed'] = 'no';
$config->execution->datatable->fieldList['left']['width'] = '70';
$config->execution->datatable->fieldList['left']['required'] = 'no';
$config->execution->datatable->fieldList['left']['sort'] = 'no';
$config->execution->datatable->fieldList['progress']['title'] = 'progress';
$config->execution->datatable->fieldList['progress']['fixed'] = 'no';
$config->execution->datatable->fieldList['progress']['type'] = 'circleProgress';
$config->execution->datatable->fieldList['progress']['width'] = '70';
$config->execution->datatable->fieldList['progress']['required'] = 'no';
$config->execution->datatable->fieldList['progress']['sort'] = 'no';
$config->execution->datatable->fieldList['burn']['title'] = 'burn';
$config->execution->datatable->fieldList['burn']['fixed'] = 'no';
$config->execution->datatable->fieldList['burn']['width'] = '80';
$config->execution->datatable->fieldList['burn']['required'] = 'no';
$config->execution->datatable->fieldList['burn']['sort'] = 'no';
+144
View File
@@ -0,0 +1,144 @@
$(function()
{
$("#" + status + "Tab").addClass('btn-active-text');
$(document).on('click', '.plan-toggle', function(e)
{
var id = $(this).data('id');
var $toggle = $(this);
var isCollapsed = $toggle.toggleClass('collapsed').hasClass('collapsed');
$toggle.closest('#executionsForm').find('tr.parent-' + id).toggle(!isCollapsed);
e.stopPropagation();
e.preventDefault();
});
if($('#executionList thead th.c-name').width() < 260) $('#executionList thead th.c-name').width(260);
$('#executionTableList').on('sort.sortable', function(e, data)
{
var list = '';
for(i = 0; i < data.list.length; i++) list += $(data.list[i].item).attr('data-id') + ',';
$.post(createLink('execution', 'updateOrder'), {'executions' : list, 'orderBy' : orderBy});
});
toggleFold('#executionsForm', unfoldExecutions, 0, 'execution');
$('.table td.has-child > .plan-toggle').each(function()
{
var fold = $(this).hasClass('collapsed');
var parentID = $(this).closest('tr').attr('data-id');
if(fold)
{
$('.parent-' + parentID).hide();
$(this).closest('td').removeClass('parent');
}
else
{
$('.parent-' + parentID).show();
$(this).closest('td').addClass('parent');
}
});
/* Expand and fold substages. */
$('.table td.has-child > .plan-toggle').click(function()
{
var parentID = $(this).closest('tr').attr('data-id');
$('.parent-' + parentID).toggle();
if($('.parent-' + parentID).css('display') == 'none')
{
$(this).closest('td').removeClass('parent');
}
else
{
$(this).closest('td').addClass('parent');
}
});
$(document).on('click', "#toggleFold", function()
{
var fold = $(this).hasClass('collapsed');
if(fold)
{
$('.has-child.c-name.flex').removeClass('parent');
$('.table td.has-child > .plan-toggle').addClass('collapsed');
}
else
{
$('.has-child.c-name.flex').addClass('parent');
$('.table td.has-child > .plan-toggle').removeClass('collapsed');
}
});
/* Update table summary text. */
$('#executionsForm').table(
{
statisticCreator: function(table)
{
var $table = table.getTable();
var $checkedRows = $table.find(table.isDataTable ? '.datatable-row-left.checked' : 'tbody>tr.checked');
var $originTable = table.isDataTable ? table.$.find('.datatable-origin') : null;
var checkedTotal = $checkedRows.length;
var $rows = checkedTotal ? $checkedRows : $table.find(table.isDataTable ? '.datatable-rows .datatable-row-left' : 'tbody>tr');
var checkedWait = 0;
var checkedDoing = 0;
var executionIDList = [];
$rows.each(function()
{
var $row = $(this);
if($originTable) $row = $originTable.find('tbody>tr[data-id="' + $row.data('id') + '"]');
var data = $row.data();
executionIDList.push(data.id);
if(data.status === 'wait') checkedWait++;
if(data.status === 'doing') checkedDoing++;
});
if(status != 'all') return (checkedTotal ? checkedExecutions : executionSummary).replace('%s', $rows.length);
return (checkedTotal ? checkedSummary : pageSummary).replace('%total%', $rows.length).replace('%wait%', checkedWait).replace('%doing%', checkedDoing);
}
})
$('input[name^="showEdit"]').click(function()
{
$.cookie('showExecutionBatchEdit', $(this).is(':checked') ? 1 : 0, {expires: config.cookieLife, path: config.webRoot});
setCheckbox();
});
setCheckbox();
$('#executionTableList tr').on('click', function(e)
{
if($.cookie('showExecutionBatchEdit') != 1) e.stopPropagation();
});
});
/**
* Location to product list.
*
* @param int productID
* @param int projectID
* @param string status
* @access public
* @return void
*/
function byProduct(productID, projectID, status)
{
location.href = createLink('project', 'all', "status=" + status + "&project=" + projectID + "&orderBy=" + orderBy + '&productID=' + productID);
}
/**
* Set batch edit checkbox.
*
* @access public
* @return void
*/
function setCheckbox()
{
$('#executionsForm .checkbox-primary').hide();
$('.check-all, .sortable tr').removeClass('checked');
$(":checkbox[name^='executionIDList']").prop('checked', false);
$('#executionsForm').removeClass('has-row-checked');
if($.cookie('showExecutionBatchEdit') == 1) $('#executionsForm .checkbox-primary').show();
}
+78
View File
@@ -5158,6 +5158,84 @@ class executionModel extends model
}
}
public function generateCol()
{
$this->loadModel('datatable');
$setting = '';
if(isset($this->config->datatable->executionAll->cols)) $setting = json_decode($this->config->datatable->executionAll->cols);
$fieldList = $this->config->execution->datatable->fieldList;
foreach($fieldList as $field => $items)
{
$title = zget($this->lang->execution, $items['title'], zget($this->lang, $items['title'], $items['title']));
$fieldList[$field]['title'] = $title;
}
if(empty($setting))
{
$setting = $this->config->execution->datatable->defaultField;
$order = 1;
foreach($setting as $key => $value)
{
$id = $value;
$set = new stdclass();;
$set->order = $order++;
$set->show = true;
$set->name = $value;
$set->title = $fieldList[$id]['title'];
if(isset($fieldList[$id]['checkbox'])) $set->nestedToggle = $fieldList[$id]['checkbox'];
if(isset($fieldList[$id]['nestedToggle'])) $set->nestedToggle = $fieldList[$id]['nestedToggle'];
if(isset($fieldList[$id]['fixed'])) $set->fixed = $fieldList[$id]['fixed'];
if(isset($fieldList[$id]['width'])) $set->width = $fieldList[$id]['width'];
if(isset($fieldList[$id]['type'])) $set->type = $fieldList[$id]['type'];
if(isset($fieldList[$id]['sortType'])) $set->sortType = $fieldList[$id]['sortType'];
if(isset($fieldList[$id]['flex'])) $set->flex = $fieldList[$id]['flex'];
if(isset($fieldList[$id]['minWidth'])) $set->minWidth = $fieldList[$id]['minWidth'];
if(isset($fieldList[$id]['maxWidth'])) $set->maxWidth = $fieldList[$id]['maxWidth'];
if(isset($fieldList[$id]['pri'])) $set->pri = $fieldList[$id]['pri'];
$setting[$key] = $set;
}
}
else
{
foreach($setting as $key => $set)
{
if($set->id == 'actions') $set->width = $fieldList[$set->id]['width'];
$set->title = $fieldList[$set->id]['title'];
if(isset($fieldList[$id]['sortType'])) $set->sortType = $fieldList[$id]['sortType'];
}
}
usort($setting, array('datatableModel', 'sortCols'));
return $setting;
}
public function generateRow($executions, $users, $productID)
{
$canBatchEdit = common::hasPriv('execution', 'batchEdit');
foreach($executions as $id => $execution)
{
$label = $execution->type == 'stage' ? 'label-warning' : 'label-info';
$link = $execution->type == 'kanban' ? helper::createLink('execution', 'kanban', "id=$execution->id") : helper::createLink('execution', 'task', "id=$execution->id");
$execution->name = "<span class='project-type-label label label-outline $label'>{$this->lang->execution->typeList[$execution->type]}</span> " . html::a($link, $execution->name);
$execution->project = $execution->projectName;
$execution->status = zget($this->lang->execution->statusList, $execution->status);
$execution->PM = zget($users, $execution->PM);
$execution->progress = $execution->hours->progress;
$execution->estimate = $execution->hours->totalEstimate;
$execution->consumed = $execution->hours->totalConsumed;
$execution->left = $execution->hours->totalLeft;
}
return $executions;
}
/*
* Build search form
*
+92 -41
View File
@@ -1,47 +1,98 @@
<?php include '../../common/view/header.html.php';?>
<?php js::import($jsRoot . 'dtable/min.js'); ?>
<?php css::import($jsRoot . 'dtable/min.css'); ?>
<?php
$setting = $this->datatable->getSetting('execution');
$widths = $this->datatable->setFixedFieldWidth($setting);
js::import($jsRoot . 'dtable/min.js');
css::import($jsRoot . 'dtable/min.css');
$cols = $this->execution->generateCol();
$executions = $this->execution->generateRow($executionStats, $users, $productID);
js::set('cols', json_encode($cols));
js::set('data', json_encode($executions));
js::set('orderBy', $orderBy);
js::set('status', $status);
js::set('unfoldExecutions', array());
js::set('from', $from);
/* Replace Iteration to Execution. */
js::set('checkedSummary', str_replace($lang->executionCommon, $lang->execution->common, $lang->execution->checkedExecSummary));
js::set('pageSummary', str_replace($lang->executionCommon, $lang->execution->common, $lang->execution->pageExecSummary));
js::set('executionSummary', str_replace($lang->executionCommon, $lang->execution->common, $lang->execution->executionSummary));
js::set('checkedExecutions', str_replace($lang->executionCommon, $lang->execution->common, $lang->execution->checkedExecutions));
/* Set unfold parent executionID. */
js::set('unfoldAll', $lang->execution->treeLevel['all']);
js::set('foldAll', $lang->execution->treeLevel['root']);
js::set('isCNLang', !$this->loadModel('common')->checkNotCN())
?>
<div id="myTable"></div>
<script>
// 定义一个方法用于渲染操作列单元格内的操作按钮
//const renderActions = (result, rowID, col, rowData) => {
// return [{
// html: rowData[col.name].map(action => {
// const actionNames = {start: '开始', close: '关闭', edit: '编辑'};
// return `<a href="#action=${action}">${actionNames[action] || action}</a>`;
// }).join(' '),
// }];
//};
<?php $canBatchEdit = common::hasPriv('execution', 'batchEdit');?>
<div id='mainMenu' class='clearfix'>
<div class='btn-toolBar pull-left'>
<?php if($from == 'project'):?>
<div class='btn-group'>
<?php $viewName = $productID != 0 ? zget($productList,$productID) : $lang->product->allProduct;?>
<a href='javascript:;' class='btn btn-link btn-limit' data-toggle='dropdown'><span class='text' title='<?php echo $viewName;?>'><?php echo $viewName;?></span> <span class='caret'></span></a>
<ul class='dropdown-menu' style='max-height:240px; max-width: 300px; overflow-y:auto'>
<?php
$class = '';
if($productID == 0) $class = 'class="active"';
echo "<li $class>" . html::a($this->createLink('project', 'execution', "status=$status&orderby=$orderBy"), $lang->product->allProduct) . "</li>";
foreach($productList as $key => $product)
{
$class = $productID == $key ? 'class="active"' : '';
echo "<li $class>" . html::a($this->createLink('project', 'execution', "status=$status&orderby=$orderBy&productID=$key"), $product) . "</li>";
}
?>
</ul>
</div>
<?php endif;?>
<?php common::sortFeatureMenu();?>
<?php foreach($lang->execution->featureBar['all'] as $key => $label):?>
<?php $label = "<span class='text'>$label</span>";?>
<?php if($status == $key) $label .= " <span class='label label-light label-badge'>{$pager->recTotal}</span>";?>
<?php echo html::a($this->createLink($this->app->rawModule, $this->app->rawMethod, "status=$key&orderBy=$orderBy&productID=$productID"), $label, '', "class='btn btn-link' id='{$key}Tab' data-app='$from'");?>
<?php endforeach;?>
<?php if($canBatchEdit) echo html::checkbox('showEdit', array('1' => $lang->execution->editAction), $showBatchEdit);?>
<a class="btn btn-link querybox-toggle" id='bysearchTab'><i class="icon icon-search muted"></i> <?php echo $lang->execution->byQuery;?></a>
</div>
<div class='btn-toolbar pull-right'>
<?php common::printLink('execution', 'export', "status=$status&productID=$productID&orderBy=$orderBy&from=$from", "<i class='icon-export muted'> </i> " . $lang->export, '', "class='btn btn-link export'")?>
<?php if(common::hasPriv('execution', 'create')) echo html::a($this->createLink('execution', 'create'), "<i class='icon icon-sm icon-plus'></i> " . ($from == 'execution' ? $lang->execution->createExec : $lang->execution->create), '', "class='btn btn-primary create-execution-btn' data-app='execution' onclick='$(this).removeAttr(\"data-toggle\")'");?>
</div>
</div>
// 定义数据表格初始化选项
const options = {
height: 400,
width: '100%',
striped: true,
cols: [
{name: 'id', title: 'ID', width: 60, fixed: 'left', sortType: true},
{name: 'project', title: '项目名称', width: 600, fixed: 'left'},
{name: 'manager', title: '负责人', width: 60},
{name: 'storyPoints', title: '需求规模', width: 80, align: 'center'},
{name: 'executionCounts', title: '执行数', width: 70, align: 'center'},
{name: 'investedDays', title: '已投入', width: 70, align: 'center'},
{name: 'startDate', title: '开始日期', width: 90, align: 'center'},
{name: 'finishDate', title: '完成日期', width: 90, align: 'center'},
{name: 'progress', title: '进度', width: 65, align: 'center'},
],
data: [
{id: 1, project: '禅道开源版', manager: '李明', storyPoints: 1024, executionCounts: 42, investedDays: 32, startDate: '2022-05-03', finishDate: '2022-09-20', progress: 55},
{id: 2, project: '禅道企业版', manager: 'Zhang Giao', storyPoints: 1024, executionCounts: 42, investedDays: 32, startDate: '2022-05-03', finishDate: '2022-09-20', progress: 55},
{id: 2, project: '禅道旗舰版', manager: 'HAHAHA', storyPoints: 1024, executionCounts: 42, investedDays: 32, startDate: '2022-05-03', finishDate: '2022-09-20', progress: 55},
],
};
// 初始化数据表格
$('#myTable').dtable(options);
</script>
<div id='mainContent' class="main-row fade">
<div class="cell<?php if($status == 'bySearch') echo ' show';?>" id="queryBox" data-module='execution'></div>
<?php if(empty($executionStats)):?>
<div class="table-empty-tip">
<p>
<span class="text-muted"><?php echo $from == 'execution' ? $lang->execution->noExecutions : $lang->execution->noExecution;?></span>
<?php if(empty($allExecutionsNum)):?>
<?php if(common::hasPriv('execution', 'create')):?>
<?php echo html::a($this->createLink('execution', 'create'), "<i class='icon icon-plus'></i> " . ($from == 'execution' ? $lang->execution->createExec : $lang->execution->create), '', "class='btn btn-info' data-app='execution'");?>
<?php endif;?>
<?php endif;?>
</p>
</div>
<?php else:?>
<form class='main-table' id='executionsForm' method='post' action='<?php echo inLink('batchEdit');?>'>
<div id="myTable"></div>
<div class='table-footer'>
<?php $pager->show('right', 'pagerjs');?>
</div>
</form>
<script>
cols = JSON.parse(cols);
data = JSON.parse(data);
const options = {
height: 'auto',
striped: true,
cols: cols,
data: data,
};
$('#myTable').dtable(options);
</script>
<?php endif;?>
</div>
<?php include '../../common/view/footer.html.php';?>