up
This commit is contained in:
@@ -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
|
||||
|
||||
|
||||
Reference in New Issue
Block a user