* Merge: Finish task #103981, In a non-iterative project, multiple test tasks can generate a test report.

This commit is contained in:
hufangzhou
2023-11-03 15:22:47 +08:00
parent 3f1b5c6890
commit a23e557589
3 changed files with 103 additions and 7 deletions
+6 -5
View File
@@ -387,11 +387,12 @@ $config->project->dtable->testtask->fieldList['product']['title'] = $lang->testt
$config->project->dtable->testtask->fieldList['product']['type'] = 'text';
$config->project->dtable->testtask->fieldList['product']['group'] = '1';
$config->project->dtable->testtask->fieldList['id']['name'] = 'id';
$config->project->dtable->testtask->fieldList['id']['title'] = $lang->idAB;
$config->project->dtable->testtask->fieldList['id']['type'] = 'id';
$config->project->dtable->testtask->fieldList['id']['group'] = '2';
$config->project->dtable->testtask->fieldList['id']['fixed'] = false;
$config->project->dtable->testtask->fieldList['id']['name'] = 'id';
$config->project->dtable->testtask->fieldList['id']['title'] = $lang->idAB;
$config->project->dtable->testtask->fieldList['id']['type'] = 'id';
$config->project->dtable->testtask->fieldList['id']['checkbox'] = true;
$config->project->dtable->testtask->fieldList['id']['group'] = '2';
$config->project->dtable->testtask->fieldList['id']['fixed'] = false;
$config->project->dtable->testtask->fieldList['title']['name'] = 'name';
$config->project->dtable->testtask->fieldList['title']['title'] = $lang->testtask->name;
+74
View File
@@ -4,6 +4,26 @@ $(function()
initialOptions = $.extend(true, {}, options);
});
$(document).off('click','.batch-btn').on('click', '.batch-btn', function()
{
const dtable = zui.DTable.query($(this).target);
const checkedList = dtable.$.getChecks();
if(!checkedList.length) return;
const url = $(this).data('url');
const form = new FormData();
checkedList.forEach((id) => form.append('taskIdList[]', id));
if($(this).hasClass('ajax-btn'))
{
$.ajaxSubmit({url, data: form});
}
else
{
postAndLoadPage(url, form);
}
})
/**
* 产品列合并单元格。
* Merge cell in the product column.
@@ -104,3 +124,57 @@ window.deformation = function(event)
$('#taskTable').zui('dtable').render();
}
}
/**
* 计算测试单表格信息的统计。
* Set task summary for table footer.
*
* @param element element
* @param array checkedIDList
* @access public
* @return object
*/
window.setStatistics = function(element, checkedIDList)
{
let waitCount = 0;
let doingCount = 0;
let doneCount = 0;
let blockedCount = 0;
let totalCount = 0;
const rows = element.layout.allRows;
rows.forEach((row) => {
if(checkedIDList.length == 0 || checkedIDList.includes(row.id))
{
const task = row.data;
if(task.status == 'wait')
{
waitCount ++;
}
else if(task.status == 'doing')
{
doingCount ++;
}
else if(task.status == 'done')
{
doneCount ++;
}
else if(task.status == 'blocked')
{
blockedCount ++;
}
totalCount ++;
}
})
const summary = checkedIDList.length > 0 ? checkedAllSummary : pageSummary;
return {
html: summary.replace('%total%', totalCount)
.replace('%wait%', waitCount)
.replace('%testing%', doingCount)
.replace('%blocked%', blockedCount)
.replace('%done%', doneCount)
};
}
+23 -2
View File
@@ -11,6 +11,9 @@ declare(strict_types=1);
namespace zin;
jsVar('allTasks', $lang->testtask->allTasks);
jsVar('pageSummary', sprintf($lang->testtask->allSummary, count($tasks), $waitCount, $testingCount, $blockedCount, $doneCount));
jsVar('checkedAllSummary', $lang->testtask->checkedAllSummary);
featureBar
(
li
@@ -39,6 +42,18 @@ toolbar
$config->project->dtable->testtask->fieldList['actions']['list']['report']['url']['params'] = "objectID={project}&objectType=project&extra={id}";
$tasks = initTableData($tasks, $config->project->dtable->testtask->fieldList);
$summary = sprintf($lang->testtask->allSummary, count($tasks), $waitCount, $testingCount, $blockedCount, $doneCount);
$footToolbar = array();
if(common::canModify('project', $project) and common::hasPriv('project', 'testreport'))
{
$footToolbar = array('items' => array
(
array('text' => $lang->testreport->common, 'className' => 'batch-btn', 'data-url' => createLink('project', 'testreport', "objectID={$project->id}&objctType=project"))
), 'btnProps' => array('size' => 'sm', 'btnType' => 'secondary'));
}
if($project->multiple) $config->project->dtable->testtask->fieldList['id']['checkbox'] = false;
dtable
(
set::id('taskTable'),
@@ -51,8 +66,14 @@ dtable
set::plugins(array('cellspan')),
set::getCellSpan(jsRaw('window.getCellSpan')),
set::fixedLeftWidth('20%'),
set::footer(array(array('html' => $summary), 'flex', 'pager')),
set::footPager(usePager()),
$project->multiple ? set::footer(array(array('html' => $summary), 'flex', 'pager')) : set::footToolbar($footToolbar),
set::footPager(usePager(array
(
'recPerPage' => $pager->recPerPage,
'recTotal' => $pager->recTotal,
'linkCreator' => helper::createLink('project', 'testtask', "projectID={$project->id}&orderBy={$orderBy}&recTotal={$pager->recTotal}&recPerPage={recPerPage}&page={page}")
))),
set::checkInfo(jsRaw('function(checkedIDList){return window.setStatistics(this, checkedIDList);}')),
);
render();