|
@@ -1,7 +1,7 @@
|
|
package v1main
|
|
package v1main
|
|
|
|
|
|
import (
|
|
import (
|
|
- "errors"
|
|
|
|
|
|
+ "database/sql"
|
|
"fmt"
|
|
"fmt"
|
|
"fyne.io/fyne/v2"
|
|
"fyne.io/fyne/v2"
|
|
"fyne.io/fyne/v2/container"
|
|
"fyne.io/fyne/v2/container"
|
|
@@ -11,21 +11,14 @@ import (
|
|
"github.com/SuperH-0630/hdangan/src/model"
|
|
"github.com/SuperH-0630/hdangan/src/model"
|
|
"github.com/SuperH-0630/hdangan/src/runtime"
|
|
"github.com/SuperH-0630/hdangan/src/runtime"
|
|
"github.com/SuperH-0630/hdangan/src/systeminit"
|
|
"github.com/SuperH-0630/hdangan/src/systeminit"
|
|
|
|
+ datepicker "github.com/sdassow/fyne-datepicker"
|
|
"strconv"
|
|
"strconv"
|
|
|
|
+ "strings"
|
|
"time"
|
|
"time"
|
|
)
|
|
)
|
|
|
|
|
|
-func ShowNew(rt runtime.RunTime, refresh func(rt runtime.RunTime)) {
|
|
|
|
- config, err := systeminit.GetInit()
|
|
|
|
- if errors.Is(err, systeminit.LuckyError) {
|
|
|
|
- rt.DBConnectError(err)
|
|
|
|
- return
|
|
|
|
- } else if err != nil {
|
|
|
|
- rt.DBConnectError(fmt.Errorf("配置文件错误,请检查配置文件状态。"))
|
|
|
|
- return
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- newWindow := rt.App().NewWindow("创建新卷宗")
|
|
|
|
|
|
+func ShowNew(rt runtime.RunTime, w *CtrlWindow, refresh func(rt runtime.RunTime)) {
|
|
|
|
+ newWindow := rt.App().NewWindow("创建记录")
|
|
|
|
|
|
newWindow.SetOnClosed(func() {
|
|
newWindow.SetOnClosed(func() {
|
|
rt.Action()
|
|
rt.Action()
|
|
@@ -37,49 +30,169 @@ func ShowNew(rt runtime.RunTime, refresh func(rt runtime.RunTime)) {
|
|
newWindow = nil
|
|
newWindow = nil
|
|
})
|
|
})
|
|
|
|
|
|
- fid, err := model.GetNewFileID(rt)
|
|
|
|
- if err != nil {
|
|
|
|
- dialog.ShowError(fmt.Errorf("获取新的档案ID出错:%s", err.Error()), newWindow)
|
|
|
|
|
|
+ maker, ok := model.FileSetTypeMaker[w.table.fileSetType]
|
|
|
|
+ if !ok {
|
|
|
|
+ rt.DBConnectError(fmt.Errorf("配置文件错误,请检查配置文件状态。"))
|
|
|
|
+ return
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ fm := maker()
|
|
|
|
+ f := fm.GetFile()
|
|
|
|
+
|
|
|
|
+ f.PeopleCount = 1
|
|
|
|
+
|
|
|
|
+ comment := widget.NewMultiLineEntry()
|
|
|
|
+ comment.Text = strToStr(f.Comment, "")
|
|
|
|
+ comment.Wrapping = fyne.TextWrapWord
|
|
|
|
+ comment.OnChanged = func(s string) {
|
|
|
|
+ rt.Action()
|
|
|
|
+ comment.Text = strToStr(f.Comment, "")
|
|
}
|
|
}
|
|
|
|
|
|
- now := time.Now()
|
|
|
|
|
|
+ material := widget.NewMultiLineEntry()
|
|
|
|
+ material.Text = strToStr(f.Comment, "")
|
|
|
|
+ material.Wrapping = fyne.TextWrapWord
|
|
|
|
+ material.OnChanged = func(s string) {
|
|
|
|
+ rt.Action()
|
|
|
|
+ material.Text = strToStr(f.Comment, "")
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if !f.OldName.Valid {
|
|
|
|
+ f.OldName.String = ""
|
|
|
|
+ }
|
|
|
|
|
|
- f := model.File{
|
|
|
|
- FileID: fid,
|
|
|
|
- FirstMoveIn: now,
|
|
|
|
- LastMoveIn: now,
|
|
|
|
- MoveStatus: config.Yaml.Move.MoveInStatus,
|
|
|
|
|
|
+ if !f.IDCard.Valid {
|
|
|
|
+ f.IDCard.String = ""
|
|
}
|
|
}
|
|
|
|
|
|
- fileComment := widget.NewMultiLineEntry()
|
|
|
|
- fileComment.Text = strToStr(f.FileComment, "")
|
|
|
|
- fileComment.Wrapping = fyne.TextWrapWord
|
|
|
|
|
|
+ if !f.Comment.Valid {
|
|
|
|
+ f.Comment.String = ""
|
|
|
|
+ }
|
|
|
|
|
|
- formLayout := layout.NewFormLayout()
|
|
|
|
- form := container.New(formLayout,
|
|
|
|
- widget.NewLabel("卷宗号:"),
|
|
|
|
- newFileIDEntry4(fmt.Sprintf("%d", f.FileID), &f.FileID),
|
|
|
|
|
|
+ sameAboveDisableList := make([]fyne.Disableable, 0, 10)
|
|
|
|
|
|
|
|
+ leftLayout := layout.NewFormLayout()
|
|
|
|
+ left := container.New(leftLayout,
|
|
widget.NewLabel("姓名:"),
|
|
widget.NewLabel("姓名:"),
|
|
- newEntry4(fmt.Sprintf("%s", f.Name), &f.Name),
|
|
|
|
|
|
+ newEntry4(fmt.Sprintf("%s", f.Name), &f.Name, nil),
|
|
|
|
+
|
|
|
|
+ widget.NewLabel("曾用名:"),
|
|
|
|
+ newEntryValid4(fmt.Sprintf("%s", f.OldName.String), &f.OldName, nil),
|
|
|
|
|
|
widget.NewLabel("身份证号:"),
|
|
widget.NewLabel("身份证号:"),
|
|
- newEntry4(fmt.Sprintf("%s", f.IDCard), &f.IDCard),
|
|
|
|
|
|
+ newEntryValid4(fmt.Sprintf("%s", f.IDCard.String), &f.IDCard, nil),
|
|
|
|
|
|
- widget.NewLabel("户籍地:"),
|
|
|
|
- newEntry4(fmt.Sprintf("%s", f.Location), &f.Location),
|
|
|
|
|
|
+ widget.NewLabel("性别:"),
|
|
|
|
+ newSexSelect4(f.IsMan, &f.IsMan),
|
|
|
|
|
|
- widget.NewLabel("卷宗标题:"),
|
|
|
|
- newEntry4(fmt.Sprintf("%s", f.FileTitle), &f.FileTitle),
|
|
|
|
|
|
+ widget.NewLabel("出生日期:"),
|
|
|
|
+ newDatePicker4(f.Birthday, &f.Birthday, newWindow, nil),
|
|
|
|
|
|
- widget.NewLabel("卷宗类型:"),
|
|
|
|
- newFileTypeSelect4(fmt.Sprintf("%s", f.FileType), config.Yaml.File.FileType, &f.FileType),
|
|
|
|
|
|
+ widget.NewLabel("同上:"),
|
|
|
|
+ newSameAboveCheck4("", &f.SameAsAbove, &sameAboveDisableList),
|
|
|
|
|
|
- widget.NewLabel("卷宗备注:"),
|
|
|
|
- fileComment,
|
|
|
|
|
|
+ widget.NewLabel("备注:"),
|
|
|
|
+ comment,
|
|
)
|
|
)
|
|
|
|
|
|
- upBox := container.NewHBox(form)
|
|
|
|
|
|
+ rightDigit := make([]fyne.CanvasObject, 0, 10)
|
|
|
|
+
|
|
|
|
+ switch ff := fm.(type) {
|
|
|
|
+ case *model.FileQianRu:
|
|
|
|
+ rightDigit = append(rightDigit,
|
|
|
|
+ widget.NewLabel("类型:"),
|
|
|
|
+ newFileTypeSelect4(ff.Type, ff.FileSetType, &ff.Type, &sameAboveDisableList),
|
|
|
|
+
|
|
|
|
+ widget.NewLabel("旧地址:"),
|
|
|
|
+ newEntry4(ff.OldLocation, &ff.OldLocation, &sameAboveDisableList),
|
|
|
|
+
|
|
|
|
+ widget.NewLabel("新地址:"),
|
|
|
|
+ newEntry4(ff.NewLocation, &ff.NewLocation, &sameAboveDisableList),
|
|
|
|
+ )
|
|
|
|
+ case *model.FileChuSheng:
|
|
|
|
+ rightDigit = append(rightDigit,
|
|
|
|
+ widget.NewLabel("类型:"),
|
|
|
|
+ newFileTypeSelect4(ff.Type, ff.FileSetType, &ff.Type, &sameAboveDisableList),
|
|
|
|
+
|
|
|
|
+ widget.NewLabel("地址:"),
|
|
|
|
+ newEntry4(ff.NewLocation, &ff.NewLocation, &sameAboveDisableList),
|
|
|
|
+ )
|
|
|
|
+ case *model.FileQianChu:
|
|
|
|
+ rightDigit = append(rightDigit,
|
|
|
|
+ widget.NewLabel("类型:"),
|
|
|
|
+ newFileTypeSelect4(ff.Type, ff.FileSetType, &ff.Type, &sameAboveDisableList),
|
|
|
|
+
|
|
|
|
+ widget.NewLabel("新地址:"),
|
|
|
|
+ newEntry4(ff.NewLocation, &ff.NewLocation, &sameAboveDisableList),
|
|
|
|
+ )
|
|
|
|
+ case *model.FileSiWang:
|
|
|
|
+ rightDigit = append(rightDigit,
|
|
|
|
+ widget.NewLabel("类型:"),
|
|
|
|
+ newFileTypeSelect4(ff.Type, ff.FileSetType, &ff.Type, &sameAboveDisableList),
|
|
|
|
+
|
|
|
|
+ widget.NewLabel("地址:"),
|
|
|
|
+ newEntry4(ff.Location, &ff.Location, &sameAboveDisableList),
|
|
|
|
+ )
|
|
|
|
+ case *model.FileBianGeng:
|
|
|
|
+ rightDigit = append(rightDigit,
|
|
|
|
+ widget.NewLabel("类型:"),
|
|
|
|
+ newFileTypeSelect4(ff.Type, ff.FileSetType, &ff.Type, &sameAboveDisableList),
|
|
|
|
+
|
|
|
|
+ widget.NewLabel("地址:"),
|
|
|
|
+ newEntry4(ff.Location, &ff.Location, &sameAboveDisableList),
|
|
|
|
+ )
|
|
|
|
+ case *model.FileSuoNeiYiJu:
|
|
|
|
+ rightDigit = append(rightDigit,
|
|
|
|
+ widget.NewLabel("类型:"),
|
|
|
|
+ newFileTypeSelect4(ff.Type, ff.FileSetType, &ff.Type, &sameAboveDisableList),
|
|
|
|
+
|
|
|
|
+ widget.NewLabel("地址:"),
|
|
|
|
+ newEntry4(ff.Location, &ff.Location, &sameAboveDisableList),
|
|
|
|
+ )
|
|
|
|
+ case *model.FileSuoJianYiJu:
|
|
|
|
+ rightDigit = append(rightDigit,
|
|
|
|
+ widget.NewLabel("类型:"),
|
|
|
|
+ newFileTypeSelect4(ff.Type, ff.FileSetType, &ff.Type, &sameAboveDisableList),
|
|
|
|
+
|
|
|
|
+ widget.NewLabel("地址:"),
|
|
|
|
+ newEntry4(ff.Location, &ff.Location, &sameAboveDisableList),
|
|
|
|
+ )
|
|
|
|
+ case *model.FileNongZiZhuanFei:
|
|
|
|
+ rightDigit = append(rightDigit,
|
|
|
|
+ widget.NewLabel("类型:"),
|
|
|
|
+ newFileTypeSelect4(ff.Type, ff.FileSetType, &ff.Type, &sameAboveDisableList),
|
|
|
|
+
|
|
|
|
+ widget.NewLabel("地址:"),
|
|
|
|
+ newEntry4(ff.Location, &ff.Location, &sameAboveDisableList),
|
|
|
|
+ )
|
|
|
|
+ case *model.FileYiZhanShiQianYiZheng:
|
|
|
|
+ rightDigit = append(rightDigit,
|
|
|
|
+ widget.NewLabel("类型:"),
|
|
|
|
+ newFileTypeSelect4(ff.Type, ff.FileSetType, &ff.Type, &sameAboveDisableList),
|
|
|
|
+
|
|
|
|
+ widget.NewLabel("地址:"),
|
|
|
|
+ newEntry4(ff.Location, &ff.Location, &sameAboveDisableList),
|
|
|
|
+ )
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ rightDigit = append(rightDigit,
|
|
|
|
+ widget.NewLabel("办理时间:"),
|
|
|
|
+ newDatePicker4(f.Time, &f.Time, newWindow, &sameAboveDisableList),
|
|
|
|
+
|
|
|
|
+ widget.NewLabel("备考:"),
|
|
|
|
+ newFileBeiKaoSelect4(f.BeiKao.String, f.FileSetType, &f.BeiKao, &f.Material, newWindow, nil),
|
|
|
|
+
|
|
|
|
+ widget.NewLabel("材料页数:"),
|
|
|
|
+ newEntryPage4(f.PageCount, &f.PageCount, &sameAboveDisableList),
|
|
|
|
+
|
|
|
|
+ widget.NewLabel("材料:"),
|
|
|
|
+ material,
|
|
|
|
+ )
|
|
|
|
+
|
|
|
|
+ rightLayout := layout.NewFormLayout()
|
|
|
|
+ right := container.New(rightLayout, rightDigit...)
|
|
|
|
+
|
|
|
|
+ upBox := container.NewHBox(left, right)
|
|
|
|
|
|
save := widget.NewButton("保存", func() {
|
|
save := widget.NewButton("保存", func() {
|
|
rt.Action()
|
|
rt.Action()
|
|
@@ -89,16 +202,10 @@ func ShowNew(rt runtime.RunTime, refresh func(rt runtime.RunTime)) {
|
|
return
|
|
return
|
|
}
|
|
}
|
|
|
|
|
|
- err = checkNewFile(&f)
|
|
|
|
- if err != nil {
|
|
|
|
- dialog.ShowError(fmt.Errorf("请检查错误:%s", err.Error()), newWindow)
|
|
|
|
- return
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- dialog.ShowConfirm("创建?", "你确定要新增卷宗嘛?", func(b bool) {
|
|
|
|
|
|
+ dialog.ShowConfirm("创建?", "你确定要新增档案嘛?", func(b bool) {
|
|
rt.Action()
|
|
rt.Action()
|
|
if b {
|
|
if b {
|
|
- err := model.CreateFile(&f)
|
|
|
|
|
|
+ err := model.CreateFile(rt, w.table.fileSetType, fm)
|
|
if err != nil {
|
|
if err != nil {
|
|
dialog.ShowError(fmt.Errorf("数据库错误: %s", err.Error()), newWindow)
|
|
dialog.ShowError(fmt.Errorf("数据库错误: %s", err.Error()), newWindow)
|
|
}
|
|
}
|
|
@@ -140,49 +247,9 @@ func ShowNew(rt runtime.RunTime, refresh func(rt runtime.RunTime)) {
|
|
newWindow.SetFixedSize(true)
|
|
newWindow.SetFixedSize(true)
|
|
}
|
|
}
|
|
|
|
|
|
-func checkNewFile(f *model.File) error {
|
|
|
|
- if f.ID != 0 {
|
|
|
|
- return fmt.Errorf("系统错误")
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- if f.FileID <= 0 {
|
|
|
|
- return fmt.Errorf("卷宗号必须大于0")
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- if len(f.Name) <= 0 || len(f.Name) >= 45 {
|
|
|
|
- return fmt.Errorf("姓名必填,最大45字符")
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- if len(f.IDCard) <= 0 || len(f.IDCard) >= 20 {
|
|
|
|
- return fmt.Errorf("身份证必填,最大20字符")
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- if len(f.Location) <= 0 || len(f.Location) >= 20 {
|
|
|
|
- return fmt.Errorf("户籍地必填,最大145字符")
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- if len(f.FileTitle) <= 0 || len(f.FileTitle) >= 45 {
|
|
|
|
- return fmt.Errorf("卷宗标题必填,最大45字符")
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- if len(f.FileType) <= 0 || len(f.FileType) >= 45 {
|
|
|
|
- return fmt.Errorf("卷宗类型必填,最大15字符")
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- if f.FileComment.Valid {
|
|
|
|
- if len(f.FileComment.String) == 0 {
|
|
|
|
- f.FileComment.Valid = false
|
|
|
|
- }
|
|
|
|
- } else {
|
|
|
|
- f.FileComment.Valid = true
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- return nil
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
var entryList4 []*widget.Entry
|
|
var entryList4 []*widget.Entry
|
|
|
|
|
|
-func newEntry4(data string, input *string) *widget.Entry {
|
|
|
|
|
|
+func newEntry4(data string, input *string, disableLst *[]fyne.Disableable) *widget.Entry {
|
|
entry := widget.NewEntry()
|
|
entry := widget.NewEntry()
|
|
entry.Text = data
|
|
entry.Text = data
|
|
|
|
|
|
@@ -193,12 +260,18 @@ func newEntry4(data string, input *string) *widget.Entry {
|
|
}
|
|
}
|
|
|
|
|
|
entryList4 = append(entryList4, entry)
|
|
entryList4 = append(entryList4, entry)
|
|
|
|
+
|
|
|
|
+ if disableLst != nil {
|
|
|
|
+ *disableLst = append(*disableLst, entry)
|
|
|
|
+ }
|
|
|
|
+
|
|
return entry
|
|
return entry
|
|
}
|
|
}
|
|
|
|
|
|
-func newFileIDEntry4(data string, input *int64) *widget.Entry {
|
|
|
|
|
|
+func newEntryPage4(data int64, input *int64, disableLst *[]fyne.Disableable) *widget.Entry {
|
|
entry := widget.NewEntry()
|
|
entry := widget.NewEntry()
|
|
- entry.Text = data
|
|
|
|
|
|
+ entry.Text = fmt.Sprintf("%d", data)
|
|
|
|
+
|
|
entry.Validator = func(s string) error {
|
|
entry.Validator = func(s string) error {
|
|
n, err := strconv.ParseInt(s, 10, 64)
|
|
n, err := strconv.ParseInt(s, 10, 64)
|
|
if err != nil {
|
|
if err != nil {
|
|
@@ -206,7 +279,7 @@ func newFileIDEntry4(data string, input *int64) *widget.Entry {
|
|
}
|
|
}
|
|
|
|
|
|
if n <= 0 {
|
|
if n <= 0 {
|
|
- return fmt.Errorf("must bigger than zero")
|
|
|
|
|
|
+ return fmt.Errorf("page musr bigger than zero")
|
|
}
|
|
}
|
|
|
|
|
|
return nil
|
|
return nil
|
|
@@ -221,30 +294,190 @@ func newFileIDEntry4(data string, input *int64) *widget.Entry {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ if disableLst != nil {
|
|
|
|
+ *disableLst = append(*disableLst, entry)
|
|
|
|
+ }
|
|
|
|
+
|
|
entryList4 = append(entryList4, entry)
|
|
entryList4 = append(entryList4, entry)
|
|
return entry
|
|
return entry
|
|
}
|
|
}
|
|
|
|
|
|
-func newFileTypeSelect4(data string, options []string, input *string) *widget.Select {
|
|
|
|
- if data != "" {
|
|
|
|
- func() {
|
|
|
|
- for _, option := range options {
|
|
|
|
- if option == data {
|
|
|
|
- return
|
|
|
|
- }
|
|
|
|
|
|
+func newEntryValid4(data string, input *sql.NullString, disableLst *[]fyne.Disableable) *widget.Entry {
|
|
|
|
+ entry := widget.NewEntry()
|
|
|
|
+ entry.Text = data
|
|
|
|
+
|
|
|
|
+ entry.OnChanged = func(s string) {
|
|
|
|
+ if entry.Validate() == nil {
|
|
|
|
+ if len(s) == 0 {
|
|
|
|
+ *input = sql.NullString{Valid: false}
|
|
|
|
+ } else {
|
|
|
|
+ *input = sql.NullString{Valid: true, String: s}
|
|
}
|
|
}
|
|
- options = append(options, data)
|
|
|
|
- }()
|
|
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if disableLst != nil {
|
|
|
|
+ *disableLst = append(*disableLst, entry)
|
|
}
|
|
}
|
|
|
|
|
|
- sel := widget.NewSelect(options, func(s string) {
|
|
|
|
|
|
+ entryList4 = append(entryList4, entry)
|
|
|
|
+ return entry
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+func newFileTypeSelect4(data string, fst model.FileSetType, input *string, disableLst *[]fyne.Disableable) fyne.CanvasObject {
|
|
|
|
+ c, err := systeminit.GetInit()
|
|
|
|
+ if err != nil {
|
|
|
|
+ return newEntry4(data, input, disableLst)
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ fstName, ok := model.FileSetTypeName[fst]
|
|
|
|
+ if !ok {
|
|
|
|
+ return newEntry4(data, input, disableLst)
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ fileType, ok := c.Yaml.File.FileType[fstName]
|
|
|
|
+ if !ok {
|
|
|
|
+ return newEntry4(data, input, disableLst)
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if !func() bool {
|
|
|
|
+ for _, t := range fileType {
|
|
|
|
+ if t == data {
|
|
|
|
+ return true
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ return false
|
|
|
|
+ }() {
|
|
|
|
+ return newEntry4(data, input, disableLst)
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ sel := widget.NewSelect(fileType, func(s string) {
|
|
*input = s
|
|
*input = s
|
|
})
|
|
})
|
|
|
|
|
|
|
|
+ if disableLst != nil {
|
|
|
|
+ *disableLst = append(*disableLst, sel)
|
|
|
|
+ }
|
|
|
|
+
|
|
sel.Selected = data
|
|
sel.Selected = data
|
|
return sel
|
|
return sel
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+func newFileBeiKaoSelect4(data string, fst model.FileSetType, input *sql.NullString, materialInput *sql.NullString, w fyne.Window, disableLst *[]fyne.Disableable) fyne.CanvasObject {
|
|
|
|
+ c, err := systeminit.GetInit()
|
|
|
|
+ if err != nil {
|
|
|
|
+ return newEntryValid4(data, input, disableLst)
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ fstName, ok := model.FileSetTypeName[fst]
|
|
|
|
+ if !ok {
|
|
|
|
+ return newEntryValid4(data, input, disableLst)
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ beiKao, ok := c.Yaml.File.BeiKao[fstName]
|
|
|
|
+ if !ok {
|
|
|
|
+ return newEntryValid4(data, input, disableLst)
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if !func() bool {
|
|
|
|
+ for _, t := range beiKao {
|
|
|
|
+ if t.Name == data {
|
|
|
|
+ return true
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ return false
|
|
|
|
+ }() {
|
|
|
|
+ return newEntryValid4(data, input, disableLst)
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ for _, i := range beiKao {
|
|
|
|
+ for _, j := range beiKao {
|
|
|
|
+ if i.Name == j.Name {
|
|
|
|
+ return newEntryValid4(data, input, disableLst)
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ beiKaoLst := make([]string, 0, len(beiKao))
|
|
|
|
+ for _, i := range beiKao {
|
|
|
|
+ beiKaoLst = append(beiKaoLst, i.Name)
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ sel := widget.NewSelect(beiKaoLst, func(s string) {
|
|
|
|
+ input.Valid = len(s) != 0
|
|
|
|
+ input.String = s
|
|
|
|
+
|
|
|
|
+ for _, i := range beiKao {
|
|
|
|
+ if s == i.Name && len(i.Material) != 0 {
|
|
|
|
+ dialog.ShowConfirm("确认", "此”备考“有预先录制的材料列表,是否立即使用?", func(b bool) {
|
|
|
|
+ if !b {
|
|
|
|
+ return
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ materialInput.Valid = true
|
|
|
|
+ materialInput.String = strings.Join(i.Material, "、") + "。"
|
|
|
|
+ }, w)
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ })
|
|
|
|
+
|
|
|
|
+ if disableLst != nil {
|
|
|
|
+ *disableLst = append(*disableLst, sel)
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ sel.Selected = data
|
|
|
|
+ return sel
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+func newSexSelect4(data bool, isMan *bool) *widget.Select {
|
|
|
|
+ sel := widget.NewSelect([]string{"男性", "女性"}, func(s string) {
|
|
|
|
+ *isMan = s == "男性"
|
|
|
|
+ })
|
|
|
|
+
|
|
|
|
+ if data {
|
|
|
|
+ sel.Selected = "男性"
|
|
|
|
+ } else {
|
|
|
|
+ sel.Selected = "女性"
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ return sel
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+func newDatePicker4(data time.Time, input *time.Time, w fyne.Window, disableLst *[]fyne.Disableable) *widget.Button {
|
|
|
|
+ btn := widget.NewButton("选择时间", func() {})
|
|
|
|
+
|
|
|
|
+ d := datepicker.NewDatePicker(data, time.Monday, func(t time.Time, b bool) {
|
|
|
|
+ if b {
|
|
|
|
+ *input = t
|
|
|
|
+ btn.SetText(t.Format("2006-01-02"))
|
|
|
|
+ }
|
|
|
|
+ })
|
|
|
|
+
|
|
|
|
+ btn.OnTapped = func() {
|
|
|
|
+ dialog.ShowCustomConfirm("选择时间", "确认", "放弃", d, d.OnActioned, w)
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if disableLst != nil {
|
|
|
|
+ *disableLst = append(*disableLst, btn)
|
|
|
|
+ }
|
|
|
|
+ return btn
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+func newSameAboveCheck4(data string, input *bool, disableLst *[]fyne.Disableable) *widget.Check {
|
|
|
|
+ btn := widget.NewCheck(data, func(b bool) {
|
|
|
|
+ *input = b
|
|
|
|
+ for _, d := range *disableLst {
|
|
|
|
+ if b {
|
|
|
|
+ d.Disable()
|
|
|
|
+ } else {
|
|
|
|
+ d.Enable()
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ })
|
|
|
|
+ return btn
|
|
|
|
+}
|
|
|
|
+
|
|
func checkAllInputRight4() error {
|
|
func checkAllInputRight4() error {
|
|
for _, e := range entryList4 {
|
|
for _, e := range entryList4 {
|
|
err := e.Validate()
|
|
err := e.Validate()
|