Files
tianrunCRM/Assets/trCRM/upgradeRes4Dev/priority/lua/ui/panel/TRPNewFollow.lua

314 lines
10 KiB
Lua
Raw Normal View History

2020-08-07 22:40:04 +08:00
---@class _ParamTRPNewFollow
---@field cust
---@field followData
---@field bookingData
---@type IDBasePanel
2020-07-19 12:52:05 +08:00
local TRBasePanel = require("ui.panel.TRBasePanel")
---@class TRPNewFollow:TRBasePanel 邮件列表
local TRPNewFollow = class("TRPNewFollow", TRBasePanel)
local uiobjs = {}
local stars = {}
-- 初始化,只会调用一次
function TRPNewFollow:init(csObj)
TRPNewFollow.super.init(self, csObj)
self:initFiledsAttr()
self:setEventDelegate()
2020-08-04 21:58:27 +08:00
MyUtl.setContentView(getChild(self.transform, "PanelContent"), MyUtl.defaultTopHeight, 0)
2020-07-19 12:52:05 +08:00
---@type UIScrollView
uiobjs.scrollView = getCC(self.transform, "PanelContent", "UIScrollView")
2020-08-01 17:55:18 +08:00
uiobjs.scrollView.dampenStrength = MyUtl.dampenStrength
2020-07-19 12:52:05 +08:00
---@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")
2020-08-06 22:56:33 +08:00
uiobjs.ButtonCustDetail = getChild(self.transform, "ButtonCustDetail")
2020-07-19 12:52:05 +08:00
end
2020-08-03 23:05:29 +08:00
---public 当有通用背板显示时的回调
---@param cs Coolape.CLPanelLua
function TRPNewFollow:onShowFrame(cs)
if cs.frameObj then
---@type _BGFrame1Param
local d = {}
-- d.title = LGet(cs.titleKeyName)
if self.isNewFollow then
d.title = "新建跟进"
else
d.title = "跟进详情"
end
d.panel = cs
cs.frameObj:init(d)
end
end
2020-07-19 12:52:05 +08:00
function TRPNewFollow:initFiledsAttr()
---@type _ParamFieldAttr
local attr
self.baseFiledsAttr = {}
attr = {}
attr.attrName = "商机"
2020-07-20 22:20:21 +08:00
attr.id = "opportunity"
2020-07-19 12:52:05 +08:00
attr.attrType = DBCust.FieldType.popuplist
2020-07-20 22:20:21 +08:00
attr.ifMust = 0
2020-07-19 12:52:05 +08:00
attr.donotJoinKey = true
2020-07-20 22:20:21 +08:00
local popInfor = DBCust.getFilter4Popup(DBCust.FilterGroup.opportunityList)
attr.popOptions = popInfor.options
attr.popValues = popInfor.values
2020-07-19 12:52:05 +08:00
table.insert(self.baseFiledsAttr, attr)
attr = {}
attr.attrName = "跟进类型"
attr.id = "followUpType"
attr.attrType = DBCust.FieldType.popuplist
attr.ifMust = 1
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 = "跟时时间"
2020-08-01 17:55:18 +08:00
attr.id = "recordingTime"
2020-07-19 12:52:05 +08:00
attr.attrType = DBCust.FieldType.dateTime
attr.ifMust = 1
2020-07-28 21:02:59 +08:00
attr.ifTime = 1
2020-07-19 12:52:05 +08:00
attr.donotJoinKey = true
table.insert(self.baseFiledsAttr, attr)
attr = {}
attr.attrName = "客户名称"
attr.id = "custName"
attr.attrType = DBCust.FieldType.text
2020-08-01 17:55:18 +08:00
attr.ifMust = 0
2020-07-19 12:52:05 +08:00
attr.donotJoinKey = true
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 _ParamTRPNewFollow
function TRPNewFollow:setData(paras)
2020-08-07 22:40:04 +08:00
self.cust = paras.cust
self.mdata = paras.followData
self.bookingData = paras.bookingData
if self.mdata and self.mdata.recordingTime then
2020-08-01 17:55:18 +08:00
self.isNewFollow = false
else
self.mdata = {}
2020-08-07 22:40:04 +08:00
self.mdata.custId = self.cust.custId
self.mdata.taskId = self.cust.taskId
self.mdata.custName = self.cust.custName
2020-08-01 17:55:18 +08:00
self.mdata.opportunity = "0"
self.mdata.followUpType = "0"
self.mdata.recordingTime = DateEx.nowString()
self.mdata.dealFlag = "0"
self.isNewFollow = true
end
2020-07-19 12:52:05 +08:00
end
-- 显示在c#中。show为调用refreshshow和refresh的区别在于当页面已经显示了的情况当页面再次出现在最上层时只会调用refresh
function TRPNewFollow:show()
2020-08-06 22:56:33 +08:00
if self.isNewFollow then
SetActive(uiobjs.ButtonCustDetail.gameObject, false)
else
---@type Coolape.CLPanelLua
local panel = CLPanelManager.getPanel("PanelCustDetail")
if panel and panel.gameObject.activeInHierarchy then
SetActive(uiobjs.ButtonCustDetail.gameObject, false)
else
SetActive(uiobjs.ButtonCustDetail.gameObject, true)
end
end
2020-07-19 12:52:05 +08:00
self:refreshContent()
SetActive(uiobjs.ButtonSave.gameObject, self.isNewFollow)
uiobjs.scrollView:ResetPosition()
end
function TRPNewFollow:refreshContent()
self:showBaseFields()
self.csSelf:invoke4Lua(self:wrapFunc(self.reposition), 0.1)
end
function TRPNewFollow:showBaseFields()
---@type _ParamCellExtendFiledRoot
local param = {}
param.data = self.mdata or {}
param.onFinish = self:wrapFunc(self.reposition)
param.onLoadOneField = self:wrapFunc(self.onLoadOneField)
param.fields = {}
---@type _ParamCellExtendFiled
local filedInfor
for i, v in ipairs(self.baseFiledsAttr) do
-- 工单模板
filedInfor = {}
filedInfor.attr = v
2020-08-05 20:46:00 +08:00
if v.id == "custName" then
2020-08-01 17:55:18 +08:00
filedInfor.showMode = _FieldMode.showOnly
2020-08-05 20:46:00 +08:00
else
if self.isNewFollow then
filedInfor.showMode = _FieldMode.inputOnly
else
filedInfor.showMode = _FieldMode.showOnly
end
2020-08-01 17:55:18 +08:00
end
2020-07-19 12:52:05 +08:00
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 TRPNewFollow:onLoadOneField(cell)
local el = cell:GetComponent("CLUIElement")
if el and el.jsonKey == "followUpContent" then
uiobjs.followUpContent = el
end
end
function TRPNewFollow:onPopupFieldValChg(go)
---@type CLUIElement
local el = go:GetComponent("CLUIElement")
if el.jsonKey == "dealFlag" then
2020-07-28 21:02:59 +08:00
if uiobjs.followUpContent then
2020-07-19 12:52:05 +08:00
local popList = go:GetComponent("UIPopupList")
2020-07-28 21:02:59 +08:00
if isNilOrEmpty(uiobjs.followUpContent.value) or self.oldselectedItem == uiobjs.followUpContent.value then
uiobjs.followUpContent.value = popList.selectedItem
self.oldselectedItem = popList.selectedItem
end
2020-07-19 12:52:05 +08:00
end
end
end
function TRPNewFollow:reposition()
uiobjs.DetailRootTabel.repositionNow = true
uiobjs.Table.repositionNow = true
end
-- 刷新
function TRPNewFollow:refresh()
end
-- 关闭页面
function TRPNewFollow:hide()
2020-07-28 21:02:59 +08:00
self.oldselectedItem = nil
2020-07-19 12:52:05 +08:00
if uiobjs.DetailRoot.luaTable then
uiobjs.DetailRoot.luaTable.release()
end
end
-- 网络请求的回调cmd指命succ成功失败msg消息paras服务器下行数据
function TRPNewFollow:procNetwork(cmd, succ, msg, paras)
if (succ == NetSuccess) then
if cmd == NetProto.cmds.update_customer then
self:refreshContent()
end
end
end
function TRPNewFollow: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)
2020-08-07 22:40:04 +08:00
if self.bookingData then
self.mdata.bookingId = self.bookingData.bookingId
end
2020-07-19 12:52:05 +08:00
showHotWheel()
NetProto.send.create_followUp_record(
self.mdata,
function(content)
hideHotWheel()
if content.success then
2020-08-07 22:40:04 +08:00
if self.bookingData then
-- 刷新预约的状态
self.bookingData.bookingDone = "1"
end
2020-07-19 12:52:05 +08:00
MyUtl.toastS("保存成功")
hideTopPanel(self.csSelf)
end
end
)
end,
InputTask = function()
self:showExtentFiles(uiobjs.InputTask.value)
2020-08-06 22:56:33 +08:00
end,
ButtonCustDetail = function()
showHotWheel()
NetProto.send.get_customerById(
self.mdata.custId,
function(content)
hideHotWheel()
if content.success then
local cust = content.result
2020-08-07 22:40:04 +08:00
---@type _ParamTRPCustDetail
local param = {}
param.cust = cust
param.bookingData = self.mdata
param.needShowMore = false
2020-08-06 22:56:33 +08:00
if cust then
2020-08-07 22:40:04 +08:00
getPanelAsy("PanelCustDetail", onLoadedPanelTF, param)
2020-08-06 22:56:33 +08:00
end
end
end
)
2020-07-19 12:52:05 +08:00
end
}
end
-- 处理ui上的事件例如点击等
function TRPNewFollow:uiEventDelegate(go)
local func = self.EventDelegate[go.name]
if func then
func()
end
end
-- 当顶层页面发生变化时回调
function TRPNewFollow:onTopPanelChange(topPanel)
end
--------------------------------------------
return TRPNewFollow