Jianw
2025-05-13 3b39fe3810c3ee2ec9ec97236c1769c5c85e062c
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
--[[
    编码: WMS-01-17
    名称: 容器-禁用启用
    作者:HAN  
    日期:2025-01-29
 
    级别:固定 (说明本段代码在项目中不太会变化)
    
    函数: Enable
 
    功能:
        如果容器是启用状态设置为禁用,如果是禁用设置为启用
 
    更改记录:
 
 
--]]
wms_cntr = require( "wms_container" )
 
function Enable ( strLuaDEID ) 
    local   nRet, strRetInfo
 
    -- step1  获取当前点中的任务
    nRet, objs = m3.GetSysDataJson( strLuaDEID )
    if ( nRet ~=0 ) then lua.Error( strLuaDEID, debug.getinfo(1), objs ) end  
    -- [{"id":"","attrs":[{"attr":"","value":""},..]},..]
    local nCount = #objs
    if (nCount == 0) then  return end
 
    local obj_attrs = m3.KeyValueAttrsToObjAttr(objs[1].attrs)
    local cntr
    nRet, cntr = wms_cntr.GetInfo( strLuaDEID, obj_attrs.S_CODE )
    if ( nRet ~= 0 ) then 
        lua.Error( strLuaDEID, debug.getinfo(1), "获取容器'"..cntr.code.."'信息失败!"..strRetInfo )
    end
 
    local strUpdateSql 
    if ( cntr.enable == 'Y' ) then
        -- 禁用
        strUpdateSql = "C_ENABLE = 'N'"
    else
        -- 启用
        strUpdateSql = "C_ENABLE = 'Y'"
    end
    local strCondition = "S_CODE = '"..obj_attrs.S_CODE.."'"
    nRet, strRetInfo = mobox.updateDataAttrByCondition( strLuaDEID, "Container", strCondition, strUpdateSql )
    if ( nRet ~= 0 ) then  
        lua.Error( strLuaDEID, debug.getinfo(1), "更新【容器】信息失败!"..strRetInfo ) 
    end     
 
    local action = {
        {
            action_type = "refresh_cur_row",
            value = ""
        }
    }
    nRet, strRetInfo = mobox.setAction(strLuaDEID, lua.table2str(action))
    if ( nRet ~= 0 ) then lua.Error( strLuaDEID, debug.getinfo(1), "setAction错误: "..strRetInfo) end  
end