UNPKG

@wufengteam/wform

Version:

@wufengteam/wform

862 lines (860 loc) 53.2 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.default = void 0; var _tool = require("./tool"); function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); } function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); } function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); } function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); } function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); } function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; } function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } } function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; } var areArraysEqual = function areArraysEqual(arr1, arr2) { if (Array.isArray(arr1) && Array.isArray(arr2)) { if (arr1.length !== arr2.length) { return false; } return arr1.every(function (item) { return arr2.includes(item); }); } return false; }; var isArrayContainsArray = function isArrayContainsArray(arr1, arr2) { if (Array.isArray(arr1) && Array.isArray(arr2) && arr2.length > 0) { return arr2.some(function (item) { return arr1.includes(item); }); } return false; }; var isAnyItemInArray = function isAnyItemInArray(sourceArray, targetArray) { if (Array.isArray(targetArray) && Array.isArray(sourceArray) && sourceArray.length > 0) { return sourceArray.some(function (item) { return targetArray.includes(item); }); } return false; }; function areAllItemsInArray(sourceArray, targetArray) { if (Array.isArray(targetArray) && Array.isArray(sourceArray) && sourceArray.length > 0) { return sourceArray.every(function (element) { return targetArray.includes(element); }); } return false; } function constructsWFViewChildrenIdsMap(data) { var result = {}; function traverse(node) { if (node.id && node.id.startsWith('WFView_')) { result[node.id] = []; if (node.components && node.components.length > 0) { node.components.forEach(function (subNode) { if (!subNode.id.startsWith('WFView_')) { result[node.id].push(subNode.id); } traverse(subNode); }); } } else if (node.components && node.components.length > 0) { node.components.forEach(traverse); } } if (Array.isArray(data)) { data.forEach(traverse); } return result; } function constructsWFTabPaneChildrenIdsMap(data) { var _a; var result = {}; if (Array.isArray((_a = data === null || data === void 0 ? void 0 : data[0]) === null || _a === void 0 ? void 0 : _a.components) && data[0].components.length > 0) { var WFTabsNode = data[0].components.find(function (i) { return (i === null || i === void 0 ? void 0 : i.compName) === 'WFTabs'; }); if (Array.isArray(WFTabsNode === null || WFTabsNode === void 0 ? void 0 : WFTabsNode.components) && WFTabsNode.components.length > 0) { WFTabsNode.components.forEach(function (i) { result[i.id] = []; if (Array.isArray(i === null || i === void 0 ? void 0 : i.components) && i.components.length > 0) { i.components.forEach(function (j) { if ((j === null || j === void 0 ? void 0 : j.compName) === 'WFView') { if (j === null || j === void 0 ? void 0 : j.id) { result[i.id].push(j.id); } if (Array.isArray(j === null || j === void 0 ? void 0 : j.components) && j.components.length > 0) { j.components.forEach(function (k) { if (k === null || k === void 0 ? void 0 : k.id) { result[i.id].push(k.id); } }); } } else if (j === null || j === void 0 ? void 0 : j.id) { result[i.id].push(j.id); } }); } }); } } return result; } function constructsWFTabPaneFatherIdMap(data) { var _a; var result = {}; if (Array.isArray((_a = data === null || data === void 0 ? void 0 : data[0]) === null || _a === void 0 ? void 0 : _a.components) && data[0].components.length > 0) { var WFTabsNode = data[0].components.find(function (i) { return (i === null || i === void 0 ? void 0 : i.compName) === 'WFTabs'; }); if ((WFTabsNode === null || WFTabsNode === void 0 ? void 0 : WFTabsNode.id) && Array.isArray(WFTabsNode === null || WFTabsNode === void 0 ? void 0 : WFTabsNode.components) && WFTabsNode.components.length > 0) { WFTabsNode.components.forEach(function (j) { if (j === null || j === void 0 ? void 0 : j.id) { result[j.id] = WFTabsNode === null || WFTabsNode === void 0 ? void 0 : WFTabsNode.id; } }); } } return result; } function constructsSubFormChildrenIdsMap(data) { var result = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; if (Array.isArray(data)) { data.forEach(function (item) { if (item.id && item.id.startsWith('SubForm_')) { var subIds = []; constructsSubFormChildrenIdsMap(item.components, result); if (item.components && Array.isArray(item.components)) { item.components.forEach(function (component) { subIds.push(component.id); }); result[item.id] = subIds; } } else if (item.components && Array.isArray(item.components)) { constructsSubFormChildrenIdsMap(item.components, result); } }); } return result; } function constructsWFTabNoHideIdsList(data) { var _a; var result = []; if (Array.isArray((_a = data === null || data === void 0 ? void 0 : data[0]) === null || _a === void 0 ? void 0 : _a.components) && data[0].components.length > 0) { var WFTabsNode = data[0].components.find(function (i) { return (i === null || i === void 0 ? void 0 : i.compName) === 'WFTabs'; }); if (Array.isArray(WFTabsNode === null || WFTabsNode === void 0 ? void 0 : WFTabsNode.components)) { WFTabsNode.components.forEach(function (item) { if (item.props.basicStatus === 1) { result.push(item.id); } }); } } return result; } var getBusinessRulesFn = function getBusinessRulesFn(params) { var _params$rules = params.rules, rules = _params$rules === void 0 ? [] : _params$rules, _params$compFnMap = params.compFnMap, compFnMap = _params$compFnMap === void 0 ? {} : _params$compFnMap, _params$initialValues = params.initialValues, initialValues = _params$initialValues === void 0 ? {} : _params$initialValues, attrMappingJson = params.attrMappingJson, addToAwaitQueue = params.addToAwaitQueue; var pageData = {}; try { pageData = JSON.parse(attrMappingJson); } catch (error) { console.log('attrMappingJson', attrMappingJson); } var WFViewChildrenIdsMap = constructsWFViewChildrenIdsMap(pageData.components) || {}; var WFTabPaneChildrenIdsMap = constructsWFTabPaneChildrenIdsMap(pageData.components) || {}; var WFTabPaneFatherIdMap = constructsWFTabPaneFatherIdMap(pageData.components) || {}; var SubFormChildrenIdsMap = constructsSubFormChildrenIdsMap(pageData.components) || {}; var WFTabNoHideIdsList = constructsWFTabNoHideIdsList(pageData.components) || []; var executedActionsMap = {}; var businessRules = []; if (Array.isArray(rules)) { rules.forEach(function (ruleDto) { var attrRuleJson = ruleDto.attrRuleJson; try { var ruleObject = JSON.parse(attrRuleJson); if ((ruleObject === null || ruleObject === void 0 ? void 0 : ruleObject.ruleCondition) && ruleDto.statusCd === '00A') { businessRules.push({ id: ruleDto.attrShowRuleId, name: ruleObject.ruleName, expressions: ruleObject.ruleCondition, actions: ruleObject.ruleResult }); } } catch (error) { console.error('业务规则数据格式错误'); } }); } // console.log('businessRules', businessRules); var onValuesChange = function onValuesChange(values) { // console.log('values', values); if (Array.isArray(businessRules)) { businessRules.forEach(function (businessRule) { var _ref = businessRule || {}, expressions = _ref.expressions, actions = _ref.actions, id = _ref.id; if (Array.isArray(expressions)) { var expressionResult = 'return'; expressions.forEach(function (expression) { var _a; if ((expression === null || expression === void 0 ? void 0 : expression.type) === 'condition') { var _ref2 = (expression === null || expression === void 0 ? void 0 : expression.value) || {}, field = _ref2.field, operator = _ref2.operator, conditionVal = _ref2.value; if (values && Object.keys(values).includes(field === null || field === void 0 ? void 0 : field.name)) { var currentVal = values[field.name]; switch (operator === null || operator === void 0 ? void 0 : operator.operator) { case 'equals': if (conditionVal === currentVal || areArraysEqual(conditionVal, currentVal)) { // console.log('等于'); expressionResult = "".concat(expressionResult, " true"); } else { expressionResult = "".concat(expressionResult, " false"); } break; case 'notEquals': if (!(conditionVal === currentVal || areArraysEqual(conditionVal, currentVal))) { // console.log('不等于'); expressionResult = "".concat(expressionResult, " true"); } else { expressionResult = "".concat(expressionResult, " false"); } break; case 'empty': if (currentVal === null || currentVal === undefined || currentVal === '' || Array.isArray(currentVal) && currentVal.length === 0) { expressionResult = "".concat(expressionResult, " true"); } else { expressionResult = "".concat(expressionResult, " false"); } break; case 'notEmpty': if (!(currentVal === null || currentVal === undefined || currentVal === '' || Array.isArray(currentVal) && currentVal.length === 0)) { // console.log('不为空'); expressionResult = "".concat(expressionResult, " true"); } else { expressionResult = "".concat(expressionResult, " false"); } break; case 'contains': if ((conditionVal === null || conditionVal === void 0 ? void 0 : conditionVal.includes(currentVal)) || isArrayContainsArray(conditionVal, currentVal)) { // console.log('包含'); expressionResult = "".concat(expressionResult, " true"); } else { expressionResult = "".concat(expressionResult, " false"); } break; case 'notContains': if (!((conditionVal === null || conditionVal === void 0 ? void 0 : conditionVal.includes(currentVal)) || isArrayContainsArray(conditionVal, currentVal))) { // console.log('不包含'); expressionResult = "".concat(expressionResult, " true"); } else { expressionResult = "".concat(expressionResult, " false"); } break; case 'range': // eslint-disable-next-line no-case-declarations var min = conditionVal.min, max = conditionVal.max; if ((0, _tool.isNumer)(min) && (0, _tool.isNumer)(max) && min < currentVal && max > currentVal) { // console.log('在范围内'); expressionResult = "".concat(expressionResult, " true"); } else { expressionResult = "".concat(expressionResult, " false"); } break; default: expressionResult = "".concat(expressionResult, " false"); break; } } else { expressionResult = "".concat(expressionResult, " false"); } } if ((expression === null || expression === void 0 ? void 0 : expression.type) === 'operator') { switch ((_a = expression === null || expression === void 0 ? void 0 : expression.value) === null || _a === void 0 ? void 0 : _a.operator) { case 'AND': expressionResult = "".concat(expressionResult, " &&"); break; case 'OR': expressionResult = "".concat(expressionResult, " ||"); break; default: break; } } }); // console.log('expressionResult', expressionResult); // eslint-disable-next-line no-new-func var isExecuteActions = new Function(expressionResult)(); // console.log('是否执行', isExecuteActions); executedActionsMap[id] = actions; if (isExecuteActions) { // console.log('执行动作') if (Array.isArray(actions)) { actions.forEach(function (action, index) { var _a, _b, _c, _d; var _ref3 = action || {}, type = _ref3.type, fields = _ref3.fields, hint = _ref3.hint; switch (type) { case 'hide': if (Array.isArray(fields)) { fields.forEach(function (key) { var _a; if ((_a = compFnMap === null || compFnMap === void 0 ? void 0 : compFnMap[key]) === null || _a === void 0 ? void 0 : _a.setVisible) { compFnMap[key].setVisible(false); } else { addToAwaitQueue === null || addToAwaitQueue === void 0 ? void 0 : addToAwaitQueue(key, 'setVisible', false); } }); } var SubFormHideIds = []; Object.entries(SubFormChildrenIdsMap).forEach(function (_ref4) { var _ref5 = _slicedToArray(_ref4, 2), key = _ref5[0], value = _ref5[1]; var _a, _b; if (areAllItemsInArray(value, fields)) { SubFormHideIds.push(key); if ((_a = compFnMap === null || compFnMap === void 0 ? void 0 : compFnMap[key]) === null || _a === void 0 ? void 0 : _a.setVisible) { compFnMap[key].setVisible(false); } else { addToAwaitQueue === null || addToAwaitQueue === void 0 ? void 0 : addToAwaitQueue(key, 'setVisible', false); } } else if ((_b = compFnMap === null || compFnMap === void 0 ? void 0 : compFnMap[key]) === null || _b === void 0 ? void 0 : _b.setSubFormFieldHidden) { compFnMap[key].setSubFormFieldHidden(fields); } else { addToAwaitQueue === null || addToAwaitQueue === void 0 ? void 0 : addToAwaitQueue(key, 'setSubFormFieldHidden', fields); } }); var WFViewHideIds = []; Object.entries(WFViewChildrenIdsMap).forEach(function (_ref6) { var _ref7 = _slicedToArray(_ref6, 2), key = _ref7[0], value = _ref7[1]; var _a; if (areAllItemsInArray(value, fields)) { WFViewHideIds.push(key); if ((_a = compFnMap === null || compFnMap === void 0 ? void 0 : compFnMap[key]) === null || _a === void 0 ? void 0 : _a.setVisible) { compFnMap[key].setVisible(false); } else { addToAwaitQueue === null || addToAwaitQueue === void 0 ? void 0 : addToAwaitQueue(key, 'setVisible', false); } } }); var hiddenWFTabPaneIds = []; var WFTabId = ''; Object.entries(WFTabPaneChildrenIdsMap).forEach(function (_ref8) { var _ref9 = _slicedToArray(_ref8, 2), key = _ref9[0], value = _ref9[1]; WFTabId = WFTabPaneFatherIdMap[key]; if (areAllItemsInArray(value, [].concat(WFViewHideIds, SubFormHideIds, _toConsumableArray(fields)))) { hiddenWFTabPaneIds.push(key); } }); if (hiddenWFTabPaneIds.length > 0) { if ((_a = compFnMap === null || compFnMap === void 0 ? void 0 : compFnMap[WFTabId]) === null || _a === void 0 ? void 0 : _a.removeDisPlayWFTabPaneIds) { compFnMap[WFTabId].removeDisPlayWFTabPaneIds(hiddenWFTabPaneIds); } else { addToAwaitQueue === null || addToAwaitQueue === void 0 ? void 0 : addToAwaitQueue(WFTabId, 'removeDisPlayWFTabPaneIds', hiddenWFTabPaneIds); } } if (areAllItemsInArray(WFTabNoHideIdsList, hiddenWFTabPaneIds)) { if ((_b = compFnMap === null || compFnMap === void 0 ? void 0 : compFnMap[WFTabId]) === null || _b === void 0 ? void 0 : _b.setVisible) { compFnMap[WFTabId].setVisible(false); } else { addToAwaitQueue === null || addToAwaitQueue === void 0 ? void 0 : addToAwaitQueue(WFTabId, 'setVisible', false); } } break; case 'show': if (Array.isArray(fields)) { fields.forEach(function (key) { var _a; if ((_a = compFnMap === null || compFnMap === void 0 ? void 0 : compFnMap[key]) === null || _a === void 0 ? void 0 : _a.setVisible) { compFnMap[key].setVisible(true); } else { addToAwaitQueue === null || addToAwaitQueue === void 0 ? void 0 : addToAwaitQueue(key, 'setVisible', true); } }); } var SubFormShowIds = []; Object.entries(SubFormChildrenIdsMap).forEach(function (_ref10) { var _ref11 = _slicedToArray(_ref10, 2), key = _ref11[0], value = _ref11[1]; var _a, _b; if (isAnyItemInArray(value, fields)) { SubFormShowIds.push(key); if ((_a = compFnMap === null || compFnMap === void 0 ? void 0 : compFnMap[key]) === null || _a === void 0 ? void 0 : _a.setVisible) { compFnMap[key].setVisible(true); } else { addToAwaitQueue === null || addToAwaitQueue === void 0 ? void 0 : addToAwaitQueue(key, 'setVisible', true); } if ((_b = compFnMap === null || compFnMap === void 0 ? void 0 : compFnMap[key]) === null || _b === void 0 ? void 0 : _b.setSubFormFieldShow) { compFnMap[key].setSubFormFieldShow(fields); } else { addToAwaitQueue === null || addToAwaitQueue === void 0 ? void 0 : addToAwaitQueue(key, 'setSubFormFieldShow', fields); } } }); var WFViewShowIds = []; Object.entries(WFViewChildrenIdsMap).forEach(function (_ref12) { var _ref13 = _slicedToArray(_ref12, 2), key = _ref13[0], value = _ref13[1]; var _a; if (isAnyItemInArray(value, fields)) { WFViewShowIds.push(key); if ((_a = compFnMap === null || compFnMap === void 0 ? void 0 : compFnMap[key]) === null || _a === void 0 ? void 0 : _a.setVisible) { compFnMap[key].setVisible(true); } else { addToAwaitQueue === null || addToAwaitQueue === void 0 ? void 0 : addToAwaitQueue(key, 'setVisible', true); } } }); var displayedWFTabPaneIds = []; var WFTabShowId = ''; Object.entries(WFTabPaneChildrenIdsMap).forEach(function (_ref14) { var _ref15 = _slicedToArray(_ref14, 2), key = _ref15[0], value = _ref15[1]; WFTabShowId = WFTabPaneFatherIdMap[key]; if (isAnyItemInArray(value, [].concat(WFViewShowIds, SubFormShowIds, _toConsumableArray(fields)))) { displayedWFTabPaneIds.push(key); } }); if (displayedWFTabPaneIds.length > 0) { displayedWFTabPaneIds.forEach(function (WFTabPaneId) { var _a; if ((_a = compFnMap === null || compFnMap === void 0 ? void 0 : compFnMap[WFTabPaneId]) === null || _a === void 0 ? void 0 : _a.setVisible) { compFnMap[WFTabPaneId].setVisible(true); } else { addToAwaitQueue === null || addToAwaitQueue === void 0 ? void 0 : addToAwaitQueue(WFTabPaneId, 'setVisible', true); } }); if ((_c = compFnMap === null || compFnMap === void 0 ? void 0 : compFnMap[WFTabShowId]) === null || _c === void 0 ? void 0 : _c.addDisPlayWFTabPaneIds) { compFnMap[WFTabShowId].addDisPlayWFTabPaneIds(displayedWFTabPaneIds); } else { addToAwaitQueue === null || addToAwaitQueue === void 0 ? void 0 : addToAwaitQueue(WFTabShowId, 'addDisPlayWFTabPaneIds', displayedWFTabPaneIds); } if ((_d = compFnMap === null || compFnMap === void 0 ? void 0 : compFnMap[WFTabShowId]) === null || _d === void 0 ? void 0 : _d.setVisible) { compFnMap[WFTabShowId].setVisible(true); } else { addToAwaitQueue === null || addToAwaitQueue === void 0 ? void 0 : addToAwaitQueue(WFTabShowId, 'setVisible', true); } } break; case 'editable': if (Array.isArray(fields)) { fields.forEach(function (key) { var _a; if ((_a = compFnMap === null || compFnMap === void 0 ? void 0 : compFnMap[key]) === null || _a === void 0 ? void 0 : _a.setDisabled) { compFnMap[key].setDisabled(false); } else { addToAwaitQueue === null || addToAwaitQueue === void 0 ? void 0 : addToAwaitQueue(key, 'setDisabled', false); } }); } Object.entries(SubFormChildrenIdsMap).forEach(function (_ref16) { var _ref17 = _slicedToArray(_ref16, 2), key = _ref17[0], value = _ref17[1]; var _a, _b; if (areAllItemsInArray(value, fields)) { if ((_a = compFnMap === null || compFnMap === void 0 ? void 0 : compFnMap[key]) === null || _a === void 0 ? void 0 : _a.setDisabled) { compFnMap[key].setDisabled(false); } else { addToAwaitQueue === null || addToAwaitQueue === void 0 ? void 0 : addToAwaitQueue(key, 'setDisabled', false); } } else if ((_b = compFnMap === null || compFnMap === void 0 ? void 0 : compFnMap[key]) === null || _b === void 0 ? void 0 : _b.setSubFormFieldEditable) { compFnMap[key].setSubFormFieldEditable(fields); } else { addToAwaitQueue === null || addToAwaitQueue === void 0 ? void 0 : addToAwaitQueue(key, 'setSubFormFieldEditable', fields); } }); break; case 'readonly': if (Array.isArray(fields)) { fields.forEach(function (key) { var _a; if ((_a = compFnMap === null || compFnMap === void 0 ? void 0 : compFnMap[key]) === null || _a === void 0 ? void 0 : _a.setDisabled) { compFnMap[key].setDisabled(true); } else { addToAwaitQueue === null || addToAwaitQueue === void 0 ? void 0 : addToAwaitQueue(key, 'setDisabled', true); } }); } Object.entries(SubFormChildrenIdsMap).forEach(function (_ref18) { var _ref19 = _slicedToArray(_ref18, 2), key = _ref19[0], value = _ref19[1]; var _a, _b; if (areAllItemsInArray(value, fields)) { if ((_a = compFnMap === null || compFnMap === void 0 ? void 0 : compFnMap[key]) === null || _a === void 0 ? void 0 : _a.setDisabled) { compFnMap[key].setDisabled(true); } else { addToAwaitQueue === null || addToAwaitQueue === void 0 ? void 0 : addToAwaitQueue(key, 'setDisabled', true); } } else if ((_b = compFnMap === null || compFnMap === void 0 ? void 0 : compFnMap[key]) === null || _b === void 0 ? void 0 : _b.setSubFormFieldDisabled) { compFnMap[key].setSubFormFieldDisabled(fields); } else { addToAwaitQueue === null || addToAwaitQueue === void 0 ? void 0 : addToAwaitQueue(key, 'setSubFormFieldDisabled', fields); } }); break; case 'required': if (Array.isArray(fields)) { fields.forEach(function (key) { var _a; if ((_a = compFnMap === null || compFnMap === void 0 ? void 0 : compFnMap[key]) === null || _a === void 0 ? void 0 : _a.setRequired) { compFnMap[key].setRequired(true); } else { addToAwaitQueue === null || addToAwaitQueue === void 0 ? void 0 : addToAwaitQueue(key, 'setRequired', true); } }); } Object.entries(SubFormChildrenIdsMap).forEach(function (_ref20) { var _ref21 = _slicedToArray(_ref20, 2), key = _ref21[0], value = _ref21[1]; var _a, _b; if (areAllItemsInArray(value, fields)) { if ((_a = compFnMap === null || compFnMap === void 0 ? void 0 : compFnMap[key]) === null || _a === void 0 ? void 0 : _a.setRequired) { compFnMap[key].setRequired(true); } else { addToAwaitQueue === null || addToAwaitQueue === void 0 ? void 0 : addToAwaitQueue(key, 'setRequired', true); } } else if ((_b = compFnMap === null || compFnMap === void 0 ? void 0 : compFnMap[key]) === null || _b === void 0 ? void 0 : _b.setSubFormFieldRequired) { compFnMap[key].setSubFormFieldRequired(fields); } else { addToAwaitQueue === null || addToAwaitQueue === void 0 ? void 0 : addToAwaitQueue(key, 'setSubFormFieldRequired', fields); } }); break; case 'prompt': if (Array.isArray(expressions)) { var fieldsVal = []; expressions.forEach(function (expression) { var _a, _b, _c, _d, _e, _f, _g; var field = (_b = (_a = expression === null || expression === void 0 ? void 0 : expression.value) === null || _a === void 0 ? void 0 : _a.field) === null || _b === void 0 ? void 0 : _b.name; if (field) { if ((_c = compFnMap === null || compFnMap === void 0 ? void 0 : compFnMap[field]) === null || _c === void 0 ? void 0 : _c.changeValidateStatus) { compFnMap[field].changeValidateStatus('error', hint); } else { addToAwaitQueue === null || addToAwaitQueue === void 0 ? void 0 : addToAwaitQueue(field, 'changeValidateStatus', 'error', hint); } if ((_d = compFnMap === null || compFnMap === void 0 ? void 0 : compFnMap[field]) === null || _d === void 0 ? void 0 : _d.appendRules) { compFnMap[field].appendRules([{ validator: function validator() { return Promise.reject(new Error(hint)); }, mark: 'prompt' }]); } else { (_f = (_e = compFnMap === null || compFnMap === void 0 ? void 0 : compFnMap[field]) === null || _e === void 0 ? void 0 : _e.appendRules) === null || _f === void 0 ? void 0 : _f.call(_e, [{ validator: function validator() { return Promise.reject(new Error(hint)); }, mark: 'prompt' }]); } fieldsVal.push(field); } if ((_g = executedActionsMap === null || executedActionsMap === void 0 ? void 0 : executedActionsMap[id]) === null || _g === void 0 ? void 0 : _g[index]) { executedActionsMap[id][index].fields = fieldsVal; } }); if (fieldsVal.length > 0) { Object.keys(compFnMap).forEach(function (key) { var _a; if (key.startsWith('Form')) { if ((_a = compFnMap === null || compFnMap === void 0 ? void 0 : compFnMap[key]) === null || _a === void 0 ? void 0 : _a.validateFormAndScroll) { compFnMap[key].validateFormAndScroll(false); } else { addToAwaitQueue === null || addToAwaitQueue === void 0 ? void 0 : addToAwaitQueue(key, 'validateFormAndScroll', false); } } }); } } break; default: break; } }); } } if (!isExecuteActions && Array.isArray(executedActionsMap[id])) { var executedActions = executedActionsMap[id]; executedActions.forEach(function (action) { var _a, _b, _c, _d; var _ref22 = action || {}, type = _ref22.type, fields = _ref22.fields; switch (type) { case 'hide': if (Array.isArray(fields)) { fields.forEach(function (key) { var _a; if ((_a = compFnMap === null || compFnMap === void 0 ? void 0 : compFnMap[key]) === null || _a === void 0 ? void 0 : _a.setVisible) { compFnMap[key].setVisible(true); } else { addToAwaitQueue === null || addToAwaitQueue === void 0 ? void 0 : addToAwaitQueue(key, 'setVisible', true); } }); } var SubFormShowIds = []; Object.entries(SubFormChildrenIdsMap).forEach(function (_ref23) { var _ref24 = _slicedToArray(_ref23, 2), key = _ref24[0], value = _ref24[1]; var _a, _b; if (isAnyItemInArray(value, fields)) { SubFormShowIds.push(key); if ((_a = compFnMap === null || compFnMap === void 0 ? void 0 : compFnMap[key]) === null || _a === void 0 ? void 0 : _a.setVisible) { compFnMap[key].setVisible(true); } else { addToAwaitQueue === null || addToAwaitQueue === void 0 ? void 0 : addToAwaitQueue(key, 'setVisible', true); } if ((_b = compFnMap === null || compFnMap === void 0 ? void 0 : compFnMap[key]) === null || _b === void 0 ? void 0 : _b.setSubFormFieldShow) { compFnMap[key].setSubFormFieldShow(fields); } else { addToAwaitQueue === null || addToAwaitQueue === void 0 ? void 0 : addToAwaitQueue(key, 'setSubFormFieldShow', fields); } } }); var WFViewShowIds = []; Object.entries(WFViewChildrenIdsMap).forEach(function (_ref25) { var _ref26 = _slicedToArray(_ref25, 2), key = _ref26[0], value = _ref26[1]; var _a; if (isAnyItemInArray(value, fields)) { WFViewShowIds.push(key); if ((_a = compFnMap === null || compFnMap === void 0 ? void 0 : compFnMap[key]) === null || _a === void 0 ? void 0 : _a.setVisible) { compFnMap[key].setVisible(true); } else { addToAwaitQueue === null || addToAwaitQueue === void 0 ? void 0 : addToAwaitQueue(key, 'setVisible', true); } } }); var displayedWFTabPaneIds = []; var WFTabShowId = ''; Object.entries(WFTabPaneChildrenIdsMap).forEach(function (_ref27) { var _ref28 = _slicedToArray(_ref27, 2), key = _ref28[0], value = _ref28[1]; WFTabShowId = WFTabPaneFatherIdMap[key]; if (isAnyItemInArray(value, [].concat(WFViewShowIds, SubFormShowIds, _toConsumableArray(fields)))) { displayedWFTabPaneIds.push(key); } }); if (displayedWFTabPaneIds.length > 0) { displayedWFTabPaneIds.forEach(function (WFTabPaneId) { var _a; if ((_a = compFnMap === null || compFnMap === void 0 ? void 0 : compFnMap[WFTabPaneId]) === null || _a === void 0 ? void 0 : _a.setVisible) { compFnMap[WFTabPaneId].setVisible(true); } else { addToAwaitQueue === null || addToAwaitQueue === void 0 ? void 0 : addToAwaitQueue(WFTabPaneId, 'setVisible', true); } }); if ((_a = compFnMap === null || compFnMap === void 0 ? void 0 : compFnMap[WFTabShowId]) === null || _a === void 0 ? void 0 : _a.addDisPlayWFTabPaneIds) { compFnMap[WFTabShowId].addDisPlayWFTabPaneIds(displayedWFTabPaneIds); } else { addToAwaitQueue === null || addToAwaitQueue === void 0 ? void 0 : addToAwaitQueue(WFTabShowId, 'addDisPlayWFTabPaneIds', displayedWFTabPaneIds); } if ((_b = compFnMap === null || compFnMap === void 0 ? void 0 : compFnMap[WFTabShowId]) === null || _b === void 0 ? void 0 : _b.setVisible) { compFnMap[WFTabShowId].setVisible(true); } else { addToAwaitQueue === null || addToAwaitQueue === void 0 ? void 0 : addToAwaitQueue(WFTabShowId, 'setVisible', true); } } break; case 'show': if (Array.isArray(fields)) { fields.forEach(function (key) { var _a; if ((_a = compFnMap === null || compFnMap === void 0 ? void 0 : compFnMap[key]) === null || _a === void 0 ? void 0 : _a.setVisible) { compFnMap[key].setVisible(false); } else { addToAwaitQueue === null || addToAwaitQueue === void 0 ? void 0 : addToAwaitQueue(key, 'setVisible', false); } }); } var SubFormHideIds = []; Object.entries(SubFormChildrenIdsMap).forEach(function (_ref29) { var _ref30 = _slicedToArray(_ref29, 2), key = _ref30[0], value = _ref30[1]; var _a, _b; if (areAllItemsInArray(value, fields)) { SubFormHideIds.push(key); if ((_a = compFnMap === null || compFnMap === void 0 ? void 0 : compFnMap[key]) === null || _a === void 0 ? void 0 : _a.setVisible) { compFnMap[key].setVisible(false); } else { addToAwaitQueue === null || addToAwaitQueue === void 0 ? void 0 : addToAwaitQueue(key, 'setVisible', false); } } else if ((_b = compFnMap === null || compFnMap === void 0 ? void 0 : compFnMap[key]) === null || _b === void 0 ? void 0 : _b.setSubFormFieldHidden) { compFnMap[key].setSubFormFieldHidden(fields); } else { addToAwaitQueue === null || addToAwaitQueue === void 0 ? void 0 : addToAwaitQueue(key, 'setSubFormFieldHidden', fields); } }); var WFViewHideIds = []; Object.entries(WFViewChildrenIdsMap).forEach(function (_ref31) { var _ref32 = _slicedToArray(_ref31, 2), key = _ref32[0], value = _ref32[1]; var _a; if (areAllItemsInArray(value, fields)) { WFViewHideIds.push(key); if ((_a = compFnMap === null || compFnMap === void 0 ? void 0 : compFnMap[key]) === null || _a === void 0 ? void 0 : _a.setVisible) { compFnMap[key].setVisible(false); } else { addToAwaitQueue === null || addToAwaitQueue === void 0 ? void 0 : addToAwaitQueue(key, 'setVisible', false); } } }); var hiddenWFTabPaneIds = []; var WFTabId = ''; Object.entries(WFTabPaneChildrenIdsMap).forEach(function (_ref33) { var _ref34 = _slicedToArray(_ref33, 2), key = _ref34[0], value = _ref34[1]; WFTabId = WFTabPaneFatherIdMap[key]; if (areAllItemsInArray(value, [].concat(WFViewHideIds, SubFormHideIds, _toConsumableArray(fields)))) { hiddenWFTabPaneIds.push(key); } }); if (hiddenWFTabPaneIds.length > 0) { if ((_c = compFnMap === null || compFnMap === void 0 ? void 0 : compFnMap[WFTabId]) === null || _c === void 0 ? void 0 : _c.removeDisPlayWFTabPaneIds) { compFnMap[WFTabId].removeDisPlayWFTabPaneIds(hiddenWFTabPaneIds); } else { addToAwaitQueue === null || addToAwaitQueue === void 0 ? void 0 : addToAwaitQueue(WFTabId, 'removeDisPlayWFTabPaneIds', hiddenWFTabPaneIds); } } if (areAllItemsInArray(WFTabNoHideIdsList, hiddenWFTabPaneIds)) { if ((_d = compFnMap === null || compFnMap === void 0 ? void 0 : compFnMap[WFTabId]) === null || _d === void 0 ? void 0 : _d.setVisible) { compFnMap[WFTabId].setVisible(false); } else { addToAwaitQueue === null || addToAwaitQueue === void 0 ? void 0 : addToAwaitQueue(WFTabId, 'setVisible', false); } } break; case 'editable': if (Array.isArray(fields)) { fields.forEach(function (key) { var _a; if ((_a = compFnMap === null || compFnMap === void 0 ? void 0 : compFnMap[key]) === null || _a === void 0 ? void 0 : _a.setDisabled) { compFnMap[key].setDisabled(true); } else { addToAwaitQueue === null || addToAwaitQueue === void 0 ? void 0 : addToAwaitQueue(key, 'setDisabled', true); } }); } Object.entries(SubFormChildrenIdsMap).forEach(function (_ref35) { var _ref36 = _slicedToArray(_ref35, 2), key = _ref36[0], value = _ref36[1]; var _a, _b; if (areAllItemsInArray(value, fields)) { if ((_a = compFnMap === null || compFnMap === void 0 ? void 0 : compFnMap[key]) === null || _a === void 0 ? void 0 : _a.setDisabled) { compFnMap[key].setDisabled(true); } else { addToAwaitQueue === null || addToAwaitQueue === void 0 ? void 0 : addToAwaitQueue(key, 'setDisabled', true); } } else if ((_b = compFnMap === null || compFnMap === void 0 ? void 0 : compFnMap[key]) === null || _b === void 0 ? void 0 : _b.setSubFormFieldDisabled) { compFnMap[key].setSubFormFieldDisabled(fields); } else { addToAwaitQueue === null || addToAwaitQueue === void 0 ? void 0 : addToAwaitQueue(key, 'setSubFormFieldDisabled', fields); } }); break; case 'readonly': if (Array.isArray(fields)) { fields.forEach(function (key) { var _a, _b; if ((_a = compFnMap === null || compFnMap === void 0 ? void 0 : compFnMap[key]) === null || _a === void 0 ? void 0 : _a.setReadOnly) { compFnMap[key].setReadOnly(false); } else { addToAwaitQueue === null || addToAwaitQueue === void 0 ? void 0 : addToAwaitQueue(key, 'setReadOnly', false); } if ((_b = compFnMap === null || compFnMap === void 0 ? void 0 : compFnMap[key]) === null || _b === void 0 ? void 0 : _b.setDisabled) { compFnMap[key].setDisabled(false); } else { addToAwaitQueue === null || addToAwaitQueue === void 0 ? void 0 : addToAwaitQueue(key, 'setDisabled', false); } }); } Object.entries(SubFormChildrenIdsMap).forEach(function (_ref37) { var _ref38 = _slicedToArray(_ref37, 2), key = _ref38[0], value = _ref38[1]; var _a, _b, _c; if (areAllItemsInArray(value, fields)) { if ((_a = compFnMap === null || compFnMap === void 0 ? void 0 : compFnMap[key]) === null || _a === void 0 ? void 0 : _a.setReadOnly) { compFnMap[key].setReadOnly(false); } else { addToAwaitQueue === null || addToAwaitQueue === void 0 ? void 0 : addToAwaitQueue(key, 'setReadOnly', false); } if ((_b = compFnMap === null || compFnMap === void 0 ? void 0 : compFnMap[key]) === null || _b === void 0 ? void 0 : _b.setDisabled) { compFnMap[key].setDisabled(false); } else { addToAwaitQueue === null || addToAwaitQueue === void 0 ? void 0 : addToAwaitQueue(key, 'setDisabled', false); } } else if ((_c = compFnMap === null || compFnMap === void 0 ? void 0 : compFnMap[key]) === null || _c === void 0 ? void 0 : _c.setSubFormFieldEditable) { compFnMap[key].setSubFormFieldEditable(fields); } else { addToAwaitQueue === null || addToAwaitQueue === void 0 ? void 0 : addToAwaitQueue(key, 'setSubFormFieldEditable', fields); } }); break; case 'required': if (Array.isArray(fields)) { fields.forEach(function (key) { var _a; if ((_a = compFnMap === null || compFnMap === void 0 ? void 0 : compFnMap[key]) === null || _a === void 0 ? void 0 : _a.setRequired) { compFnMap[key].setRequired(false); } else { addToAwaitQueue === null || addToAwaitQueue === void 0 ? void 0 : addToAwaitQueue(key, 'setRequired', false); } }); } Object.entries(SubFormChildrenIdsMap).forEach(function (_ref39) { var _ref40 = _slicedToArray(_ref39, 2), key = _ref40[0], value = _ref40[1]; var _a, _b; if (areAllItemsInArray(value, fields)) { if ((_a = compFnMap === null || compFnMap === void 0 ? void 0 : compFnMap[key]) === null || _a === void 0 ? void 0 : _a.setRequired) { compFnMap[key].setRequired(false); } else { addToAwaitQueue === null || addToAwaitQueue === void 0 ? void 0 : addToAwaitQueue(key, 'setRequired', false); } } else if ((_b = compFnMap === null || compFnMap === void 0 ? void 0 : compFnMap[key]) === null || _b === void 0 ? void 0 : _b.setSubFormFieldNoRequired) { compFnMap[key].setSubFormFieldNoRequired(fields); } else { addToAwaitQueue === null || addToAwaitQueue === void 0 ? void 0 : addToAwaitQueue(key, 'setSubFormFieldNoRequired', fields); } }); break; case 'prompt': if (Array.isArray(fields)) {