财务台账:压缩待办行高并支持调整列宽
This commit is contained in:
parent
e873f35241
commit
1a9654b6d5
@ -31,10 +31,12 @@
|
||||
.pending-balance-toolbar-actions { display:flex; justify-content:flex-end; gap:.55rem; margin-top:.65rem; }
|
||||
.pending-balance-button { display:inline-flex; align-items:center; justify-content:center; gap:.35rem; height:2.15rem; padding:0 .8rem; border:1px solid var(--vip-border, #D8D2C7); border-radius:.4rem; background:#fff; color:var(--vip-content-accent-dark, #856632); font:inherit; font-weight:600; text-decoration:none; cursor:pointer; }
|
||||
.pending-balance-button.is-primary { border-color:var(--vip-content-accent-dark, #856632); background:var(--vip-content-accent-dark, #856632); color:#fff; }
|
||||
.pending-balance-table-hint { margin:0 0 .35rem; color:var(--vip-content-muted, #595959); font-size:.66rem; text-align:right; }
|
||||
.pending-balance-table-wrap { max-height:calc(100vh - 360px); min-height:20rem; overflow:auto; border:1px solid var(--vip-border, #D8D2C7); border-radius:.65rem; background:#fff; }
|
||||
.pending-balance-table { width:100%; min-width:72rem; border-collapse:separate; border-spacing:0; font-size:.72rem; }
|
||||
.pending-balance-table th,
|
||||
.pending-balance-table td { padding:.55rem .65rem; border-right:1px solid #e8e3da; border-bottom:1px solid #e8e3da; text-align:left; vertical-align:middle; white-space:nowrap; }
|
||||
.pending-balance-table td { padding:.32rem .52rem; border-right:1px solid #e8e3da; border-bottom:1px solid #e8e3da; line-height:1.4; text-align:left; vertical-align:middle; white-space:nowrap; }
|
||||
.pending-balance-table tbody td { overflow:hidden; text-overflow:ellipsis; }
|
||||
.pending-balance-table th { position:sticky; top:0; z-index:4; background:var(--vip-content-accent-soft, #F7F0DE); box-shadow:0 1px 0 var(--vip-border, #D8D2C7); font-weight:700; text-align:center; }
|
||||
.pending-balance-table th:last-child,
|
||||
.pending-balance-table td:last-child { border-right:0; }
|
||||
@ -44,14 +46,20 @@
|
||||
.pending-balance-sort { display:inline-flex; align-items:center; justify-content:center; gap:.2rem; color:inherit; text-decoration:none; }
|
||||
.pending-balance-sort:hover { color:var(--vip-content-accent-dark, #856632); }
|
||||
.pending-balance-sort .material-icons-outlined { font-size:.9rem; }
|
||||
.pending-balance-task-input { width:100%; min-width:8rem; height:2rem; padding:0 .45rem; border:1px solid var(--vip-border, #D8D2C7); border-radius:.35rem; background:#fff; color:var(--vip-content-ink, #171717); font:inherit; }
|
||||
.pending-balance-task-input.is-compact { min-width:6.5rem; }
|
||||
.pending-balance-task-input { width:100%; min-width:0; height:1.75rem; padding:0 .42rem; border:1px solid var(--vip-border, #D8D2C7); border-radius:.35rem; background:#fff; color:var(--vip-content-ink, #171717); font:inherit; }
|
||||
.pending-balance-task-input:focus { border-color:var(--vip-content-accent-dark, #856632); outline:none; box-shadow:0 0 0 3px rgba(133,102,50,.14); }
|
||||
.pending-balance-task-input:disabled { background:#f6f4ef; color:var(--vip-content-muted, #595959); cursor:not-allowed; }
|
||||
.pending-balance-progress { display:flex; align-items:center; gap:.35rem; min-width:9rem; }
|
||||
.pending-balance-save { display:inline-grid; flex:0 0 auto; place-items:center; width:2rem; height:2rem; padding:0; border:1px solid var(--vip-content-accent-dark, #856632); border-radius:.35rem; background:var(--vip-content-accent-dark, #856632); color:#fff; cursor:pointer; }
|
||||
.pending-balance-progress { display:flex; align-items:center; gap:.3rem; min-width:0; }
|
||||
.pending-balance-save { display:inline-grid; flex:0 0 auto; place-items:center; width:1.75rem; height:1.75rem; padding:0; border:1px solid var(--vip-content-accent-dark, #856632); border-radius:.35rem; background:var(--vip-content-accent-dark, #856632); color:#fff; cursor:pointer; }
|
||||
.pending-balance-save:hover { border-color:#6A5129; background:#6A5129; }
|
||||
.pending-balance-status { display:inline-flex; align-items:center; justify-content:center; min-height:1.6rem; padding:.1rem .4rem; border:1px solid transparent; border-radius:999px; font-size:.68rem; font-weight:700; }
|
||||
.pending-balance-status { display:inline-flex; align-items:center; justify-content:center; min-height:1.45rem; padding:.08rem .35rem; border:1px solid transparent; border-radius:999px; font-size:.68rem; font-weight:700; }
|
||||
.pending-column-resizer { position:absolute; top:0; right:0; z-index:6; width:.45rem; height:100%; cursor:col-resize; touch-action:none; }
|
||||
.pending-column-resizer::after { content:""; position:absolute; top:20%; bottom:20%; left:50%; width:1px; background:transparent; transition:background .15s ease; }
|
||||
.pending-column-resizer:hover::after,
|
||||
.pending-column-resizer.is-active::after { background:var(--vip-content-accent-dark, #856632); }
|
||||
.pending-column-resizer:focus { outline:none; }
|
||||
.pending-column-resizer:focus-visible::after { width:2px; background:var(--vip-content-accent-dark, #856632); }
|
||||
body.is-resizing-pending-column { cursor:col-resize; user-select:none; }
|
||||
.pending-balance-status.is-normal { border-color:rgba(83,121,62,.3); background:#f3f7ee; color:var(--vip-success, #53793E); }
|
||||
.pending-balance-status.is-online_banking_abnormal { border-color:rgba(184,0,0,.3); background:#fff5f5; color:var(--vip-danger, #B80000); }
|
||||
.pending-balance-status.is-limited { border-color:rgba(147,95,7,.32); background:#fff8eb; color:var(--vip-warning, #935F07); }
|
||||
@ -185,34 +193,35 @@
|
||||
);
|
||||
@endphp
|
||||
|
||||
<p class="pending-balance-table-hint">拖动表头右侧边界可调整列宽,双击边界恢复默认</p>
|
||||
<div class="pending-balance-table-wrap">
|
||||
<table class="pending-balance-table">
|
||||
<table class="pending-balance-table" data-pending-table data-column-storage-key="caiwu.financial-ledger.pending-columns.v1.{{ auth()->id() }}.{{ company_id() }}">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>公司名称</th>
|
||||
<th>账户简称</th>
|
||||
<th>账户类型</th>
|
||||
<th>账户状态</th>
|
||||
<th>账号</th>
|
||||
<th>开户行</th>
|
||||
<th>开户城市/网点</th>
|
||||
<th>异常原因</th>
|
||||
<th>办理方式</th>
|
||||
<th>责任人员</th>
|
||||
<th @if ($sortField === 'started_at') aria-sort="{{ $sortDirection === 'asc' ? 'ascending' : 'descending' }}" @endif>
|
||||
<th data-pending-column-key="company_name">公司名称</th>
|
||||
<th data-pending-column-key="account_short">账户简称</th>
|
||||
<th data-pending-column-key="account_type">账户类型</th>
|
||||
<th data-pending-column-key="account_status">账户状态</th>
|
||||
<th data-pending-column-key="account_no">账号</th>
|
||||
<th data-pending-column-key="bank_name">开户行</th>
|
||||
<th data-pending-column-key="bank_city_branch">开户城市/网点</th>
|
||||
<th data-pending-column-key="abnormal_reason">异常原因</th>
|
||||
<th data-pending-column-key="handling_method">办理方式</th>
|
||||
<th data-pending-column-key="owner_name">责任人员</th>
|
||||
<th data-pending-column-key="started_at" @if ($sortField === 'started_at') aria-sort="{{ $sortDirection === 'asc' ? 'ascending' : 'descending' }}" @endif>
|
||||
<a class="pending-balance-sort" href="{{ $sortUrl('started_at') }}" title="按开始时间排序">
|
||||
开始时间
|
||||
<span class="material-icons-outlined" aria-hidden="true">{{ $sortField === 'started_at' ? ($sortDirection === 'asc' ? 'arrow_upward' : 'arrow_downward') : 'unfold_more' }}</span>
|
||||
</a>
|
||||
</th>
|
||||
<th @if ($sortField === 'completed_at') aria-sort="{{ $sortDirection === 'asc' ? 'ascending' : 'descending' }}" @endif>
|
||||
<th data-pending-column-key="completed_at" @if ($sortField === 'completed_at') aria-sort="{{ $sortDirection === 'asc' ? 'ascending' : 'descending' }}" @endif>
|
||||
<a class="pending-balance-sort" href="{{ $sortUrl('completed_at') }}" title="按完成时间排序">
|
||||
完成时间
|
||||
<span class="material-icons-outlined" aria-hidden="true">{{ $sortField === 'completed_at' ? ($sortDirection === 'asc' ? 'arrow_upward' : 'arrow_downward') : 'unfold_more' }}</span>
|
||||
</a>
|
||||
</th>
|
||||
<th>当前进度</th>
|
||||
<th>是否完成</th>
|
||||
<th data-pending-column-key="current_progress">当前进度</th>
|
||||
<th data-pending-column-key="completion_status">是否完成</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody data-pending-tbody>
|
||||
@ -291,6 +300,129 @@
|
||||
@endif
|
||||
</section>
|
||||
|
||||
<script>
|
||||
(() => {
|
||||
const table = document.querySelector('[data-pending-table]');
|
||||
if (!table) return;
|
||||
const headers = [...table.querySelectorAll('thead th[data-pending-column-key]')];
|
||||
if (headers.length === 0) return;
|
||||
|
||||
const storageKey = table.dataset.columnStorageKey || 'caiwu.financial-ledger.pending-columns';
|
||||
const minimumWidth = 56;
|
||||
const maximumWidth = 720;
|
||||
const clampWidth = (value) => Math.min(maximumWidth, Math.max(minimumWidth, Math.round(Number(value) || 0)));
|
||||
const defaults = new Map(headers.map((header) => [
|
||||
header.dataset.pendingColumnKey,
|
||||
Math.max(minimumWidth, Math.round(header.getBoundingClientRect().width * 10) / 10),
|
||||
]));
|
||||
const widths = new Map(defaults);
|
||||
|
||||
try {
|
||||
const saved = JSON.parse(localStorage.getItem(storageKey) || 'null');
|
||||
if (saved?.widths && typeof saved.widths === 'object') {
|
||||
Object.entries(saved.widths).forEach(([key, value]) => {
|
||||
if (widths.has(key)) widths.set(key, clampWidth(value));
|
||||
});
|
||||
}
|
||||
} catch (_) {}
|
||||
|
||||
const group = document.createElement('colgroup');
|
||||
group.dataset.pendingColumnGroup = 'true';
|
||||
headers.forEach((header) => {
|
||||
const column = document.createElement('col');
|
||||
column.dataset.pendingColumnKey = header.dataset.pendingColumnKey;
|
||||
group.appendChild(column);
|
||||
});
|
||||
table.insertBefore(group, table.firstChild);
|
||||
|
||||
const applyWidths = () => {
|
||||
let totalWidth = 0;
|
||||
headers.forEach((header) => {
|
||||
const key = header.dataset.pendingColumnKey;
|
||||
const width = clampWidth(widths.get(key) ?? defaults.get(key));
|
||||
const column = group.querySelector('col[data-pending-column-key="' + key + '"]');
|
||||
if (column) column.style.width = width + 'px';
|
||||
const resizer = header.querySelector('[data-pending-column-resizer]');
|
||||
resizer?.setAttribute('aria-valuenow', String(width));
|
||||
totalWidth += width;
|
||||
});
|
||||
table.style.tableLayout = 'fixed';
|
||||
table.style.width = totalWidth + 'px';
|
||||
table.style.minWidth = totalWidth + 'px';
|
||||
};
|
||||
|
||||
const persist = () => {
|
||||
try {
|
||||
localStorage.setItem(storageKey, JSON.stringify({
|
||||
widths: Object.fromEntries(widths),
|
||||
}));
|
||||
} catch (_) {}
|
||||
};
|
||||
|
||||
headers.forEach((header) => {
|
||||
const key = header.dataset.pendingColumnKey;
|
||||
const link = header.querySelector('.pending-balance-sort');
|
||||
const label = (link?.firstChild?.textContent || header.textContent).trim() || '未命名字段';
|
||||
const resizer = document.createElement('span');
|
||||
resizer.className = 'pending-column-resizer';
|
||||
resizer.dataset.pendingColumnResizer = 'true';
|
||||
resizer.tabIndex = 0;
|
||||
resizer.setAttribute('role', 'separator');
|
||||
resizer.setAttribute('aria-orientation', 'vertical');
|
||||
resizer.setAttribute('aria-label', '调整“' + label + '”列宽');
|
||||
resizer.setAttribute('aria-valuemin', String(minimumWidth));
|
||||
resizer.setAttribute('aria-valuemax', String(maximumWidth));
|
||||
resizer.title = '拖动调整列宽,双击恢复默认';
|
||||
|
||||
const setWidth = (value, save = false) => {
|
||||
widths.set(key, clampWidth(value));
|
||||
applyWidths();
|
||||
if (save) persist();
|
||||
};
|
||||
|
||||
resizer.addEventListener('pointerdown', (event) => {
|
||||
if (event.button !== 0) return;
|
||||
event.preventDefault();
|
||||
event.stopPropagation();
|
||||
const startX = event.clientX;
|
||||
const startWidth = header.getBoundingClientRect().width;
|
||||
resizer.classList.add('is-active');
|
||||
document.body.classList.add('is-resizing-pending-column');
|
||||
|
||||
const move = (moveEvent) => {
|
||||
setWidth(startWidth + moveEvent.clientX - startX);
|
||||
};
|
||||
const finish = () => {
|
||||
document.removeEventListener('pointermove', move);
|
||||
document.removeEventListener('pointerup', finish);
|
||||
document.removeEventListener('pointercancel', finish);
|
||||
resizer.classList.remove('is-active');
|
||||
document.body.classList.remove('is-resizing-pending-column');
|
||||
persist();
|
||||
};
|
||||
document.addEventListener('pointermove', move);
|
||||
document.addEventListener('pointerup', finish);
|
||||
document.addEventListener('pointercancel', finish);
|
||||
});
|
||||
resizer.addEventListener('keydown', (event) => {
|
||||
if (!['ArrowLeft', 'ArrowRight'].includes(event.key)) return;
|
||||
event.preventDefault();
|
||||
const width = Number(widths.get(key)) || header.getBoundingClientRect().width;
|
||||
setWidth(width + (event.key === 'ArrowLeft' ? -1 : 1) * (event.shiftKey ? 24 : 8), true);
|
||||
});
|
||||
resizer.addEventListener('dblclick', (event) => {
|
||||
event.preventDefault();
|
||||
event.stopPropagation();
|
||||
setWidth(defaults.get(key), true);
|
||||
});
|
||||
resizer.addEventListener('click', (event) => event.stopPropagation());
|
||||
header.appendChild(resizer);
|
||||
});
|
||||
|
||||
applyWidths();
|
||||
})();
|
||||
</script>
|
||||
|
||||
<script>
|
||||
(() => {
|
||||
const page = document.querySelector('.pending-balance-page');
|
||||
|
||||
@ -227,6 +227,8 @@ class FinanceLedgerAccountStatusTest extends FeatureTestCase
|
||||
->assertDontSee('name="pending_q"', false)
|
||||
->assertSee('data-pending-tbody', false)
|
||||
->assertSee('data-pending-pagination', false)
|
||||
->assertSee('data-pending-table', false)
|
||||
->assertSee('拖动表头右侧边界可调整列宽')
|
||||
->assertSee('ledger-page-box', false)
|
||||
->assertSee('1 / 1', false)
|
||||
->assertSee('data-pending-account="待办测试账户二"', false)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user