新增清潔費欄位 {{清潔費}},並記憶每份範本上次使用的值
- 表單新增「清潔費」欄位,預設 1200
- 後端 PDF 產生成功後自動將 monthlyRent / paymentDay / deposit / cleaningFee
寫入 templates/defaults.json,key 為範本檔名
- 切換範本時呼叫 /api/templates/:name/defaults 自動帶入上次的值
- 表單版面調整為 2x2:每月租金/繳款日期、保證金/清潔費 各一行
- 4 份逢甲範本加入 {{清潔費}} 佔位符
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -7,6 +7,8 @@ const {
|
||||
getTemplatePreviewPdf,
|
||||
saveTemplate,
|
||||
deleteTemplate,
|
||||
getTemplateDefaults,
|
||||
saveTemplateDefaults,
|
||||
} = require('./src/contractService');
|
||||
|
||||
const app = express();
|
||||
@@ -61,6 +63,14 @@ app.get('/api/templates', async (_req, res, next) => {
|
||||
}
|
||||
});
|
||||
|
||||
app.get('/api/templates/:name/defaults', async (req, res, next) => {
|
||||
try {
|
||||
res.json(await getTemplateDefaults(req.params.name));
|
||||
} catch (error) {
|
||||
next(error);
|
||||
}
|
||||
});
|
||||
|
||||
app.get('/api/templates/:name/preview', async (req, res) => {
|
||||
try {
|
||||
const pdfBuffer = await getTemplatePreviewPdf(req.params.name, req.query);
|
||||
@@ -82,10 +92,18 @@ app.post('/api/contracts/pdf', async (req, res) => {
|
||||
monthlyRent: req.body.monthlyRent,
|
||||
paymentDay: req.body.paymentDay,
|
||||
deposit: req.body.deposit,
|
||||
cleaningFee: req.body.cleaningFee,
|
||||
leaseStart: req.body.leaseStart,
|
||||
leaseEnd: req.body.leaseEnd,
|
||||
});
|
||||
|
||||
await saveTemplateDefaults(req.body.template, {
|
||||
monthlyRent: req.body.monthlyRent,
|
||||
paymentDay: req.body.paymentDay,
|
||||
deposit: req.body.deposit,
|
||||
cleaningFee: req.body.cleaningFee,
|
||||
}).catch(() => {});
|
||||
|
||||
res.setHeader('Content-Type', 'application/pdf');
|
||||
res.setHeader(
|
||||
'Content-Disposition',
|
||||
|
||||
Reference in New Issue
Block a user