---@class _ParamTRPCustDetail ---@field cust ---@field bookingData ---@field needShowMore ---@type IDBasePanel local TRBasePanel = require("ui.panel.TRBasePanel") ---@class TRPCustDetail:TRBasePanel 邮件列表 local TRPCustDetail = class("TRPCustDetail", TRBasePanel) local uiobjs = {} -- 初始化,只会调用一次 function TRPCustDetail:init(csObj) TRPCustDetail.super.init(self, csObj) self:prepareMoreData() self:setEventDelegate() MyUtl.setContentView(getChild(self.transform, "PanelContent"), MyUtl.defaultTopHeight + 400 + 160 + 60, 200) uiobjs.bottomGrid = getCC(self.transform, "AnchorBottom/offset/Grid", "UIGrid") local width = NumEx.getIntPart(CSPMain.contentRect.z / 4) uiobjs.bottomGrid.cellWidth = width ---@type UIScrollView uiobjs.scrollView = getCC(self.transform, "PanelContent", "UIScrollView") uiobjs.scrollView.dampenStrength = MyUtl.dampenStrength ---@type UITable uiobjs.Table = getCC(uiobjs.scrollView.transform, "Table", "UITable") uiobjs.Head = getCC(self.transform, "Top/SpriteHead", "CLUIFormRoot") ---@type UIPopupList uiobjs.LabelStatus = getCC(uiobjs.Head.transform, "LabelStatus", "UIPopupList") uiobjs.LabelType = getCC(uiobjs.Head.transform, "LabelType", "UIPopupList") uiobjs.LabelLoginNo = getCC(uiobjs.Head.transform, "LabelLoginNo", "UIPopupList") uiobjs.starGrid = getCC(uiobjs.Head.transform, "LabelStars/Grid", "UIGrid") uiobjs.starGridPrefab = getChild(uiobjs.starGrid.transform, "00000").gameObject ---@type UIGrid uiobjs.SpriteToggle = getCC(self.transform, "Top/SpriteToggle", "UIGrid") local width = NumEx.getIntPart(CSPMain.contentRect.z / 4) uiobjs.SpriteToggle.cellWidth = width ---@type UIToggle uiobjs.ToggleDetail = getCC(uiobjs.SpriteToggle.transform, "ToggleDetail", "UIToggle") ---@type UIToggle uiobjs.ToggleMore = getCC(uiobjs.SpriteToggle.transform, "ToggleMore", "UIToggle") ---@type CLUIFormRoot uiobjs.DetailRoot = getCC(uiobjs.Table.transform, "DetailRoot", "CLUIFormRoot") 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 ---@type Coolape.CLUILoopGrid uiobjs.Records = getCC(uiobjs.Table.transform, "Records", "CLUILoopGrid") uiobjs.ButtonEndList = getChild(uiobjs.Records.transform, "ButtonEndList") uiobjs.ExtendRoot = getCC(uiobjs.Table.transform, "ExtendRoot", "CLCellLua") ---@type Coolape.CLUILoopGrid uiobjs.OrderRoot = getCC(uiobjs.Table.transform, "OrderRoot", "CLUILoopGrid") uiobjs.ButtonEndListOrder = getChild(uiobjs.OrderRoot.transform, "ButtonEndList") uiobjs.MoreRoot = getCC(uiobjs.Table.transform, "MoreRoot", "CLCellLua") uiobjs.SysRoot = getCC(uiobjs.Table.transform, "SysRoot", "CLCellLua") end function TRPCustDetail:prepareMoreData() self.moreProcList = {} ---@type _ParamFieldAttr local attr = {} attr.id = "follows" attr.attrName = "跟进记录" attr.attrType = DBCust.FieldType.text attr.ifMust = 0 attr.height = 180 attr.donotJoinKey = true table.insert(self.moreProcList, attr) attr = {} attr.id = "followTasks" attr.attrName = "预约记录" attr.attrType = DBCust.FieldType.text attr.ifMust = 0 attr.height = 180 attr.donotJoinKey = true table.insert(self.moreProcList, attr) --[[ attr = {} attr.id = "smsList" attr.attrName = "短信记录" attr.attrType = DBCust.FieldType.text attr.ifMust = 0 attr.height = 180 attr.donotJoinKey = true table.insert(self.moreProcList, attr) attr = {} attr.id = "opList" attr.attrName = "操作记录" attr.attrType = DBCust.FieldType.text attr.ifMust = 0 attr.height = 180 attr.donotJoinKey = true table.insert(self.moreProcList, attr) ]] -------------------------------------------- self.sysFields = {} ---@type _ParamFieldAttr local attr = {} attr.id = "loginNo" attr.attrName = "创建人员" attr.attrType = DBCust.FieldType.popuplist attr.ifMust = 0 attr.height = 180 attr.donotJoinKey = true local popInfor = DBUser.getPopList(DBUser.FilterGroup.user) attr.popOptions = popInfor.options attr.popValues = popInfor.values table.insert(self.sysFields, attr) ---@type _ParamFieldAttr attr = {} attr.id = "groupId" attr.attrName = "所属部门" attr.attrType = DBCust.FieldType.popuplist attr.ifMust = 0 attr.height = 180 attr.donotJoinKey = true local popInfor = DBUser.getPopList(DBUser.FilterGroup.group) attr.popOptions = popInfor.options attr.popValues = popInfor.values table.insert(self.sysFields, attr) ---@type _ParamFieldAttr attr = {} attr.id = "createTime" attr.attrName = "创建时间" attr.attrType = DBCust.FieldType.text attr.ifMust = 0 attr.height = 180 attr.donotJoinKey = true table.insert(self.sysFields, attr) ---@type _ParamFieldAttr attr = {} attr.id = "updateTime" attr.attrName = "更新时间" attr.attrType = DBCust.FieldType.text attr.ifMust = 0 attr.height = 180 attr.donotJoinKey = true table.insert(self.sysFields, attr) ---@type _ParamFieldAttr attr = {} attr.id = "lastFollowUpTime" attr.attrName = "最后跟进" attr.attrType = DBCust.FieldType.text attr.ifMust = 0 attr.height = 180 attr.donotJoinKey = true table.insert(self.sysFields, attr) ---@type _ParamFieldAttr -- attr = {} -- attr.id = "followupTime" -- attr.attrName = "下次跟进" -- attr.attrType = DBCust.FieldType.text -- attr.ifMust = 0 -- attr.height = 180 -- attr.donotJoinKey = true -- table.insert(self.sysFields, attr) end -- 设置数据 ---@param paras _ParamTRPCustDetail function TRPCustDetail:setData(paras) ---@type _DBCust self.mdata = paras.cust self.mdata._phoneNo = MyUtl.hidePhone(self.mdata.phoneNo) if type(self.mdata.jsonStr) == "string" then self.mdata.jsonStr = json.decode(self.mdata.jsonStr) end self.bookingData = paras.bookingData self.needShowMore = paras.needShowMore end ---public 当有通用背板显示时的回调 ---@param cs Coolape.CLPanelLua function TRPCustDetail:onShowFrame(cs) if cs.frameObj then ---@type _BGFrame1Param local d = {} -- d.title = LGet(cs.titleKeyName) d.title = self.mdata.companyName d.panel = cs cs.frameObj:init(d) end end -- 显示,在c#中。show为调用refresh,show和refresh的区别在于,当页面已经显示了的情况,当页面再次出现在最上层时,只会调用refresh function TRPCustDetail:show() -- SetActive(uiobjs.ToggleMore.gameObject, self.needShowMore) self.records = nil self.orders = nil local optionInfor = DBCust.getFilter4Popup(DBCust.FilterGroup.dealFlagList) uiobjs.LabelStatus:refreshItems(optionInfor.options, optionInfor.values) uiobjs.InputStatus:refreshItems(optionInfor.options, optionInfor.values) optionInfor = DBCust.getFilter4Popup(DBCust.FilterGroup.custTypeList) uiobjs.LabelType:refreshItems(optionInfor.options, optionInfor.values) 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) local poplist = DBUser.getPopList(DBUser.FilterGroup.user) uiobjs.InputLogin:refreshItems(poplist.options, poplist.values) uiobjs.LabelLoginNo:refreshItems(poplist.options, poplist.values) -- 设置星级 local stars = {} for i = 1, 5 do table.insert(stars, i <= (self.mdata.customerLabel or 0) and true or false) end CLUIUtl.resetList4Lua(uiobjs.starGrid, uiobjs.starGridPrefab, stars, self:wrapFunc(self.initStarCell)) uiobjs.Head:setValue(self.mdata) uiobjs.ToggleDetail:Set(true) self.currToggle = 1 self:showDetail() end function TRPCustDetail:initStarCell(cell, data) local sp = cell:GetComponent("UISprite") if data then sp.color = ColorEx.getColor(0xffFFC000) CLUIUtl.setSpriteFit(sp, "cust_full_star") else sp.color = ColorEx.getColor(0xffd9d9d9) CLUIUtl.setSpriteFit(sp, "cust_star") end end function TRPCustDetail:showDetail() self:release() SetActive(uiobjs.DetailRoot.gameObject, true) SetActive(uiobjs.ExtendRoot.gameObject, true) SetActive(uiobjs.SysRoot.gameObject, true) SetActive(uiobjs.OrderRoot.gameObject, false) SetActive(uiobjs.Records.gameObject, false) SetActive(uiobjs.MoreRoot.gameObject, false) uiobjs.DetailRoot:setValue(self.mdata) -- uiobjs.ExtendRoot:init({data = self.mdata, isEditMode = false}, nil) self:showExtentFiles(self.mdata.taskId) self:showSysFiles() -- 设置星级 local stars = {} for i = 1, 5 do table.insert(stars, i <= (self.mdata.customerLabel or 0) and true or false) end CLUIUtl.resetList4Lua(uiobjs.starGrid, uiobjs.starGridPrefab, stars, self:wrapFunc(self.initStarCell)) CLUIUtl.resetList4Lua(uiobjs.starGrid2, uiobjs.starGridPrefab2, stars, self:wrapFunc(self.initStarCell)) uiobjs.Table:Reposition() uiobjs.scrollView.restrictWithinPanel = true uiobjs.scrollView.disableDragIfFits = true uiobjs.scrollView:ResetPosition() end function TRPCustDetail:reposition() uiobjs.Table:Reposition() uiobjs.scrollView.disableDragIfFits = true uiobjs.scrollView:ResetPosition() self.csSelf:invoke4Lua( function() uiobjs.scrollView:ResetPosition() end, 0.1 ) end ---public 显示扩展字段 function TRPCustDetail:showExtentFiles(taskId) ---@type _ParamCellExtendFiledRoot local param = {} param.data = self.mdata and self.mdata.jsonStr or {} -- param.onFinish = self:wrapFunc(self.setExtendFieldsMode) param.fields = {} local fields = DBCust.getFieldsByTask(taskId) or {} ---@type _ParamCellExtendFiled local filedInfor for i, v in ipairs(fields) do filedInfor = {} filedInfor.attr = v filedInfor.showMode = _FieldMode.showOnly table.insert(param.fields, filedInfor) end uiobjs.ExtendRoot:init(param, nil) end ---public 显示扩展字段 function TRPCustDetail:showSysFiles() ---@type _ParamCellExtendFiledRoot local param = {} param.data = self.mdata param.onFinish = self:wrapFunc(self.reposition) param.fields = {} local fields = self.sysFields ---@type _ParamCellExtendFiled local filedInfor for i, v in ipairs(fields) do filedInfor = {} filedInfor.attr = v filedInfor.showMode = _FieldMode.showOnly table.insert(param.fields, filedInfor) end uiobjs.SysRoot:init(param, nil) end function TRPCustDetail:showRecords() self:release() SetActive(uiobjs.DetailRoot.gameObject, false) SetActive(uiobjs.ExtendRoot.gameObject, false) SetActive(uiobjs.SysRoot.gameObject, false) SetActive(uiobjs.OrderRoot.gameObject, false) SetActive(uiobjs.Records.gameObject, true) SetActive(uiobjs.MoreRoot.gameObject, false) if self.records == nil or #(self.records.data) then SetActive(uiobjs.ButtonEndList.gameObject, true) else SetActive(uiobjs.ButtonEndList.gameObject, false) end if self.records then uiobjs.Records:setList( self.records.data or {}, self:wrapFunc(self.initRecordCell), self:wrapFunc(self.onHeadList), self:wrapFunc(self.onEndList) ) else showHotWheel() NetProto.send.query_cust_calllog(self.mdata.phoneNo, nil, 1) uiobjs.Records:setList({}, self:wrapFunc(self.initRecordCell)) end self:reposition() end function TRPCustDetail:initRecordCell(cell, data) cell:init(data, nil) end function TRPCustDetail:onHeadList(head) printw("到最顶端了") end function TRPCustDetail:onEndList(tail) printw("到最后了==" .. tail.name) if self.records and self.records.meta.current_page < self.records.meta.total_pages then showHotWheel() -- 取得下一页 NetProto.send.query_cust_calllog(self.mdata.phoneNo, nil, self.records.meta.current_page + 1) else uiobjs.ButtonEndList.localPosition = tail.transform.localPosition + Vector3.up * -270 SetActive(uiobjs.ButtonEndList.gameObject, true) end end function TRPCustDetail:showOrders() self:release() SetActive(uiobjs.DetailRoot.gameObject, false) SetActive(uiobjs.ExtendRoot.gameObject, false) SetActive(uiobjs.SysRoot.gameObject, false) SetActive(uiobjs.Records.gameObject, false) SetActive(uiobjs.OrderRoot.gameObject, true) SetActive(uiobjs.MoreRoot.gameObject, false) if self.orders == nil or #(self.orders.data) then SetActive(uiobjs.ButtonEndListOrder.gameObject, true) else SetActive(uiobjs.ButtonEndListOrder.gameObject, false) end if self.orders then uiobjs.OrderRoot:setList( self.orders.data or {}, self:wrapFunc(self.initOrderCell), self:wrapFunc(self.onOrderHeadList), self:wrapFunc(self.onOrderEndList) ) else showHotWheel() NetProto.send.workFlowQuery({custId = self.mdata.custId}, "", 1) uiobjs.OrderRoot:setList({}, self:wrapFunc(self.initOrderCell)) end self:reposition() end function TRPCustDetail:initOrderCell(cell, data) cell:init(data, self:wrapFunc(self.onClickOrderCell)) end function TRPCustDetail:onClickOrderCell(cell, data) getPanelAsy("PanelOrderDetail", onLoadedPanelTT, data) end function TRPCustDetail:onOrderHeadList(head) printw("到最顶端了") end function TRPCustDetail:onOrderEndList(tail) printw("到最后了==" .. tail.name) if self.orders and self.orders.meta.current_page < self.orders.meta.total_pages then showHotWheel() -- 取得下一页 NetProto.send.workFlowQuery({custId = self.mdata.custId}, "", self.orders.meta.current_page + 1) else uiobjs.ButtonEndListOrder.localPosition = tail.transform.localPosition + Vector3.up * -240 SetActive(uiobjs.ButtonEndListOrder.gameObject, true) end end function TRPCustDetail:showMore() self:release() SetActive(uiobjs.DetailRoot.gameObject, false) SetActive(uiobjs.ExtendRoot.gameObject, false) SetActive(uiobjs.SysRoot.gameObject, false) SetActive(uiobjs.Records.gameObject, false) SetActive(uiobjs.OrderRoot.gameObject, false) SetActive(uiobjs.MoreRoot.gameObject, true) if not self.hasSetMoreProc then self.hasSetMoreProc = true ---@type _ParamCellExtendFiledRoot local param = {} param.data = nil param.onFinish = function() uiobjs.scrollView:ResetPosition() end param.fields = {} ---@type _ParamCellExtendFiled local filedInfor for i, v in ipairs(self.moreProcList) do filedInfor = {} filedInfor.attr = v filedInfor.showMode = _FieldMode.button filedInfor.onClick = self:wrapFunc(self.onClickMoreProc) table.insert(param.fields, filedInfor) end uiobjs.MoreRoot:init(param, nil) end uiobjs.Table:Reposition() uiobjs.scrollView.restrictWithinPanel = true uiobjs.scrollView.disableDragIfFits = true uiobjs.scrollView:ResetPosition() end ---@param el CLUIElement function TRPCustDetail:onClickMoreProc(el) if el.jsonKey == "follows" then -- 跟进记录 getPanelAsy("PanelFollowList4Cust", onLoadedPanelTT, {custId = self.mdata.custId}) elseif el.jsonKey == "followTasks" then -- 预约记录 getPanelAsy("PanelTaskList4Cust", onLoadedPanelTT, {custId = self.mdata.custId}) elseif el.jsonKey == "smsList" then -- 短信记录 elseif el.jsonKey == "opList" then -- 操作记录 end end -- 刷新 function TRPCustDetail:refresh() end function TRPCustDetail:release() if uiobjs.ExtendRoot.luaTable then uiobjs.ExtendRoot.luaTable.release() end if uiobjs.MoreRoot.luaTable then uiobjs.MoreRoot.luaTable.release() end if uiobjs.SysRoot.luaTable then uiobjs.SysRoot.luaTable.release() end self.hasSetMoreProc = false end -- 关闭页面 function TRPCustDetail:hide() self:release() end -- 网络请求的回调;cmd:指命,succ:成功失败,msg:消息;paras:服务器下行数据 function TRPCustDetail:procNetwork(cmd, succ, msg, paras) if (succ == NetSuccess) then if cmd == NetProto.cmds.query_cust_calllog then local result = paras.result if self.records == nil then self.records = result else if self.records.meta.current_page < result.meta.current_page then self.records.meta = result.meta for i, v in ipairs(result.data) do table.insert(self.records.data, v) end end end hideHotWheel() if self.records and uiobjs.Records.gameObject.activeInHierarchy then if self.records.meta.current_page == 1 then self:showRecords() else uiobjs.Records:appendList(result.data) end end elseif cmd == NetProto.cmds.workFlowQuery then local result = paras.result if self.orders == nil then self.orders = result else if self.orders.meta.current_page < result.meta.current_page then self.orders.meta = result.meta for i, v in ipairs(result.data) do table.insert(self.orders.data, v) end end end hideHotWheel() if self.orders and uiobjs.OrderRoot.gameObject.activeInHierarchy then if self.orders.meta.current_page == 1 then self:showOrders() else uiobjs.OrderRoot:appendList(result.data) end end elseif cmd == NetProto.cmds.update_customer or cmd == NetProto.cmds.create_followUp_record then if self.currToggle == 1 then self:showDetail() uiobjs.Head:setValue(self.mdata) end elseif cmd == NetProto.cmds.delCustomerInfo or cmd == NetProto.cmds.backToGH then hideTopPanel(self.csSelf) elseif cmd == NetProto.cmds.createWfInfo then self.orders = nil if self.currToggle == 3 then self:showOrders() end elseif cmd == NetProto.cmds.get_customerById then -- hideHotWheel() if self.mdata.custId == paras.result.custId then self.mdata = paras.result if self.currToggle == 1 then self:showDetail() uiobjs.Head:setValue(self.mdata) end end end end end function TRPCustDetail:setEventDelegate() self.EventDelegate = { ToggleDetail = function() self.currToggle = 1 self:showDetail() end, ToggleRecords = function() self.currToggle = 2 self:showRecords() end, ToggleOrders = function() self.currToggle = 3 self:showOrders() end, ToggleMore = function() self.currToggle = 4 self:showMore() end, ButtonNewFollow = function() ---@type _ParamTRPNewFollow local param = {} param.cust = self.mdata param.bookingData = self.bookingData getPanelAsy("PanelNewFollow", onLoadedPanelTT, param) end, ButtonNewTask = function() getPanelAsy("PanelNewFollowTask", onLoadedPanelTT, self.mdata) end, ButtonCall = function() MyUtl.showCallOption(self.mdata) end, ButtonNewOrder = function() getPanelAsy("PanelNewOrder", onLoadedPanelTT, self.mdata) end, ButtonMore = function() getPanelAsy("PanelMoreProc4Cust", onLoadedPanelTT, self.mdata) end } end -- 处理ui上的事件,例如点击等 function TRPCustDetail:uiEventDelegate(go) local func = self.EventDelegate[go.name] if func then func() end end -- 当顶层页面发生变化时回调 function TRPCustDetail:onTopPanelChange(topPanel) end -------------------------------------------- return TRPCustDetail