Files
tianrunCRM/Assets/trCRM/upgradeRes4Dev/priority/lua/ui/panel/TRPCustDetail.lua
2020-07-19 12:52:05 +08:00

277 lines
10 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 TRPCustDetail:TRBasePanel 邮件列表
local TRPCustDetail = class("TRPCustDetail", TRBasePanel)
local uiobjs = {}
-- 初始化,只会调用一次
function TRPCustDetail:init(csObj)
TRPCustDetail.super.init(self, csObj)
self:setEventDelegate()
MyUtl.setContentView(getChild(self.transform, "PanelContent"), 132 + 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")
---@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.starGrid = getCC(uiobjs.Head.transform, "LabelStars/Grid", "UIGrid")
uiobjs.starGridPrefab = getChild(uiobjs.starGrid.transform, "00000").gameObject
---@type UIToggle
uiobjs.ToggleDetail = getCC(self.transform, "Top/SpriteToggle/ToggleDetail", "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")
end
-- 设置数据
---@param paras _ParamTRPCustDetail
function TRPCustDetail:setData(paras)
self.mdata = paras
self.mdata._phoneNo = MyUtl.hidePhone(self.mdata.phoneNo)
if type(self.mdata.jsonStr) == "string" then
self.mdata.jsonStr = json.decode(self.mdata.jsonStr)
end
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为调用refreshshow和refresh的区别在于当页面已经显示了的情况当页面再次出现在最上层时只会调用refresh
function TRPCustDetail:show()
self.records = 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()
uiobjs.InputLogin: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()
SetActive(uiobjs.DetailRoot.gameObject, true)
SetActive(uiobjs.ExtendRoot.gameObject, true)
SetActive(uiobjs.Records.gameObject, false)
uiobjs.DetailRoot:setValue(self.mdata)
-- uiobjs.ExtendRoot:init({data = self.mdata, isEditMode = false}, nil)
self:showExtentFiles(self.mdata.taskId)
-- 设置星级
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:ResetPosition()
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.isEditMode = false
table.insert(param.fields, filedInfor)
end
uiobjs.ExtendRoot:init(param, nil)
end
function TRPCustDetail:showRecords()
SetActive(uiobjs.DetailRoot.gameObject, false)
SetActive(uiobjs.ExtendRoot.gameObject, false)
SetActive(uiobjs.Records.gameObject, true)
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
uiobjs.Table:Reposition()
uiobjs.scrollView:ResetPosition()
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:refresh()
end
-- 关闭页面
function TRPCustDetail:hide()
if uiobjs.ExtendRoot.luaTable then
uiobjs.ExtendRoot.luaTable.release()
end
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.update_customer then
if self.currToggle == 1 then
self:showDetail()
uiobjs.Head:setValue(self.mdata)
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,
ButtonNewFollow = function()
getPanelAsy("PanelNewFollow", onLoadedPanelTT, self.mdata)
end,
ButtonNewTask = function()
getPanelAsy("PanelNewFollowTask", onLoadedPanelTT, self.mdata)
end,
ButtonCall = function()
MyUtl.callCust(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