---@type IDBasePanel local TRBasePanel = require("ui.panel.TRBasePanel") ---@class TRPNewFollowSimple:TRBasePanel 邮件列表 local TRPNewFollowSimple = class("TRPNewFollowSimple", TRBasePanel) local uiobjs = {} local stars = {} -- 初始化,只会调用一次 function TRPNewFollowSimple:init(csObj) TRPNewFollowSimple.super.init(self, csObj) self:initFiledsAttr() self:setEventDelegate() MyUtl.setContentView(getChild(self.transform, "PanelContent"), MyUtl.defaultTopHeight, 0) ---@type UIScrollView uiobjs.scrollView = getCC(self.transform, "PanelContent", "UIScrollView") uiobjs.scrollView.dampenStrength = MyUtl.dampenStrength ---@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 TRPNewFollowSimple:initFiledsAttr() ---@type _ParamFieldAttr local attr self.baseFiledsAttr = {} attr = {} attr.attrName = "跟进类型" attr.id = "followUpType" attr.attrType = DBCust.FieldType.popuplist attr.ifMust = 0 attr.donotJoinKey = true local popInfor = DBCust.getFilter4Popup(DBCust.FilterGroup.followUpTypeList) attr.popOptions = popInfor.options attr.popValues = popInfor.values table.insert(self.baseFiledsAttr, attr) attr = {} attr.attrName = "客户状态" attr.id = "dealFlag" attr.attrType = DBCust.FieldType.popuplist attr.ifMust = 1 attr.donotJoinKey = true local popInfor = DBCust.getFilter4Popup(DBCust.FilterGroup.dealFlagList) attr.popOptions = popInfor.options attr.popValues = popInfor.values table.insert(self.baseFiledsAttr, attr) attr = {} attr.attrName = "跟进内容" attr.id = "followUpContent" attr.attrType = DBCust.FieldType.multext attr.ifMust = 1 attr.donotJoinKey = true table.insert(self.baseFiledsAttr, attr) end -- 设置数据 ---@param paras _ParamTRPNewFollowSimple function TRPNewFollowSimple:setData(paras) self.mdata = {} self.mdata.custId = paras.custId self.mdata.taskId = paras.taskId self.mdata.followUpType = "0" self.mdata.dealFlag = "0" self.isNewFollow = true end -- 显示,在c#中。show为调用refresh,show和refresh的区别在于,当页面已经显示了的情况,当页面再次出现在最上层时,只会调用refresh function TRPNewFollowSimple:show() self:refreshContent() SetActive(uiobjs.ButtonSave.gameObject, self.isNewFollow) uiobjs.scrollView:ResetPosition() end function TRPNewFollowSimple:refreshContent() self:showBaseFields() self.csSelf:invoke4Lua(self:wrapFunc(self.reposition), 0.1) end function TRPNewFollowSimple:showBaseFields() ---@type _ParamCellExtendFiledRoot local param = {} param.data = self.mdata or {} param.onFinish = self:wrapFunc(self.setExtendFieldsMode) param.onLoadOneField = self:wrapFunc(self.onLoadOneField) 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 TRPNewFollowSimple:onPopupFieldValChg(go) ---@type CLUIElement local el = go:GetComponent("CLUIElement") if el.jsonKey == "dealFlag" then if uiobjs.followUpContent then local popList = go:GetComponent("UIPopupList") if isNilOrEmpty(uiobjs.followUpContent.value) or self.oldselectedItem == uiobjs.followUpContent.value then uiobjs.followUpContent.value = popList.selectedItem self.oldselectedItem = popList.selectedItem end end end end function TRPNewFollowSimple:reposition() uiobjs.DetailRootTabel.repositionNow = true uiobjs.Table.repositionNow = true end function TRPNewFollowSimple:onLoadOneField(cell) local el = cell:GetComponent("CLUIElement") if el and el.jsonKey == "followUpContent" then uiobjs.followUpContent = el end end function TRPNewFollowSimple:setExtendFieldsMode(root) local elements = root:GetComponentsInChildren(typeof(CLUIElement), true) for i = 0, elements.Length - 1 do self:setElementMode(elements[i]) end self:reposition() end function TRPNewFollowSimple: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 TRPNewFollowSimple:refresh() end -- 关闭页面 function TRPNewFollowSimple:hide() self.oldselectedItem = nil if uiobjs.DetailRoot.luaTable then uiobjs.DetailRoot.luaTable.release() end end -- 网络请求的回调;cmd:指命,succ:成功失败,msg:消息;paras:服务器下行数据 function TRPNewFollowSimple:procNetwork(cmd, succ, msg, paras) if (succ == NetSuccess) then if cmd == NetProto.cmds.update_customer then self:refreshContent() end end end function TRPNewFollowSimple: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_record(self.mdata, function(content) hideHotWheel() if content.success then MyUtl.toastS("保存成功") hideTopPanel(self.csSelf) end end) end, InputTask = function() self:showExtentFiles(uiobjs.InputTask.value) end } end -- 处理ui上的事件,例如点击等 function TRPNewFollowSimple:uiEventDelegate(go) local func = self.EventDelegate[go.name] if func then func() end end -- 当顶层页面发生变化时回调 function TRPNewFollowSimple:onTopPanelChange(topPanel) end -------------------------------------------- return TRPNewFollowSimple