|
|
@@ -759,12 +759,19 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
|
|
|
if (!$.isArray(ymList) || !ymList.length) {
|
|
|
return;
|
|
|
}
|
|
|
+ // 月份列表未变则不重绘侧栏,避免搜索刷新时打断焦点
|
|
|
+ var norm = ymList.map(function (ym) {
|
|
|
+ return String(ym || '');
|
|
|
+ }).filter(function (ym) {
|
|
|
+ return /^\d{4}-\d{2}$/.test(ym);
|
|
|
+ });
|
|
|
+ var sig = norm.slice().sort().join(',');
|
|
|
+ if (Controller._sidebarYmSig === sig && $('.procuremen-sidebar .procuremen-ym-item').length) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ Controller._sidebarYmSig = sig;
|
|
|
var byYear = {};
|
|
|
- ymList.forEach(function (ym) {
|
|
|
- ym = String(ym || '');
|
|
|
- if (!/^\d{4}-\d{2}$/.test(ym)) {
|
|
|
- return;
|
|
|
- }
|
|
|
+ norm.forEach(function (ym) {
|
|
|
var y = ym.substring(0, 4);
|
|
|
var mo = parseInt(ym.substring(5, 7), 10) || 1;
|
|
|
if (!byYear[y]) {
|
|
|
@@ -796,12 +803,109 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ function procuremenNormalizeToolbarRight($ft) {
|
|
|
+ if (!$ft || !$ft.length) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ var $search = $ft.find('.search').first();
|
|
|
+ if (!$search.length) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ // 专用右侧容器:不能把 .search 自身当 wrap(.search 的 display 会盖掉 flex,导致搜索与图标折成两行)
|
|
|
+ var $right = $ft.children('.procuremen-toolbar-search-wrap').first();
|
|
|
+ if (!$right.length) {
|
|
|
+ $right = $('<div class="columns columns-right pull-right procuremen-toolbar-search-wrap"></div>');
|
|
|
+ $ft.append($right);
|
|
|
+ } else {
|
|
|
+ $right.addClass('columns columns-right pull-right procuremen-toolbar-search-wrap');
|
|
|
+ }
|
|
|
+ // 若历史上把图标塞进了 .search 里,先拆出来
|
|
|
+ if ($search.hasClass('procuremen-toolbar-search-wrap')) {
|
|
|
+ $search.removeClass('procuremen-toolbar-search-wrap columns columns-right');
|
|
|
+ }
|
|
|
+ $search.children().not('input, .form-control').appendTo($right);
|
|
|
+ if ($search.parent()[0] !== $right[0]) {
|
|
|
+ $search.appendTo($right);
|
|
|
+ }
|
|
|
+
|
|
|
+ $ft.children().each(function () {
|
|
|
+ var $c = $(this);
|
|
|
+ if ($c.is('.bars, .bs-bars') || $c[0] === $right[0] || $c.hasClass('search')) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ var mergeToolbarExtras = $c.hasClass('columns')
|
|
|
+ || $c.hasClass('pull-right')
|
|
|
+ || ($c.hasClass('btn-group') && $c.find('.search').length === 0)
|
|
|
+ || $c.is('button[name="commonSearch"], button[name="toggle"]');
|
|
|
+ if (!mergeToolbarExtras) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ if ($c.hasClass('btn-group') && !$c.hasClass('columns')) {
|
|
|
+ $c.appendTo($right);
|
|
|
+ } else if ($c.is('button')) {
|
|
|
+ $c.appendTo($right);
|
|
|
+ } else {
|
|
|
+ $c.children().appendTo($right);
|
|
|
+ if (!$c.children().length) {
|
|
|
+ $c.remove();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
+ // 顺序:搜索框 → 切换 → 列显隐 → 导出 → 通用搜索(放大镜)
|
|
|
+ // 已在正确位置则勿再 prepend/insert(否则每次刷新会挪动 input,线上输入时反复失焦)
|
|
|
+ $right.addClass('procuremen-toolbar-search-wrap');
|
|
|
+ var $toggle = $right.find('button[name="toggle"]').first();
|
|
|
+ var $columns = $right.find('.keep-open').first();
|
|
|
+ var $export = $right.find('.export').first();
|
|
|
+ var $common = $right.find('button[name="commonSearch"]').first();
|
|
|
+ $search = $right.find('.search').first();
|
|
|
+ function moveIfNeeded($node, $ref, asFirst) {
|
|
|
+ if (!$node || !$node.length) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ if (asFirst) {
|
|
|
+ if ($right.children().first()[0] !== $node[0]) {
|
|
|
+ $node.prependTo($right);
|
|
|
+ }
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ if (!$ref || !$ref.length) {
|
|
|
+ if ($node.parent()[0] !== $right[0]) {
|
|
|
+ $node.appendTo($right);
|
|
|
+ }
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ if ($node.prev()[0] !== $ref[0]) {
|
|
|
+ $node.insertAfter($ref);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ moveIfNeeded($search, null, true);
|
|
|
+ moveIfNeeded($toggle, $search, false);
|
|
|
+ moveIfNeeded($columns, $toggle.length ? $toggle : $search, false);
|
|
|
+ var $afterCols = $columns.length ? $columns : ($toggle.length ? $toggle : $search);
|
|
|
+ moveIfNeeded($export, $afterCols, false);
|
|
|
+ if ($common.length && $right.children().last()[0] !== $common[0]) {
|
|
|
+ $common.appendTo($right);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
function procuremenPlaceToolbar() {
|
|
|
var $host = $('#procuremen-toolbar-host');
|
|
|
var $bt = table.closest('.bootstrap-table');
|
|
|
if (!$host.length || !$bt.length) {
|
|
|
return;
|
|
|
}
|
|
|
+ var $focusInp = $(document.activeElement);
|
|
|
+ var keepSearchFocus = $focusInp.length
|
|
|
+ && $focusInp.is('input')
|
|
|
+ && $focusInp.closest('.search').length
|
|
|
+ && ($focusInp.closest('#procuremen-toolbar-host').length || $focusInp.closest($bt).length);
|
|
|
+ var caretStart = null;
|
|
|
+ var caretEnd = null;
|
|
|
+ if (keepSearchFocus && $focusInp[0] && typeof $focusInp[0].selectionStart === 'number') {
|
|
|
+ caretStart = $focusInp[0].selectionStart;
|
|
|
+ caretEnd = $focusInp[0].selectionEnd;
|
|
|
+ }
|
|
|
$host.show().css({
|
|
|
display: 'block',
|
|
|
height: '',
|
|
|
@@ -823,11 +927,24 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
|
|
|
// 每次都校正右侧顺序,保证贴右且图标顺序与图二一致
|
|
|
procuremenNormalizeToolbarRight($hostFt);
|
|
|
procuremenBindToolbarDropdownFix();
|
|
|
- if (typeof Controller._procuremenApplyStageButtons === 'function') {
|
|
|
- Controller._procuremenApplyStageButtons();
|
|
|
+ if (typeof Controller._procuremenApplyStageButtons === 'function') {
|
|
|
+ Controller._procuremenApplyStageButtons();
|
|
|
+ }
|
|
|
+ if (keepSearchFocus) {
|
|
|
+ var $restore = $host.find('.search input').first();
|
|
|
+ if ($restore.length) {
|
|
|
+ $restore.focus();
|
|
|
+ if (caretStart != null) {
|
|
|
+ try {
|
|
|
+ $restore[0].setSelectionRange(caretStart, caretEnd != null ? caretEnd : caretStart);
|
|
|
+ } catch (ignoreCaret) {
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
- return;
|
|
|
}
|
|
|
+ $host.find('.search input').attr('placeholder', '回车搜索').attr('autocomplete', 'off');
|
|
|
+ return;
|
|
|
+ }
|
|
|
|
|
|
// 把表格内工具栏挪到宿主(脱离 overflow:hidden,避免上半截被裁切)
|
|
|
var $ft = $btFt.length ? $btFt : $hostFt;
|
|
|
@@ -852,6 +969,19 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
|
|
|
if (typeof Controller._procuremenApplyStageButtons === 'function') {
|
|
|
Controller._procuremenApplyStageButtons();
|
|
|
}
|
|
|
+ if (keepSearchFocus) {
|
|
|
+ var $restore2 = $host.find('.search input').first();
|
|
|
+ if ($restore2.length) {
|
|
|
+ $restore2.focus();
|
|
|
+ if (caretStart != null) {
|
|
|
+ try {
|
|
|
+ $restore2[0].setSelectionRange(caretStart, caretEnd != null ? caretEnd : caretStart);
|
|
|
+ } catch (ignoreCaret2) {
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ $host.find('.search input').attr('placeholder', '回车搜索').attr('autocomplete', 'off');
|
|
|
// 工具栏移出后重算表高,避免占位错乱
|
|
|
setTimeout(function () {
|
|
|
procuremenTableHeightCached = 0;
|
|
|
@@ -862,77 +992,6 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
|
|
|
}, 0);
|
|
|
}
|
|
|
|
|
|
- function procuremenNormalizeToolbarRight($ft) {
|
|
|
- if (!$ft || !$ft.length) {
|
|
|
- return;
|
|
|
- }
|
|
|
- var $search = $ft.find('.search').first();
|
|
|
- if (!$search.length) {
|
|
|
- return;
|
|
|
- }
|
|
|
- // 专用右侧容器:不能把 .search 自身当 wrap(.search 的 display 会盖掉 flex,导致搜索与图标折成两行)
|
|
|
- var $right = $ft.children('.procuremen-toolbar-search-wrap').first();
|
|
|
- if (!$right.length) {
|
|
|
- $right = $('<div class="columns columns-right pull-right procuremen-toolbar-search-wrap"></div>');
|
|
|
- $ft.append($right);
|
|
|
- } else {
|
|
|
- $right.addClass('columns columns-right pull-right procuremen-toolbar-search-wrap');
|
|
|
- }
|
|
|
- // 若历史上把图标塞进了 .search 里,先拆出来
|
|
|
- if ($search.hasClass('procuremen-toolbar-search-wrap')) {
|
|
|
- $search.removeClass('procuremen-toolbar-search-wrap columns columns-right');
|
|
|
- }
|
|
|
- $search.children().not('input, .form-control').appendTo($right);
|
|
|
- $search.appendTo($right);
|
|
|
-
|
|
|
- $ft.children().each(function () {
|
|
|
- var $c = $(this);
|
|
|
- if ($c.is('.bars, .bs-bars') || $c[0] === $right[0] || $c.hasClass('search')) {
|
|
|
- return;
|
|
|
- }
|
|
|
- var mergeToolbarExtras = $c.hasClass('columns')
|
|
|
- || $c.hasClass('pull-right')
|
|
|
- || ($c.hasClass('btn-group') && $c.find('.search').length === 0)
|
|
|
- || $c.is('button[name="commonSearch"], button[name="toggle"]');
|
|
|
- if (!mergeToolbarExtras) {
|
|
|
- return;
|
|
|
- }
|
|
|
- if ($c.hasClass('btn-group') && !$c.hasClass('columns')) {
|
|
|
- $c.appendTo($right);
|
|
|
- } else if ($c.is('button')) {
|
|
|
- $c.appendTo($right);
|
|
|
- } else {
|
|
|
- $c.children().appendTo($right);
|
|
|
- if (!$c.children().length) {
|
|
|
- $c.remove();
|
|
|
- }
|
|
|
- }
|
|
|
- });
|
|
|
- // 顺序:搜索框 → 切换 → 列显隐 → 导出 → 通用搜索(放大镜)
|
|
|
- $right.addClass('procuremen-toolbar-search-wrap');
|
|
|
- var $toggle = $right.find('button[name="toggle"]').first();
|
|
|
- var $columns = $right.find('.keep-open').first();
|
|
|
- var $export = $right.find('.export').first();
|
|
|
- var $common = $right.find('button[name="commonSearch"]').first();
|
|
|
- $search = $right.find('.search').first();
|
|
|
- if ($search.length) {
|
|
|
- $search.prependTo($right);
|
|
|
- }
|
|
|
- if ($toggle.length) {
|
|
|
- $toggle.insertAfter($search);
|
|
|
- }
|
|
|
- if ($columns.length) {
|
|
|
- $columns.insertAfter($toggle.length ? $toggle : $search);
|
|
|
- }
|
|
|
- if ($export.length) {
|
|
|
- var $afterCols = $columns.length ? $columns : ($toggle.length ? $toggle : $search);
|
|
|
- $export.insertAfter($afterCols);
|
|
|
- }
|
|
|
- if ($common.length) {
|
|
|
- $common.appendTo($right);
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
/** 列显隐下拉用 fixed,避免被表格区域 overflow 裁切 */
|
|
|
function procuremenBindToolbarDropdownFix() {
|
|
|
var $host = $('#procuremen-toolbar-host');
|
|
|
@@ -1859,6 +1918,9 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
|
|
|
showColumns: true,
|
|
|
showExport: true,
|
|
|
search: true,
|
|
|
+ // 回车再搜:避免每敲一字就请求(线上跨月扫 Redis 很重,表现为输入时不断刷新/失焦)
|
|
|
+ searchOnEnterKey: true,
|
|
|
+ searchTimeOut: 800,
|
|
|
smartDisplay: false,
|
|
|
// 请求发出即显示加载态
|
|
|
// 注意:勿在 ajaxOptions 里覆盖 beforeSend,否则会冲掉 Fast.api.fixurl,
|
|
|
@@ -1879,7 +1941,20 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
|
|
|
if (!/^\d{4}-\d{2}$/.test(pickYm) || res.sidebarYms.indexOf(pickYm) < 0) {
|
|
|
pickYm = String(res.sidebarYms[0] || '');
|
|
|
}
|
|
|
- if (/^\d{4}-\d{2}$/.test(pickYm) && pickYm !== Controller.currYm) {
|
|
|
+ var searchTextNow = '';
|
|
|
+ try {
|
|
|
+ searchTextNow = $.trim((table.bootstrapTable('getOptions') || {}).searchText || '');
|
|
|
+ } catch (ignoreSearchText) {
|
|
|
+ searchTextNow = '';
|
|
|
+ }
|
|
|
+ if (!searchTextNow) {
|
|
|
+ var $searchInp = $('#procuremen-toolbar-host .search input, .bootstrap-table .search input').first();
|
|
|
+ if ($searchInp.length) {
|
|
|
+ searchTextNow = $.trim($searchInp.val() || '');
|
|
|
+ }
|
|
|
+ }
|
|
|
+ // 搜索中不要自动切月份再 refresh,否则输入框像被反复刷新
|
|
|
+ if (!searchTextNow && /^\d{4}-\d{2}$/.test(pickYm) && pickYm !== Controller.currYm) {
|
|
|
Controller.currYm = pickYm;
|
|
|
$('.procuremen-ym-item').removeClass('active');
|
|
|
$('.procuremen-ym-item[data-ym="' + pickYm + '"]').addClass('active');
|
|
|
@@ -1944,6 +2019,26 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
|
|
|
// 本页不需要「跨页选择模式」提示
|
|
|
table.closest('.bootstrap-table').find('.btn-selected-tips').remove();
|
|
|
$('#procuremen-toolbar-host .btn-selected-tips, #toolbar .btn-selected-tips').remove();
|
|
|
+ // 快速搜索:禁止回车触发表单整页刷新;仍放行给 bootstrap-table(searchOnEnterKey)
|
|
|
+ $(document).off('keydown.procuremenQuickSearch', '#procuremen-toolbar-host .search input, .bootstrap-table .fixed-table-toolbar .search input')
|
|
|
+ .on('keydown.procuremenQuickSearch', '#procuremen-toolbar-host .search input, .bootstrap-table .fixed-table-toolbar .search input', function (e) {
|
|
|
+ if (e.keyCode === 13 || e.which === 13) {
|
|
|
+ e.preventDefault();
|
|
|
+ }
|
|
|
+ });
|
|
|
+ $(document).off('submit.procuremenQuickSearch', 'form')
|
|
|
+ .on('submit.procuremenQuickSearch', 'form', function (e) {
|
|
|
+ if ($(document.activeElement).closest('#procuremen-toolbar-host .search, .bootstrap-table .search').length) {
|
|
|
+ e.preventDefault();
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ });
|
|
|
+ // 占位提示:回车搜索(线上勿逐字请求)
|
|
|
+ setTimeout(function () {
|
|
|
+ $('#procuremen-toolbar-host .search input, .bootstrap-table .fixed-table-toolbar .search input')
|
|
|
+ .attr('placeholder', '回车搜索')
|
|
|
+ .attr('autocomplete', 'off');
|
|
|
+ }, 0);
|
|
|
procuremenInjectHeaderFilters();
|
|
|
table.on('post-body.bs.table post-header.bs.table', function () {
|
|
|
$('#procuremen-toolbar-host .btn-selected-tips, .bootstrap-table .btn-selected-tips, #toolbar .btn-selected-tips').remove();
|
|
|
@@ -4710,13 +4805,13 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
|
|
|
return a.label.localeCompare(b.label, 'zh-CN');
|
|
|
});
|
|
|
var n = entries.length;
|
|
|
+ var $summary = $('#review-selected-summary');
|
|
|
$('#review-selected-count').text(String(n));
|
|
|
+ $summary.toggleClass('is-empty', n === 0);
|
|
|
$('#review-selected-tags').empty();
|
|
|
if (!n) {
|
|
|
- $('#review-selected-empty').show();
|
|
|
return;
|
|
|
}
|
|
|
- $('#review-selected-empty').hide();
|
|
|
$.each(entries, function (i, e) {
|
|
|
var $chip = $('<span class="review-selected-chip"/>').attr('title', e.label);
|
|
|
$chip.data('reviewSelKey', e.k);
|