up
This commit is contained in:
@@ -15,6 +15,7 @@ local uiobjs = {}
|
||||
local fieldsObjs = {}
|
||||
local queue = CLLQueue.new()
|
||||
local isLoading = false
|
||||
local count = 0
|
||||
|
||||
-- 初始化,只调用一次
|
||||
function _cell.init(csObj)
|
||||
@@ -36,18 +37,6 @@ function _cell.show(go, data)
|
||||
end
|
||||
|
||||
function _cell.refresh()
|
||||
--[[
|
||||
local taskId = tostring(cust.taskId)
|
||||
if (not isFieldLoading) or taskId ~= oldtaskId then
|
||||
isFieldLoading = true
|
||||
oldtaskId = taskId
|
||||
fields = DBCust.getFieldsByTask(taskId)
|
||||
if fields and #fields > 0 then
|
||||
showHotWheel()
|
||||
_cell.initField(1, taskId)
|
||||
end
|
||||
end
|
||||
]]
|
||||
if queue:size() == 0 then
|
||||
return
|
||||
end
|
||||
@@ -56,7 +45,9 @@ function _cell.refresh()
|
||||
mData = queue:deQueue()
|
||||
if mData.fields and #(mData.fields) > 0 then
|
||||
showHotWheel()
|
||||
_cell.initField(1)
|
||||
for i, v in ipairs(mData.fields) do
|
||||
_cell.initField(i)
|
||||
end
|
||||
else
|
||||
_cell.onFinisInitFields()
|
||||
end
|
||||
@@ -73,6 +64,8 @@ function _cell.initField(index)
|
||||
name = "InputMultText"
|
||||
elseif fileAttr.attrType == DBCust.FieldType.checkbox then
|
||||
name = "InputCheckboxs"
|
||||
elseif fileAttr.attrType == DBCust.FieldType.empty then
|
||||
name = "EmptySpace"
|
||||
else
|
||||
name = "InputText"
|
||||
end
|
||||
@@ -82,36 +75,45 @@ end
|
||||
---@param go UnityEngine.GameObject
|
||||
function _cell.onLoadField(name, go, orgs)
|
||||
local index = orgs
|
||||
go.transform.parent = transform
|
||||
go.transform.localScale = Vector3.one
|
||||
go.transform.localEulerAngles = Vector3.zero
|
||||
---@type _ParamCellExtendFiled
|
||||
local param = mData.fields[index]
|
||||
local cell = go:GetComponent("CLCellLua")
|
||||
SetActive(go, true)
|
||||
if param.attr.attrType == DBCust.FieldType.multext then
|
||||
-- 要设置一次
|
||||
param.orgOnMultTextInputChg = param.onMultTextInputChg
|
||||
param.onMultTextInputChg = _cell.onMultTextInputChg
|
||||
end
|
||||
cell:init(param, nil)
|
||||
table.insert(fieldsObjs, cell)
|
||||
uiobjs.Table:Reposition()
|
||||
fieldsObjs[index] = cell
|
||||
count = count + 1
|
||||
Utl.doCallback(mData.onLoadOneField, cell)
|
||||
if index == #(mData.fields) then
|
||||
if count == #(mData.fields) then
|
||||
_cell.onFinisInitFields()
|
||||
else
|
||||
_cell.initField(index + 1)
|
||||
end
|
||||
end
|
||||
|
||||
function _cell.onFinisInitFields()
|
||||
isLoading = false
|
||||
uiobjs.Table:Reposition()
|
||||
for i, cell in ipairs(fieldsObjs) do
|
||||
-- 在完成的时候时候再处理,是为了保证加进去的顺序不变
|
||||
cell.transform.parent = transform
|
||||
cell.transform.localScale = Vector3.one
|
||||
cell.transform.localEulerAngles = Vector3.zero
|
||||
SetActive(cell.gameObject, true)
|
||||
uiobjs.Table:Reposition()
|
||||
end
|
||||
uiobjs.formRoot:setValue(mData.data)
|
||||
uiobjs.Table.repositionNow = true
|
||||
hideHotWheel()
|
||||
Utl.doCallback(mData.onFinish, csSelf.gameObject)
|
||||
_cell.refresh()
|
||||
|
||||
csSelf:invoke4Lua(
|
||||
function()
|
||||
Utl.doCallback(mData.onFinish, csSelf.gameObject)
|
||||
isLoading = false
|
||||
-- 再次处理
|
||||
_cell.refresh()
|
||||
end,
|
||||
0.1
|
||||
)
|
||||
end
|
||||
|
||||
function _cell.release()
|
||||
@@ -120,6 +122,7 @@ function _cell.release()
|
||||
CLUIOtherObjPool.returnObj(v.gameObject)
|
||||
end
|
||||
fieldsObjs = {}
|
||||
count = 0
|
||||
end
|
||||
|
||||
function _cell.onMultTextInputChg(go)
|
||||
@@ -139,5 +142,11 @@ function _cell.getData()
|
||||
return mData
|
||||
end
|
||||
|
||||
|
||||
function _cell.OnDisable()
|
||||
if #(fieldsObjs) > 0 then
|
||||
printe("动态加载的字段没有释放")
|
||||
end
|
||||
end
|
||||
--------------------------------------------
|
||||
return _cell
|
||||
|
||||
Reference in New Issue
Block a user