---@type IDBasePanel local TRBasePanel = require("ui.panel.TRBasePanel") ---@class TRPOrderDetail:TRBasePanel local TRPOrderDetail = class("TRPOrderDetail", TRBasePanel) local uiobjs = {} -- 初始化,只会调用一次 function TRPOrderDetail:init(csObj) TRPOrderDetail.super.init(self, csObj) self:prepareMoreData() self:setEventDelegate() uiobjs.TogglesPanel = getCC(self.transform, "Top/SpriteToggle/Toggles", "UIPanel") local v4 = MyUtl.getUIContent(self.csSelf, 0, 0) ---@type UnityEngine.Vector4 local baseClipRegion = uiobjs.TogglesPanel.baseClipRegion baseClipRegion.z = v4.z - 100 uiobjs.TogglesPanel.baseClipRegion = baseClipRegion ---@type UIScrollView uiobjs.TogglesScroll = uiobjs.TogglesPanel:GetComponent("UIScrollView") ---@type UIGrid uiobjs.ToggleGrid = getCC(uiobjs.TogglesPanel.transform, "Grid", "UIGrid") ---@type UIToggle uiobjs.ToggleDetail = getCC(uiobjs.ToggleGrid.transform, "ToggleDetail", "UIToggle") MyUtl.setContentView(getChild(self.transform, "PanelContent"), MyUtl.defaultTopHeight + 160 + 30, 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.DetailRoot = getCC(uiobjs.Table.transform, "DetailRoot", "CLCellLua") uiobjs.ExtendRoot = getCC(uiobjs.Table.transform, "ExtendRoot", "CLCellLua") uiobjs.ProductRoot = getCC(uiobjs.Table.transform, "ProductRoot", "UITable") uiobjs.ProductPrefab = getChild(uiobjs.ProductRoot.transform, "00000").gameObject ---@type Coolape.CLUILoopGrid uiobjs.Records = getCC(uiobjs.Table.transform, "Records", "CLUILoopGrid") uiobjs.ButtonEndList = getChild(uiobjs.Records.transform, "ButtonEndList") uiobjs.AttachmentRoot = getCC(uiobjs.Table.transform, "AttachmentRoot", "UIGrid") uiobjs.AttachmentPrefab = getChild(uiobjs.AttachmentRoot.transform, "00000").gameObject uiobjs.FinanceRoot = getCC(uiobjs.Table.transform, "FinanceRoot", "CLCellLua") ---@type Coolape.CLUILoopGrid uiobjs.SubOrders = getCC(uiobjs.Table.transform, "SubOrders", "CLUILoopGrid") uiobjs.ButtonEndListSub = getChild(uiobjs.SubOrders.transform, "ButtonEndList") end function TRPOrderDetail:prepareMoreData() self.baseFileds = {} ---@type _ParamFieldAttr local attr = {} attr.id = "id" attr.attrName = "订单ID" attr.attrType = DBCust.FieldType.text attr.ifMust = 0 attr.height = 160 attr.donotJoinKey = true table.insert(self.baseFileds, attr) attr = {} attr.id = "title" attr.attrName = "订单名称" attr.attrType = DBCust.FieldType.text attr.ifMust = 0 attr.height = 160 attr.donotJoinKey = true table.insert(self.baseFileds, attr) attr = {} attr.id = "templetName" attr.attrName = "订单模板" attr.attrType = DBCust.FieldType.text attr.ifMust = 0 attr.height = 160 attr.donotJoinKey = true table.insert(self.baseFileds, attr) attr = {} attr.id = "urgency" attr.attrName = "紧急程度" attr.attrType = DBCust.FieldType.popuplist attr.ifMust = 0 attr.height = 160 attr.donotJoinKey = true local popInfor = DBOrder.getPopupList(DBOrder.PopListGroup.urgencyLevels) attr.popOptions = popInfor.options attr.popValues = popInfor.values table.insert(self.baseFileds, attr) attr = {} attr.id = "custName" attr.attrName = "客户名称" attr.attrType = DBCust.FieldType.text attr.ifMust = 0 attr.height = 160 attr.donotJoinKey = true table.insert(self.baseFileds, attr) attr = {} attr.id = "_phoneNo" attr.attrName = "联系方式" attr.attrType = DBCust.FieldType.text attr.ifMust = 0 attr.height = 160 attr.donotJoinKey = true table.insert(self.baseFileds, attr) attr = {} attr.id = "companyName" attr.attrName = "公司名称" attr.attrType = DBCust.FieldType.text attr.ifMust = 0 attr.height = 160 attr.donotJoinKey = true table.insert(self.baseFileds, attr) attr = {} attr.id = "address" attr.attrName = "联系地址" attr.attrType = DBCust.FieldType.text attr.ifMust = 0 attr.height = 160 attr.donotJoinKey = true table.insert(self.baseFileds, attr) attr = {} attr.id = "content" attr.attrName = "订单内容" attr.attrType = DBCust.FieldType.multext attr.ifMust = 0 attr.height = 160 attr.donotJoinKey = true table.insert(self.baseFileds, attr) -------------------------------------------- end -- 设置数据 ---@param paras _ParamTRPOrderDetail function TRPOrderDetail:setData(paras) self.mdata = paras self.mdata._phoneNo = MyUtl.hidePhone(self.mdata.phoneNo) if type(self.mdata.attrJson) == "string" then self.mdata.attrJson = json.decode(self.mdata.attrJson) end if type(self.mdata.prodJson) == "string" then self.mdata.prodJson = json.decode(self.mdata.prodJson) end if type(self.mdata.wfOptJson) == "string" then self.mdata.wfOptJson = json.decode(self.mdata.wfOptJson) end end ---public 当有通用背板显示时的回调 ---@param cs Coolape.CLPanelLua function TRPOrderDetail: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 TRPOrderDetail:show() self.records = nil uiobjs.ToggleDetail:Set(true) self.currToggle = 1 uiobjs.TogglesScroll:ResetPosition() self:showDetail() end function TRPOrderDetail:showDetail() self:release() SetActive(uiobjs.DetailRoot.gameObject, true) SetActive(uiobjs.FinanceRoot.gameObject, false) SetActive(uiobjs.Records.gameObject, false) SetActive(uiobjs.AttachmentRoot.gameObject, false) SetActive(uiobjs.SubOrders.gameObject, false) self:showBaseFileds() self:reposition() end function TRPOrderDetail:showProducts() if #self.mdata.prodJson > 0 then SetActive(uiobjs.ProductRoot.gameObject, true) CLUIUtl.resetList4Lua( uiobjs.ProductRoot, uiobjs.ProductPrefab, self.mdata.prodJson, self:wrapFunc(self.initProductCell) ) else SetActive(uiobjs.ProductRoot.gameObject, false) end self:reposition() end function TRPOrderDetail:initProductCell(cell, data) local formRoot = cell:GetComponent("CLUIFormRoot") formRoot:setValue(data) end function TRPOrderDetail:reposition() uiobjs.Table:Reposition() uiobjs.scrollView.disableDragIfFits = true uiobjs.scrollView:ResetPosition() self.csSelf:invoke4Lua( function() uiobjs.scrollView:ResetPosition() end, 0.1 ) end function TRPOrderDetail:showBaseFileds() ---@type _ParamCellExtendFiledRoot local param = {} param.data = self.mdata or {} param.onFinish = function() self:showExtentFiles(self.mdata.templetId) self:showProducts() self:wrapFunc(self.reposition) end param.fields = {} local fields = self.baseFileds ---@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.DetailRoot:init(param, nil) end ---public 显示扩展字段 function TRPOrderDetail:showExtentFiles(templetId) ---@type _ParamCellExtendFiledRoot local param = {} param.data = self.mdata and self.mdata.attrJson or {} param.onFinish = self:wrapFunc(self.reposition) param.fields = {} local fields = DBOrder.getFields(templetId) 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 if #fields > 0 then SetActive(uiobjs.ExtendRoot.gameObject, true) uiobjs.ExtendRoot:init(param, nil) else SetActive(uiobjs.ExtendRoot.gameObject, false) end end function TRPOrderDetail:showAttachment() self:release() SetActive(uiobjs.DetailRoot.gameObject, false) SetActive(uiobjs.ExtendRoot.gameObject, false) SetActive(uiobjs.ProductRoot.gameObject, false) SetActive(uiobjs.AttachmentRoot.gameObject, true) SetActive(uiobjs.Records.gameObject, false) SetActive(uiobjs.FinanceRoot.gameObject, false) SetActive(uiobjs.SubOrders.gameObject, false) CLUIUtl.resetList4Lua( uiobjs.AttachmentRoot, uiobjs.AttachmentPrefab, self.mdata.wfOptJson, self:wrapFunc(self.initAttachmentCell) ) self:reposition() end function TRPOrderDetail:initAttachmentCell(cell, data) cell:init(data, self:wrapFunc(self.onClickAttachment)) end function TRPOrderDetail:onClickAttachment(cell, data) local had, path = DBTextures.hadDownloaded(data.name) if had then CLUIUtl.showConfirm( joinStr("附件已保存本地:", path), false, "打开", function() -- Application.OpenURL(joinStr("file://", path)) MyFileOpen.open(path) end, "取消", nil ) else cell.luaTable.download() -- MyUtl.toastW("附件未下载完成,暂时无法查看") end end function TRPOrderDetail:showRecords() self:release() SetActive(uiobjs.DetailRoot.gameObject, false) SetActive(uiobjs.ExtendRoot.gameObject, false) SetActive(uiobjs.ProductRoot.gameObject, false) SetActive(uiobjs.AttachmentRoot.gameObject, false) SetActive(uiobjs.Records.gameObject, true) SetActive(uiobjs.FinanceRoot.gameObject, false) SetActive(uiobjs.SubOrders.gameObject, false) 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 MyUtl.toastW("TODO:流转记录接口还没有") self:reposition() end function TRPOrderDetail:initRecordCell(cell, data) cell:init(data, nil) end function TRPOrderDetail:onHeadList(head) printw("到最顶端了") end function TRPOrderDetail: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 TRPOrderDetail:showFinance() self:release() SetActive(uiobjs.DetailRoot.gameObject, false) SetActive(uiobjs.ExtendRoot.gameObject, false) SetActive(uiobjs.ProductRoot.gameObject, false) SetActive(uiobjs.AttachmentRoot.gameObject, false) SetActive(uiobjs.Records.gameObject, false) SetActive(uiobjs.FinanceRoot.gameObject, true) SetActive(uiobjs.SubOrders.gameObject, false) MyUtl.toastW("TODO:财务数据怎么来??") self:reposition() end function TRPOrderDetail:showSubOrders() self:release() SetActive(uiobjs.DetailRoot.gameObject, false) SetActive(uiobjs.ExtendRoot.gameObject, false) SetActive(uiobjs.ProductRoot.gameObject, false) SetActive(uiobjs.AttachmentRoot.gameObject, false) SetActive(uiobjs.Records.gameObject, false) SetActive(uiobjs.FinanceRoot.gameObject, false) SetActive(uiobjs.SubOrders.gameObject, true) MyUtl.toastW("TODO:子订单数据怎么来??") self:reposition() end -- 刷新 function TRPOrderDetail:refresh() end function TRPOrderDetail:release() if uiobjs.ExtendRoot.luaTable then uiobjs.ExtendRoot.luaTable.release() end if uiobjs.DetailRoot.luaTable then uiobjs.DetailRoot.luaTable.release() end end -- 关闭页面 function TRPOrderDetail:hide() self:release() end -- 网络请求的回调;cmd:指命,succ:成功失败,msg:消息;paras:服务器下行数据 function TRPOrderDetail: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 end end end function TRPOrderDetail:setEventDelegate() self.EventDelegate = { ToggleDetail = function() self.currToggle = 1 self:showDetail() end, ToggleAttachment = function() self.currToggle = 2 self:showAttachment() end, ToggleProcessHis = function() self.currToggle = 3 self:showRecords() end, ToggleFinance = function() self.currToggle = 4 self:showFinance() end, ToggleSub = function() self.currToggle = 5 self:showSubOrders() end, ButtonAddAttachment = function(go) self:addAttachment(go) end, ButtonAddMoney = function() end, ButtonAddLogistics = function() end, ButtonAdd = function() end } end function TRPOrderDetail:addAttachment(go) -- 添加附件 ---@type UIPopupList local popList = go:GetComponent("UIPopupList") if popList.value == "1" then -- 相机 local permission = MyCamera.getImage(self:wrapFunc(self.onGetImage)) if permission ~= NativeCamera.Permission.Granted then if permission == NativeCamera.Permission.ShouldAsk then NativeCamera.RequestPermission() else CLUIUtl.showConfirm( "没有使用相机的权限,打开设置允许使用相机", function() if not MyCamera.openSetting() then MyUtl.toastW("打开权限设置失败") end end, nil ) end end elseif popList.value == "2" then local permission = MyGallery.getImage(self:wrapFunc(self.onGetImage)) if permission ~= NativeGallery.Permission.Granted then if permission == NativeGallery.Permission.ShouldAsk then NativeGallery.RequestPermission() else CLUIUtl.showConfirm( "没有使用相册的权限,打开设置允许使用相册", function() if not MyGallery.openSetting() then MyUtl.toastW("打开权限设置失败") end end, nil ) end NativeCamera.RequestPermission() end end end function TRPOrderDetail:onGetImage(path) if isNilOrEmpty(path) then return end -- table.insert(self.images, {path = path, onDelete = self:wrapFunc(self.onDelImage)}) --//TODO: MyUtl.toastW("接口要修改") end -- 处理ui上的事件,例如点击等 function TRPOrderDetail:uiEventDelegate(go) local func = self.EventDelegate[go.name] if func then func(go) end end -- 当顶层页面发生变化时回调 function TRPOrderDetail:onTopPanelChange(topPanel) end -------------------------------------------- return TRPOrderDetail