合入主线登录和营业时段策略,对齐旧界面与 React 访问流程
This commit is contained in:
commit
42395de23a
113 files changed
+1915
-558
No files matched your search
@@ -19,6 +19,8 @@ function shopSettingsValues(settings = state.shopSettings) {
|
||||
storeName: settings.storeName,
|
||||
receiptSubtitle: settings.receiptSubtitle || '',
|
||||
contact: settings.contact || '',
|
||||
businessOpen: settings.businessHours?.open ?? '',
|
||||
businessClose: settings.businessHours?.close ?? '',
|
||||
creditCardRatePermille: String(settings.creditCardRatePermille),
|
||||
profitSharePercent: String(settings.profitSharePercent),
|
||||
profitShareEffectiveMonth:
|
||||
@@ -65,7 +67,7 @@ function shopSettingsHTML() {
|
||||
if (state.user.role !== 'owner' || !state.shopSettings) return '';
|
||||
const settings = state.shopSettings,
|
||||
values = shopSettingsValues(settings);
|
||||
return `<section class="panel shop-settings" id="shop-settings-panel"><div class="panel-title"><div><h2>店铺配置</h2><p id="shop-settings-status" class="small muted" aria-live="polite">当前生效配置;仅店主可以修改。</p></div></div><form id="shop-settings-form" data-revision="${e(settings.revision)}" data-baseline="${e(JSON.stringify(values))}"><fieldset class="shop-settings-fields"><div class="grid three">${field('店名', 'storeName', values.storeName, 'text', 'required maxlength="80"')}${field('单据标题', 'receiptSubtitle', values.receiptSubtitle, 'text', 'maxlength="80"')}${field('联系电话/客户联系信息(选填)', 'contact', values.contact, 'text', 'maxlength="80"')}</div><h3>开单默认费用</h3><div class="grid four">${field('证书成本(元)', 'certificate', values.certificate, 'number', 'required min="0" max="1000000" step="0.01"')}${field('包装成本(元)', 'packaging', values.packaging, 'number', 'required min="0" max="1000000" step="0.01"')}${field('整单快递成本(元)', 'shipping', values.shipping, 'number', 'required min="0" max="1000000" step="0.01"')}${choice('包装默认付款人', 'packagingPayer', teamMemberOptions(), values.packagingPayer)}</div><p class="small muted">默认费用只用于新增项目。已有订单、模板和草稿里已经填写的费用及付款人按原值保留,开单时仍可按实际修改。</p><h3>手续费与利润分成</h3><div class="grid three">${field('信用卡手续费率(‰)', 'creditCardRatePermille', values.creditCardRatePermille, 'number', 'required min="0" max="1000" step="1"')}${field('助理利润分成比例(%)', 'profitSharePercent', values.profitSharePercent, 'number', 'required min="0" max="100" step="1"')}${field('分成生效月份', 'profitShareEffectiveMonth', values.profitShareEffectiveMonth, 'month', `required min="${e(state.today.slice(0, 7))}"`)}</div><p class="small muted">新建订单使用当前信用卡费率;修改旧单沿用原费率。分成按生效月份统计,历史月份保留原口径。</p></fieldset><div id="shop-settings-error" aria-live="polite"></div><div class="form-actions"><button type="submit" class="primary">保存店铺配置</button></div></form>${shopCostManagerHTML()}</section>`;
|
||||
return `<section class="panel shop-settings" id="shop-settings-panel"><div class="panel-title"><div><h2>店铺配置</h2><p id="shop-settings-status" class="small muted" aria-live="polite">当前生效配置;仅店主可以修改。</p></div></div><form id="shop-settings-form" data-revision="${e(settings.revision)}" data-baseline="${e(JSON.stringify(values))}"><fieldset class="shop-settings-fields"><div class="grid three">${field('店名', 'storeName', values.storeName, 'text', 'required maxlength="80"')}${field('单据标题', 'receiptSubtitle', values.receiptSubtitle, 'text', 'maxlength="80"')}${field('联系电话/客户联系信息(选填)', 'contact', values.contact, 'text', 'maxlength="80"')}</div><h3>营业时间(北京时间)</h3><div class="grid two">${field('开始时间', 'businessOpen', values.businessOpen, 'time')}${field('结束时间', 'businessClose', values.businessClose, 'time')}</div><p class="small muted">结束时间早于开始时间,表示营业到次日。两项留空时暂停员工访问。超级管理员可全天登录和使用账本。</p><h3>开单默认费用</h3><div class="grid four">${field('证书成本(元)', 'certificate', values.certificate, 'number', 'required min="0" max="1000000" step="0.01"')}${field('包装成本(元)', 'packaging', values.packaging, 'number', 'required min="0" max="1000000" step="0.01"')}${field('整单快递成本(元)', 'shipping', values.shipping, 'number', 'required min="0" max="1000000" step="0.01"')}${choice('包装默认付款人', 'packagingPayer', teamMemberOptions(), values.packagingPayer)}</div><p class="small muted">默认费用只用于新增项目。已有订单、模板和草稿里已经填写的费用及付款人按原值保留,开单时仍可按实际修改。</p><h3>手续费与利润分成</h3><div class="grid three">${field('信用卡手续费率(‰)', 'creditCardRatePermille', values.creditCardRatePermille, 'number', 'required min="0" max="1000" step="1"')}${field('助理利润分成比例(%)', 'profitSharePercent', values.profitSharePercent, 'number', 'required min="0" max="100" step="1"')}${field('分成生效月份', 'profitShareEffectiveMonth', values.profitShareEffectiveMonth, 'month', `required min="${e(state.today.slice(0, 7))}"`)}</div><p class="small muted">新建订单使用当前信用卡费率;修改旧单沿用原费率。分成按生效月份统计,历史月份保留原口径。</p></fieldset><div id="shop-settings-error" aria-live="polite"></div><div class="form-actions"><button type="submit" class="primary">保存店铺配置</button></div></form>${shopCostManagerHTML()}</section>`;
|
||||
}
|
||||
function shopSettingsInput(form) {
|
||||
if (state.user.role !== 'owner') throw new Error('店铺配置由店主账号修改。');
|
||||
@@ -85,14 +87,16 @@ function shopSettingsInput(form) {
|
||||
values.profitShareEffectiveMonth < state.today.slice(0, 7)
|
||||
)
|
||||
throw new Error('分成生效月份请选择本月或以后。');
|
||||
const baseline = JSON.parse(form.dataset.baseline);
|
||||
return {
|
||||
revision: Number(form.dataset.revision),
|
||||
...LedgerValues.businessHoursPatch(values.businessOpen, values.businessClose, baseline),
|
||||
storeName: values.storeName.trim(),
|
||||
receiptSubtitle: values.receiptSubtitle.trim(),
|
||||
contact: values.contact.trim(),
|
||||
creditCardRatePermille: integer('creditCardRatePermille', 1000, '信用卡费率'),
|
||||
...(values.profitSharePercent !== JSON.parse(form.dataset.baseline).profitSharePercent ||
|
||||
values.profitShareEffectiveMonth !== JSON.parse(form.dataset.baseline).profitShareEffectiveMonth
|
||||
...(values.profitSharePercent !== baseline.profitSharePercent ||
|
||||
values.profitShareEffectiveMonth !== baseline.profitShareEffectiveMonth
|
||||
? {
|
||||
profitSharePercent: integer('profitSharePercent', 100, '利润分成比例'),
|
||||
profitShareEffectiveMonth: values.profitShareEffectiveMonth,
|
||||
@@ -146,6 +150,7 @@ async function saveShopSettings(form) {
|
||||
}
|
||||
syncPrintSettingsPreview();
|
||||
syncShopSettingsStatus(true);
|
||||
if (Object.hasOwn(input, 'businessHours')) window.dispatchEvent(new Event('ledger-business-hours-changed'));
|
||||
await loadTeamMembers();
|
||||
if (typeof loadEmployees === 'function' && document.querySelector('#employee-list')) await loadEmployees();
|
||||
toast('店铺配置已保存');
|
||||
|
||||
Reference in new issue
Block a user