1
Jianw
10 天以前 f6f5e6b632d6649386a380558d84003f3de7ec6c
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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
--[[
   编码: JX-01-24
   名称: 料箱编码输入后
   作者:KUN
   日期:2025-03-06
 
   函数: CntrChange
   功能:
        -- 校验料箱信息,并显示在货品明细界面
        -- 判断是否存在码盘数据
 
--]]
 
wms_cntr = require( "wms_container" )
jx_base = require( "jx_base" )
wms_wh = require( "wms_wh" )
 
function CntrChange( strLuaDEID )
    local nRet, strRetInfo
    local cntr_detail_array
 
    -- 获取当前编辑的容器编码
    nRet, strRetInfo = mobox.getCurEditDataObjAttr(strLuaDEID, "S_CODE")
    if (nRet ~= 0) then
        mobox.setInfo(strLuaDEID, "获取当前编辑属性失败! " .. strRetInfo)
        return
    end
 
    local obj_attrs = json.decode(strRetInfo)
    local cntr_code = lua.Get_StrAttrValue(obj_attrs[1].value)
 
    -- 获取容器信息
    local cntr_obj
    nRet, cntr_obj = wms_cntr.GetInfo(strLuaDEID, cntr_code)
    if (nRet ~= 0 or cntr_obj == '') then
        mobox.setInfo(strLuaDEID, "编码 = '" .. cntr_code .. "'的拣料箱不存在或获取失败!")
        return
    end
    if (cntr_obj.source ~= '巨沃') then
        mobox.setInfo(strLuaDEID, "编码 = '" .. cntr_code .. "'的拣料箱不是巨沃的料箱!")
        return
    end
    if (cntr_obj.empty_full ~= 0) then
        mobox.setInfo(strLuaDEID, "编码 = '" .. cntr_code .. "'的拣料箱是有货的料箱!")
        return
    end
    if (cntr_obj.position ~= '') then
        mobox.setInfo(strLuaDEID, "编码 = '" .. cntr_code .. "'的拣料箱在库里!")
        return
    end
    
    if (cntr_obj.lock_state ~= 0) then
        mobox.setInfo(strLuaDEID, "编码 = '" .. cntr_code .. "'的拣料箱有锁!")
        return
    end
    
    local strCondition = "S_CNTR_CODE = '" .. cntr_code .. "' AND ( N_B_STATE = 0 or N_B_STATE = 1 )"
    nRet, data_objs = mobox.getDataObjCount(strLuaDEID, "JX_Transfer_Order", strCondition)
    lua.Debug(strLuaDEID, debug.getinfo(1), "data_objs--->", data_objs)
    
    if (nRet ~= 0) then
        mobox.setInfo(strLuaDEID, debug.getinfo(1), "查询码盘单失败!" .. data_objs)
        return
    end
    
    nCount = tonumber(data_objs)
    if (nCount > 0) then
        mobox.setInfo(strLuaDEID, "容器 '" .. cntr_code .. "' 存在码盘单,无法操作!")
        return
    end
        
    
    
    strCondition = "S_CODE = '" .. cntr_code .. "'"
    nRet, strRetInfo = m3.GetDataObjByCondition(strLuaDEID, "Container", strCondition)
    if (nRet ~= 0) then 
        mobox.setInfo(strLuaDEID, "查询 Container 表失败: " .. strRetInfo) 
        return
    end
    
    local spec = strRetInfo.spec
    local code = strRetInfo.code
    local source = strRetInfo.source
    
    lua.Debug(strLuaDEID, debug.getinfo(1), "strRetInfo--->", strRetInfo)
    
    local detail_strCondition = "S_CODE = '" .. cntr_code .. "'"
    local container_detail
    nRet, container_detail = m3.QueryDataObject(strLuaDEID, "Container", detail_strCondition)
    if (nRet ~= 0) then
        mobox.setInfo(strLuaDEID,"查询明细数据失败! " .. container_detail)
        return
    end
    local action_array = {}
    -- 将所有行数据批量插入到页面
        action_array[1] = {
            action_type = "set_subtable_page_content",
            value = {
                page_name = "料箱信息",
                content = container_detail,
                clear = true,
                clear_confirm = false,
                checkbox = false
            }
        }
        -- 提交前端操作
        nRet, strRetInfo = mobox.setAction(strLuaDEID, lua.table2str(action_array))
        if (nRet ~= 0) then
            lua.Error(strLuaDEID, debug.getinfo(1), "setAction失败! " .. strRetInfo)
        end
    
 
end