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
ÿþ--[[
   x: GT-103-13
    Tðy:
   \O€ÿ
   åegÿ2025-05-20
 
   ýQpeÿ BeforeGridShow
   ŸRý€:
 
   ôf9e°‹U_:
 
--]]
json  = require("json")
m3    = require("oi_base_mobox")
mobox = require("OILua_JavelinExt")
function BeforeGridShow(strLuaDEID)
    local nRet, strRetInfo
    local arobjs, attrs
    local n, nCount
 
    nRet, arobjs = m3.GetSysDataJson(strLuaDEID)
    if (nRet ~= 0) then lua.Error(strLuaDEID, debug.getinfo(1), arobjs) end
    nCount = #arobjs
    if (nCount == 0) then return end
 
    local obj, attrs, id
    local strDataJson
    local strCurYear = os.date("%Y")
    strCurYear = strCurYear .. "--"
 
    strDataJson = '['
    for n = 1, nCount do
        obj = arobjs[n]
        attrs = obj.attrs
        nattr_count = #attrs
        id = obj.id
 
        local str = m3.KeyValueAttrsToObjAttr(attrs)
        lua.Debug(strLuaDEID, debug.getinfo(1), "str", str)
 
        local strAttrs = ''
        -- ·ƒÖS ir™ex ŒT “^:Sx
        for nIndex = 1, nattr_count do
            local strAttr = attrs[nIndex].attr
            local strValue = attrs[nIndex].value
            local strItem = '{"attr":"' .. strAttr .. '","value":"' .. strValue .. '"},'
            strAttrs = strAttrs .. strItem
        end
        -- Am4l÷S*gÑ~š[¹[hV¶r`:N*gÑ~š[ ÿÑ~š[†N¹[hV¶r`:Nò]Ñ~š[
        local cg_detail
        local strValue
        local strCondition = "S_SERIAL_NO = '"..str.S_SERIAL_NO.."'"
        nRet, cg_detail = m3.GetDataObjByCondition(strLuaDEID, "CG_Detail", strCondition, "T_CREATE DESC")
        lua.Debug(strLuaDEID, debug.getinfo(1), "cg_detail", cg_detail)
        if (nRet == 1) then
            strValue = '*gÑ~š['
        elseif (nRet == 0) then
            strValue = 'ò]Ñ~š['
        elseif (nRet > 1) then
            lua.Error(strLuaDEID, debug.getinfo(1), "·ƒÖSAm4l÷SáOo`1Y%!" .. cg_detail)
        end
        local strItem = '{"attr":"CUSTOM_STATE","value":"' .. strValue .. '"},'
        strAttrs = strAttrs .. strItem
        strAttrs = lua.trim_laster_char(strAttrs)
        local strRow = '{"id":"' .. id .. '","attrs":[' .. strAttrs .. ']},'
        strDataJson = strDataJson .. strRow
    end
    -- ÖSˆmgTN*N,÷S
    strDataJson = lua.trim_laster_char(strDataJson)
    strDataJson = strDataJson .. ']'
 
    local strAction = '[{"action_type":"reset_data_attr","value":' .. strDataJson .. '}]'
    lua.Debug(strLuaDEID, debug.getinfo(1), "strAction", strAction)
    nRet, strRetInfo = mobox.setAction(strLuaDEID, strAction)
    if (nRet ~= 0) then
        lua.Warning(strLuaDEID, debug.getinfo(1), strAction)
        lua.Error(strLuaDEID, debug.getinfo(1), "setAction•ï‹: " .. strRetInfo)
    end
end