fy36
2025-05-14 a37aca60ff9914b0abb710f04118b22420f4f398
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
--[[
    编码: WMS-71-10
    名称: 库存量表差异-新增窗口-初始化
    作者:HAN  
    日期:2025-1-29
    级别:固定 (说明本段代码在项目中不太会变化)
    
    函数: InitialNewAddDlg
 
    功能:
          根据登录人员获取仓库下拉列表
 
    更改记录:
   
--]]
 
wms_base = require ("wms_base")
 
function InitialNewAddDlg ( strLuaDEID ) 
    local nRet, strRetInfo, factory
 
    nRet, factory = m3.GetMyFactory( strLuaDEID )
    if ( factory == '' ) then
        nRet, factory = wms_base.Get_sConst2( strLuaDEID, "默认工厂标识" )
        if ( nRet ~= 0 ) then
            lua.Stop( strLuaDEID, "系统无法获取常量'默认工厂标识'")
            return
        end          
    end
 
    local choic_items = ''
    local wh_code = ''
    if ( factory ~= '' ) then
        local strCondition
        local strOrder = 'S_CODE'
        strCondition = "S_FACTORY = '"..factory.."'"
        nRet, strRetInfo = mobox.queryDataObjAttr(strLuaDEID, "Warehouse", strCondition, strOrder,"S_CODE" )
        if (nRet ~= 0) then error( "获取【仓库】信息失败! " .. strRetInfo) end
        if ( strRetInfo ~= '' ) then
            local warehouse = {}
            local n, nCount
            local success
            local attrs
            success, warehouse = pcall( json.decode, strRetInfo)
            if ( success == false ) then lua.Error( strLuaDEID, debug.getinfo(1), "获取【仓库】信息失败! 非法的JSON格式!"..warehouse ) end
 
            nCount = #warehouse
            -- 组织下拉列表选项
            
            for n = 1, nCount do
                attrs = warehouse[n].attrs
                choic_items = choic_items..'"'..attrs[1].value..'",'
            end
            choic_items = lua.trim_laster_char( choic_items )
        end
    end
 
    local setAttr = '[{"attr":"S_WH_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