1
Jianw
9 天以前 70f29da38121b9a467841253e3268feb5df02902
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
54
55
56
57
58
59
--[[
   编码: AMS-24-03
   名称: 
   作者:
   日期:2025-05-07
 
   函数: BeforeDataObjDelete
   功能:
 
   更改记录:
 
--]]
 
json  = require ("json")
mobox = require ("OILua_JavelinExt")
m3 = require ("oi_base_mobox")
 
function BeforeDataObjDelete( strLuaDEID )
    
    m3.PrintLuaDEInfo( strLuaDEID )
    local nRet, strRetInfo
    local outbound_order = {}
    nRet, outbound_order = m3.GetCurEditDataObj( strLuaDEID )
    if (nRet ~= 0) then lua.Error( strLuaDEID, debug.getinfo(1), "获取当前编辑属性失败!"..outbound_order ) end
 
    if (outbound_order.state == '发布') then
        -- 用于校验入库单的状态值,料箱库的入库单看N_B_STATE,人工库的看累计入库数量是否有值
        strCondition = "S_BS_NO = '"..outbound_order.bs_no.."' AND N_B_STATE <> 0  AND S_AREA_CODE = '料箱库' "
        nRet, outbound_date = m3.QueryDataObject(strLuaDEID, "Outbound_Order", strCondition)
        if (nRet ~= 0) then
            lua.Stop(strLuaDEID,"查询对应的入库单失败!:"..outbound_order.no)
            return
        end
        if (outbound_date ~= "") then
            lua.Stop(strLuaDEID,"该来源单号对应的入库单有非新建状态,不可删除!"..outbound_order.no)
            return
        end
        
        -- 这个是校验入库单明细有已入库的数据
        Condition = "S_IO_NO IN (SELECT S_NO FROM TN_Outbound_Order WHERE S_BS_NO = '"..outbound_order.bs_no.."')  AND F_ACC_O_QTY <> 0 "
        nRet, container_data = m3.QueryDataObject(strLuaDEID, "Outbound_Detail", Condition)
        if (nRet ~= 0) then
            lua.Stop(strLuaDEID,"查询对应的入库单失败!:!"..outbound_order.no)
            return
        end
        
        if (container_data ~= "") then
            lua.Stop(strLuaDEID,"该来源单号对应的入库单明细有已入库的数据,不可删除!"..outbound_order.no)
            return
        end
    end
 
    
    if(outbound_order.state ~= '新建' and outbound_order.state ~= '发布') then
        lua.Stop(strLuaDEID,"该单据非新建状态不可删除"..outbound_order.no)
        return
    end
 
end