up
This commit is contained in:
@@ -24,6 +24,15 @@ function TRPNewOrder:init(csObj)
|
||||
uiobjs.ExtendRoot = getCC(uiobjs.Table.transform, "ExtendRoot", "CLCellLua")
|
||||
---@type CLUIFormRoot
|
||||
uiobjs.ExtendFormRoot = uiobjs.ExtendRoot:GetComponent("CLUIFormRoot")
|
||||
|
||||
---@type UITable
|
||||
uiobjs.StepRoot = getCC(uiobjs.Table.transform, "StepRoot", "UITable")
|
||||
---@type CLUIFormRoot
|
||||
uiobjs.StepFormRoot = uiobjs.StepRoot:GetComponent("CLUIFormRoot")
|
||||
---@type UIPopupList
|
||||
uiobjs.InputNextLogino = getCC(uiobjs.StepRoot.transform, "InputNextLogino", "UIPopupList")
|
||||
uiobjs.gridProjects = getCC(uiobjs.Table.transform, "InputSelectProduct/Products", "UIGrid")
|
||||
uiobjs.gridProjectsPrefab = getChild(uiobjs.gridProjects.transform, "00000").gameObject
|
||||
-- uiobjs.elements = uiobjs.DetailRoot.gameObject:GetComponentsInChildren(typeof(CLUIElement), true)
|
||||
uiobjs.ButtonSave = getChild(self.transform, "Top/ButtonSave")
|
||||
end
|
||||
@@ -34,15 +43,18 @@ function TRPNewOrder:initFiledsAttr()
|
||||
self.baseFiledsAttr = {}
|
||||
attr = {}
|
||||
attr.attrName = "工单模板"
|
||||
attr.id = ""
|
||||
attr.id = "templetId"
|
||||
attr.attrType = DBCust.FieldType.popuplist
|
||||
attr.ifMust = 1
|
||||
attr.donotJoinKey = true
|
||||
local popInfor = DBOrder.getPopupList(DBOrder.PopListGroup.templateList)
|
||||
attr.popOptions = popInfor.options
|
||||
attr.popValues = popInfor.values
|
||||
table.insert(self.baseFiledsAttr, attr)
|
||||
|
||||
attr = {}
|
||||
attr.attrName = "工单名称"
|
||||
attr.id = ""
|
||||
attr.id = "title"
|
||||
attr.attrType = DBCust.FieldType.text
|
||||
attr.ifMust = 1
|
||||
attr.donotJoinKey = true
|
||||
@@ -50,10 +62,13 @@ function TRPNewOrder:initFiledsAttr()
|
||||
|
||||
attr = {}
|
||||
attr.attrName = "紧急程序"
|
||||
attr.id = ""
|
||||
attr.id = "urgency"
|
||||
attr.attrType = DBCust.FieldType.popuplist
|
||||
attr.ifMust = 0
|
||||
attr.donotJoinKey = true
|
||||
local popInfor = DBOrder.getPopupList(DBOrder.PopListGroup.urgencyLevels) or {}
|
||||
attr.popOptions = popInfor.options
|
||||
attr.popValues = popInfor.values
|
||||
table.insert(self.baseFiledsAttr, attr)
|
||||
|
||||
attr = {}
|
||||
@@ -101,7 +116,7 @@ function TRPNewOrder:initFiledsAttr()
|
||||
|
||||
attr = {}
|
||||
attr.attrName = "订单内容"
|
||||
attr.id = ""
|
||||
attr.id = "content"
|
||||
attr.attrType = DBCust.FieldType.multext
|
||||
attr.ifMust = 0
|
||||
attr.donotJoinKey = true
|
||||
@@ -115,16 +130,25 @@ function TRPNewOrder:setData(paras)
|
||||
self.isNewOrder = false
|
||||
self.mdata = paras
|
||||
|
||||
if type(self.mdata.jsonStr) == "string" then
|
||||
self.mdata.jsonStr = json.decode(self.mdata.jsonStr)
|
||||
if type(self.mdata.attrJson) == "string" then
|
||||
self.mdata.attrJson = json.decode(self.mdata.attrJson)
|
||||
end
|
||||
self.mdata.jsonStr = self.mdata.jsonStr or {}
|
||||
self.mdata.attrJson = self.mdata.attrJson or {}
|
||||
---@type _DBCust
|
||||
self.cust = nil
|
||||
else
|
||||
--//TODO:初始值
|
||||
self.isNewOrder = true
|
||||
---@type _DBCust
|
||||
self.cust = paras
|
||||
self.mdata = {}
|
||||
local popInfor = DBOrder.getPopupList(DBOrder.PopListGroup.templateList)
|
||||
self.mdata.templetId = popInfor.values[0]
|
||||
popInfor = DBOrder.getPopupList(DBOrder.PopListGroup.urgencyLevels)
|
||||
self.mdata.urgency = popInfor.values[0]
|
||||
local templateInfor = DBOrder.getTemplateInfor(self.mdata.templetId)
|
||||
self.mdata.content = templateInfor.content
|
||||
self.selectedProducts = {}
|
||||
end
|
||||
end
|
||||
|
||||
@@ -154,12 +178,39 @@ end
|
||||
|
||||
function TRPNewOrder:refreshContent()
|
||||
self:showBaseFields()
|
||||
local taskId = self.mdata and self.mdata.taskId or nil
|
||||
self:showExtentFiles(taskId)
|
||||
self:showProducts()
|
||||
local templetId = self.mdata and self.mdata.templetId or nil
|
||||
self:showExtentFiles(templetId)
|
||||
|
||||
self.csSelf:invoke4Lua(self:wrapFunc(self.reposition), 0.1)
|
||||
end
|
||||
|
||||
function TRPNewOrder:showProducts()
|
||||
local products
|
||||
if self.isNewOrder then
|
||||
products = self.selectedProducts
|
||||
else
|
||||
products = json.decode(self.mdata.prodJson)
|
||||
end
|
||||
CLUIUtl.resetList4Lua(uiobjs.gridProjects, uiobjs.gridProjectsPrefab, products, self:wrapFunc(self.initProductCell))
|
||||
self:reposition()
|
||||
end
|
||||
|
||||
function TRPNewOrder:initProductCell(cell, data)
|
||||
cell:init(data, nil)
|
||||
cell.luaTable.onDeleteProduct = self:wrapFunc(self.onDeleteProduct)
|
||||
end
|
||||
|
||||
function TRPNewOrder:onDeleteProduct(data)
|
||||
for i, v in ipairs(self.selectedProducts) do
|
||||
if v.id == data.id then
|
||||
table.remove(self.selectedProducts, i)
|
||||
break
|
||||
end
|
||||
end
|
||||
self:showProducts()
|
||||
end
|
||||
|
||||
function TRPNewOrder:showBaseFields()
|
||||
---@type _ParamCellExtendFiledRoot
|
||||
local param = {}
|
||||
@@ -182,9 +233,9 @@ function TRPNewOrder:showBaseFields()
|
||||
if filedInfor.attr.attrType == DBCust.FieldType.multext then
|
||||
filedInfor.onMultTextInputChg = self:wrapFunc(self.reposition)
|
||||
end
|
||||
filedInfor.onSelect = self:wrapFunc(self.onPopupFieldValChg)
|
||||
if not self.isNewOrder then
|
||||
filedInfor.onClick = self:wrapFunc(self.onClickInputField)
|
||||
filedInfor.onSelect = self:wrapFunc(self.onPopupFieldValChg)
|
||||
end
|
||||
table.insert(param.fields, filedInfor)
|
||||
end
|
||||
@@ -193,30 +244,62 @@ function TRPNewOrder:showBaseFields()
|
||||
end
|
||||
|
||||
---public 显示扩展字段
|
||||
function TRPNewOrder:showExtentFiles(taskId)
|
||||
---@type _ParamCellExtendFiledRoot
|
||||
local param = {}
|
||||
param.data = self.mdata and self.mdata.jsonStr or {}
|
||||
-- param.isEditMode = true
|
||||
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 = true
|
||||
if filedInfor.attr.attrType == DBCust.FieldType.multext then
|
||||
filedInfor.onMultTextInputChg = self:wrapFunc(self.reposition)
|
||||
function TRPNewOrder:showExtentFiles(templetId)
|
||||
local cfgInfor = DBOrder.getTemplateInfor(templetId)
|
||||
local fields = DBOrder.getFields(templetId) or {}
|
||||
if #fields > 0 then
|
||||
---@type _ParamCellExtendFiledRoot
|
||||
local param = {}
|
||||
param.data = self.mdata and self.mdata.attrJson or {}
|
||||
-- param.isEditMode = true
|
||||
param.onFinish = self:wrapFunc(self.setExtendFieldsMode)
|
||||
param.fields = {}
|
||||
---@type _ParamCellExtendFiled
|
||||
local filedInfor
|
||||
for i, v in ipairs(fields) do
|
||||
filedInfor = {}
|
||||
filedInfor.attr = v
|
||||
filedInfor.isEditMode = true
|
||||
if filedInfor.attr.attrType == DBCust.FieldType.multext then
|
||||
filedInfor.onMultTextInputChg = self:wrapFunc(self.reposition)
|
||||
end
|
||||
if not self.isNewOrder then
|
||||
filedInfor.onClick = self:wrapFunc(self.onClickInputField4Extend)
|
||||
filedInfor.onSelect = self:wrapFunc(self.onPopupFieldValChg4Extend)
|
||||
end
|
||||
table.insert(param.fields, filedInfor)
|
||||
end
|
||||
if not self.isNewOrder then
|
||||
filedInfor.onClick = self:wrapFunc(self.onClickInputField4Extend)
|
||||
filedInfor.onSelect = self:wrapFunc(self.onPopupFieldValChg4Extend)
|
||||
end
|
||||
table.insert(param.fields, filedInfor)
|
||||
SetActive(uiobjs.ExtendRoot.gameObject, true)
|
||||
uiobjs.ExtendRoot:init(param, nil)
|
||||
else
|
||||
SetActive(uiobjs.ExtendRoot.gameObject, false)
|
||||
end
|
||||
uiobjs.ExtendRoot:init(param, nil)
|
||||
|
||||
-- next Step
|
||||
local nextStep = DBOrder.getNextHandler(templetId)
|
||||
if nextStep and tonumber(cfgInfor.ifToLoginNo) == 1 then
|
||||
SetActive(uiobjs.StepFormRoot.gameObject, true)
|
||||
uiobjs.InputNextLogino:refreshItems(nextStep.options, nextStep.values)
|
||||
uiobjs.StepFormRoot:setValue(self.mdata)
|
||||
else
|
||||
SetActive(uiobjs.StepFormRoot.gameObject, false)
|
||||
end
|
||||
|
||||
-- product
|
||||
if tonumber(cfgInfor.ifProduct) == 1 then
|
||||
SetActive(uiobjs.gridProjects.transform.parent.gameObject, true)
|
||||
self.selectedProducts = {}
|
||||
self:showProducts()
|
||||
else
|
||||
SetActive(uiobjs.gridProjects.transform.parent.gameObject, false)
|
||||
end
|
||||
|
||||
-- refresh content
|
||||
local d = uiobjs.DetailFromRoot:getValue(true)
|
||||
d.content = cfgInfor.content
|
||||
uiobjs.DetailFromRoot:setValue(d)
|
||||
-------
|
||||
uiobjs.StepRoot:Reposition()
|
||||
end
|
||||
|
||||
function TRPNewOrder:reposition()
|
||||
@@ -241,7 +324,7 @@ function TRPNewOrder:setElementMode(el)
|
||||
local boxcollider = el:GetComponent("BoxCollider")
|
||||
local ButtonReset = getCC(el.transform, "ButtonReset", "MyInputReset")
|
||||
|
||||
if (not self.isNewOrder) and (el.jsonKey == "taskId" or el.jsonKey == "phoneNo") then
|
||||
if el.jsonKey == "taskId" or el.jsonKey == "phoneNo" then
|
||||
boxcollider.enabled = false
|
||||
else
|
||||
boxcollider.enabled = true
|
||||
@@ -296,18 +379,21 @@ function TRPNewOrder:procNetwork(cmd, succ, msg, paras)
|
||||
end
|
||||
|
||||
function TRPNewOrder:onPopupFieldValChg(go)
|
||||
if self.isNewOrder then
|
||||
return
|
||||
end
|
||||
---@type CLUIElement
|
||||
local el = go:GetComponent("CLUIElement")
|
||||
if el then
|
||||
local err = el:checkValid()
|
||||
if tostring(el.value) ~= tostring(self.mdata[el.jsonKey]) then
|
||||
if isNilOrEmpty(err) then
|
||||
self:sendModifymsg(el.jsonKey, el.value, false)
|
||||
else
|
||||
MyUtl.toastW(err)
|
||||
if self.isNewOrder then
|
||||
if el and el.jsonKey == "templetId" then
|
||||
self:showExtentFiles(el.value)
|
||||
end
|
||||
else
|
||||
if el then
|
||||
local err = el:checkValid()
|
||||
if tostring(el.value) ~= tostring(self.mdata[el.jsonKey]) then
|
||||
if isNilOrEmpty(err) then
|
||||
self:sendModifymsg(el.jsonKey, el.value, false)
|
||||
else
|
||||
MyUtl.toastW(err)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -416,33 +502,71 @@ end
|
||||
function TRPNewOrder:setEventDelegate()
|
||||
self.EventDelegate = {
|
||||
ButtonSave = function()
|
||||
local err = uiobjs.DetailRoot:checkValid()
|
||||
local err = uiobjs.DetailFromRoot:checkValid()
|
||||
err = joinStr(err, uiobjs.ExtendFormRoot:checkValid())
|
||||
if not isNilOrEmpty(err) then
|
||||
MyUtl.toastW(err)
|
||||
return
|
||||
end
|
||||
|
||||
local cust = uiobjs.DetailRoot:getValue(true)
|
||||
cust.customerLabel = self.mdata.customerLabel
|
||||
local jsonStr = uiobjs.ExtendFormRoot:getValue(true)
|
||||
cust.jsonStr = jsonStr
|
||||
local order = uiobjs.DetailFromRoot:getValue(true)
|
||||
order.custId = self.cust.custId
|
||||
local attrJson = uiobjs.ExtendFormRoot:getValue(true)
|
||||
order.attrJson = attrJson
|
||||
if uiobjs.StepFormRoot.gameObject.activeInHierarchy then
|
||||
order = uiobjs.StepFormRoot:getValue(order, true)
|
||||
end
|
||||
local templateInfor = DBOrder.getTemplateInfor(order.templetId)
|
||||
order.ifToLoginNo = templateInfor.ifToLoginNo
|
||||
order.ifMail = templateInfor.ifMail
|
||||
order.ifProduct = templateInfor.ifProduct
|
||||
if uiobjs.gridProjects.gameObject.activeInHierarchy then
|
||||
if self.selectedProducts == nil or #(self.selectedProducts) <= 0 then
|
||||
MyUtl.toastW("请添加产品")
|
||||
return
|
||||
end
|
||||
order.prodJson = self.selectedProducts
|
||||
-- 计算价格
|
||||
for i, v in ipairs(order.prodJson) do
|
||||
v.totalPrice = tonumber(v.productNum) * tonumber(v.price)
|
||||
v.salePrice = tonumber(v.productNum) * tonumber(v.productPrice)
|
||||
end
|
||||
end
|
||||
order.wfType = "0" -- 0:正常工单,1:退货工单
|
||||
showHotWheel()
|
||||
NetProto.send.save_customer(
|
||||
cust,
|
||||
NetProto.send.createWfInfo(
|
||||
order,
|
||||
function(content)
|
||||
if content.success then
|
||||
getPanelAsy("PanelCustDetail", onLoadedPanel, cust)
|
||||
MyUtl.toastS("订单创建成功")
|
||||
hideTopPanel(self.csSelf)
|
||||
end
|
||||
hideHotWheel()
|
||||
end
|
||||
)
|
||||
end,
|
||||
InputSeachKey = function()
|
||||
local queryKey = uiobjs.InputSeachKey.value
|
||||
NetProto.send.selectProductInfo(queryKey, 1)
|
||||
end,
|
||||
InputSelectProduct = function()
|
||||
getPanelAsy("PanelSelectProduct", onLoadedPanelTT)
|
||||
-- 选择商品
|
||||
getPanelAsy(
|
||||
"PanelSelectProduct",
|
||||
onLoadedPanelTT,
|
||||
{selectedProducts = self.selectedProducts, callback = self:wrapFunc(self.onGetSelectedProducts)}
|
||||
)
|
||||
end,
|
||||
InputAttachment = function()
|
||||
-- 添加附件
|
||||
end
|
||||
}
|
||||
end
|
||||
|
||||
function TRPNewOrder:onGetSelectedProducts(list)
|
||||
self.selectedProducts = list
|
||||
self:showProducts()
|
||||
end
|
||||
|
||||
-- 处理ui上的事件,例如点击等
|
||||
function TRPNewOrder:uiEventDelegate(go)
|
||||
local func = self.EventDelegate[go.name]
|
||||
|
||||
Reference in New Issue
Block a user