Files
tianrunCRM/Assets/trCRM/upgradeRes4Dev/priority/lua/ui/panel/TRPSelectCompany.lua

118 lines
3.5 KiB
Lua
Raw Normal View History

2020-07-04 14:41:25 +08:00
---@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为调用refreshshow和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
2020-07-09 09:23:09 +08:00
MyUtl.toastW("请选择要进入的公司")
2020-07-04 14:41:25 +08:00
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