又优化了很多
This commit is contained in:
parent
8ae6f7ee1d
commit
a83ca924b7
@ -22,16 +22,16 @@ type CommonResourceService struct {
|
||||
func initCommonResourcesRepo(db *gorm.DB) {
|
||||
r(consts.ResourcesName_Project, "项目管理", repo.NewCommonResourceRepo(db, &model.Project{}), ShowMethod_Get|ShowMethod_Post|ShowMethod_Put|ShowMethod_Delete)
|
||||
r(consts.ResourcesName_Server, "服务器管理", repo.NewCommonResourceRepo(db, &model.Server{}), ShowMethod_Get|ShowMethod_Post|ShowMethod_Put|ShowMethod_Delete)
|
||||
r(consts.ResourcesName_Account, "账号管理", repo.NewCommonResourceRepo(db, &model.Account{}), ShowMethod_Get) // 账号管理不需要在后台读写数据,都是通过项目api拉
|
||||
r(consts.ResourcesName_Account, "账号列表", repo.NewCommonResourceRepo(db, &model.Account{}), ShowMethod_Get) // 账号管理不需要在后台读写数据,都是通过项目api拉
|
||||
r(consts.ResourcesName_SupportAccount, "扶持账号", repo.NewCommonResourceRepo(db, &model.SupportAccount{}), ShowMethod_Get|ShowMethod_Post|ShowMethod_Delete) // 扶持账号,只是标记哪些账号是扶持好
|
||||
r(consts.ResourcesName_Role, "角色管理", repo.NewCommonResourceRepo(db, &model.Role{}), ShowMethod_Get) // 角色管理不需要在后台读写数据,都是通过项目api拉
|
||||
r(consts.ResourcesName_Role, "角色列表", repo.NewCommonResourceRepo(db, &model.Role{}), ShowMethod_Get) // 角色管理不需要在后台读写数据,都是通过项目api拉
|
||||
r(consts.ResourcesName_WhiteList, "白名单", repo.NewCommonResourceRepo(db, &model.WhiteList{}), ShowMethod_Get|ShowMethod_Post|ShowMethod_Delete)
|
||||
r(consts.ResourcesName_Ban, "封禁管理", repo.NewCommonResourceRepo(db, &model.Ban{}), ShowMethod_Get|ShowMethod_Post|ShowMethod_Put|ShowMethod_Delete)
|
||||
r(consts.ResourcesName_MailRole, "个人邮件", repo.NewCommonResourceRepo(db, &model.RoleMail{}), ShowMethod_Get|ShowMethod_Post) // 个人邮件发放就没法撤回?
|
||||
r(consts.ResourcesName_MailGlobal, "全服邮件", repo.NewCommonResourceRepo(db, &model.GlobalMail{}), ShowMethod_Get|ShowMethod_Post) // 直接删除,别修改了,玩家收到的更乱
|
||||
r(consts.ResourcesName_Notice, "公告", repo.NewCommonResourceRepo(db, &model.Notice{}), ShowMethod_Get|ShowMethod_Post|ShowMethod_Put|ShowMethod_Delete)
|
||||
r(consts.ResourcesName_CDKey, "礼包码", repo.NewCommonResourceRepo(db, &model.CDKey{}), ShowMethod_Get|ShowMethod_Post|ShowMethod_Put|ShowMethod_Delete)
|
||||
r(consts.ResourcesName_DevicePush, "设备推送", repo.NewCommonResourceRepo(db, &model.DevicePush{}), ShowMethod_Get)
|
||||
r(consts.ResourcesName_DevicePush, "设备推送(暂无)", repo.NewCommonResourceRepo(db, &model.DevicePush{}), ShowMethod_Get)
|
||||
}
|
||||
|
||||
func NewCommonResourceService(db *gorm.DB) *CommonResourceService {
|
||||
@ -167,18 +167,18 @@ func (svc *CommonResourceService) Edit(projectId int, resource string, dtoObj dt
|
||||
return nil
|
||||
}
|
||||
|
||||
func (svc *CommonResourceService) Delete(projectId int, resource string, id int) error {
|
||||
func (svc *CommonResourceService) Delete(projectId int, resource string, id int) (*entity.CommonResource, error) {
|
||||
_, projectEt, find, err := svc.projectRepo.GetById(projectId)
|
||||
if err != nil {
|
||||
return err
|
||||
return nil, err
|
||||
}
|
||||
if resource != consts.ResourcesName_Project && !find {
|
||||
return errcode.New(errcode.ServerError, "not found project %v db data", projectId)
|
||||
return nil, errcode.New(errcode.ServerError, "not found project %v db data", projectId)
|
||||
}
|
||||
|
||||
oldEt, find, err := findCommResourceRepo(resource).Delete(projectEt, id)
|
||||
if err != nil {
|
||||
return err
|
||||
return nil, err
|
||||
}
|
||||
|
||||
// 执行各个项目特定的钩子方法
|
||||
@ -186,13 +186,13 @@ func (svc *CommonResourceService) Delete(projectId int, resource string, id int)
|
||||
if hook, ok := projects.GetProjectResourceHook(projectEt, resource).(projects.IPostResourceOpDeleteHook); ok {
|
||||
err = hook.Delete(projectEt, resource, oldEt.ToCommonDto())
|
||||
if err != nil {
|
||||
return err
|
||||
return oldEt, err
|
||||
}
|
||||
return nil
|
||||
return oldEt, nil
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
return oldEt, nil
|
||||
}
|
||||
|
||||
func (svc *CommonResourceService) GetSupportResourcesList(permissions []string) []*api.ResourceInitInfo {
|
||||
|
@ -49,12 +49,21 @@ func (hook *AccountHook) List(projectInfo *entity.Project, resource string, para
|
||||
} `json:"data"`
|
||||
}
|
||||
|
||||
body := &url.Values{}
|
||||
|
||||
for _, cond := range params.ParsedWhereConditions.Conditions {
|
||||
if cond.Key == "Account" {
|
||||
// 按账号查询
|
||||
body.Set("userId", cond.Value1.(string))
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
for _, reqServer := range reqPageServerList {
|
||||
body := &url.Values{}
|
||||
body.Add("serverid", reqServer.RawInfo.ServerId)
|
||||
body.Add("offset", strconv.Itoa(reqServer.Offset))
|
||||
body.Add("count", strconv.Itoa(reqServer.Count))
|
||||
body.Add("userlist", "true")
|
||||
body.Set("serverid", reqServer.RawInfo.ServerId)
|
||||
body.Set("offset", strconv.Itoa(reqServer.Offset))
|
||||
body.Set("count", strconv.Itoa(reqServer.Count))
|
||||
body.Set("userlist", "true")
|
||||
|
||||
rsp := &RspData{}
|
||||
err := httpclient.Request(alisrvAddr+"/rolelist", "get", body, rsp)
|
||||
@ -80,7 +89,7 @@ func (hook *AccountHook) List(projectInfo *entity.Project, resource string, para
|
||||
}
|
||||
}
|
||||
userPo.LatestLoginTime = utils.ParseUnixTimestamp2LocalTime(latestLoginTime)
|
||||
userPo.CreateTime = utils.ParseUnixTimestamp2LocalTime(earliestCreateTime)
|
||||
userPo.CreatedAt = utils.ParseUnixTimestamp2LocalTime(earliestCreateTime)
|
||||
et := (&entity.CommonResource{}).FromPo(userPo)
|
||||
rows = append(rows, et.ToCommonDto())
|
||||
}
|
||||
@ -95,30 +104,27 @@ func getPaginationServerReqList(projectInfo *entity.Project, serverInfoList inte
|
||||
|
||||
pageNo := params.PageNo
|
||||
pageLen := params.PageLen
|
||||
whereConditions := params.ParsedWhereConditions
|
||||
|
||||
reqServerList := make([]*internal.PageServerCountInfo, 0)
|
||||
|
||||
if len(whereConditions.Conditions) > 1 {
|
||||
// 第一个是ProjectId条件
|
||||
if whereConditions.Conditions[1].Key != "ServerConfId" { // 账号、角色的条件检索只支持区服
|
||||
return 0, nil, errcode.New(errcode.ParamsInvalid, "where condition invalid:%+v", whereConditions.Conditions[0])
|
||||
}
|
||||
// 前端指定了查询某个区服的数据
|
||||
specServerId := whereConditions.Conditions[1].Value1.(string)
|
||||
for _, v := range serverInfoList {
|
||||
if v.ServerId == specServerId {
|
||||
offset := (pageNo - 1) * pageLen
|
||||
limit := pageLen
|
||||
totalCount = queryCountField(v)
|
||||
reqServerList = append(reqServerList, &internal.PageServerCountInfo{
|
||||
RawInfo: v,
|
||||
Offset: offset,
|
||||
Count: limit,
|
||||
})
|
||||
break
|
||||
if specServerId, serverInfo, find := findWhereConditionSpecServer(params.ParsedWhereConditions.Conditions, serverInfoList); find {
|
||||
if serverInfo == nil {
|
||||
logServerList := make([]string, 0, len(serverInfoList))
|
||||
for _, s := range serverInfoList {
|
||||
logServerList = append(logServerList, s.ServerId)
|
||||
}
|
||||
return 0, nil, errcode.New(errcode.GameServerNotRunning,
|
||||
"运行的区服列表(%+v)中没有指定的区服(%v)", logServerList, specServerId)
|
||||
}
|
||||
// 前端检索条件指定了区服
|
||||
totalCount = queryCountField(serverInfo)
|
||||
offset := (pageNo - 1) * pageLen
|
||||
limit := pageLen
|
||||
reqServerList = append(reqServerList, &internal.PageServerCountInfo{
|
||||
RawInfo: serverInfo,
|
||||
Offset: offset,
|
||||
Count: limit,
|
||||
})
|
||||
} else {
|
||||
// 根据分页参数计算需要几个区服数据参与查询
|
||||
totalCountTmp, tidyPageInfoList := serverInfoList.TidyToPageList(pageLen, queryCountField)
|
||||
@ -134,6 +140,25 @@ func getPaginationServerReqList(projectInfo *entity.Project, serverInfoList inte
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return totalCount, reqServerList, nil
|
||||
}
|
||||
|
||||
func findWhereConditionSpecServer(whereConditions []*dto.GetWhereCondition, serverInfoList internal.ServerInfoList) (string, *internal.ServerInfo, bool) {
|
||||
if len(whereConditions) > 1 {
|
||||
// 第一个是ProjectId条件
|
||||
for _, cond := range whereConditions {
|
||||
if cond.Key == "ServerConfId" {
|
||||
specServerId := cond.Value1.(string)
|
||||
// 前端指定了查询某个区服的数据
|
||||
for _, v := range serverInfoList {
|
||||
if v.ServerId == specServerId {
|
||||
return v.ServerId, v, true
|
||||
}
|
||||
}
|
||||
return specServerId, nil, true
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return "", nil, false
|
||||
}
|
||||
|
@ -50,16 +50,26 @@ func (hook *RoleHook) List(projectInfo *entity.Project, resource string, params
|
||||
Code int `json:"code"`
|
||||
Msg string `json:"msg"`
|
||||
} `json:"state"`
|
||||
Data struct {
|
||||
Data []*Role `json:"data"`
|
||||
} `json:"data"`
|
||||
Data []*Role `json:"data"`
|
||||
}
|
||||
|
||||
body := &url.Values{}
|
||||
|
||||
for _, cond := range params.ParsedWhereConditions.Conditions {
|
||||
if cond.Key == "Account" {
|
||||
// 按账号查询
|
||||
body.Set("userId", cond.Value1.(string))
|
||||
} else if cond.Key == "RoleId" {
|
||||
body.Set("roleId", cond.Value1.(string))
|
||||
} else if cond.Key == "Name" {
|
||||
body.Set("name", cond.Value1.(string))
|
||||
}
|
||||
}
|
||||
|
||||
for _, reqServer := range reqPageServerList {
|
||||
body := make(url.Values)
|
||||
body.Add("serverid", reqServer.RawInfo.ServerId)
|
||||
body.Add("offset", strconv.Itoa(reqServer.Offset))
|
||||
body.Add("count", strconv.Itoa(reqServer.Count))
|
||||
body.Set("serverid", reqServer.RawInfo.ServerId)
|
||||
body.Set("offset", strconv.Itoa(reqServer.Offset))
|
||||
body.Set("count", strconv.Itoa(reqServer.Count))
|
||||
|
||||
rsp := &RspData{}
|
||||
err := httpclient.Request(alisrvAddr+"/rolelist", "get", body, rsp)
|
||||
@ -67,7 +77,7 @@ func (hook *RoleHook) List(projectInfo *entity.Project, resource string, params
|
||||
return 0, nil, nil, err
|
||||
}
|
||||
|
||||
for _, role := range rsp.Data.Data {
|
||||
for _, role := range rsp.Data {
|
||||
rolePo := &model.Role{
|
||||
RoleId: role.RoleId,
|
||||
Account: role.Account,
|
||||
@ -77,12 +87,12 @@ func (hook *RoleHook) List(projectInfo *entity.Project, resource string, params
|
||||
Level: role.Level,
|
||||
Profession: role.Profession,
|
||||
LatestLoginTime: utils.ParseUnixTimestamp2LocalTime(role.LatestLoginTime),
|
||||
CreateTime: utils.ParseUnixTimestamp2LocalTime(role.CreateTime),
|
||||
CreatedAt: utils.ParseUnixTimestamp2LocalTime(role.CreateTime),
|
||||
}
|
||||
et := (&entity.CommonResource{}).FromPo(rolePo)
|
||||
rows = append(rows, et.ToCommonDto())
|
||||
}
|
||||
}
|
||||
|
||||
return 0, fields, rows, nil
|
||||
return totalCount, fields, rows, nil
|
||||
}
|
||||
|
@ -58,13 +58,13 @@ func (repo *commonResourceRepoImpl) List(projectEt *entity.Project, params *dto.
|
||||
var err error
|
||||
if len(whereConditions) <= 0 {
|
||||
txCount = repo.db.Model(repo.poTemplate)
|
||||
txFind = repo.db.Offset(limitStart).Limit(limitLen)
|
||||
txFind = repo.db.Offset(limitStart).Limit(limitLen).Order("created_at desc")
|
||||
} else {
|
||||
whereSql, whereArgs := repo.parseWhereConditions2Sql(whereConditions)
|
||||
xlog.Debugf("list resource %v where sql:%v, args:%+v",
|
||||
repo.poTemplate.TableName(), whereSql, whereArgs)
|
||||
txCount = repo.db.Model(repo.poTemplate).Where(whereSql, whereArgs...)
|
||||
txFind = repo.db.Where(whereSql, whereArgs...).Offset(limitStart).Limit(limitLen)
|
||||
txFind = repo.db.Where(whereSql, whereArgs...).Offset(limitStart).Limit(limitLen).Order("created_at desc")
|
||||
}
|
||||
|
||||
err = txCount.Count(&totalCount).Error
|
||||
|
@ -1,6 +1,7 @@
|
||||
package model
|
||||
|
||||
import (
|
||||
"admin/apps/game/model/dto"
|
||||
"admin/internal/db"
|
||||
"time"
|
||||
)
|
||||
@ -12,11 +13,11 @@ func init() {
|
||||
// Account 空表,就是用来兼容资源增删改查公共操作的,实际列举账号等都是走各个项目api拉取
|
||||
type Account struct {
|
||||
ProjectId int `gorm:"index:idx_project_id"`
|
||||
ServerConfId string `name:"区服id" json:"serveId" choices:"GetServerConfIDChoices" where:"eq"`
|
||||
Account string `name:"账号" json:"account" where:"eq"`
|
||||
ServerConfId string `name:"区服id" json:"serveId" where:"eq"`
|
||||
RoleIds []string `gorm:"type:json;serializer:json" name:"角色id列表" json:"roleIds"`
|
||||
LatestLoginTime time.Time `name:"最近登录时间" json:"latest_login_time"`
|
||||
CreateTime time.Time `name:"创建时间" json:"create_time"`
|
||||
CreatedAt time.Time `name:"创建时间" json:"create_time"`
|
||||
}
|
||||
|
||||
func (lm *Account) TableName() string {
|
||||
@ -26,3 +27,7 @@ func (lm *Account) TableName() string {
|
||||
func (m *Account) GetId() int {
|
||||
return 0
|
||||
}
|
||||
|
||||
func (m *Account) GetServerConfIDChoices(project *Project) []*dto.CommonDtoFieldChoice {
|
||||
return getChoiceServers(project)
|
||||
}
|
||||
|
@ -25,9 +25,9 @@ type Project struct {
|
||||
// 不为空就代表项目要实现一个自己统一对外暴露的gm调用服务对内聚合、分发指令执行,本后台执行指令只调用一次;
|
||||
// 为空就代表command_list实现在各个逻辑服,由本后台系统在执行指令时聚合、分发指令
|
||||
// 调用各个逻辑服执行,本后台执行指令需要根据逻辑服数量调用;
|
||||
ApiAddr string `name:"游戏api地址" desc:"api服务器地址,例如神魔大陆就是alisrv服务器地址,用于后台调用gm"`
|
||||
|
||||
CreatedAt time.Time `readonly:"true"`
|
||||
ApiAddr string `name:"游戏api地址" desc:"api服务器地址,例如神魔大陆就是alisrv服务器地址,用于后台调用gm"`
|
||||
SortWeight int `name:"菜单排序" desc:"越大越靠前"`
|
||||
CreatedAt time.Time `readonly:"true"`
|
||||
}
|
||||
|
||||
func (lm *Project) TableName() string {
|
||||
|
@ -1,6 +1,7 @@
|
||||
package model
|
||||
|
||||
import (
|
||||
"admin/apps/game/model/dto"
|
||||
"admin/internal/db"
|
||||
"time"
|
||||
)
|
||||
@ -12,15 +13,15 @@ func init() {
|
||||
// Role 空表,就是用来兼容资源增删改查公共操作的,实际列举账号等都是走各个项目api拉取
|
||||
type Role struct {
|
||||
ProjectId int
|
||||
RoleId string `name:"角色ID" json:"roleId" where:"eq"`
|
||||
ServerConfId string `name:"区服id" json:"serverId" choices:"GetServerConfIDChoices" where:"eq"`
|
||||
Account string `name:"账号" json:"account" where:"eq"`
|
||||
ServerConfId string `name:"区服id" json:"serverId" where:"eq"`
|
||||
RoleId string `name:"角色ID" json:"roleId" where:"eq"`
|
||||
Name string `name:"名称" json:"roleName" where:"eq"`
|
||||
Status string `name:"状态" desc:"离线|在线" json:"status"`
|
||||
Level int `name:"等级" json:"roleLevel"`
|
||||
Profession string `name:"职业" json:"profession"`
|
||||
LatestLoginTime time.Time `name:"最近登录时间" json:"latestLoginAt"`
|
||||
CreateTime time.Time `name:"创建时间" json:"createAt"`
|
||||
CreatedAt time.Time `name:"创建时间" json:"createAt"`
|
||||
}
|
||||
|
||||
func (lm *Role) TableName() string {
|
||||
@ -30,3 +31,7 @@ func (lm *Role) TableName() string {
|
||||
func (m *Role) GetId() int {
|
||||
return 0
|
||||
}
|
||||
|
||||
func (m *Role) GetServerConfIDChoices(project *Project) []*dto.CommonDtoFieldChoice {
|
||||
return getChoiceServers(project)
|
||||
}
|
||||
|
@ -102,8 +102,11 @@ func (svc *Service) CommonPut(ctx context.Context, projectId int, resourceName s
|
||||
}
|
||||
|
||||
func (svc *Service) CommonDelete(ctx context.Context, projectId int, resourceName string, id int) error {
|
||||
err := svc.resourceSvc.Delete(projectId, resourceName, id)
|
||||
|
||||
deletedEt, err := svc.resourceSvc.Delete(projectId, resourceName, id)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
userId := ctx.Value("user_id").(int)
|
||||
userName := ctx.Value("user_name").(string)
|
||||
|
||||
@ -113,7 +116,7 @@ func (svc *Service) CommonDelete(ctx context.Context, projectId int, resourceNam
|
||||
ProjectId: projectId,
|
||||
Resource: resourceName,
|
||||
Method: "删除",
|
||||
NewData: id,
|
||||
NewData: deletedEt.ToCommonDto(),
|
||||
})
|
||||
|
||||
return err
|
||||
|
@ -6,6 +6,7 @@ import (
|
||||
"admin/apps/game/model/dto"
|
||||
"admin/internal/consts"
|
||||
"admin/internal/permission"
|
||||
"sort"
|
||||
)
|
||||
|
||||
func (svc *Service) GetRoutes(req *api.GetRoutesReq) (*api.GetRoutesRsp, error) {
|
||||
@ -56,11 +57,18 @@ func (svc *Service) GetRoutes(req *api.GetRoutesReq) (*api.GetRoutesRsp, error)
|
||||
}
|
||||
rsp.Projects = append(rsp.Projects, projectDto)
|
||||
}
|
||||
|
||||
return rsp, nil
|
||||
}
|
||||
|
||||
func (svc *Service) GetProjectList() ([]*entity.Project, error) {
|
||||
_, _, list, err := svc.projectSvc.List()
|
||||
sort.SliceStable(list, func(i, j int) bool {
|
||||
if list[i].Po.SortWeight == list[j].Po.SortWeight {
|
||||
return list[i].Po.CreatedAt.After(list[j].Po.CreatedAt)
|
||||
}
|
||||
return list[i].Po.SortWeight > list[j].Po.SortWeight
|
||||
})
|
||||
return list, err
|
||||
}
|
||||
|
||||
|
@ -27,6 +27,8 @@ func GetErrCodeContent(code int) string {
|
||||
return "参数不合法"
|
||||
case DBInsertDuplicate:
|
||||
return "数据重复"
|
||||
case GameServerNotRunning:
|
||||
return "游戏服务器区服没有运行"
|
||||
case CDKey_:
|
||||
return "cdkey系统占用100"
|
||||
case CDKeyInvalid:
|
||||
|
@ -45,9 +45,11 @@ func Request(addr string, method string, body interface{}, resData interface{})
|
||||
|
||||
if params, ok := body.(*url.Values); ok {
|
||||
removeUrl = removeUrl + "?" + params.Encode()
|
||||
} else if params, ok := body.(map[string]string); ok {
|
||||
} else if params1, ok := body.(url.Values); ok {
|
||||
removeUrl = removeUrl + "?" + params1.Encode()
|
||||
} else if params2, ok := body.(map[string]string); ok {
|
||||
values := &url.Values{}
|
||||
for k, v := range params {
|
||||
for k, v := range params2 {
|
||||
values.Add(k, v)
|
||||
}
|
||||
removeUrl = removeUrl + "?" + values.Encode()
|
||||
|
@ -23,8 +23,8 @@ const rows = ref([])
|
||||
const rules = ref({})
|
||||
|
||||
const current_page = ref(1)
|
||||
const page_size = ref(2)
|
||||
const pageSizes = [2, 10, 20, 50, 100]
|
||||
const page_size = ref(10)
|
||||
const pageSizes = [10, 20, 50, 100]
|
||||
const totalRowCount = ref(0)
|
||||
|
||||
const item = ref({
|
||||
@ -148,7 +148,7 @@ const submitAdd = async () => {
|
||||
resourcePost(resource_url, dialogObjectForm.value).then((res) => {
|
||||
ElNotification({
|
||||
title: "添加结果通知",
|
||||
message: "添加成功!",
|
||||
message: "添加成功!如果页面没有变化,刷新一下!",
|
||||
type: 'success',
|
||||
duration: 4000,
|
||||
"show-close": true,
|
||||
@ -171,16 +171,22 @@ const submitEdit = async () => {
|
||||
try {
|
||||
await dialogEditFormRef.value.validate(valid => {
|
||||
if (valid) {
|
||||
const oldIndex = dialogObjectForm.value.oldIndex
|
||||
const oldData = dialogObjectForm.value.oldData
|
||||
// 这两句必须,因为上一步点击编辑按钮把value = row,然后把value.oldIndex = index,
|
||||
// 貌似会引起类字段循环引用,然后发送时候序列化造成死循环
|
||||
delete dialogObjectForm.value.oldIndex
|
||||
delete dialogObjectForm.value.oldData
|
||||
resourcePut(resource_url, dialogObjectForm.value).then((res) => {
|
||||
ElNotification({
|
||||
title: "编辑结果通知",
|
||||
message: "编辑成功!",
|
||||
message: "编辑成功!如果页面没有变化,刷新一下!",
|
||||
type: 'success',
|
||||
duration: 4000,
|
||||
"show-close": true,
|
||||
})
|
||||
dialogEditVisible.value = false
|
||||
rows.value[dialogObjectForm.value.oldIndex] = res.data.dto
|
||||
rows.value[oldIndex] = res.data.dto
|
||||
handleCloseDialog()
|
||||
}, (err) => {
|
||||
console.log("添加报错:", err)
|
||||
@ -206,7 +212,7 @@ const handleDelete = (index, row) => {
|
||||
resourceDelete(resource_url, {id: row.ID}).then((res) => {
|
||||
ElNotification({
|
||||
title: "删除结果通知",
|
||||
message: "删除数据[" + row.ID + "]成功!",
|
||||
message: "删除数据[" + row.ID + "]成功!如果页面没有变化,刷新一下!",
|
||||
type: 'success',
|
||||
duration: 4000,
|
||||
"show-close": true,
|
||||
|
@ -23,8 +23,10 @@ const calcElColSpan = ref(0)
|
||||
const rows = ref([])
|
||||
const rules = ref({})
|
||||
|
||||
const current_page = ref(0)
|
||||
const page_size = ref(0)
|
||||
const current_page = ref(1)
|
||||
const page_size = ref(10)
|
||||
const pageSizes = [10, 20, 50, 100]
|
||||
const totalRowCount = ref(0)
|
||||
|
||||
const item = ref({
|
||||
id: '',
|
||||
@ -37,10 +39,13 @@ const item = ref({
|
||||
const listData = async () => {
|
||||
try {
|
||||
let listParams = {
|
||||
page_no: 0,
|
||||
page_len: 100,
|
||||
page_no: current_page.value,
|
||||
page_len: page_size.value,
|
||||
where_conditions: "",
|
||||
}
|
||||
|
||||
console.log(`查询页:${listParams.page_no},查询页大小:${listParams.page_len}`)
|
||||
|
||||
let whereReqConditions = {
|
||||
conditions: []
|
||||
}
|
||||
@ -60,6 +65,7 @@ const listData = async () => {
|
||||
listRsp.value = rspData;
|
||||
if (listRsp.value.code !== 200) throw new Error("请求失败,错误码:", listRsp.code);
|
||||
fieldsDescInfo.value = listRsp.value.data.fields_desc
|
||||
totalRowCount.value = listRsp.value.data.total_count
|
||||
rows.value = listRsp.value.data.rows
|
||||
|
||||
for (let i = 0; i < fieldsDescInfo.value.length; i++) {
|
||||
@ -146,7 +152,7 @@ const submitAdd = async () => {
|
||||
resourcePost(resource_url, dialogObjectForm.value).then((res) => {
|
||||
ElNotification({
|
||||
title: "添加结果通知",
|
||||
message: "添加成功!",
|
||||
message: "添加成功!如果页面没有变化,刷新一下!",
|
||||
type: 'success',
|
||||
duration: 4000,
|
||||
"show-close": true,
|
||||
@ -171,12 +177,14 @@ const submitEdit = async () => {
|
||||
if (valid) {
|
||||
const oldIndex = dialogObjectForm.value.oldIndex
|
||||
const oldData = dialogObjectForm.value.oldData
|
||||
// 这两句必须,因为上一步点击编辑按钮把value = row,然后把value.oldIndex = index,
|
||||
// 貌似会引起类字段循环引用,然后发送时候序列化造成死循环
|
||||
delete dialogObjectForm.value.oldIndex
|
||||
delete dialogObjectForm.value.oldData
|
||||
resourcePut(resource_url, dialogObjectForm.value).then((res) => {
|
||||
ElNotification({
|
||||
title: "编辑结果通知",
|
||||
message: "编辑成功!",
|
||||
message: "编辑成功!如果页面没有变化,刷新一下!",
|
||||
type: 'success',
|
||||
duration: 4000,
|
||||
"show-close": true,
|
||||
@ -244,7 +252,7 @@ const handleDelete = (index, row) => {
|
||||
resourceDelete(resource_url, {id: row.ID}).then((res) => {
|
||||
ElNotification({
|
||||
title: "删除结果通知",
|
||||
message: "删除数据[" + row.ID + "]成功!",
|
||||
message: "删除数据[" + row.ID + "]成功!如果页面没有变化,刷新一下!",
|
||||
type: 'success',
|
||||
duration: 4000,
|
||||
"show-close": true,
|
||||
@ -342,6 +350,25 @@ const handleGetUsedHistory = (index, row) => {
|
||||
})
|
||||
}
|
||||
|
||||
const handlePaginationSizeChange = (val) => {
|
||||
// console.log(`${val} 大小改变`)
|
||||
if (totalRowCount.value <= 0) {
|
||||
return
|
||||
}
|
||||
if (page_size.value * current_page.value > totalRowCount.value) {
|
||||
// 当总数据少于页数乘以页大小,就拒绝请求
|
||||
return
|
||||
}
|
||||
// console.log(`${page_size.value} 大小改变`)
|
||||
listData()
|
||||
}
|
||||
|
||||
const handlePaginationCurChange = (val) => {
|
||||
// console.log(`${val} 页面改变`)
|
||||
listData()
|
||||
}
|
||||
|
||||
|
||||
</script>
|
||||
|
||||
<template>
|
||||
@ -435,9 +462,11 @@ const handleGetUsedHistory = (index, row) => {
|
||||
<el-pagination
|
||||
v-model:current-page="current_page"
|
||||
v-model:page-size="page_size"
|
||||
:page-sizes="[20, 50, 100]"
|
||||
:page-sizes="pageSizes"
|
||||
layout="total, sizes, prev, pager, next, jumper"
|
||||
:total="400"
|
||||
:total="totalRowCount"
|
||||
@size-change="handlePaginationSizeChange"
|
||||
@current-change="handlePaginationCurChange"
|
||||
/>
|
||||
</div>
|
||||
|
||||
|
@ -116,7 +116,7 @@ const submitAdd = async () => {
|
||||
resourcePost(resource_url, dialogAddForm.value).then((res) => {
|
||||
ElNotification({
|
||||
title: "添加结果通知",
|
||||
message: "添加成功!",
|
||||
message: "添加成功!如果页面没有变化,刷新一下!",
|
||||
type: 'success',
|
||||
duration: 4000,
|
||||
"show-close": true,
|
||||
@ -143,7 +143,7 @@ const submitEdit = async () => {
|
||||
resourcePut(resource_url, dialogEditForm.value).then((res) => {
|
||||
ElNotification({
|
||||
title: "编辑结果通知",
|
||||
message: "编辑成功!",
|
||||
message: "编辑成功!如果页面没有变化,刷新一下!",
|
||||
type: 'success',
|
||||
duration: 4000,
|
||||
"show-close": true,
|
||||
@ -179,7 +179,7 @@ const handleDelete = (index, row) => {
|
||||
resourceDelete(resource_url, {id: row.ID}).then((res) => {
|
||||
ElNotification({
|
||||
title: "删除结果通知",
|
||||
message: "删除数据[" + row.ID + "]成功!",
|
||||
message: "删除数据[" + row.ID + "]成功!如果页面没有变化,刷新一下!",
|
||||
type: 'success',
|
||||
duration: 4000,
|
||||
"show-close": true,
|
||||
|
@ -3,6 +3,7 @@
|
||||
import {createApp} from 'vue'
|
||||
import {createPinia} from 'pinia'
|
||||
import ElementPlus from 'element-plus'
|
||||
import locale from "element-plus/dist/locale/zh-cn.mjs"; // 中文语言
|
||||
|
||||
import '@/assets/styles/global.scss' // global css
|
||||
|
||||
@ -22,7 +23,9 @@ for (const [key, component] of Object.entries(ElementPlusIconsVue)) {
|
||||
app.component(key, component)
|
||||
}
|
||||
|
||||
app.use(ElementPlus)
|
||||
app.use(ElementPlus, {
|
||||
locale: locale,
|
||||
})
|
||||
app.use(pinia)
|
||||
app.use(router)
|
||||
|
||||
|
15
ui/todo.md
15
ui/todo.md
@ -4,25 +4,28 @@
|
||||
|
||||
- [x] 道具列表选择支持远程搜索(避免道具列表太长卡顿)
|
||||
- [x] 表格字段搜索
|
||||
- [ ] 表格各种项目支持分页(难点是账户、角色、订单这种来自各个游戏区服数据如何分)
|
||||
- [x] 表格各种项目支持分页(难点是账户、角色、订单这种来自各个游戏区服数据如何分)
|
||||
- [x] 执行历史记录
|
||||
- [x] 奖励码接入
|
||||
|
||||
* 中优先级
|
||||
|
||||
- [ ] 表格定制化按钮,比如服务器列表支持单个服务器维护、一键维护(难点是带页面跳转的比如角色列表快速封禁)
|
||||
- [x] 账号列表、角色列表支持条件检索(从远程游戏服拉取数据)
|
||||
- [x] 统一错误码内容
|
||||
- [ ] 执行历史查看和条件检索
|
||||
- [ ] 订单列表从游戏服拉取可以查看
|
||||
- [x] 项目信息添加排序字段,支持菜单排序
|
||||
|
||||
* 低优先级
|
||||
|
||||
- [ ] 项目信息添加排序字段,支持菜单排序
|
||||
- [ ] 执行历史查看和条件检索
|
||||
- [ ] 分页总条数数据、远程获取的区服信息、道具列表等加入缓存,避免每次获取都拉取影响性能
|
||||
- [ ] 表格定制化按钮-实现定制化单选、多选数据行发送到服务器,比如服务器列表支持单个服务器维护、一键维护
|
||||
- [ ] 表格定制化按钮-实现带参数页面跳转,比如角色页面快速封禁
|
||||
- [ ] 表格字段排序
|
||||
- [ ] 公告发送游戏
|
||||
- [ ] 订单列表从游戏服拉取可以查看
|
||||
- [ ] 优化header右上角昵称部分显示
|
||||
|
||||
* bug记录
|
||||
|
||||
- [ ] 执行删除记录的历史信息只记录了id
|
||||
- [x] 执行删除记录的历史信息只记录了id
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user