up
This commit is contained in:
@@ -67,6 +67,7 @@ function _cell.uiEventDelegate(go)
|
||||
local goName = go.name
|
||||
if goName == "ButtonFollow" then
|
||||
elseif goName == "ButtonTask" then
|
||||
getPanelAsy("PanelNewFollowTask", onLoadedPanelTT, mData)
|
||||
elseif goName == "ButtonContact" then
|
||||
MyUtl.callCust(mData)
|
||||
end
|
||||
|
||||
@@ -0,0 +1,30 @@
|
||||
-- xx单元
|
||||
local _cell = {}
|
||||
---@type Coolape.CLCellLua
|
||||
local csSelf = nil
|
||||
local transform = nil
|
||||
local mData = nil
|
||||
local uiobjs = {}
|
||||
|
||||
-- 初始化,只调用一次
|
||||
function _cell.init(csObj)
|
||||
csSelf = csObj
|
||||
transform = csSelf.transform
|
||||
---@type UIWidget
|
||||
uiobjs.widget = csSelf:GetComponent("UIWidget")
|
||||
end
|
||||
|
||||
-- 显示,
|
||||
-- 注意,c#侧不会在调用show时,调用refresh
|
||||
function _cell.show(go, data)
|
||||
mData = data
|
||||
uiobjs.widget.height = mData.height or 40
|
||||
end
|
||||
|
||||
-- 取得数据
|
||||
function _cell.getData()
|
||||
return mData
|
||||
end
|
||||
|
||||
--------------------------------------------
|
||||
return _cell
|
||||
@@ -0,0 +1,7 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 60ac659ac409f43f6b5e7ec6133bf1cd
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,17 +1,20 @@
|
||||
---@class _ParamFieldAttr
|
||||
---@field id
|
||||
---@field attrType
|
||||
---@field ifMust boolean 1:true
|
||||
---@field ifTime boolean 1:true
|
||||
---@field cannotEdit
|
||||
---@field attrName
|
||||
---@field attrValue
|
||||
---@field id
|
||||
---@field checkMin
|
||||
---@field checkMax
|
||||
---@field popOptions
|
||||
---@field popValues
|
||||
---@field donotJoinKey boolean 是否要拼接key
|
||||
---@field height numb 高度,只有在emptyspace有用
|
||||
|
||||
---@class _ParamCellExtendFiled
|
||||
---@field isEditMode boolean
|
||||
---@field showMode _FieldMode
|
||||
---@field attr _ParamFieldAttr
|
||||
---@field onSelect function 当选择了poplist
|
||||
---@field onClick function 当点击了输入框
|
||||
@@ -39,10 +42,6 @@ function _cell.init(csObj)
|
||||
uiobjs.spriteBg = getCC(transform, "Background", "UISprite")
|
||||
end
|
||||
|
||||
-- if uiobjs.spriteBg then
|
||||
-- uiobjs.spriteBg.width = NumEx.getIntPart(CSPMain.contentRect.z)
|
||||
-- end
|
||||
|
||||
uiobjs.boxCollider = csSelf:GetComponent("BoxCollider")
|
||||
---@type UIInput
|
||||
uiobjs.input = csSelf:GetComponent("UIInput")
|
||||
@@ -67,35 +66,6 @@ function _cell.show(go, data)
|
||||
attr = mData.attr
|
||||
attr.ifMust = attr.ifMust or 0
|
||||
|
||||
if data.isEditMode then
|
||||
_cell.enabeldObj(uiobjs.boxCollider, true)
|
||||
if uiobjs.Label then
|
||||
uiobjs.Label.text = uiobjs.inputLabel
|
||||
end
|
||||
if uiobjs.input then
|
||||
uiobjs.input.defaultText = uiobjs.inputLabel
|
||||
end
|
||||
_cell.enabeldObj(uiobjs.Label4, true)
|
||||
_cell.enabeldObj(uiobjs.SpriteRight, true)
|
||||
if uiobjs.ButtonReset then
|
||||
uiobjs.ButtonReset.disabled = false
|
||||
end
|
||||
else
|
||||
_cell.enabeldObj(uiobjs.boxCollider, false)
|
||||
if uiobjs.Label then
|
||||
uiobjs.Label.text = ""
|
||||
end
|
||||
if uiobjs.input then
|
||||
uiobjs.input.defaultText = ""
|
||||
end
|
||||
_cell.enabeldObj(uiobjs.Label4, false)
|
||||
_cell.enabeldObj(uiobjs.SpriteRight, false)
|
||||
|
||||
if uiobjs.ButtonReset then
|
||||
uiobjs.ButtonReset.disabled = true
|
||||
end
|
||||
end
|
||||
|
||||
local jsonKey
|
||||
if attr.donotJoinKey then
|
||||
jsonKey = attr.id
|
||||
@@ -114,7 +84,6 @@ function _cell.show(go, data)
|
||||
uiobjs.checkbox.labeName.text = attr.attrName
|
||||
end
|
||||
|
||||
_cell.enabeldObj(uiobjs.input, true)
|
||||
if attr.attrType == DBCust.FieldType.text then
|
||||
uiobjs.input.keyboardType = UIInput.KeyboardType.Default
|
||||
elseif attr.attrType == DBCust.FieldType.number then
|
||||
@@ -126,14 +95,15 @@ function _cell.show(go, data)
|
||||
elseif attr.attrType == DBCust.FieldType.multext then
|
||||
uiobjs.input.keyboardType = UIInput.KeyboardType.Default
|
||||
elseif attr.attrType == DBCust.FieldType.dateTime then
|
||||
_cell.enabeldObj(uiobjs.input, false)
|
||||
local elementDate = csSelf:GetComponent("CLUIElementDate")
|
||||
if elementDate then
|
||||
elementDate.isSetTime = ((attr.ifTime and attr.ifTime == 1) and true or false)
|
||||
end
|
||||
elseif attr.attrType == DBCust.FieldType.checkbox then
|
||||
_cell.enabeldObj(uiobjs.input, false)
|
||||
local max = tonumber(attr.checkMax) or 0
|
||||
uiobjs.checkbox.isMultMode = (max > 1) or (max == 0)
|
||||
uiobjs.checkbox:init(attr)
|
||||
elseif attr.attrType == DBCust.FieldType.popuplist then
|
||||
_cell.enabeldObj(uiobjs.input, false)
|
||||
if attr.popOptions then
|
||||
uiobjs.popList:refreshItems(attr.popOptions, attr.popValues)
|
||||
else
|
||||
@@ -146,6 +116,9 @@ function _cell.show(go, data)
|
||||
uiobjs.popList:refreshItems(array, array)
|
||||
end
|
||||
end
|
||||
|
||||
-- 设置展示的模式
|
||||
_cell.setElementMode(mData.showMode or _FieldMode.inputOnly)
|
||||
end
|
||||
|
||||
function _cell.enabeldObj(obj, val)
|
||||
@@ -154,6 +127,123 @@ function _cell.enabeldObj(obj, val)
|
||||
end
|
||||
end
|
||||
|
||||
function _cell.setElementMode(mode)
|
||||
local isPopList = uiobjs.popList
|
||||
local isPopCheckbox = uiobjs.checkbox
|
||||
---@type UIInput
|
||||
local input = uiobjs.input
|
||||
local inputOnGUI = csSelf:GetComponent("UIInputOnGUI")
|
||||
local boxcollider = uiobjs.boxCollider
|
||||
local ButtonReset = uiobjs.ButtonReset
|
||||
|
||||
if mode == _FieldMode.inputOnly then
|
||||
_cell.enabeldObj(boxcollider, true)
|
||||
_cell.enabeldObj(inputOnGUI, true)
|
||||
_cell.enabeldObj(input, true)
|
||||
if uiobjs.Label2 then
|
||||
uiobjs.Label2.color = ColorEx.getColor(0xff999999)
|
||||
end
|
||||
if uiobjs.ButtonReset then
|
||||
uiobjs.ButtonReset.disabled = false
|
||||
end
|
||||
if uiobjs.Label then
|
||||
uiobjs.Label.text = uiobjs.inputLabel
|
||||
end
|
||||
if uiobjs.input then
|
||||
uiobjs.input.defaultText = uiobjs.inputLabel
|
||||
end
|
||||
_cell.enabeldObj(uiobjs.Label4, true) -- multext
|
||||
if
|
||||
attr.attrType == DBCust.FieldType.dateTime or attr.attrType == DBCust.FieldType.checkbox or
|
||||
attr.attrType == DBCust.FieldType.popuplist
|
||||
then
|
||||
_cell.enabeldObj(uiobjs.SpriteRight, true)
|
||||
else
|
||||
_cell.enabeldObj(uiobjs.SpriteRight, false)
|
||||
end
|
||||
elseif mode == _FieldMode.showOnly then
|
||||
_cell.enabeldObj(boxcollider, false)
|
||||
_cell.enabeldObj(inputOnGUI, false)
|
||||
_cell.enabeldObj(input, false)
|
||||
if uiobjs.Label2 then
|
||||
uiobjs.Label2.color = ColorEx.getColor(0xff999999)
|
||||
end
|
||||
if uiobjs.ButtonReset then
|
||||
uiobjs.ButtonReset.disabled = true
|
||||
end
|
||||
if uiobjs.Label then
|
||||
uiobjs.Label.text = ""
|
||||
end
|
||||
if uiobjs.input then
|
||||
uiobjs.input.defaultText = ""
|
||||
end
|
||||
_cell.enabeldObj(uiobjs.Label4, false)
|
||||
_cell.enabeldObj(uiobjs.SpriteRight, false)
|
||||
elseif mode == _FieldMode.modifyOnly then
|
||||
_cell.enabeldObj(boxcollider, true)
|
||||
_cell.enabeldObj(inputOnGUI, false)
|
||||
_cell.enabeldObj(input, false)
|
||||
if uiobjs.Label2 then
|
||||
uiobjs.Label2.color = ColorEx.getColor(0xff999999)
|
||||
end
|
||||
if uiobjs.ButtonReset then
|
||||
uiobjs.ButtonReset.disabled = true
|
||||
end
|
||||
if uiobjs.Label then
|
||||
uiobjs.Label.text = uiobjs.inputLabel
|
||||
end
|
||||
if uiobjs.input then
|
||||
uiobjs.input.defaultText = uiobjs.inputLabel
|
||||
end
|
||||
_cell.enabeldObj(uiobjs.Label4, true)
|
||||
_cell.enabeldObj(uiobjs.SpriteRight, true)
|
||||
elseif mode == _FieldMode.showAndModify then
|
||||
_cell.enabeldObj(boxcollider, true)
|
||||
_cell.enabeldObj(inputOnGUI, false)
|
||||
_cell.enabeldObj(input, false)
|
||||
if uiobjs.Label2 then
|
||||
uiobjs.Label2.color = ColorEx.getColor(0xff999999)
|
||||
end
|
||||
if uiobjs.ButtonReset then
|
||||
uiobjs.ButtonReset.disabled = true
|
||||
end
|
||||
if uiobjs.Label then
|
||||
uiobjs.Label.text = ""
|
||||
end
|
||||
if uiobjs.input then
|
||||
uiobjs.input.defaultText = ""
|
||||
end
|
||||
_cell.enabeldObj(uiobjs.Label4, false)
|
||||
_cell.enabeldObj(uiobjs.SpriteRight, true)
|
||||
elseif mode == _FieldMode.button then
|
||||
_cell.enabeldObj(boxcollider, true)
|
||||
_cell.enabeldObj(inputOnGUI, false)
|
||||
_cell.enabeldObj(input, false)
|
||||
if uiobjs.Label2 then
|
||||
uiobjs.Label2.color = ColorEx.getColor(0xff363636)
|
||||
end
|
||||
if uiobjs.ButtonReset then
|
||||
uiobjs.ButtonReset.disabled = true
|
||||
end
|
||||
if uiobjs.Label then
|
||||
uiobjs.Label.text = ""
|
||||
end
|
||||
if uiobjs.input then
|
||||
uiobjs.input.defaultText = ""
|
||||
end
|
||||
_cell.enabeldObj(uiobjs.Label4, false)
|
||||
_cell.enabeldObj(uiobjs.SpriteRight, true)
|
||||
end
|
||||
|
||||
-- 再次修正input
|
||||
if
|
||||
attr.attrType == DBCust.FieldType.dateTime or attr.attrType == DBCust.FieldType.checkbox or
|
||||
attr.attrType == DBCust.FieldType.popuplist
|
||||
then
|
||||
_cell.enabeldObj(input, false)
|
||||
end
|
||||
end
|
||||
|
||||
-- 取得数据
|
||||
function _cell.getData()
|
||||
return mData
|
||||
@@ -164,12 +254,12 @@ function _cell.uiEventDelegate(go)
|
||||
-- 说明大文本框改变了
|
||||
NGUITools.AddWidgetCollider(csSelf.gameObject, false)
|
||||
uiobjs.Label4.enabled = (uiobjs.element.value == "" and true or false)
|
||||
Utl.doCallback(mData.onMultTextInputChg, csSelf.gameObject)
|
||||
Utl.doCallback(mData.onMultTextInputChg, uiobjs.element)
|
||||
elseif
|
||||
attr.attrType == DBCust.FieldType.number or attr.attrType == DBCust.FieldType.phone or
|
||||
attr.attrType == DBCust.FieldType.text
|
||||
then
|
||||
Utl.doCallback(mData.onInputChange, csSelf.gameObject)
|
||||
Utl.doCallback(mData.onInputChange, uiobjs.element)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -178,9 +268,9 @@ function _cell.onNotifyLua(go)
|
||||
attr.attrType == DBCust.FieldType.popuplist or attr.attrType == DBCust.FieldType.checkbox or
|
||||
attr.attrType == DBCust.FieldType.dateTime
|
||||
then
|
||||
Utl.doCallback(mData.onSelect, csSelf.gameObject)
|
||||
Utl.doCallback(mData.onSelect, uiobjs.element)
|
||||
else
|
||||
Utl.doCallback(mData.onClick, csSelf.gameObject)
|
||||
Utl.doCallback(mData.onClick, uiobjs.element)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -0,0 +1,69 @@
|
||||
---@class _ParamCellImage
|
||||
---@field path string
|
||||
---@field onDelete function
|
||||
|
||||
-- xx单元
|
||||
local _cell = {}
|
||||
---@type Coolape.CLCellLua
|
||||
local csSelf = nil
|
||||
local transform = nil
|
||||
---@type _ParamCellImage
|
||||
local mData = nil
|
||||
local uiobjs = {}
|
||||
|
||||
-- 初始化,只调用一次
|
||||
function _cell.init(csObj)
|
||||
csSelf = csObj
|
||||
transform = csSelf.transform
|
||||
---@type UITexture
|
||||
uiobjs.texture = csSelf:GetComponent("UITexture")
|
||||
end
|
||||
|
||||
-- 显示,
|
||||
-- 注意,c#侧不会在调用show时,调用refresh
|
||||
function _cell.show(go, data)
|
||||
mData = data
|
||||
local url
|
||||
if startswith(mData.path, "/") then
|
||||
url = joinStr("file://", mData.path)
|
||||
else
|
||||
url = mData.path
|
||||
end
|
||||
print(url)
|
||||
if uiobjs.texture.mainTexture and uiobjs.texture.mainTexture.name == mData.path then
|
||||
else
|
||||
_cell.release()
|
||||
DBTextures.getByUrl(url, _cell.onGetTextue, mData.path)
|
||||
end
|
||||
end
|
||||
|
||||
function _cell.onGetTextue(content, orgs)
|
||||
if mData.path ~= orgs then
|
||||
GameObject.DestroyImmediate(content)
|
||||
content = nil
|
||||
return
|
||||
end
|
||||
_cell.release()
|
||||
content.name = orgs
|
||||
uiobjs.texture.mainTexture = content
|
||||
end
|
||||
|
||||
function _cell.release()
|
||||
if uiobjs.texture.mainTexture ~= nil then
|
||||
uiobjs.texture.mainTexture = nil
|
||||
end
|
||||
end
|
||||
|
||||
-- 取得数据
|
||||
function _cell.getData()
|
||||
return mData
|
||||
end
|
||||
|
||||
function _cell.uiEventDelegate(go)
|
||||
if go.name == "ButtonDel" then
|
||||
Utl.doCallback(mData.onDelete, mData)
|
||||
end
|
||||
end
|
||||
|
||||
--------------------------------------------
|
||||
return _cell
|
||||
@@ -0,0 +1,7 @@
|
||||
fileFormatVersion: 2
|
||||
guid: b0b74c6ac6d214694bf232a299e48b6b
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in New Issue
Block a user