加入來源帳戶選項

This commit is contained in:
Wancat
2022-11-05 00:21:44 +08:00
parent ae86204c84
commit 22229fc5bc
4 changed files with 17 additions and 15 deletions

View File

@@ -1,15 +1,16 @@
{{ define "main" }} {{ define "main" }}
<h1>Ledger Quick Note</h1> <h1>Ledger 速記</h1>
<form action="/new" method="POST"> <form action="/new" method="POST">
<label>Action: <label>選擇模板:
{{ range .Templates }} {{ range .Templates }}
<input type="radio" name="action" value="{{ .Name }}">{{ .Name }}</option> <input type="radio" name="action" value="{{ .Name }}">{{ .Name }}</option>
{{ end }} {{ end }}
</label><br> </label><br>
<label>Amount: <input name="amount" type="number"></label><br> <label>金額:<input name="amount" type="number"></label><br>
<label>Account: <input name="account" type="text"></label></br> <label>目的帳戶:<input name="dest" type="text"></label></br>
<label>Tx Name: <input name="name" type="text"></label></br> <label>來源帳戶:<input name="src" type="text"></label></br>
<input type="submit"> <label>名稱:<input name="name" type="text"></label></br>
<input type="submit" value="新增記錄">
</form> </form>
{{ template "scripts" .Scripts }} {{ template "scripts" .Scripts }}
{{ end }} {{ end }}

View File

@@ -1,5 +1,5 @@
{{ define "scripts" }} {{ define "scripts" }}
<h3>常用指令</h3> <h3>快速查詢</h3>
<ul> <ul>
{{ range $k, $v := . }} {{ range $k, $v := . }}
<li><a href="/query?query={{ urlquery $v }}">{{ $k }}</a></li> <li><a href="/query?query={{ urlquery $v }}">{{ $k }}</a></li>

3
tx.go
View File

@@ -13,7 +13,8 @@ type TxData struct {
Name string `form:"name"` Name string `form:"name"`
Date string Date string
Amount string `form:"amount" binding:"required"` Amount string `form:"amount" binding:"required"`
Account string `form:"account"` Destination string `form:"dest"`
Source string `form:"src"`
} }
func newTx(data TxData) (result string, err error) { func newTx(data TxData) (result string, err error) {

View File

@@ -1,4 +1,4 @@
{{ .Date }} {{ with .Name }}{{ . }}{{ else }}{{ .Account }}{{ end }} {{ .Date }} {{ with .Name }}{{ . }}{{ else }}{{ .Destination }}{{ end }}
{{ .Account }} ${{ .Amount }} {{ .Destination }} ${{ .Amount }}
cash {{ with .Source }}{{ . }}{{ else }}cash{{ end }}