* Add dtable.

This commit is contained in:
Yagami
2023-02-08 17:45:51 +08:00
parent b0d4622093
commit 7d5d82693a
6 changed files with 328 additions and 147 deletions
+131
View File
@@ -0,0 +1,131 @@
<?php if($extView = $this->getExtViewFile(__FILE__)){include $extView; return helper::cd();}?>
<?php js::import($jsRoot . 'dtable/min.js'); ?>
<?php css::import($jsRoot . 'dtable/min.css'); ?>
<?php if(!empty($lang->datatable)):?>
<style>
.datatable {margin-bottom: 0;}
.datatable .table>tbody>tr>td, .datatable .table>thead>tr>th {line-height: 29px; padding-top: 2px; padding-bottom: 2px; height: 36px; vertical-align: middle; white-space: nowrap;}
.datatable .table>tbody>tr.hover {box-shadow: none!important;}
.datatable .flexarea .table-children,
.datatable .fixed-left .table-children {border-right: none;}
.datatable .flexarea .table-children,
.datatable .fixed-right .table-children {border-left: none;}
.datatable tr.hover td.c-actions .more {display: block; background-color: #ebf2f9}
.datatable .fixed-left .table,
.datatable .flexarea .table,
.datatable .flexarea tbody > tr.checked,
.datatable .fixed-left tbody > tr.checked {border-top-right-radius: 0; border-bottom-right-radius: 0;}
.datatable .flexarea tbody > tr.checked,
.datatable .fixed-right .table,
.datatable .flexarea .table,
.datatable .fixed-right tbody > tr.checked {border-top-left-radius: 0; border-bottom-left-radius: 0;}
.datatable .flexarea tbody>tr.checked>td:first-child:before,
.datatable .fixed-right tbody>tr.checked>td:first-child:before {display: none}
.datatable>.scroll-wrapper {z-index: 10;}
.has-fixed-footer .scroll-wrapper {bottom: 49px; position: fixed;}
.has-fixed-footer .scroll-wrapper .scroll-slide.scroll-pos-out{height:8px;bottom: -8px;}
.has-fixed-footer .scroll-wrapper .scroll-slide.scroll-pos-out .bar{height:8px;}
.datatable .flexarea thead>tr>th:first-child,
.datatable .flexarea tbody>tr>td:first-child,
.datatable .fixed-right thead>tr>th:first-child,
.datatable .fixed-right tbody>tr>td {padding-left: 5px!important;}
.datatable .c-actions {white-space: nowrap;}
.datatable.head-fixed {padding-top: 41px;}
.datatable .table>thead>tr>th.col-hover {background: rgba(0,0,0,.07);}
</style>
<script>
<?php $datatableId = $this->moduleName . ucfirst($this->methodName);?>
var datatableOptions =
{
customizable : false,
sortable : false,
scrollPos : 'out',
tableClass : 'tablesorter',
storage : false,
fixCellHeight : false,
selectable : false,
fixedHeader: true,
ready: function()
{
this.$table.addClass('datatable-origin');
if (this.$table.hasClass('has-sort-head'))
{
this.$datatable.find('.table').addClass('has-sort-head');
}
this.$datatable.find('.sparkline').sparkline();
$('.progress-pie').progressPie();
}
};
/**
* Init datatable.
*
* @param int $datatable
* @access public
* @return void
*/
function initDatatable($datatable)
{
$datatable = $datatable || $('table.datatable').first();
if(!$datatable.length || $datatable.data('zui.datatable')) return null;
var $datatable = $('table.datatable').first();
var datatableId = $datatable.attr('id');
var dtSetting = $.cookie('datatable.<?php echo $datatableId?>' + '.cols') || {};
if(dtSetting === 'null') dtSetting = {};
if(typeof dtSetting === 'string') dtSetting = $.parseJSON(dtSetting);
$datatable.datatable(datatableOptions);
$datatable.find('thead>tr>th').each(function(idx)
{
var $th = $(this);
idx = $th.data('index') || idx;
var colSetting = dtSetting[idx];
$th.toggleClass('ignore', !!(colSetting && colSetting.ignore));
});
return $datatable;
};
$(document).ready(function()
{
var $datatable = initDatatable();
if($datatable && $datatable.length)
{
$('#main').on('beforeTableReload', '[data-ride="table"]', function()
{
initDatatable($datatable);
});
}
window.saveDatatableConfig = function(name, value, reload, global)
{
if('<?php echo $this->app->user->account?>' == 'guest') return;
var datatableId = '<?php echo $datatableId;?>';
if(typeof value === 'object') value = JSON.stringify(value);
if(typeof global === 'undefined') global = 0;
$.ajax(
{
type: "POST",
dataType: 'json',
data: {target: datatableId, name: name, value: value, global: global},
success:function(e){if(reload) window.location.reload();},
url: '<?php echo $this->createLink('datatable', 'ajaxSave')?>'
});
};
var $modal = $('#customDatatable');
var $checkList = $modal.find('.modal-body > .table > tbody');
$checkList.on('click', 'tr', function()
{
var $tr = $(this);
if($tr.hasClass('disabled')) return;
$tr.toggleClass('checked');
});
$(window).on('fixFooter', function(e, isFixed)
{
$('body').toggleClass('has-fixed-footer', isFixed);
});
});
</script>
<?php endif;?>
+41 -147
View File
@@ -1,151 +1,45 @@
<?php
/**
* The html template file of all method of execution module of ZenTaoPMS.
*
* @copyright Copyright 2009-2015 青岛易软天创网络科技有限公司(QingDao Nature Easy Soft Network Technology Co,LTD, www.cnezsoft.com)
* @license ZPL(http://zpl.pub/page/zplv12.html) or AGPL(https://www.gnu.org/licenses/agpl-3.0.en.html)
* @author Yidong Wang <yidong@cnezsoft.com>
* @package execution
* @version $Id: index.html.php 5094 2013-07-10 08:46:15Z chencongzhi520@gmail.com $
*/
?>
<?php include '../../common/view/header.html.php';?>
<?php include '../../common/view/sortable.html.php';?>
<?php include '../../common/view/datatable.fix.html.php';?>
<?php
$datatableId = $this->moduleName . ucfirst($this->methodName);
$useDatatable = (isset($config->datatable->$datatableId->mode) and $config->datatable->$datatableId->mode == 'datatable');
?>
<?php
js::set('unfoldExecutions', array());
js::set('useDatatable', $useDatatable);
js::set('from', $from);
<?php js::import($jsRoot . 'dtable/min.js'); ?>
<?php css::import($jsRoot . 'dtable/min.css'); ?>
<div id="myTable"></div>
/* 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));
?>
<?php
/* 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())
?>
<?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>
<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 class="table-header fixed-right">
<nav class="btn-toolbar pull-right setting"></nav>
</div>
<?php
$vars = "status=$status&orderBy=%s&productID=$productID&param=$param&recTotal={$pager->recTotal}&recPerPage={$pager->recPerPage}&pageID={$pager->pageID}";
if($useDatatable) include '../../common/view/datatable.html.php';
else include '../../common/view/tablesorter.html.php';
<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(' '),
// }];
//};
$setting = $this->datatable->getSetting('execution');
$widths = $this->datatable->setFixedFieldWidth($setting);
$columns = 0;
?>
<?php if(!$useDatatable) echo '<div class="table-responsive">';?>
<table class='table has-sort-head<?php if($useDatatable) echo ' datatable';?>' id='executionList' data-fixed-left-width='<?php echo $widths['leftWidth']?>' data-fixed-right-width='<?php echo $widths['rightWidth']?>'>
<thead>
<tr>
<?php
foreach($setting as $key => $value)
{
if($value->show)
{
$this->datatable->printHead($value, $orderBy, $vars, $canBatchEdit);
$columns ++;
}
}
?>
</tr>
</thead>
<tbody class='sortable' id='executionTableList'>
<?php foreach($executionStats as $execution):?>
<tr data-id='<?php echo $execution->id ?>' data-order='<?php echo $execution->order ?>' data-status='<?php echo $execution->status?>'>
<?php foreach($setting as $key => $value) $this->execution->printCell($value, $execution, $users, $useDatatable ? 'datatable' : 'table', $isStage, $productID);?>
</tr>
<?php if(!empty($execution->children)):?>
<?php $i = 0;?>
<?php foreach($execution->children as $key => $child):?>
<?php $class = $i == 0 ? ' table-child-top' : '';?>
<?php $class .= ($i + 1 == count($execution->children)) ? ' table-child-bottom' : '';?>
<tr class='table-children<?php echo $class;?> parent-<?php echo $execution->id;?>' data-id='<?php echo $child->id?>'>
<?php foreach($setting as $key => $value) $this->execution->printCell($value, $child, $users, $useDatatable ? 'datatable' : 'table', $isStage, $productID, true);?>
</tr>
<?php $i ++;?>
<?php endforeach;?>
<?php endif;?>
<?php endforeach;?>
</tbody>
</table>
<?php if(!$useDatatable) echo '</div>';?>
<?php if($executionStats):?>
<div class='table-footer'>
<?php if($canBatchEdit):?>
<div class="checkbox-primary check-all"><label><?php echo $lang->selectAll?></label></div>
<div class="table-actions btn-toolbar">
<?php echo html::submitButton($lang->execution->batchEdit, '', 'btn');?>
</div>
<?php endif;?>
<div class="table-statistic"></div>
<?php $pager->show('right', 'pagerjs');?>
</div>
<?php endif;?>
</form>
<?php endif;?>
</div>
<?php js::set('orderBy', $orderBy)?>
<?php js::set('status', $status)?>
// 定义数据表格初始化选项
const options = {
height: 400,
width: '100%',
striped: true,
cols: [
{name: 'id', title: 'ID', width: 60, fixed: 'left', sortType: true},
{name: 'project', title: '项目名称', width: 200, fixed: 'left'},
{name: 'manager', title: '负责人', width: 60, flex: 1},
{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'},
{name: 'actions', title: '操作', width: 100, fixed: 'right'}, // renderActions 为单元格自定义渲染方法
],
data: [
{id: 1, project: '禅道开源版', manager: '李明', storyPoints: 1024, executionCounts: 42, investedDays: 32, startDate: '2022-05-03', finishDate: '2022-09-20', progress: 55, actions: ''},
{id: 2, project: '禅道企业版', manager: 'Zhang Giao', storyPoints: 1024, executionCounts: 42, investedDays: 32, startDate: '2022-05-03', finishDate: '2022-09-20', progress: 55, actions: ''},
{id: 2, project: '禅道旗舰版', manager: 'HAHAHA', storyPoints: 1024, executionCounts: 42, investedDays: 32, startDate: '2022-05-03', finishDate: '2022-09-20', progress: 55, actions: ''},
],
striped: false
};
// 初始化数据表格
$('#myTable').dtable(options);
</script>
<?php include '../../common/view/footer.html.php';?>
+151
View File
@@ -0,0 +1,151 @@
<?php
/**
* The html template file of all method of execution module of ZenTaoPMS.
*
* @copyright Copyright 2009-2015 青岛易软天创网络科技有限公司(QingDao Nature Easy Soft Network Technology Co,LTD, www.cnezsoft.com)
* @license ZPL(http://zpl.pub/page/zplv12.html) or AGPL(https://www.gnu.org/licenses/agpl-3.0.en.html)
* @author Yidong Wang <yidong@cnezsoft.com>
* @package execution
* @version $Id: index.html.php 5094 2013-07-10 08:46:15Z chencongzhi520@gmail.com $
*/
?>
<?php include '../../common/view/header.html.php';?>
<?php include '../../common/view/sortable.html.php';?>
<?php include '../../common/view/datatable.fix.html.php';?>
<?php
$datatableId = $this->moduleName . ucfirst($this->methodName);
$useDatatable = (isset($config->datatable->$datatableId->mode) and $config->datatable->$datatableId->mode == 'datatable');
?>
<?php
js::set('unfoldExecutions', array());
js::set('useDatatable', $useDatatable);
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));
?>
<?php
/* 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())
?>
<?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>
<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 class="table-header fixed-right">
<nav class="btn-toolbar pull-right setting"></nav>
</div>
<?php
$vars = "status=$status&orderBy=%s&productID=$productID&param=$param&recTotal={$pager->recTotal}&recPerPage={$pager->recPerPage}&pageID={$pager->pageID}";
if($useDatatable) include '../../common/view/datatable.html.php';
else include '../../common/view/tablesorter.html.php';
$setting = $this->datatable->getSetting('execution');
$widths = $this->datatable->setFixedFieldWidth($setting);
$columns = 0;
?>
<?php if(!$useDatatable) echo '<div class="table-responsive">';?>
<table class='table has-sort-head<?php if($useDatatable) echo ' datatable';?>' id='executionList' data-fixed-left-width='<?php echo $widths['leftWidth']?>' data-fixed-right-width='<?php echo $widths['rightWidth']?>'>
<thead>
<tr>
<?php
foreach($setting as $key => $value)
{
if($value->show)
{
$this->datatable->printHead($value, $orderBy, $vars, $canBatchEdit);
$columns ++;
}
}
?>
</tr>
</thead>
<tbody class='sortable' id='executionTableList'>
<?php foreach($executionStats as $execution):?>
<tr data-id='<?php echo $execution->id ?>' data-order='<?php echo $execution->order ?>' data-status='<?php echo $execution->status?>'>
<?php foreach($setting as $key => $value) $this->execution->printCell($value, $execution, $users, $useDatatable ? 'datatable' : 'table', $isStage, $productID);?>
</tr>
<?php if(!empty($execution->children)):?>
<?php $i = 0;?>
<?php foreach($execution->children as $key => $child):?>
<?php $class = $i == 0 ? ' table-child-top' : '';?>
<?php $class .= ($i + 1 == count($execution->children)) ? ' table-child-bottom' : '';?>
<tr class='table-children<?php echo $class;?> parent-<?php echo $execution->id;?>' data-id='<?php echo $child->id?>'>
<?php foreach($setting as $key => $value) $this->execution->printCell($value, $child, $users, $useDatatable ? 'datatable' : 'table', $isStage, $productID, true);?>
</tr>
<?php $i ++;?>
<?php endforeach;?>
<?php endif;?>
<?php endforeach;?>
</tbody>
</table>
<?php if(!$useDatatable) echo '</div>';?>
<?php if($executionStats):?>
<div class='table-footer'>
<?php if($canBatchEdit):?>
<div class="checkbox-primary check-all"><label><?php echo $lang->selectAll?></label></div>
<div class="table-actions btn-toolbar">
<?php echo html::submitButton($lang->execution->batchEdit, '', 'btn');?>
</div>
<?php endif;?>
<div class="table-statistic"></div>
<?php $pager->show('right', 'pagerjs');?>
</div>
<?php endif;?>
</form>
<?php endif;?>
</div>
<?php js::set('orderBy', $orderBy)?>
<?php js::set('status', $status)?>
<?php include '../../common/view/footer.html.php';?>
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long