* Refactor batch action of the plan list.

This commit is contained in:
tianshujie
2023-09-26 09:46:21 +08:00
parent d695992f1b
commit e092991ece
2 changed files with 57 additions and 8 deletions
+7 -8
View File
@@ -115,21 +115,21 @@ window.deleteProductPlan = function(planID)
$(document).off('click', '.batch-btn').on('click', '.batch-btn', function()
{
const $this = $(this);
const dtable = zui.DTable.query($('#planList'));
const dtable = zui.DTable.query($(this).target);
const checkedList = dtable.$.getChecks();
if(!checkedList.length) return;
const postData = new FormData();
checkedList.forEach((id) => postData.append('planIdList[]', id));
const url = $(this).data('url');
const form = new FormData();
checkedList.forEach((id) => form.append('planIdList[]', id));
if($(this).data('page') == 'batch')
if($(this).hasClass('ajax-btn'))
{
postAndLoadPage($(this).data('formaction'), postData);
$.ajaxSubmit({url, data: form});
}
else
{
$.ajaxSubmit({"url": $(this).data('formaction'), "data": postData});
postAndLoadPage(url, form);
}
});
@@ -182,7 +182,6 @@ window.renderCell = function(result, info)
content = content.replace(/"/g, '"');
const buttonHtml = `<button type='button' data-toggle='popover' data-trigger='click' data-content="${content}" data-close-btn='false' data-placement='right'><i class='icon-run text-primary'></i></button>`;
console.log(buttonHtml);
result[0] = {html: buttonHtml};
}
}
@@ -29,12 +29,62 @@ $canCreatePlan ? toolbar
$cols = $this->loadModel('datatable')->getSetting('productplan');
$tableData = initTableData($plans, $cols, $this->productplan);
$canBatchEdit = common::hasPriv('productplan', 'batchEdit');
$canBatchChangeStatus = common::hasPriv('productplan', 'batchChangeStatus');
$canBatchAction = $canBatchEdit || $canBatchChangeStatus;
$footToolbar = array();
if($canBatchAction)
{
if($canBatchEdit)
{
$footToolbar['items'][] = array(
'text' => $lang->edit,
'className' => 'btn batch-btn size-sm secondary',
'data-url' => $this->createLink('productplan', 'batchEdit', "productID={$productID}&branch={$branch}")
);
}
if($canBatchChangeStatus)
{
$items = array();
foreach($lang->productplan->statusList as $statusKey => $statusText)
{
$items[$statusKey] = array
(
'text' => $statusText,
'class' => 'batch-btn',
'data-url' => createLink('productplan', 'batchChangeStatus', "status={$statusKey}&productID={$productID}"),
);
if($statusKey == 'closed') $items[$statusKey]['data-page'] = 'batch';
}
menu
(
set::id('navStatus'),
set::className('dropdown-menu'),
set::items(array_values($items))
);
$footToolbar['items'][] = array(
'text' => $lang->statusAB,
'btnType' => 'secondary',
'caret' => 'up',
'url' => '#navStatus',
'data-toggle' => 'dropdown',
'data-placement' => 'top-start',
);
}
}
dtable
(
set::cols($cols),
set::data($tableData),
set::customCols(true),
set::onRenderCell(jsRaw('window.renderCell')),
set::footToolbar($footToolbar),
set::checkInfo(jsRaw('function(checkedIDList){return window.setStatistics(this, checkedIDList);}')),
set::footPager(
usePager(array('linkCreator' => createLink($app->rawModule, 'browse', "productID={$productID}&branch={$branch}&browseType={$browseType}&queryID={$queryID}&orderBy={$orderBy}&recTotal={$pager->recTotal}&recPerPage={recPerPage}&pageID={page}"))),