Files
tianrunCRM/Assets/trCRM/upgradeRes4Dev/priority/lua/ui/panel/TRPNewFollowTask.lua
2020-07-20 22:20:21 +08:00

231 lines
7.2 KiB
Lua
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

---@type IDBasePanel
local TRBasePanel = require("ui.panel.TRBasePanel")
---@class TRPNewFollowTask:TRBasePanel
local TRPNewFollowTask = class("TRPNewFollowTask", TRBasePanel)
local uiobjs = {}
local stars = {}
-- 初始化,只会调用一次
function TRPNewFollowTask:init(csObj)
TRPNewFollowTask.super.init(self, csObj)
self:initFiledsAttr()
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.DetailFromRoot = getCC(uiobjs.Table.transform, "DetailRoot", "CLUIFormRoot")
uiobjs.DetailRoot = getCC(uiobjs.Table.transform, "DetailRoot", "CLCellLua")
---@type UITable
uiobjs.DetailRootTabel = uiobjs.DetailRoot:GetComponent("UITable")
uiobjs.ButtonSave = getChild(self.transform, "Top/ButtonSave")
end
function TRPNewFollowTask:initFiledsAttr()
---@type _ParamFieldAttr
local attr
self.baseFiledsAttr = {}
attr = {}
attr.attrName = "预约内容"
attr.id = "bookingNote"
attr.attrType = DBCust.FieldType.multext
attr.ifMust = 1
attr.donotJoinKey = true
table.insert(self.baseFiledsAttr, attr)
attr = {}
attr.attrName = "预约时间"
attr.id = "FollowUpTime"
attr.attrType = DBCust.FieldType.dateTime
attr.ifTime = 1
attr.ifMust = 1
attr.donotJoinKey = true
table.insert(self.baseFiledsAttr, attr)
attr = {}
attr.attrName = "跟进人员"
attr.id = "loginNo"
attr.attrType = DBCust.FieldType.popuplist
attr.ifMust = 1
attr.donotJoinKey = true
local popList = DBCust.getFilter4Popup(DBCust.FilterGroup.loginNoList)
attr.popOptions = popList.options
attr.popValues = popList.values
table.insert(self.baseFiledsAttr, attr)
end
-- 设置数据
---@param paras _ParamTRPNewFollowTask
function TRPNewFollowTask:setData(paras)
self.mdata = {}
self.mdata.custId = paras.custId
self.mdata.taskId = paras.taskId
self.mdata.loginNo = NetProto.loginNo
self.isNewFollow = true
end
-- 显示在c#中。show为调用refreshshow和refresh的区别在于当页面已经显示了的情况当页面再次出现在最上层时只会调用refresh
function TRPNewFollowTask:show()
self:refreshContent()
SetActive(uiobjs.ButtonSave.gameObject, self.isNewFollow)
uiobjs.scrollView:ResetPosition()
end
function TRPNewFollowTask:refreshContent()
self:showBaseFields()
self.csSelf:invoke4Lua(self:wrapFunc(self.reposition), 0.1)
end
function TRPNewFollowTask:showBaseFields()
---@type _ParamCellExtendFiledRoot
local param = {}
param.data = self.mdata or {}
param.onFinish = self:wrapFunc(self.setExtendFieldsMode)
param.fields = {}
---@type _ParamCellExtendFiled
local filedInfor
for i, v in ipairs(self.baseFiledsAttr) do
-- 工单模板
filedInfor = {}
filedInfor.attr = v
filedInfor.isEditMode = true
if filedInfor.attr.attrType == DBCust.FieldType.multext then
filedInfor.onMultTextInputChg = self:wrapFunc(self.reposition)
end
filedInfor.onClick = nil
filedInfor.onSelect = self:wrapFunc(self.onPopupFieldValChg)
table.insert(param.fields, filedInfor)
end
uiobjs.DetailRoot:init(param, nil)
end
function TRPNewFollowTask:onPopupFieldValChg(go)
---@type CLUIElement
local el = go:GetComponent("CLUIElement")
if el.jsonKey == "dealFlag" then
if uiobjs.followUpContent and isNilOrEmpty(uiobjs.followUpContent.value) then
local popList = go:GetComponent("UIPopupList")
uiobjs.followUpContent.value = popList.selectedItem
end
end
end
function TRPNewFollowTask:reposition()
uiobjs.DetailRootTabel.repositionNow = true
uiobjs.Table.repositionNow = true
end
function TRPNewFollowTask:setExtendFieldsMode(root)
local elements = root:GetComponentsInChildren(typeof(CLUIElement), true)
for i = 0, elements.Length - 1 do
self:setElementMode(elements[i])
if elements[i].jsonKey == "followUpContent" then
---@type CLUIElement
uiobjs.followUpContent = elements[i]
end
end
self:reposition()
end
function TRPNewFollowTask: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")
local ButtonReset = getCC(el.transform, "ButtonReset", "MyInputReset")
if (not self.isNewFollow) and (el.jsonKey == "taskId" or el.jsonKey == "phoneNo") then
boxcollider.enabled = false
else
boxcollider.enabled = true
end
if ButtonReset then
ButtonReset.disabled = (not self.isNewFollow)
end
if input then
if isPopList or isPopCheckbox then
input.enabled = false
if inputOnGUI then
inputOnGUI.enabled = false
end
else
if self.isNewFollow 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 TRPNewFollowTask:refresh()
end
-- 关闭页面
function TRPNewFollowTask:hide()
if uiobjs.DetailRoot.luaTable then
uiobjs.DetailRoot.luaTable.release()
end
end
-- 网络请求的回调cmd指命succ成功失败msg消息paras服务器下行数据
function TRPNewFollowTask:procNetwork(cmd, succ, msg, paras)
if (succ == NetSuccess) then
if cmd == NetProto.cmds.update_customer then
self:refreshContent()
end
end
end
function TRPNewFollowTask:setEventDelegate()
self.EventDelegate = {
ButtonSave = function()
local err = uiobjs.DetailFromRoot:checkValid()
if not isNilOrEmpty(err) then
MyUtl.toastW(err)
return
end
self.mdata = uiobjs.DetailFromRoot:getValue(self.mdata, true)
showHotWheel()
NetProto.send.create_followUp_task(self.mdata, function(content)
hideHotWheel()
if content.success then
MyUtl.toastS("创建成功")
hideTopPanel(self.csSelf)
end
end)
end
}
end
-- 处理ui上的事件例如点击等
function TRPNewFollowTask:uiEventDelegate(go)
local func = self.EventDelegate[go.name]
if func then
func()
end
end
-- 当顶层页面发生变化时回调
function TRPNewFollowTask:onTopPanelChange(topPanel)
end
--------------------------------------------
return TRPNewFollowTask