wsz
2025-06-20 19898bd66dec87b500b200d5d50961d0fb538ce5
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
--[[
    编码: WMS-19-05
    名称: 容器货品明细-删除后
    作者:HAN  
    日期:2025-1-29
 
    级别:固定 (说明本段代码在项目中不太会变化)
    
    函数: BeforeDataObjDelete
 
    功能:
        -- 判断一下当前要删除的 CG_Detail 相关的 上架单【】的状态是否已经是 完成状态
           如果是完成状态就不能解绑,
    更改记录:
 
--]]
 
wms_base = require( "wms_base" )
 
function BeforeDataObjDelete ( strLuaDEID ) 
    local   nRet, strRetInfo
 
    -- step1: 获取当前【容器货品明细】对象
    local cg_detail
    nRet, cg_detail = m3.GetSysCurEditDataObj( strLuaDEID, "CG_Detail" )
    if ( nRet ~= 0 )  then lua.Error( strLuaDEID, debug.getinfo(1), "获取当前编辑属性失败! "..cg_detail ) end 
  
    local str_bs_no = cg_detail.bs_no 
 
    -- 如果有上架单需要判断上架单的状态是否已经是 完成状态
    if ( str_bs_no ~= "") then
        local strCondition
        if ( cg_detail.bs_type == "Inbound_Order") then
            strCondition = "S_NO = '"..str_bs_no.."'"
            nRet, id, strRetInfo = mobox.getDataObjAttrByKeyAttr( strLuaDEID, "Inbound_Order", strCondition, "N_B_STATE" )
            if ( nRet ~= 0 )  then 
                -- 存在上架单已经被删除的情况,因此只是警告一下
                lua.Warning( strLuaDEID, debug.getinfo(1), "获取【入库单】属性失败! "..id ) 
                return
            end 
            if ( strRetInfo == '' ) then return end
            local attrs = json.decode( strRetInfo ) 
            local state = lua.StrToNumber( attrs[1].value )  
 
            -- 2 组盘完成 3 -- 入库完成
            if ( state >= 2 ) then 
                -- 前端显示信息
                mobox.stopProgram( strLuaDEID, "入库单'"..str_bs_no.."'已经组盘完成或已经入库,不能进行对象删除操作!")
                return 
            end      
        end  
    end
end