悠修复自定义实收金额和求和采集功能增强

This commit is contained in:
2026-07-28 14:16:46 +08:00
parent e72acb58ec
commit 4a1b0f71c3
9 changed files with 454 additions and 39 deletions

View File

@@ -97,6 +97,18 @@ function showCreateModal() {
const customServiceFeeNameInput = document.getElementById('custom-service-fee-name');
if (customServiceFeeNameInput) customServiceFeeNameInput.value = '';
// 重置显示自定义服务费字段开关
const showCustomServiceFeeInput = document.getElementById('show-custom-service-fee');
if (showCustomServiceFeeInput) showCustomServiceFeeInput.checked = false;
// 重置显示实收总金额字段开关
const showTotalAmountInput = document.getElementById('show-total-amount');
if (showTotalAmountInput) showTotalAmountInput.checked = false;
// 重置实收总金额表头名称
const totalAmountNameInput = document.getElementById('total-amount-name');
if (totalAmountNameInput) totalAmountNameInput.value = '';
document.getElementById('config-modal').classList.add('active');
}
@@ -126,7 +138,9 @@ const SUMMABLE_FIELD_KEYS = [
'invoice_fee', 'activity_electric_fee', 'activity_service_fee', 'activity_total_fee',
'total_money',
// 分时段电量
'sharp_electricity', 'peak_electricity', 'flat_electricity', 'valley_electricity'
'sharp_electricity', 'peak_electricity', 'flat_electricity', 'valley_electricity',
// 虚拟字段(自定义计算字段)
'custom_service_fee', 'custom_total_amount'
];
// 渲染字段列表
@@ -299,6 +313,44 @@ function updateFieldIndexes() {
});
}
// 虚拟字段开关切换事件
function onVirtualFieldToggle(cb) {
const fieldKey = cb.id === 'show-custom-service-fee' ? 'custom_service_fee' : 'custom_total_amount';
const isChecked = cb.checked;
// 获取当前字段顺序
const currentOrder = getSelectedFieldsOrder();
let newOrder = [];
if (isChecked) {
// 勾选:添加字段到列表末尾
if (!currentOrder.includes(fieldKey)) {
newOrder = [...currentOrder, fieldKey];
} else {
newOrder = currentOrder;
}
} else {
// 取消勾选:从列表中移除字段
newOrder = currentOrder.filter(f => f !== fieldKey);
}
// 获取当前求和字段选择状态
const sumFieldsList = document.getElementById('sum-fields-list');
const currentSumFields = sumFieldsList ? Array.from(sumFieldsList.querySelectorAll('input:checked')).map(c => c.value) : [];
// 更新字段顺序列表和求和字段列表
refreshSelectedFieldsOrder(newOrder);
refreshSumFieldsList(newOrder, currentSumFields);
// 如果勾选了字段,更新字段列表中的checkbox状态(保持一致)
const fieldList = document.getElementById('field-list');
const fieldCb = fieldList?.querySelector(`input[value="${fieldKey}"]`);
if (fieldCb) {
fieldCb.checked = isChecked;
fieldCb.closest('.checkbox-item')?.classList.toggle('checked', isChecked);
}
}
// 获取当前字段顺序
function getSelectedFieldsOrder() {
const orderList = document.getElementById('selected-fields-order');
@@ -548,7 +600,17 @@ async function saveConfig() {
// 获取自定义服务费表头名称
const customServiceFeeNameInput = document.getElementById('custom-service-fee-name');
const customServiceFeeName = customServiceFeeNameInput?.value.trim() || null;
// 获取显示自定义服务费字段开关
const showCustomServiceFee = document.getElementById('show-custom-service-fee')?.checked || false;
// 获取显示实收总金额字段开关
const showTotalAmount = document.getElementById('show-total-amount')?.checked || false;
// 获取实收总金额表头名称
const totalAmountNameInput = document.getElementById('total-amount-name');
const totalAmountName = totalAmountNameInput?.value.trim() || null;
if (!configName || !splitType || !splitValue) {
alert('请填写所有必填字段');
return;
@@ -590,7 +652,10 @@ async function saveConfig() {
field_custom_names: fieldCustomNamesData,
show_monthly_total: showMonthlyTotal,
custom_service_fee_price: customServiceFeePrice,
custom_service_fee_name: customServiceFeeName
custom_service_fee_name: customServiceFeeName,
show_custom_service_fee: showCustomServiceFee,
show_total_amount: showTotalAmount,
total_amount_name: totalAmountName
};
try {
@@ -683,6 +748,24 @@ async function editConfig(configId) {
customServiceFeeNameInput.value = config.custom_service_fee_name || '';
}
// 加载显示自定义服务费字段开关
const showCustomServiceFeeInput = document.getElementById('show-custom-service-fee');
if (showCustomServiceFeeInput) {
showCustomServiceFeeInput.checked = config.show_custom_service_fee === 1;
}
// 加载显示实收总金额字段开关
const showTotalAmountInput = document.getElementById('show-total-amount');
if (showTotalAmountInput) {
showTotalAmountInput.checked = config.show_total_amount === 1;
}
// 加载实收总金额表头名称
const totalAmountNameInput = document.getElementById('total-amount-name');
if (totalAmountNameInput) {
totalAmountNameInput.value = config.total_amount_name || '';
}
document.getElementById('config-modal').classList.add('active');
}
}