You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
247 lines
6.9 KiB
Go
247 lines
6.9 KiB
Go
package main
|
|
|
|
import (
|
|
"encoding/json"
|
|
"errors"
|
|
"flx/Common"
|
|
"flx/localcache"
|
|
"fmt"
|
|
"image/color"
|
|
"time"
|
|
|
|
"fyne.io/fyne/v2"
|
|
"fyne.io/fyne/v2/canvas"
|
|
"fyne.io/fyne/v2/container"
|
|
"fyne.io/fyne/v2/dialog"
|
|
"fyne.io/fyne/v2/widget"
|
|
log "github.com/sirupsen/logrus"
|
|
)
|
|
|
|
func AgendaPersonWindowControl() {
|
|
|
|
defer func() {
|
|
if r := recover(); r != nil {
|
|
log.Error("AgendaPersonWindowControl:", r)
|
|
}
|
|
}()
|
|
|
|
// fyne.DoAndWait(func() {
|
|
CardWindow = NAPP.NewWindow("参会人员")
|
|
// })
|
|
|
|
Smainview = container.NewMax()
|
|
Smainview.Add(APDefaultLayout())
|
|
|
|
// fyne.DoAndWait(func() {
|
|
CardWindow.SetContent(Smainview)
|
|
// })
|
|
|
|
// MainWindow.Maxwindow()
|
|
// CardWindow.Resize(fyne.NewSize(1600, 800), 100, 100)
|
|
CardWindow.Resize(fyne.NewSize(1920*BigPara, 800*BigPara))
|
|
|
|
// MainWindow.SetMasterf()
|
|
CardWindow.SetPadded(false)
|
|
|
|
// 添加窗口关闭拦截逻辑
|
|
// CardWindow.SetCloseIntercept(func() {
|
|
// // 重置选中行状态
|
|
// CurrentAPID = widget.TableCellID{Row: -1}
|
|
// APersonlist.Refresh() // 刷新表格清除高亮
|
|
|
|
// // 关闭窗口(执行原始关闭逻辑)
|
|
// CardWindow.Close()
|
|
// })
|
|
|
|
// fyne.DoAndWait(func() {
|
|
CardWindow.Show()
|
|
// })
|
|
|
|
}
|
|
|
|
// var AllPerson []Model.T_AgendaPerson
|
|
|
|
// 人员列表
|
|
var APersonlist *widget.Table
|
|
|
|
// 当前选择cellID
|
|
var CurrentAPID widget.TableCellID
|
|
|
|
func APDefaultLayout() fyne.CanvasObject {
|
|
|
|
defer func() {
|
|
if r := recover(); r != nil {
|
|
log.Error("APDefaultLayout:", r)
|
|
}
|
|
}()
|
|
|
|
btnUp := widget.NewButton("补报", func() {
|
|
|
|
if CurrentAPID.Row < 0 || CurrentAPID.Row >= len(localcache.AllPerson) {
|
|
dialog.ShowError(errors.New("请先选择一行数据"), CardWindow)
|
|
return
|
|
}
|
|
if localcache.AllPerson[CurrentAPID.Row].AP_CheckState == 1 {
|
|
dialog.ShowError(errors.New("已经报到"), CardWindow)
|
|
return
|
|
}
|
|
url := "http://" + Common.LoadConfig().SeverData.ServerIP + ":9800/vhwcapi/v1/web/api/service/congresscontrol/checkinBatch"
|
|
data := map[string]interface{}{
|
|
"updatebatchobj": []map[string]interface{}{
|
|
{"perid": &(localcache.AllPerson[CurrentAPID.Row].AP_ID)},
|
|
},
|
|
}
|
|
// 将map转换为JSON格式
|
|
jsonData, err := json.Marshal(data)
|
|
if err != nil {
|
|
log.Fatal(err)
|
|
}
|
|
body, statusCode, err := Common.SendPostRequest(url, jsonData, "application/json")
|
|
if err != nil {
|
|
log.Fatalf("请求错误: %v", err)
|
|
}
|
|
fmt.Printf("响应状态码: %d\n响应体: %s\n", statusCode, body)
|
|
|
|
person := GetAgendaPersonByCardNum(localcache.AllPerson[CurrentAPID.Row].AP_StaffInfo.St_ViceCardNum)
|
|
person.AP_CheckInTime = time.Now()
|
|
localcache.Currentreportper = person
|
|
RefrushData(person, true)
|
|
|
|
APersonlist.Refresh()
|
|
|
|
// var NextID widget.TableCellID = widget.TableCellID{Row: CurrentAPID.Row - 1, Col: 4}
|
|
// APersonlist.Select(NextID)
|
|
|
|
})
|
|
btnUp.Resize(fyne.NewSize(200*BigPara, 50*BigPara))
|
|
btnUp.Move(fyne.NewPos(1100*BigPara, 450*BigPara))
|
|
|
|
btnDown := widget.NewButton("销报", func() {
|
|
if CurrentAPID.Row < 0 || CurrentAPID.Row >= len(localcache.AllPerson) {
|
|
dialog.ShowError(errors.New("请先选择一行数据"), CardWindow)
|
|
return
|
|
}
|
|
if localcache.AllPerson[CurrentAPID.Row].AP_CheckState != 1 {
|
|
dialog.ShowError(errors.New("已经销报"), CardWindow)
|
|
return
|
|
}
|
|
url := "http://" + Common.LoadConfig().SeverData.ServerIP + ":9800/vhwcapi/v1/web/api/service/congresscontrol/checkoutBatch"
|
|
data := map[string]interface{}{
|
|
"updatebatchobj": []map[string]interface{}{
|
|
{"perid": &(localcache.AllPerson[CurrentAPID.Row].AP_ID)},
|
|
},
|
|
}
|
|
// 将map转换为JSON格式
|
|
jsonData, err := json.Marshal(data)
|
|
if err != nil {
|
|
log.Fatal(err)
|
|
}
|
|
body, statusCode, err := Common.SendPostRequest(url, jsonData, "application/json")
|
|
if err != nil {
|
|
log.Fatalf("请求错误: %v", err)
|
|
}
|
|
fmt.Printf("响应状态码: %d\n响应体: %s\n", statusCode, body)
|
|
|
|
person := GetAgendaPersonByCardNum(localcache.AllPerson[CurrentAPID.Row].AP_StaffInfo.St_ViceCardNum)
|
|
RefrushData(person, false)
|
|
APersonlist.Refresh()
|
|
// var NextID widget.TableCellID = widget.TableCellID{Row: CurrentAPID.Row + 1, Col: 4}
|
|
// APersonlist.Select(NextID)
|
|
|
|
})
|
|
btnDown.Resize(fyne.NewSize(200*BigPara, 50*BigPara))
|
|
btnDown.Move(fyne.NewPos(1350*BigPara, 450*BigPara))
|
|
|
|
APersonlist = widget.NewTable(
|
|
func() (int, int) { return len(localcache.AllPerson), 5 },
|
|
func() fyne.CanvasObject {
|
|
return widget.NewLabel("")
|
|
},
|
|
func(id widget.TableCellID, cell fyne.CanvasObject) {
|
|
label := cell.(*widget.Label)
|
|
// label.TextStyle.TextSize = 24 * BigPara
|
|
switch id.Col {
|
|
case 0:
|
|
label.SetText(localcache.AllPerson[id.Row].AP_CodeNum)
|
|
case 1:
|
|
label.SetText(localcache.AllPerson[id.Row].AP_StaffInfo.St_Name)
|
|
case 2:
|
|
text := ""
|
|
if !localcache.AllPerson[id.Row].AP_CheckInTime.IsZero() {
|
|
text = localcache.AllPerson[id.Row].AP_CheckInTime.Format("2006-01-02 15:04:05")
|
|
}
|
|
label.SetText(text)
|
|
|
|
case 3:
|
|
text := ""
|
|
if !localcache.AllPerson[id.Row].AP_CheckOutTime.IsZero() {
|
|
text = localcache.AllPerson[id.Row].AP_CheckOutTime.Format("2006-01-02 15:04:05")
|
|
}
|
|
label.SetText(text)
|
|
case 4:
|
|
var CheckStateName string
|
|
if localcache.AllPerson[id.Row].AP_CheckState == 1 {
|
|
CheckStateName = "已签到"
|
|
} else {
|
|
CheckStateName = "未签到"
|
|
}
|
|
label.SetText(CheckStateName)
|
|
|
|
}
|
|
})
|
|
APersonlist.OnSelected = func(id widget.TableCellID) {
|
|
CurrentAPID = id
|
|
}
|
|
|
|
APersonlist.SetColumnWidth(0, 140*BigPara)
|
|
APersonlist.SetColumnWidth(1, 140*BigPara)
|
|
APersonlist.SetColumnWidth(2, 180*BigPara)
|
|
APersonlist.SetColumnWidth(3, 180*BigPara)
|
|
APersonlist.SetColumnWidth(4, 140*BigPara)
|
|
APersonlist.Resize(fyne.NewSize(1000*BigPara, 700*BigPara))
|
|
APersonlist.Move(fyne.NewPos(50*BigPara, 100*BigPara))
|
|
|
|
lblNume := canvas.NewText("编号", color.Black)
|
|
lblNume.Resize(fyne.NewSize(140*BigPara, 50*BigPara))
|
|
lblNume.Move(fyne.NewPos(50*BigPara, 50*BigPara))
|
|
lblNume.Alignment = fyne.TextAlignCenter
|
|
lblNume.TextSize = 24 * BigPara
|
|
|
|
lblName := canvas.NewText("姓名", color.Black)
|
|
lblName.Resize(fyne.NewSize(140*BigPara, 50*BigPara))
|
|
lblName.Move(fyne.NewPos(190*BigPara, 50*BigPara))
|
|
lblName.Alignment = fyne.TextAlignCenter
|
|
lblName.TextSize = 24 * BigPara
|
|
|
|
lblType := canvas.NewText("签到时间", color.Black)
|
|
lblType.Resize(fyne.NewSize(140*BigPara, 50*BigPara))
|
|
lblType.Move(fyne.NewPos(350*BigPara, 50*BigPara))
|
|
lblType.Alignment = fyne.TextAlignCenter
|
|
lblType.TextSize = 24 * BigPara
|
|
|
|
lblGroup := canvas.NewText("签退时间", color.Black)
|
|
lblGroup.Resize(fyne.NewSize(140*BigPara, 50*BigPara))
|
|
lblGroup.Move(fyne.NewPos(540*BigPara, 50*BigPara))
|
|
lblGroup.Alignment = fyne.TextAlignCenter
|
|
lblGroup.TextSize = 24 * BigPara
|
|
|
|
lblCardNum := canvas.NewText("状态", color.Black)
|
|
lblCardNum.Resize(fyne.NewSize(140*BigPara, 50*BigPara))
|
|
lblCardNum.Move(fyne.NewPos(680*BigPara, 50*BigPara))
|
|
lblCardNum.Alignment = fyne.TextAlignCenter
|
|
lblCardNum.TextSize = 24 * BigPara
|
|
|
|
content := container.NewWithoutLayout(
|
|
lblNume,
|
|
lblName,
|
|
lblType,
|
|
lblGroup,
|
|
lblCardNum,
|
|
btnUp,
|
|
btnDown,
|
|
APersonlist,
|
|
)
|
|
return content
|
|
|
|
}
|