This commit is contained in:
2020-07-10 13:22:24 +08:00
parent 8c154e38ba
commit 9549990b66
108 changed files with 5668 additions and 888 deletions

View File

@@ -1,18 +1,19 @@
-- xx单元
---@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 = {}
---@type _DBCust
local cust
local fields
local fieldsObjs = {}
local isEditMode = true
local taskId = nil
local isFieldLoading = false
local oldtaskId
local queue = CLLQueue.new()
local isLoading = false
-- 初始化,只调用一次
function _cell.init(csObj)
@@ -27,10 +28,14 @@ end
-- 显示,
-- 注意c#侧不会在调用show时调用refresh
function _cell.show(go, data)
mData = data
cust = data.data or {}
isEditMode = data.isEditMode
_cell.release()
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
@@ -41,13 +46,23 @@ function _cell.show(go, data)
_cell.initField(1, taskId)
end
end
end
function _cell.initField(index, taskId)
if taskId ~= oldtaskId then
]]
if queue:size() == 0 then
return
end
local fileAttr = fields[index]
_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"
@@ -60,50 +75,51 @@ function _cell.initField(index, taskId)
else
name = "InputText"
end
CLUIOtherObjPool.borrowObjAsyn(name, _cell.onLoadField, {index = index, taskId = taskId})
CLUIOtherObjPool.borrowObjAsyn(name, _cell.onLoadField, index)
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
local index = orgs
go.transform.parent = transform
go.transform.localScale = Vector3.one
go.transform.localEulerAngles = Vector3.zero
local fileAttr = fields[index]
---@type _ParamCellExtendFiled
local param = mData.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
)
--[[
---@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 == #fields then
if index == #(mData.fields) then
_cell.onFinisInitFields()
else
_cell.initField(index + 1, taskId)
_cell.initField(index + 1)
end
end
function _cell.onFinisInitFields()
isFieldLoading = false
isLoading = false
uiobjs.Table:Reposition()
uiobjs.formRoot:setValue(cust.jsonStr)
uiobjs.formRoot:setValue(mData.data)
Utl.doCallback(mData.onFinish)
hideHotWheel()
_cell.refresh()
end
function _cell.release()
@@ -114,8 +130,16 @@ function _cell.release()
fieldsObjs = {}
end
function _cell.onMultTextInputChg()
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
-- 取得数据