2020-07-10 13:22:24 +08:00
|
|
|
|
---@class _ParamCellExtendFiledRoot
|
|
|
|
|
|
---@field data any
|
|
|
|
|
|
---@field fields table _ParamCellExtendFiled的list
|
|
|
|
|
|
---@field onFinish function 当加载完成
|
|
|
|
|
|
|
|
|
|
|
|
-- xx单元
|
2020-07-04 14:41:25 +08:00
|
|
|
|
local _cell = {}
|
|
|
|
|
|
---@type Coolape.CLCellLua
|
|
|
|
|
|
local csSelf = nil
|
|
|
|
|
|
local transform = nil
|
2020-07-10 13:22:24 +08:00
|
|
|
|
---@type _ParamCellExtendFiledRoot
|
2020-07-04 14:41:25 +08:00
|
|
|
|
local mData = nil
|
|
|
|
|
|
local uiobjs = {}
|
|
|
|
|
|
local fieldsObjs = {}
|
2020-07-10 13:22:24 +08:00
|
|
|
|
local queue = CLLQueue.new()
|
|
|
|
|
|
local isLoading = false
|
2020-07-04 14:41:25 +08:00
|
|
|
|
|
|
|
|
|
|
-- 初始化,只调用一次
|
|
|
|
|
|
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)
|
2020-07-10 13:22:24 +08:00
|
|
|
|
queue:enQueue(data)
|
|
|
|
|
|
if not isLoading then
|
|
|
|
|
|
_cell.refresh()
|
|
|
|
|
|
end
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
function _cell.refresh()
|
|
|
|
|
|
--[[
|
2020-07-04 14:41:25 +08:00
|
|
|
|
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
|
2020-07-10 13:22:24 +08:00
|
|
|
|
]]
|
|
|
|
|
|
if queue:size() == 0 then
|
2020-07-04 14:41:25 +08:00
|
|
|
|
return
|
|
|
|
|
|
end
|
2020-07-10 13:22:24 +08:00
|
|
|
|
_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
|
2020-07-04 14:41:25 +08:00
|
|
|
|
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
|
2020-07-10 13:22:24 +08:00
|
|
|
|
CLUIOtherObjPool.borrowObjAsyn(name, _cell.onLoadField, index)
|
2020-07-04 14:41:25 +08:00
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
---@param go UnityEngine.GameObject
|
|
|
|
|
|
function _cell.onLoadField(name, go, orgs)
|
2020-07-10 13:22:24 +08:00
|
|
|
|
local index = orgs
|
2020-07-04 14:41:25 +08:00
|
|
|
|
go.transform.parent = transform
|
|
|
|
|
|
go.transform.localScale = Vector3.one
|
|
|
|
|
|
go.transform.localEulerAngles = Vector3.zero
|
2020-07-10 13:22:24 +08:00
|
|
|
|
---@type _ParamCellExtendFiled
|
|
|
|
|
|
local param = mData.fields[index]
|
2020-07-04 14:41:25 +08:00
|
|
|
|
local cell = go:GetComponent("CLCellLua")
|
|
|
|
|
|
SetActive(go, true)
|
2020-07-10 13:22:24 +08:00
|
|
|
|
if param.attr.attrType == DBCust.FieldType.multext then
|
|
|
|
|
|
-- 要设置一次
|
|
|
|
|
|
param.orgOnMultTextInputChg = param.onMultTextInputChg
|
|
|
|
|
|
param.onMultTextInputChg = _cell.onMultTextInputChg
|
|
|
|
|
|
end
|
|
|
|
|
|
cell:init(param, nil)
|
2020-07-04 14:41:25 +08:00
|
|
|
|
table.insert(fieldsObjs, cell)
|
|
|
|
|
|
uiobjs.Table:Reposition()
|
2020-07-10 13:22:24 +08:00
|
|
|
|
if index == #(mData.fields) then
|
2020-07-04 14:41:25 +08:00
|
|
|
|
_cell.onFinisInitFields()
|
|
|
|
|
|
else
|
2020-07-10 13:22:24 +08:00
|
|
|
|
_cell.initField(index + 1)
|
2020-07-04 14:41:25 +08:00
|
|
|
|
end
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
function _cell.onFinisInitFields()
|
2020-07-10 13:22:24 +08:00
|
|
|
|
isLoading = false
|
2020-07-04 14:41:25 +08:00
|
|
|
|
uiobjs.Table:Reposition()
|
2020-07-10 13:22:24 +08:00
|
|
|
|
uiobjs.formRoot:setValue(mData.data)
|
2020-07-04 14:41:25 +08:00
|
|
|
|
hideHotWheel()
|
2020-07-11 20:53:21 +08:00
|
|
|
|
Utl.doCallback(mData.onFinish, csSelf.gameObject)
|
2020-07-10 13:22:24 +08:00
|
|
|
|
_cell.refresh()
|
2020-07-04 14:41:25 +08:00
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
function _cell.release()
|
|
|
|
|
|
for i, v in ipairs(fieldsObjs) do
|
|
|
|
|
|
SetActive(v.gameObject, false)
|
|
|
|
|
|
CLUIOtherObjPool.returnObj(v.gameObject)
|
|
|
|
|
|
end
|
|
|
|
|
|
fieldsObjs = {}
|
|
|
|
|
|
end
|
|
|
|
|
|
|
2020-07-10 13:22:24 +08:00
|
|
|
|
function _cell.onMultTextInputChg(go)
|
2020-07-04 14:41:25 +08:00
|
|
|
|
uiobjs.Table.repositionNow = true
|
2020-07-10 13:22:24 +08:00
|
|
|
|
---@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
|
2020-07-04 14:41:25 +08:00
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
-- 取得数据
|
|
|
|
|
|
function _cell.getData()
|
|
|
|
|
|
return mData
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
--------------------------------------------
|
|
|
|
|
|
return _cell
|