add
This commit is contained in:
@@ -0,0 +1,127 @@
|
||||
-- xx单元
|
||||
local _cell = {}
|
||||
---@type Coolape.CLCellLua
|
||||
local csSelf = nil
|
||||
local transform = nil
|
||||
local mData = nil
|
||||
local uiobjs = {}
|
||||
---@type _DBCust
|
||||
local cust
|
||||
local fields
|
||||
local fieldsObjs = {}
|
||||
local isEditMode = true
|
||||
local taskId = nil
|
||||
local isFieldLoading = false
|
||||
local oldtaskId
|
||||
|
||||
-- 初始化,只调用一次
|
||||
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)
|
||||
mData = data
|
||||
cust = data.data or {}
|
||||
isEditMode = data.isEditMode
|
||||
_cell.release()
|
||||
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
|
||||
end
|
||||
|
||||
function _cell.initField(index, taskId)
|
||||
if taskId ~= oldtaskId then
|
||||
return
|
||||
end
|
||||
local fileAttr = fields[index]
|
||||
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 = index, taskId = taskId})
|
||||
end
|
||||
|
||||
---@param go UnityEngine.GameObject
|
||||
function _cell.onLoadField(name, go, orgs)
|
||||
local index = orgs.index
|
||||
local taskId = orgs.taskId
|
||||
if taskId ~= oldtaskId then
|
||||
hideHotWheel()
|
||||
CLUIOtherObjPool.returnObj(go)
|
||||
SetActive(go, false)
|
||||
return
|
||||
end
|
||||
go.transform.parent = transform
|
||||
go.transform.localScale = Vector3.one
|
||||
go.transform.localEulerAngles = Vector3.zero
|
||||
local fileAttr = fields[index]
|
||||
local cell = go:GetComponent("CLCellLua")
|
||||
SetActive(go, true)
|
||||
cell:init(
|
||||
{
|
||||
attr = fileAttr,
|
||||
parent = _cell,
|
||||
isEditMode = isEditMode,
|
||||
onClick = mData.onClick,
|
||||
onSelect = mData.onSelect
|
||||
},
|
||||
nil
|
||||
)
|
||||
table.insert(fieldsObjs, cell)
|
||||
uiobjs.Table:Reposition()
|
||||
if index == #fields then
|
||||
_cell.onFinisInitFields()
|
||||
else
|
||||
_cell.initField(index + 1, taskId)
|
||||
end
|
||||
end
|
||||
|
||||
function _cell.onFinisInitFields()
|
||||
isFieldLoading = false
|
||||
uiobjs.Table:Reposition()
|
||||
uiobjs.formRoot:setValue(cust.jsonstr)
|
||||
Utl.doCallback(mData.onFinish)
|
||||
hideHotWheel()
|
||||
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()
|
||||
uiobjs.Table.repositionNow = true
|
||||
end
|
||||
|
||||
-- 取得数据
|
||||
function _cell.getData()
|
||||
return mData
|
||||
end
|
||||
|
||||
--------------------------------------------
|
||||
return _cell
|
||||
Reference in New Issue
Block a user