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-16-04
    名称: 盘点单-查询面板-仓库选择变化
    作者:HAN  
    日期:2025-1-29
 
    级别:固定 (说明本段代码在项目中不太会变化)
    
    函数: WHCodeChange
 
    功能:
        1)仓库选择变化后需要变化库区
    更改记录:
        V6.0 HAN 2023/9/6  -- lua.Error/lua.Debug 函数变化   
--]]
 
json  = require ("json")
mobox = require ("OILua_JavelinExt")
m3 = require("oi_base_mobox")
 
function WHCodeChange ( strLuaDEID ) 
    local nRet, strRetInfo
    local wh_code
 
    -- 获取 仓库编码
    nRet, wh_code = m3.GetSysCurEditDataOneAttr( strLuaDEID, "S_WH_CODE" ) 
    if ( nRet ~= 0 ) then lua.Error( strLuaDEID, debug.getinfo(1), "GetSysCurEditDataOneAttr失败! "..wh_code ) end
    
    local choic_items = ''
    if ( wh_code ~= '') then
        -- 获取【库区】,类型 是储藏区的库区 N_TYPE = 1
        local strCondition = "S_WH_CODE = '"..wh_code.."' AND N_TYPE = 1"
        local strOrder = "S_CODE"
        nRet, strRetInfo = mobox.queryDataObjAttr(strLuaDEID, "Area", strCondition, strOrder,"S_CODE" )
        if (nRet ~= 0) then lua.Error( strLuaDEID, debug.getinfo(1), "获取【库区】信息失败! " .. strRetInfo) end
        if ( strRetInfo ~= "") then  
            local areas = {}
            local n, nCount
            local success
            local attrs
            success, areas = pcall( json.decode, strRetInfo)
            if ( success == false ) then lua.Error( strLuaDEID, debug.getinfo(1), "非法的JSON格式!"..areas ) end
 
            -- 组织下拉列表选项
            nCount = #areas
            for n = 1, nCount do
                attrs = areas[n].attrs
                choic_items = choic_items..'"'..attrs[1].value..'",'
            end
            choic_items = lua.trim_laster_char( choic_items )
        end
    end
 
    -- 设置窗口中的 库区 列表
    local setAttr = '[{"attr":"S_AREA_CODE","value":"","choice_list":['..choic_items..']}]'
    local strAction = '[{"action_type":"set_dlg_attr","value":'..setAttr..'}]'
    nRet, strRetInfo = mobox.setAction( strLuaDEID, strAction  )
    if ( nRet ~= 0 ) then lua.Error( strLuaDEID, debug.getinfo(1), "setAction失败! "..strRetInfo..' action = '..strAction ) end 
end