lzh
2025-06-24 13c4a636539584ab977fddacfae884b3ec250aee
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
80
81
82
83
84
85
86
ÿþ--[[
    x: WMS-08-02
     Tðy: ¾‹Y¨R\O–R->f:yMR
    \O€ÿHAN  
    åegÿ2023-6-15
 
    §~+RÿúVš[ (ô‹f,gµkãNx(Wy˜îv-N N*YOØSS)
    
    ýQpeÿ BeforeGridShow
 
    ŸRý€:
        N_B_STATE = 2 •ï‹>f:y¢~r‚
    ôf9e°‹U_:        
--]]
 
require ("WMS-BASE")
 
function BeforeGridShow ( strLuaDEID ) 
    local nRet, strRetInfo
    local input_datajson
 
    -- ·ƒÖSGrid>f:ypencù[aŒ
    -- [{"id":"","attrs":[{"attr":"","value":""},..]},..]
    nRet, input_datajson = m3.GetSysDataJson( strLuaDEID )
    if (nRet ~= 0) then lua.Error( strLuaDEID, debug.getinfo(1), "àeÕl·ƒÖSGrid>f:ypencS!") end
    local n, nCount
 
    nCount = #input_datajson
    if (nCount == 0) then  return end
 
    local obj, attrs, id
    local strCellBkground, strDataJson
    local strRowCtrl = ''
    local b_state = 0
 
    strDataJson = '['
    for n = 1, nCount do
        obj = input_datajson[n]
        attrs = obj.attrs
        nattr_count = #attrs
        id = obj.id
 
        strAttrs = ''
        strRowCtrl = ''
        -- ·ƒÖS ir™ex ŒT “^:Sx
        for nIndex = 1, nattr_count do
            strAttr = attrs[nIndex].attr
            strValue = attrs[nIndex].value
            strCellBkground = ''
            if (strAttr == 'N_B_STATE') then
                b_state = lua.StrToNumber( strValue )
                if ( b_state == 0 ) then -- I{…_
                    strCellBkground = ', "bk_color":"#FF0000","text_color":"#FFFFFF"'
                    strValue = "I{…_"
                elseif ( b_state == 1 ) then  -- Œ[b
                    strCellBkground = ', "bk_color":"#00FF00","text_color":"#000000"'
                    strValue = "Œ[b"
                elseif ( b_state == 2 ) then  -- •ï‹
                    strCellBkground = ', "bk_color":"#FF0000","text_color":"#FFFFFF"'
                    strValue = "•ï‹"
                end
            elseif (strAttr == 'S_ERR' or strAttr == 'S_DATA') then
                strValue = string.gsub(strValue, "\\", "/")
                strValue = string.gsub(strValue, '"','\\\"')
                strValue = string.gsub(strValue, "'",'\\\"')
                strValue = string.gsub(strValue, " ","")
            end
            strItem = '{"attr":"' .. strAttr .. '","value":"' .. strValue .. '"'..strCellBkground..'},'
            strAttrs = strAttrs .. strItem
        end
        strAttrs = lua.trim_laster_char(strAttrs)
        strRow = '{"id":"'..id..'"'..strRowCtrl..',"attrs":['..strAttrs..']},'
        strDataJson = strDataJson .. strRow
    end
    -- ÖSˆmgTN*N,÷S
    strDataJson = lua.trim_laster_char(strDataJson)
    strDataJson = strDataJson .. ']'
 
    nRet, strRetInfo = mobox.strToBase64( strDataJson )
    if ( nRet ~= 0 ) then lua.Error( strLuaDEID, debug.getinfo(1), "strToBase64 1Y%: "..strRetInfo) end 
 
    strAction = '[{"action_type":"reset_data_attr","base64":true, "value":"' .. strRetInfo .. '"}]'
    nRet, strRetInfo = mobox.setAction(strLuaDEID, strAction)
    if ( nRet ~= 0 ) then lua.Error( strLuaDEID, debug.getinfo(1), "setAction•ï‹: "..strRetInfo) end    
    
end