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
--[[
    编码: WMS-22-10
    名称: 发货单-新增小窗口初始化
    作者:HAN  
    日期:2025-1-29
 
    级别:固定 (说明本段代码在项目中不太会变化)
    
    函数: InitialNewAddDlg
    功能:
        1)获取当前登录人员的【工厂】中的工厂标识,初始化【仓库】中的下拉框里内容
 
    更改记录:
 
--]]
 
wms_base = require("wms_base")
 
function InitialNewAddDlg ( strLuaDEID ) 
    local nRet, strRetInfo,factory
 
    nRet, factory = wms_base.GetMyFactory( strLuaDEID )
    if ( nRet ~= 0 ) then lua.Error( strLuaDEID, debug.getinfo(1), "GetMyFactory失败! "..factory ) end
 
    -- 获取【仓库】
    local strCondition = "S_FACTORY = '"..factory.."'"
    local strOrder = "S_CODE"
    nRet, strRetInfo = mobox.queryDataObjAttr(strLuaDEID, "Warehouse", strCondition, strOrder,"S_CODE" )
    if (nRet ~= 0) then lua.Error( strLuaDEID, debug.getinfo(1), "获取【仓库】信息失败! " .. strRetInfo) end
    if ( strRetInfo == "") then  lua.Error( strLuaDEID, debug.getinfo(1), "当前操作人员所属工厂没定义仓库! " ) end
 
    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
 
    -- 组织下拉列表选项
    local choic_items = ''
    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 )
    -- 如果只有一个仓库,那么就默认选这个仓库
    local wh_code = ''
    if ( nCount == 1) then wh_code = attrs[1].value end
 
    -- 设置窗口中的 仓库 列表
    local setAttr = '[{"attr":"S_WH_CODE","value":"'..wh_code..'","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