118 lines
3.5 KiB
Lua
118 lines
3.5 KiB
Lua
---@class _ParamTRPSelectCompany
|
||
---@field public isHideCloseBtn boolean
|
||
---@field public companyList table
|
||
|
||
---@type IDBasePanel
|
||
local TRBasePanel = require("ui.panel.TRBasePanel")
|
||
---@class TRPSelectCompany:TRBasePanel 邮件列表
|
||
local TRPSelectCompany = class("TRPSelectCompany", TRBasePanel)
|
||
local selectedCompany = nil
|
||
local selectedCell
|
||
local uiobjs = {}
|
||
-- 初始化,只会调用一次
|
||
function TRPSelectCompany:init(csObj)
|
||
TRPSelectCompany.super.init(self, csObj)
|
||
|
||
self:setEventDelegate()
|
||
uiobjs.panel = getCC(self.transform, "PanelContent", "UIPanel")
|
||
MyUtl.setContentView(uiobjs.panel)
|
||
uiobjs.grid = getCC(uiobjs.panel.transform, "Grid", "UIGrid")
|
||
uiobjs.gridPrefab = getChild(uiobjs.grid.transform, "00000").gameObject
|
||
end
|
||
|
||
-- 设置数据
|
||
---@param paras _ParamTRPSelectCompany
|
||
function TRPSelectCompany:setData(paras)
|
||
self.mdata = paras
|
||
end
|
||
|
||
function TRPSelectCompany:onShowFrame(cs)
|
||
if cs.frameObj then
|
||
---@type _BGFrame1Param
|
||
local d = {}
|
||
-- d.title = LGet(cs.titleKeyName)
|
||
d.title = cs.titleKeyName
|
||
d.isHideCloseBtn = self.mdata.isHideCloseBtn
|
||
d.panel = cs
|
||
cs.frameObj:init(d)
|
||
end
|
||
end
|
||
|
||
-- 显示,在c#中。show为调用refresh,show和refresh的区别在于,当页面已经显示了的情况,当页面再次出现在最上层时,只会调用refresh
|
||
function TRPSelectCompany:show()
|
||
selectedCompany = nil
|
||
local currGroup = Prefs.getCurrGroup(Prefs.getUserName())
|
||
if not isNilOrEmpty(currGroup) then
|
||
selectedCompany = json.decode(currGroup)
|
||
end
|
||
local list = self.mdata.companyList or {}
|
||
CLUIUtl.resetList4Lua(uiobjs.grid, uiobjs.gridPrefab, list, self:wrapFunc(self.initCell))
|
||
end
|
||
|
||
function TRPSelectCompany:initCell(cell, data)
|
||
cell:init(data, self:wrapFunc(self.onClickCell))
|
||
if selectedCompany then
|
||
if selectedCompany.company_id == data.company_id then
|
||
self:onClickCell(cell, data)
|
||
end
|
||
else
|
||
self:onClickCell(cell, data)
|
||
end
|
||
end
|
||
|
||
function TRPSelectCompany:onClickCell(cell, data)
|
||
if selectedCell then
|
||
selectedCell.luaTable.selected(false)
|
||
end
|
||
selectedCell = cell
|
||
selectedCompany = data
|
||
cell.luaTable.selected(true)
|
||
end
|
||
|
||
-- 刷新
|
||
function TRPSelectCompany:refresh()
|
||
end
|
||
|
||
-- 关闭页面
|
||
function TRPSelectCompany:hide()
|
||
selectedCell = nil
|
||
end
|
||
|
||
-- 网络请求的回调;cmd:指命,succ:成功失败,msg:消息;paras:服务器下行数据
|
||
function TRPSelectCompany:procNetwork(cmd, succ, msg, paras)
|
||
if (succ == NetSuccess) then
|
||
--[[
|
||
if cmd == xx then
|
||
end
|
||
]]
|
||
end
|
||
end
|
||
|
||
function TRPSelectCompany:setEventDelegate()
|
||
self.EventDelegate = {
|
||
ButtonRight = function()
|
||
if selectedCompany == nil then
|
||
MyUtl.toastW("请选择要进入的公司")
|
||
return
|
||
end
|
||
-- 缓存一下,下次进来后就不用再先公司了
|
||
Prefs.setCurrGroup(Prefs.getUserName(), json.encode(selectedCompany))
|
||
getPanelAsy("PanelConnect", onLoadedPanel)
|
||
end
|
||
}
|
||
end
|
||
-- 处理ui上的事件,例如点击等
|
||
function TRPSelectCompany:uiEventDelegate(go)
|
||
local func = self.EventDelegate[go.name]
|
||
if func then
|
||
func()
|
||
end
|
||
end
|
||
|
||
-- 当顶层页面发生变化时回调
|
||
function TRPSelectCompany:onTopPanelChange(topPanel)
|
||
end
|
||
|
||
--------------------------------------------
|
||
return TRPSelectCompany
|