科目映射表:序号固定用规则编号,账单项目增加与其他条件一致的下拉筛选
This commit is contained in:
parent
ea1a23c4b8
commit
05abcb6eaa
@ -317,6 +317,12 @@
|
||||
<span>搜索</span>
|
||||
<input type="search" id="amKeyword" placeholder="平台 / 账单项目 / 备注 / 科目">
|
||||
</label>
|
||||
<label class="upstream-data-field">
|
||||
<span>账单项目</span>
|
||||
<select id="amItem">
|
||||
<option value="">全部</option>
|
||||
</select>
|
||||
</label>
|
||||
<label class="upstream-data-field">
|
||||
<span>平台</span>
|
||||
<select id="amPlatform">
|
||||
@ -429,6 +435,7 @@
|
||||
var countEl = document.getElementById('amCount');
|
||||
var kw = document.getElementById('amKeyword');
|
||||
var fPlatform = document.getElementById('amPlatform');
|
||||
var fItem = document.getElementById('amItem');
|
||||
var fCategory = document.getElementById('amCategory');
|
||||
var fBasis = document.getElementById('amBasis');
|
||||
var fOnly = document.getElementById('amOnly');
|
||||
@ -518,6 +525,7 @@
|
||||
var keyword = (kw.value || '').trim().toLowerCase();
|
||||
return ROWS.filter(function (r) {
|
||||
if (fPlatform.value && r.platform !== fPlatform.value) { return false; }
|
||||
if (fItem.value && r.item !== fItem.value) { return false; }
|
||||
if (fCategory.value && r.category !== fCategory.value) { return false; }
|
||||
if (fBasis.value && r.basis !== fBasis.value) { return false; }
|
||||
if (fOnly.value) {
|
||||
@ -538,7 +546,7 @@
|
||||
var edit = (editingId === r.id && draft);
|
||||
if (edit) {
|
||||
return '<tr class="am-item is-editing" data-id="' + r.id + '">'
|
||||
+ '<td class="am-index">' + (index + 1) + '</td>'
|
||||
+ '<td class="am-index">' + r.id + '</td>'
|
||||
+ '<td class="am-edit-cell"><input data-f="platform" value="' + esc(draft.platform) + '" list="amPlatformList"></td>'
|
||||
+ '<td class="am-edit-cell"><input data-f="item" value="' + esc(draft.item) + '"></td>'
|
||||
+ '<td class="am-edit-cell"><input data-f="memo" value="' + esc(draft.memo) + '" placeholder="不限就填 -"></td>'
|
||||
@ -555,7 +563,7 @@
|
||||
+ '</div></td></tr>';
|
||||
}
|
||||
return '<tr class="am-item" data-id="' + r.id + '" data-index="' + index + '">'
|
||||
+ '<td class="am-index">' + (index + 1) + '</td>'
|
||||
+ '<td class="am-index">' + r.id + '</td>'
|
||||
+ '<td>' + esc(r.platform) + '</td>'
|
||||
+ '<td><span class="am-caret">▶</span> <span title="' + esc(r.item) + '">' + esc(r.item) + '</span></td>'
|
||||
+ '<td><span title="' + esc(r.memo) + '">' + esc(r.memo || '-') + '</span></td>'
|
||||
@ -678,6 +686,20 @@
|
||||
var cats = (OPTIONS.categories || []).slice();
|
||||
(fCategory.value ? [fCategory.value] : []).forEach(function (v) { if (cats.indexOf(v) < 0) { cats.push(v); } });
|
||||
fill(fCategory, cats, fCategory.value);
|
||||
rebuildItemOptions();
|
||||
}
|
||||
|
||||
// 账单项目筛选:和其他筛选一样用下拉,选项按当前选中的平台收窄
|
||||
function rebuildItemOptions() {
|
||||
var platform = fPlatform.value || '';
|
||||
var seen = {};
|
||||
ROWS.forEach(function (r) {
|
||||
if (platform && r.platform !== platform) { return; }
|
||||
if (r.item) { seen[r.item] = true; }
|
||||
});
|
||||
var items = Object.keys(seen).sort();
|
||||
if (fItem.value && items.indexOf(fItem.value) < 0) { items.unshift(fItem.value); }
|
||||
fill(fItem, items, fItem.value);
|
||||
}
|
||||
|
||||
function fill(select, values, current) {
|
||||
@ -1092,12 +1114,15 @@
|
||||
document.getElementById('amHistoryBtn').addEventListener('click', openHistory);
|
||||
|
||||
/* ---------- 筛选 ---------- */
|
||||
[kw, fPlatform, fCategory, fBasis, fOnly].forEach(function (el) {
|
||||
[kw, fPlatform, fItem, fCategory, fBasis, fOnly].forEach(function (el) {
|
||||
el.addEventListener('input', render);
|
||||
el.addEventListener('change', render);
|
||||
});
|
||||
// 换平台时,账单项目下拉的选项跟着换(原来选的项目保留在列表里)
|
||||
fPlatform.addEventListener('change', rebuildItemOptions);
|
||||
document.getElementById('amResetFilter').addEventListener('click', function () {
|
||||
kw.value = ''; fPlatform.value = ''; fCategory.value = ''; fBasis.value = ''; fOnly.value = '';
|
||||
kw.value = ''; fPlatform.value = ''; fItem.value = ''; fCategory.value = ''; fBasis.value = ''; fOnly.value = '';
|
||||
rebuildItemOptions();
|
||||
render();
|
||||
});
|
||||
|
||||
@ -1107,6 +1132,7 @@
|
||||
});
|
||||
|
||||
render();
|
||||
rebuildItemOptions();
|
||||
|
||||
// 后台预取账套科目清单(160KB 左右)。不做这一步的话,第一次点「编辑」要等它下载完
|
||||
// 才有反应,用户会以为按钮坏了。
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user