2020-07-14 22:04:03 +08:00
|
|
|
|
---@type IDBasePanel
|
|
|
|
|
|
local TRBasePanel = require("ui.panel.TRBasePanel")
|
|
|
|
|
|
---@class TRPEditPrice:TRBasePanel 邮件列表
|
|
|
|
|
|
local TRPEditPrice = class("TRPEditPrice", TRBasePanel)
|
|
|
|
|
|
|
|
|
|
|
|
local uiobjs = {}
|
|
|
|
|
|
local callback
|
|
|
|
|
|
-- 初始化,只会调用一次
|
|
|
|
|
|
function TRPEditPrice:init(csObj)
|
|
|
|
|
|
TRPEditPrice.super.init(self, csObj)
|
|
|
|
|
|
|
|
|
|
|
|
self:setEventDelegate()
|
2021-03-31 22:22:59 +08:00
|
|
|
|
---@type UITable
|
|
|
|
|
|
uiobjs.Table = getCC(self.csSelf.transform, "Table", "UITable")
|
2020-07-14 22:04:03 +08:00
|
|
|
|
---@type CLUIFormRoot
|
2021-03-31 22:22:59 +08:00
|
|
|
|
uiobjs.formRoot = uiobjs.Table.gameObject:GetComponent("CLUIFormRoot")
|
|
|
|
|
|
---@type CLUIElement
|
|
|
|
|
|
uiobjs.InputNum = getCC(uiobjs.formRoot.transform, "InputNum", "CLUIElement")
|
|
|
|
|
|
---@type CLUIElement
|
|
|
|
|
|
uiobjs.InputStartTime = getCC(uiobjs.formRoot.transform, "InputStartTime", "CLUIElement")
|
|
|
|
|
|
---@type CLUIElement
|
|
|
|
|
|
uiobjs.InputEndTime = getCC(uiobjs.formRoot.transform, "InputEndTime", "CLUIElement")
|
2020-07-14 22:04:03 +08:00
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
-- 设置数据
|
|
|
|
|
|
---@param paras _ParamTRPEditPrice
|
|
|
|
|
|
function TRPEditPrice:setData(paras)
|
|
|
|
|
|
self.mdata = paras.data
|
|
|
|
|
|
callback = paras.callback
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
-- 显示,在c#中。show为调用refresh,show和refresh的区别在于,当页面已经显示了的情况,当页面再次出现在最上层时,只会调用refresh
|
|
|
|
|
|
function TRPEditPrice:show()
|
|
|
|
|
|
uiobjs.formRoot:setValue(self.mdata)
|
2021-03-31 22:22:59 +08:00
|
|
|
|
-- 产品属性:1-服务类产品,0/null为实物类产品
|
|
|
|
|
|
if (not isNilOrEmpty(self.mdata.productAttribute)) and tonumber(self.mdata.productAttribute) == 1 then
|
|
|
|
|
|
SetActive(uiobjs.InputStartTime.gameObject, true)
|
|
|
|
|
|
SetActive(uiobjs.InputEndTime.gameObject, true)
|
|
|
|
|
|
uiobjs.InputStartTime.value = self.mdata.validStartTime or DateEx.format(DateEx.fmt_yyyy_MM_dd)
|
|
|
|
|
|
self:calculateEndDate(uiobjs.InputStartTime.value)
|
|
|
|
|
|
else
|
|
|
|
|
|
SetActive(uiobjs.InputStartTime.gameObject, false)
|
|
|
|
|
|
SetActive(uiobjs.InputEndTime.gameObject, false)
|
|
|
|
|
|
end
|
|
|
|
|
|
uiobjs.Table:Reposition()
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
function TRPEditPrice:calculateEndDate(startDate)
|
|
|
|
|
|
if not uiobjs.InputEndTime.gameObject.activeInHierarchy then
|
|
|
|
|
|
return
|
|
|
|
|
|
end
|
|
|
|
|
|
local begain = DateTime.Now
|
|
|
|
|
|
if not isNilOrEmpty(startDate) then
|
|
|
|
|
|
local days = strSplit(startDate, "-")
|
|
|
|
|
|
begain = DateTime(tonumber(days[1]), tonumber(days[2]), tonumber(days[3]))
|
|
|
|
|
|
end
|
|
|
|
|
|
local enddate
|
|
|
|
|
|
local num = tonumber(uiobjs.InputNum.value) or 1
|
|
|
|
|
|
--服务产品消耗时间类型,默认:NULL;0:按日,1:按月,2:按季度,3:按年
|
|
|
|
|
|
if not isNilOrEmpty(self.mdata.productComsuingType) then
|
|
|
|
|
|
local productComsuingType = tonumber(self.mdata.productComsuingType)
|
|
|
|
|
|
if productComsuingType == 0 then
|
|
|
|
|
|
enddate = begain:AddDays(num)
|
|
|
|
|
|
elseif productComsuingType == 1 then
|
|
|
|
|
|
enddate = begain:AddMonths(num)
|
|
|
|
|
|
elseif productComsuingType == 2 then
|
|
|
|
|
|
enddate = begain:AddMonths(num * 3)
|
|
|
|
|
|
elseif productComsuingType == 3 then
|
|
|
|
|
|
enddate = begain:AddYears(num)
|
|
|
|
|
|
else
|
|
|
|
|
|
return ""
|
|
|
|
|
|
end
|
|
|
|
|
|
uiobjs.InputEndTime.value = enddate:ToString(DateEx.fmt_yyyy_MM_dd)
|
|
|
|
|
|
end
|
|
|
|
|
|
return ""
|
2020-07-14 22:04:03 +08:00
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
-- 刷新
|
|
|
|
|
|
function TRPEditPrice:refresh()
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
-- 关闭页面
|
|
|
|
|
|
function TRPEditPrice:hide()
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
-- 网络请求的回调;cmd:指命,succ:成功失败,msg:消息;paras:服务器下行数据
|
|
|
|
|
|
function TRPEditPrice:procNetwork(cmd, succ, msg, paras)
|
|
|
|
|
|
if (succ == NetSuccess) then
|
|
|
|
|
|
--[[
|
|
|
|
|
|
if cmd == xx then
|
|
|
|
|
|
end
|
|
|
|
|
|
]]
|
|
|
|
|
|
end
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
function TRPEditPrice:setEventDelegate()
|
|
|
|
|
|
self.EventDelegate = {
|
|
|
|
|
|
ButtonCancel = function()
|
|
|
|
|
|
hideTopPanel(self.csSelf)
|
|
|
|
|
|
end,
|
|
|
|
|
|
ButtonOkay = function()
|
|
|
|
|
|
hideTopPanel(self.csSelf)
|
|
|
|
|
|
self.mdata = uiobjs.formRoot:getValue(self.mdata, true)
|
|
|
|
|
|
if tonumber(self.mdata.productNum) <= 0 then
|
|
|
|
|
|
MyUtl.toastW("数量不能低于1")
|
|
|
|
|
|
return
|
|
|
|
|
|
end
|
2021-03-31 22:22:59 +08:00
|
|
|
|
if (not isNilOrEmpty(self.mdata.productAttribute)) and tonumber(self.mdata.productAttribute) == 1 then
|
|
|
|
|
|
if isNilOrEmpty(uiobjs.InputStartTime.value) then
|
|
|
|
|
|
MyUtl.toastW("请设置开始日期")
|
|
|
|
|
|
return
|
|
|
|
|
|
end
|
|
|
|
|
|
end
|
2020-07-14 22:04:03 +08:00
|
|
|
|
Utl.doCallback(callback, self.mdata)
|
2021-03-31 22:22:59 +08:00
|
|
|
|
end,
|
|
|
|
|
|
InputNum = function()
|
|
|
|
|
|
self:calculateEndDate(uiobjs.InputStartTime.value)
|
|
|
|
|
|
end,
|
|
|
|
|
|
InputStartTime = function()
|
|
|
|
|
|
self:calculateEndDate(uiobjs.InputStartTime.value)
|
2020-07-14 22:04:03 +08:00
|
|
|
|
end
|
|
|
|
|
|
}
|
|
|
|
|
|
end
|
|
|
|
|
|
-- 处理ui上的事件,例如点击等
|
|
|
|
|
|
function TRPEditPrice:uiEventDelegate(go)
|
|
|
|
|
|
local func = self.EventDelegate[go.name]
|
|
|
|
|
|
if func then
|
|
|
|
|
|
func()
|
|
|
|
|
|
end
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
-- 当顶层页面发生变化时回调
|
|
|
|
|
|
function TRPEditPrice:onTopPanelChange(topPanel)
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
--------------------------------------------
|
|
|
|
|
|
return TRPEditPrice
|