add
This commit is contained in:
379
Assets/trCRM/upgradeRes4Dev/priority/lua/ui/panel/TRPNewCust.lua
Normal file
379
Assets/trCRM/upgradeRes4Dev/priority/lua/ui/panel/TRPNewCust.lua
Normal file
@@ -0,0 +1,379 @@
|
||||
---@type IDBasePanel
|
||||
local TRBasePanel = require("ui.panel.TRBasePanel")
|
||||
---@class TRPNewCust:TRBasePanel 邮件列表
|
||||
local TRPNewCust = class("TRPNewCust", TRBasePanel)
|
||||
|
||||
local uiobjs = {}
|
||||
|
||||
local stars = {}
|
||||
-- 初始化,只会调用一次
|
||||
function TRPNewCust:init(csObj)
|
||||
TRPNewCust.super.init(self, csObj)
|
||||
|
||||
self:setEventDelegate()
|
||||
MyUtl.setContentView(getChild(self.transform, "PanelContent"), 132, 0)
|
||||
---@type UIScrollView
|
||||
uiobjs.scrollView = getCC(self.transform, "PanelContent", "UIScrollView")
|
||||
---@type UITable
|
||||
uiobjs.Table = getCC(uiobjs.scrollView.transform, "Table", "UITable")
|
||||
---@type CLUIFormRoot
|
||||
uiobjs.DetailRoot = getCC(uiobjs.Table.transform, "DetailRoot", "CLUIFormRoot")
|
||||
---@type UITable
|
||||
uiobjs.DetailRootTabel = uiobjs.DetailRoot:GetComponent("UITable")
|
||||
uiobjs.InputTask = getCC(uiobjs.DetailRoot.transform, "InputTask", "UIPopupList")
|
||||
uiobjs.InputCustType = getCC(uiobjs.DetailRoot.transform, "InputCustType", "UIPopupList")
|
||||
uiobjs.InputStatus = getCC(uiobjs.DetailRoot.transform, "InputStatus", "UIPopupList")
|
||||
uiobjs.InputFrom = getCC(uiobjs.DetailRoot.transform, "InputFrom", "UIPopupList")
|
||||
uiobjs.InputLogin = getCC(uiobjs.DetailRoot.transform, "InputLogin", "UIPopupList")
|
||||
uiobjs.starGrid2 = getCC(uiobjs.DetailRoot.transform, "InputStars/Grid", "UIGrid")
|
||||
uiobjs.starGridPrefab2 = getChild(uiobjs.starGrid2.transform, "00000").gameObject
|
||||
|
||||
uiobjs.ExtendRoot = getCC(uiobjs.Table.transform, "ExtendRoot", "CLCellLua")
|
||||
uiobjs.elements = uiobjs.DetailRoot.gameObject:GetComponentsInChildren(typeof(CLUIElement), true)
|
||||
uiobjs.ButtonSave = getChild(self.transform, "Top/ButtonSave")
|
||||
end
|
||||
|
||||
-- 设置数据
|
||||
---@param paras _ParamTRPNewCust
|
||||
function TRPNewCust:setData(paras)
|
||||
if paras and paras.custId > 0 then
|
||||
self.isNewCust = false
|
||||
self.mdata = paras
|
||||
else
|
||||
self.isNewCust = true
|
||||
self.mdata = {}
|
||||
self.mdata.dealflag = "0"
|
||||
self.mdata.custType = "0"
|
||||
self.mdata.custFrom = "0"
|
||||
self.mdata.serviceNo = NetProto.loginNo
|
||||
self.mdata.customerLabel = 1
|
||||
end
|
||||
if type(self.mdata.jsonstr) == "string" then
|
||||
self.mdata.jsonstr = json.decode(self.mdata.jsonstr)
|
||||
end
|
||||
end
|
||||
|
||||
---public 当有通用背板显示时的回调
|
||||
---@param cs Coolape.CLPanelLua
|
||||
function TRPNewCust:onShowFrame(cs)
|
||||
if cs.frameObj then
|
||||
---@type _BGFrame1Param
|
||||
local d = {}
|
||||
if self.isNewCust then
|
||||
d.title = "新建客户"
|
||||
else
|
||||
d.title = "修改客户"
|
||||
end
|
||||
d.panel = cs
|
||||
cs.frameObj:init(d)
|
||||
end
|
||||
end
|
||||
|
||||
-- 显示,在c#中。show为调用refresh,show和refresh的区别在于,当页面已经显示了的情况,当页面再次出现在最上层时,只会调用refresh
|
||||
function TRPNewCust:show()
|
||||
local optionInfor = DBCust.getFilter4Popup(DBCust.FilterGroup.dealFlagList)
|
||||
uiobjs.InputStatus:refreshItems(optionInfor.options, optionInfor.values)
|
||||
optionInfor = DBCust.getFilter4Popup(DBCust.FilterGroup.custTypeList)
|
||||
uiobjs.InputCustType:refreshItems(optionInfor.options, optionInfor.values)
|
||||
optionInfor = DBCust.getFilter4Popup(DBCust.FilterGroup.custFromList)
|
||||
uiobjs.InputFrom:refreshItems(optionInfor.options, optionInfor.values)
|
||||
optionInfor = DBCust.getFilter4Popup(DBCust.FilterGroup.taskList)
|
||||
uiobjs.InputTask:refreshItems(optionInfor.options, optionInfor.values)
|
||||
optionInfor = DBCust.getFilter4Popup(DBCust.FilterGroup.loginNoList)
|
||||
uiobjs.InputLogin:refreshItems(optionInfor.options, optionInfor.values)
|
||||
|
||||
self:refreshContent()
|
||||
|
||||
self:setMode()
|
||||
SetActive(uiobjs.ButtonSave.gameObject, self.isNewCust)
|
||||
|
||||
uiobjs.scrollView:ResetPosition()
|
||||
end
|
||||
|
||||
function TRPNewCust:refreshContent()
|
||||
uiobjs.DetailRoot:setValue(self.mdata)
|
||||
if self.isNewCust then
|
||||
uiobjs.ExtendRoot:init(
|
||||
{
|
||||
data = self.mdata,
|
||||
onFinish = self:wrapFunc(self.setExtendFieldsMode),
|
||||
isEditMode = true
|
||||
},
|
||||
nil
|
||||
)
|
||||
else
|
||||
uiobjs.ExtendRoot:init(
|
||||
{
|
||||
data = self.mdata,
|
||||
isEditMode = true,
|
||||
onFinish = self:wrapFunc(self.setExtendFieldsMode),
|
||||
onClick = self:wrapFunc(self.onClickInputField4Extend),
|
||||
onSelect = self:wrapFunc(self.onPopupFieldValChg4Extend)
|
||||
},
|
||||
nil
|
||||
)
|
||||
end
|
||||
|
||||
-- 设置星级
|
||||
stars = {}
|
||||
for i = 1, 5 do
|
||||
table.insert(stars, {index = i, value = i <= (self.mdata.customerLabel or 0) and true or false})
|
||||
end
|
||||
CLUIUtl.resetList4Lua(uiobjs.starGrid2, uiobjs.starGridPrefab2, stars, self:wrapFunc(self.initStarCell))
|
||||
self.csSelf:invoke4Lua(self:wrapFunc(self.reposition), 0.1)
|
||||
end
|
||||
|
||||
function TRPNewCust:reposition()
|
||||
uiobjs.DetailRootTabel.repositionNow = true
|
||||
uiobjs.Table.repositionNow = true
|
||||
end
|
||||
|
||||
function TRPNewCust:initStarCell(cell, data)
|
||||
cell:init(data, self:wrapFunc(self.onClickStar))
|
||||
end
|
||||
|
||||
function TRPNewCust:onClickStar(cell, data)
|
||||
for i, v in ipairs(stars) do
|
||||
if v.index <= data.index then
|
||||
v.value = true
|
||||
else
|
||||
v.value = false
|
||||
end
|
||||
end
|
||||
CLUIUtl.resetList4Lua(uiobjs.starGrid2, uiobjs.starGridPrefab2, stars, self:wrapFunc(self.initStarCell))
|
||||
if (not self.isNewCust) and data.index ~= self.mdata.customerLabel then
|
||||
-- 说明更改了星级
|
||||
self:sendModifymsg("customerLabel", data.index, false)
|
||||
end
|
||||
end
|
||||
|
||||
function TRPNewCust:setMode()
|
||||
local count = uiobjs.elements.Length
|
||||
for i = 0, count - 1 do
|
||||
self:setElementMode(uiobjs.elements[i])
|
||||
end
|
||||
end
|
||||
|
||||
function TRPNewCust:setExtendFieldsMode()
|
||||
local elements = uiobjs.ExtendRoot.gameObject:GetComponentsInChildren(typeof(CLUIElement), true)
|
||||
for i = 0, elements.Length - 1 do
|
||||
self:setElementMode(elements[i])
|
||||
end
|
||||
self:reposition()
|
||||
end
|
||||
|
||||
function TRPNewCust:setElementMode(el)
|
||||
local isPopList = el:GetComponent("UIPopupList")
|
||||
local isPopCheckbox = el:GetComponent("CLUICheckbox")
|
||||
---@type UIInput
|
||||
local input = el:GetComponent("UIInput")
|
||||
local inputOnGUI = el:GetComponent("UIInputOnGUI")
|
||||
local boxcollider = el:GetComponent("BoxCollider")
|
||||
|
||||
if (not self.isNewCust) and (el.jsonKey == "taskId" or el.jsonKey == "phoneNo") then
|
||||
boxcollider.enabled = false
|
||||
else
|
||||
boxcollider.enabled = true
|
||||
end
|
||||
if input then
|
||||
if isPopList or isPopCheckbox then
|
||||
input.enabled = false
|
||||
if inputOnGUI then
|
||||
inputOnGUI.enabled = false
|
||||
end
|
||||
else
|
||||
if self.isNewCust then
|
||||
input.enabled = true
|
||||
if inputOnGUI then
|
||||
inputOnGUI.enabled = true
|
||||
end
|
||||
else
|
||||
input.enabled = false
|
||||
if inputOnGUI then
|
||||
inputOnGUI.enabled = false
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
-- 刷新
|
||||
function TRPNewCust:refresh()
|
||||
end
|
||||
|
||||
-- 关闭页面
|
||||
function TRPNewCust:hide()
|
||||
if uiobjs.ExtendRoot.luaTable then
|
||||
uiobjs.ExtendRoot.luaTable.release()
|
||||
end
|
||||
end
|
||||
|
||||
-- 网络请求的回调;cmd:指命,succ:成功失败,msg:消息;paras:服务器下行数据
|
||||
function TRPNewCust:procNetwork(cmd, succ, msg, paras)
|
||||
if (succ == NetSuccess) then
|
||||
if cmd == NetProto.cmds.update_customer then
|
||||
self:refreshContent()
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function TRPNewCust:onPopupFieldValChg(go)
|
||||
if self.isNewCust then
|
||||
return
|
||||
end
|
||||
---@type CLUIElement
|
||||
local el = go:GetComponent("CLUIElement")
|
||||
if el then
|
||||
local err = el:checkValid()
|
||||
if tostring(el.value) ~= tostring(self.mdata[el.jsonKey]) then
|
||||
if isNilOrEmpty(err) then
|
||||
self:sendModifymsg(el.jsonKey, el.value, false)
|
||||
else
|
||||
CLAlert.add(err, Color.yellow, 1)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function TRPNewCust:onClickInputField(go)
|
||||
if self.isNewCust then
|
||||
return
|
||||
end
|
||||
|
||||
---@type CLUIElement
|
||||
local el = go:GetComponent("CLUIElement")
|
||||
if el then
|
||||
getPanelAsy(
|
||||
"PanelModifyFiled",
|
||||
onLoadedPanelTT,
|
||||
{
|
||||
label = el.labeName.text,
|
||||
key = el.jsonKey,
|
||||
value = el.value,
|
||||
canNull = el.canNull,
|
||||
callback = self:wrapFunc(self.onFinishSetField)
|
||||
}
|
||||
)
|
||||
end
|
||||
end
|
||||
function TRPNewCust:onFinishSetField(key, val)
|
||||
if tostring(val) ~= tostring(self.mdata[key]) then
|
||||
self:sendModifymsg(key, val, false)
|
||||
end
|
||||
end
|
||||
|
||||
function TRPNewCust:sendModifymsg(key, val, isExtend)
|
||||
local content = {}
|
||||
content.id = self.mdata.custId
|
||||
if isExtend then
|
||||
content.jsonstr = {[key] = val}
|
||||
else
|
||||
content[key] = val
|
||||
end
|
||||
showHotWheel()
|
||||
NetProto.send.update_customer(
|
||||
content,
|
||||
function(result, orgs)
|
||||
hideHotWheel()
|
||||
if result.success then
|
||||
-- 更新本地数据
|
||||
if isExtend then
|
||||
self.mdata.jsonstr[key] = val
|
||||
else
|
||||
self.mdata[key] = val
|
||||
end
|
||||
end
|
||||
end
|
||||
)
|
||||
end
|
||||
|
||||
function TRPNewCust:onPopupFieldValChg4Extend(go)
|
||||
if self.isNewCust then
|
||||
return
|
||||
end
|
||||
---@type CLUIElement
|
||||
local el = go:GetComponent("CLUIElement")
|
||||
if el then
|
||||
local err = el:checkValid()
|
||||
if (not isNilOrEmpty(el.value)) and tostring(el.value) ~= tostring(self.mdata.jsonstr[el.jsonKey]) then
|
||||
if isNilOrEmpty(err) then
|
||||
-- 有修改,发送数据
|
||||
self:sendModifymsg(el.jsonKey, el.value, true)
|
||||
else
|
||||
CLAlert.add(err, Color.yellow, 1)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function TRPNewCust:onClickInputField4Extend(go)
|
||||
if self.isNewCust then
|
||||
return
|
||||
end
|
||||
|
||||
---@type CLUIElement
|
||||
local el = go:GetComponent("CLUIElement")
|
||||
if el then
|
||||
getPanelAsy(
|
||||
"PanelModifyFiled",
|
||||
onLoadedPanelTT,
|
||||
{
|
||||
label = el.labeName.text,
|
||||
key = el.jsonKey,
|
||||
value = el.value,
|
||||
canNull = el.canNull,
|
||||
callback = self:wrapFunc(self.onFinishSetField4Extend)
|
||||
}
|
||||
)
|
||||
end
|
||||
end
|
||||
|
||||
function TRPNewCust:onFinishSetField4Extend(key, val)
|
||||
if tostring(val) ~= tostring(self.mdata.jsonstr[key]) then
|
||||
self:sendModifymsg(key, val, true)
|
||||
end
|
||||
end
|
||||
|
||||
function TRPNewCust:setEventDelegate()
|
||||
self.EventDelegate = {
|
||||
ButtonSave = function()
|
||||
end,
|
||||
InputTask = function()
|
||||
if self.isNewCust then
|
||||
uiobjs.ExtendRoot:init(
|
||||
{
|
||||
data = {taskId = uiobjs.InputTask.value},
|
||||
onFinish = self:wrapFunc(self.setExtendFieldsMode),
|
||||
isEditMode = true
|
||||
},
|
||||
nil
|
||||
)
|
||||
else
|
||||
uiobjs.ExtendRoot:init(
|
||||
{
|
||||
data = self.mdata,
|
||||
isEditMode = true,
|
||||
onFinish = self:wrapFunc(self.setExtendFieldsMode),
|
||||
onClick = self:wrapFunc(self.onClickInputField4Extend),
|
||||
onSelect = self:wrapFunc(self.onPopupFieldValChg4Extend)
|
||||
},
|
||||
nil
|
||||
)
|
||||
end
|
||||
end
|
||||
}
|
||||
end
|
||||
-- 处理ui上的事件,例如点击等
|
||||
function TRPNewCust:uiEventDelegate(go)
|
||||
local func = self.EventDelegate[go.name]
|
||||
if func then
|
||||
func()
|
||||
end
|
||||
end
|
||||
|
||||
-- 当顶层页面发生变化时回调
|
||||
function TRPNewCust:onTopPanelChange(topPanel)
|
||||
end
|
||||
|
||||
--------------------------------------------
|
||||
return TRPNewCust
|
||||
Reference in New Issue
Block a user