---@class _ParamCellExtendFiledRoot ---@field data any ---@field fields table _ParamCellExtendFiled的list ---@field onFinish function 当加载完成 -- xx单元 local _cell = {} ---@type Coolape.CLCellLua local csSelf = nil local transform = nil ---@type _ParamCellExtendFiledRoot local mData = nil local uiobjs = {} local fieldsObjs = {} local queue = CLLQueue.new() local isLoading = false -- 初始化,只调用一次 function _cell.init(csObj) csSelf = csObj transform = csSelf.transform ---@type CLUIFormRoot uiobjs.formRoot = csSelf:GetComponent("CLUIFormRoot") ---@type UITable uiobjs.Table = csSelf:GetComponent("UITable") end -- 显示, -- 注意,c#侧不会在调用show时,调用refresh function _cell.show(go, data) queue:enQueue(data) if not isLoading then _cell.refresh() end 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 _cell.release() isLoading = true mData = queue:deQueue() if mData.fields and #(mData.fields) > 0 then showHotWheel() _cell.initField(1) else _cell.onFinisInitFields() end end function _cell.initField(index) local fileAttr = mData.fields[index].attr local name = "" if fileAttr.attrType == DBCust.FieldType.popuplist then name = "InputPoplist" elseif fileAttr.attrType == DBCust.FieldType.dateTime then name = "InputDate" elseif fileAttr.attrType == DBCust.FieldType.multext then name = "InputMultText" elseif fileAttr.attrType == DBCust.FieldType.checkbox then name = "InputCheckboxs" else name = "InputText" end CLUIOtherObjPool.borrowObjAsyn(name, _cell.onLoadField, index) 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) --[[ ---@type _ParamCellExtendFiled local param = { attr = fileAttr, onMultTextInputChg = _cell.onMultTextInputChg, isEditMode = isEditMode, onClick = mData.onClick, onSelect = mData.onSelect } ]] 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() if index == #(mData.fields) then _cell.onFinisInitFields() else _cell.initField(index + 1) end end function _cell.onFinisInitFields() isLoading = false uiobjs.Table:Reposition() uiobjs.formRoot:setValue(mData.data) hideHotWheel() Utl.doCallback(mData.onFinish, csSelf.gameObject) _cell.refresh() end function _cell.release() for i, v in ipairs(fieldsObjs) do SetActive(v.gameObject, false) CLUIOtherObjPool.returnObj(v.gameObject) end fieldsObjs = {} end function _cell.onMultTextInputChg(go) uiobjs.Table.repositionNow = true ---@param v _ParamCellExtendFiled if mData then for i, v in ipairs(mData.fields) do if v.attr.attrType == DBCust.FieldType.multext then Utl.doCallback(v.orgOnMultTextInputChg, go) end end end end -- 取得数据 function _cell.getData() return mData end -------------------------------------------- return _cell