Files
tianrunCRM/Assets/trCRM/upgradeRes4Dev/priority/lua/ui/panel/TRPCustDetailSimple.lua
2020-08-04 21:58:27 +08:00

296 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 TRPCustDetailSimple:TRBasePanel
local TRPCustDetailSimple = class("TRPCustDetailSimple", TRBasePanel)
local uiobjs = {}
-- 初始化,只会调用一次
function TRPCustDetailSimple:init(csObj)
TRPCustDetailSimple.super.init(self, csObj)
self:prepareMoreData()
self:setEventDelegate()
MyUtl.setContentView(getChild(self.transform, "PanelContent"), MyUtl.defaultTopHeight + 400 + 40, 200)
---@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 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
uiobjs.ExtendRoot = getCC(uiobjs.Table.transform, "ExtendRoot", "CLCellLua")
uiobjs.SysRoot = getCC(uiobjs.Table.transform, "SysRoot", "CLCellLua")
end
function TRPCustDetailSimple:prepareMoreData()
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 _ParamTRPCustDetailSimple
function TRPCustDetailSimple:setData(paras)
---@type _DBCust
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 TRPCustDetailSimple: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 TRPCustDetailSimple:show()
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))
self:showDetail()
end
function TRPCustDetailSimple: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 TRPCustDetailSimple:showDetail()
self:release()
SetActive(uiobjs.DetailRoot.gameObject, true)
SetActive(uiobjs.ExtendRoot.gameObject, true)
SetActive(uiobjs.SysRoot.gameObject, true)
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 TRPCustDetailSimple:reposition()
uiobjs.Table:Reposition()
uiobjs.scrollView.disableDragIfFits = true
uiobjs.scrollView:ResetPosition()
end
---public 显示扩展字段
function TRPCustDetailSimple: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 TRPCustDetailSimple: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 TRPCustDetailSimple:refresh()
end
function TRPCustDetailSimple:release()
if uiobjs.ExtendRoot.luaTable then
uiobjs.ExtendRoot.luaTable.release()
end
if uiobjs.SysRoot.luaTable then
uiobjs.SysRoot.luaTable.release()
end
self.hasSetMoreProc = false
end
-- 关闭页面
function TRPCustDetailSimple:hide()
self:release()
end
-- 网络请求的回调cmd指命succ成功失败msg消息paras服务器下行数据
function TRPCustDetailSimple:procNetwork(cmd, succ, msg, paras)
if (succ == NetSuccess) then
end
end
function TRPCustDetailSimple:setEventDelegate()
self.EventDelegate = {
ButtonGet = function()
showHotWheel()
local params = {
ids = self.mdata.custId,
oprType = "byId"
}
NetProto.send.getFromGH(
params,
function(content)
if content.success then
hideTopPanel(self.csSelf)
end
end
)
end
}
end
-- 处理ui上的事件例如点击等
function TRPCustDetailSimple:uiEventDelegate(go)
local func = self.EventDelegate[go.name]
if func then
func()
end
end
-- 当顶层页面发生变化时回调
function TRPCustDetailSimple:onTopPanelChange(topPanel)
end
--------------------------------------------
return TRPCustDetailSimple