This commit is contained in:
2021-03-31 22:22:59 +08:00
parent e913caa8f8
commit bf55cc7e54
41 changed files with 2182 additions and 1013 deletions

View File

@@ -10,9 +10,16 @@ function TRPEditPrice:init(csObj)
TRPEditPrice.super.init(self, csObj)
self:setEventDelegate()
---@type UITable
uiobjs.Table = getCC(self.csSelf.transform, "Table", "UITable")
---@type CLUIFormRoot
uiobjs.formRoot = self.csSelf:GetComponent("CLUIFormRoot")
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")
end
-- 设置数据
@@ -25,6 +32,47 @@ end
-- 显示在c#中。show为调用refreshshow和refresh的区别在于当页面已经显示了的情况当页面再次出现在最上层时只会调用refresh
function TRPEditPrice:show()
uiobjs.formRoot:setValue(self.mdata)
-- 产品属性: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
--服务产品消耗时间类型默认NULL0按日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 ""
end
-- 刷新
@@ -57,7 +105,19 @@ function TRPEditPrice:setEventDelegate()
MyUtl.toastW("数量不能低于1")
return
end
if (not isNilOrEmpty(self.mdata.productAttribute)) and tonumber(self.mdata.productAttribute) == 1 then
if isNilOrEmpty(uiobjs.InputStartTime.value) then
MyUtl.toastW("请设置开始日期")
return
end
end
Utl.doCallback(callback, self.mdata)
end,
InputNum = function()
self:calculateEndDate(uiobjs.InputStartTime.value)
end,
InputStartTime = function()
self:calculateEndDate(uiobjs.InputStartTime.value)
end
}
end