Files
tianrunCRM/Assets/trCRM/upgradeRes4Dev/priority/lua/ui/panel/TRPModifyFiled.lua
2020-07-09 09:23:09 +08:00

84 lines
2.4 KiB
Lua
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

---@class _ParamModifyField
---@field label string 字段名
---@field key string 字段key
---@field value any 字段value
---@field canNull boolean
---@type IDBasePanel
local TRBasePanel = require("ui.panel.TRBasePanel")
---@class TRPModifyFiled:TRBasePanel
local TRPModifyFiled = class("TRPModifyFiled", TRBasePanel)
local uiobjs = {}
-- 初始化,只会调用一次
function TRPModifyFiled:init(csObj)
TRPModifyFiled.super.init(self, csObj)
self:setEventDelegate()
---@type CLUIElement
uiobjs.element = getCC(self.transform, "Top/Input", "CLUIElement")
uiobjs.Input = getCC(self.transform, "Top/Input", "UIInput")
uiobjs.Label = getCC(uiobjs.Input.transform, "Label2", "UILabel")
end
-- 设置数据
---@param paras _ParamTRPModifyFiled
function TRPModifyFiled:setData(paras)
---@type _ParamModifyField
self.mdata = paras
end
-- 显示在c#中。show为调用refreshshow和refresh的区别在于当页面已经显示了的情况当页面再次出现在最上层时只会调用refresh
function TRPModifyFiled:show()
uiobjs.element.jsonKey = self.mdata.jsonKey
uiobjs.element.canNull = self.mdata.canNull
uiobjs.Label.text = self.mdata.label
uiobjs.Input.value = self.mdata.value
end
-- 刷新
function TRPModifyFiled:refresh()
end
-- 关闭页面
function TRPModifyFiled:hide()
end
-- 网络请求的回调cmd指命succ成功失败msg消息paras服务器下行数据
function TRPModifyFiled:procNetwork(cmd, succ, msg, paras)
if (succ == NetSuccess) then
--[[
if cmd == xx then
end
]]
end
end
function TRPModifyFiled:setEventDelegate()
self.EventDelegate = {
ButtonOkay = function()
local err = uiobjs.element:checkValid()
if not isNilOrEmpty(err) then
MyUtl.toastW(err)
return
end
Utl.doCallback(self.mdata.callback, self.mdata.key, uiobjs.Input.value)
hideTopPanel(self.csSelf)
end
}
end
-- 处理ui上的事件例如点击等
function TRPModifyFiled:uiEventDelegate(go)
local func = self.EventDelegate[go.name]
if func then
func()
end
end
-- 当顶层页面发生变化时回调
function TRPModifyFiled:onTopPanelChange(topPanel)
end
--------------------------------------------
return TRPModifyFiled