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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
--[[
   编码: AMS-20-31
   名称: 
   作者:
   日期:2025-04-28
 
   函数: InitialNewAddDlg
   功能:
 
   更改记录:
 
--]]
 
json  = require ("json")
mobox = require ("OILua_JavelinExt")
m3 = require ("oi_base_mobox")
wms_base = require ("wms_base")
 
function InitialNewAddDlg( strLuaDEID )
    
    local nRet, strRetInfo, factory, data_objs, n
 
    local nRet,factory = wms_base.Get_sConst2( strLuaDEID, "默认工厂标识" )
    if ( nRet ~= 0 ) then
        lua.Stop(strLuaDEID, "系统常量:默认工厂标识不存在:")
        return
    end
    if ( factory == '' ) then
        lua.Stop(strLuaDEID, "系统常量'默认工厂标识'必须有值!:")
        return
    end
 
    lua.Debug( strLuaDEID, debug.getinfo(1), "factory1 --> ", factory ) 
    local choice_list = {}
    if ( factory ~= '' ) then
        local strCondition
        local strOrder = 'S_CODE'
        strCondition = "S_FACTORY = '"..factory.."'"
        nRet, data_objs = m3.QueryDataObject( strLuaDEID, "Warehouse", strCondition, strOrder )
        if (nRet ~= 0) then lua.Error( strLuaDEID, debug.getinfo(1), "获取【Warehouse】信息失败! " .. data_objs) end
        
        lua.Debug( strLuaDEID, debug.getinfo(1), "data_objs --> ", data_objs )   
        
        local obj_attrs
        for n = 1, #data_objs do
            obj_attrs = m3.KeyValueAttrsToObjAttr(data_objs[n].attrs)
            table.insert( choice_list, obj_attrs.S_CODE )
        end
    end
 
    -- 获取结算报表有多少种时间段
    nRet, strRetInfo = mobox.groupDataObjAttr(strLuaDEID, "SKU", "1 = 1", "S_UDF01")
    if (nRet ~= 0) then
        lua.Error(strLuaDEID, debug.getinfo(1), "无法从【Material】获取信息!" .. strRetInfo)
    end
    
    local groups_serial = json.decode(strRetInfo)
    local serial_list = {}
    for n = 1, #groups_serial do
        table.insert(serial_list, groups_serial[n].value)
    end
    lua.Debug( strLuaDEID, debug.getinfo(1), "serial_list --> ", serial_list )    
    lua.Debug( strLuaDEID, debug.getinfo(1), "choice_list --> ", choice_list )    
    local action_array = {}
        action_array[1] = {
        action_type = "set_dlg_attr",
        value = {
            {attr = "S_AREA_CODE", value = serial_list[1], choice_list = serial_list },
            {attr = "S_WH_CODE",  value = choice_list[1], choice_list = choice_list }
            }
        }
    
    local strRetInfo   
    nRet, strRetInfo = mobox.setAction(strLuaDEID, lua.table2str(action_array))
    if (nRet ~= 0) then
        mobox.setInfo(strLuaDEID, "setAction失败! " .. strRetInfo)
        return
    end
end