-- 动作转化 local root = {} function root:initFuncMap() self.operateFunMap = { ["kv"] = self.isTableMatch, ["=="] = self.isConditionEqual, [">"] = self.isConditionGreater, [">="] = self.isConditionEqualGreater, ["<"] = self.isConditionLess, ["<="] = self.isConditionEqualLess, ["="] = self.isConditionEqual, ["~="] = self.isConditionNotEqual, ["!="] = self.isConditionNotEqual, ["sam"] = self.isConditionSameMember, ["unsam"] = self.isConditionNotSameMember, ["!sam"] = self.isConditionNotSameMember, [">inc"] = self.isConditionLinclude, ["uninc"] = self.isConditionNotLinclude, ["inc"] = self.isConditionNotLinclude, ["!= value then return true end end return false end -- 等于 function root:isConditionEqual(val, condValue) return val and val == condValue end -- 不等于 function root:isConditionNotEqual(val, condValue) return val and val ~= condValue end -- 大于 function root:isConditionGreater(val, condValue) return val and condValue and val > condValue end -- 大于等于 function root:isConditionEqualGreater(val, condValue) return val and condValue and val >= condValue end -- 小于 function root:isConditionLess(val, condValue) return val and condValue and val < condValue end -- 小于等于 function root:isConditionEqualLess(val, condValue) return val and condValue and val <= condValue end -- 是否范围值 function root:isRangeValue(v, range) if type(range) ~= "table" or #range ~= 2 then return false end local isMinLimit = false local isMaxLimit = false if string.lower(range[1]) == "z" then isMinLimit = true end if range[2] == -1 or string.lower(range[2]) == "z" then isMaxLimit = true end if not isMinLimit and not isMaxLimit then if v >= range[1] and v <= range[2] then return true end else if not isMinLimit then if v < range[1] then return false end end if not isMaxLimit then if v > range[2] then return false end end return true end return false end -- 包含范围 function root:isConditionRange(val, condValue) if val == nil or condValue == nil then return false end if type(condValue) ~= "table" then return false end return root:isRangeValue(val, condValue) end -- 有共同项 function root:isConditionSameMember(val, condValue) local valTable = type(val) == "table" and val or {val} local condTable = type(condValue) == "table" and condValue or {condValue} for k, v in ipairs(condTable) do if table.include(valTable, v) then return true end end return false end -- 无共同项 function root:isConditionNotSameMember(val, condValue) return not self:isConditionSameMember(val, condValue) end -- 不包含范围 function root:isConditionNotRange(val, condValue) if val == nil or condValue == nil then return false end if type(condValue) ~= "table" then return false end return not root:isRangeValue(val, condValue) end -- 左被包含 function root:isConditionLinclude(val, condValue) if val == nil or condValue == nil then return false end -- 配置参数必须为table local tbConf = nil if type(condValue) == "table" then tbConf = condValue else tbConf = {condValue} end if type(val) ~= "table" then return table.include(tbConf, val) end for k, v in ipairs(val) do if not table.include(tbConf, v) then return false end end return true end -- 右被包含 function root:isConditionRinclude(val, condValue) if val == nil or condValue == nil then return false end -- 入参必须为table local tbConf = nil if type(val) == "table" then tbConf = val else tbConf = {val} end if type(condValue) ~= "table" then return table.include(tbConf, condValue) end for k, v in ipairs(condValue) do if not table.include(tbConf, v) then return false end end return true end -- 左被不包含 function root:isConditionNotLinclude(val, condValue) if val == nil or condValue == nil then return false end -- 入参必须为table local tbConf = nil if type(condValue) == "table" then tbConf = condValue else tbConf = {condValue} end if type(val) ~= "table" then return not table.include(tbConf, val) end for k, v in ipairs(val) do if table.include(tbConf, v) then return false end end return true end -- 右被不包含 function root:isConditionNotRinclude(val, condValue) if val == nil or condValue == nil then return false end -- 配置参数必须为table local tbConf = nil if type(val) == "table" then tbConf = val else tbConf = {val} end if type(condValue) ~= "table" then return not table.include(tbConf, condValue) end for k, v in ipairs(condValue) do if table.include(tbConf, v) then return false end end return true end return root