UNPKG

oadp-material

Version:
383 lines (379 loc) 14.4 kB
import _extends from "@babel/runtime/helpers/extends"; import { common } from '@alilc/lowcode-engine'; var OadpEntityButtonReadConditionMeta = { "componentName": "OadpEntityButtonReadCondition", "title": "实体条件查询", "category": "高级组件", "group": "低代码组件", "docUrl": "", "screenshot": "https://img.alicdn.com/imgextra/i1/O1CN01O4Oshp1RA6Z0sFZ6h_!!6000000002070-55-tps-56-56.svg", "devMode": "proCode", "npm": { "package": "oadp-material", "version": "{{version}}", "exportName": "OadpEntityButtonReadCondition", "main": "src/index.tsx", "destructuring": true, "subName": "" }, "configure": { "props": [{ "name": "DataSetting", "title": "数据设置", "type": "group", "display": "block", "items": [{ "name": "label", "title": { "label": { "type": "i18n", "zh_CN": "标题", "en_US": "Label" }, "tip": { "type": "i18n", "zh_CN": "属性: label | 说明: 标题", "en_US": "prop: label | description: label content" } }, "setter": "StringSetter", "description": "标题" }, { "name": "name", "title": { "label": { "type": "i18n", "zh_CN": "表单标识", "en_US": "Name" }, "tip": { "type": "i18n", "zh_CN": "属性: name | 说明: 表单标识", "en_US": "prop: name | description: switch name" } }, "setter": "StringSetter", "supportVariable": false }, { "name": "id", "title": { "label": { "type": "i18n", "zh_CN": "唯一标识", "en_US": "ID" }, "tip": { "type": "i18n", "zh_CN": "属性: id | 说明: 唯一标识", "en_US": "prop: id | description: switch id" } }, "setter": "StringSetter" }, { "name": "entity", "title": { "label": { "type": "i18n", "en-US": "Entity", "zh-CN": "绑定实体" }, "tip": { "type": "i18n", "zh_CN": "属性: entity | 说明:绑定实体", "en_US": "prop: entity | description: Set Entity." } }, "description": "绑定实体", "setter": "OadpEntitySetter", "supportVariable": true }, { "name": "tableComponentRefId", "title": { "label": { "type": "i18n", "zh_CN": "联动表格", "en_US": "Bind Table Component" }, "tip": { "type": "i18n", "zh_CN": "属性: tableComponentRefId | 说明: 联动表格", "en_US": "prop: tableComponentRefId | description: Bind Table Component" } }, "setter": "StringSetter" }, { "name": "defaultValue", "title": { "label": { "type": "i18n", "zh_CN": "默认条件", "en_US": "Default Condition" }, "tip": { "type": "i18n", "zh_CN": "属性: defaultValue | 说明: 默认条件", "en_US": "prop: defaultValue | description: Default Condition" } }, "setter": { "componentName": "OadpEntityFilterSetter", "props": function props(target) { return { "entity": target.parent.getPropValue('entity') }; }, "initialValue": { "operator": "and", "value": [{ "attribute": "", "operator": "and", "value": "" }] } }, "supportVariable": true, "description": "默认条件" }] }, { "name": "DisplaySetting", "title": "显示设置", "type": "group", "display": "block", "items": [{ "name": "type", "title": { "label": { "type": "i18n", "en-US": "type", "zh-CN": "类型" }, "tip": "type | 类型" }, "description": "类型", "setter": { "componentName": "RadioGroupSetter", "props": { "dataSource": [{ "label": "主按钮", "value": "primary" }, { "label": "次按钮", "value": "secondary" }, { "label": "普通按钮", "value": "normal" }], "options": [{ "label": "主按钮", "value": "primary" }, { "label": "次按钮", "value": "secondary" }, { "label": "普通按钮", "value": "normal" }] }, "initialValue": "primary" } }, { "title": { "label": { "type": "i18n", "en-US": "size", "zh-CN": "尺寸" }, "tip": "size | 尺寸" }, "name": "size", "description": "尺寸", "setter": { "componentName": "RadioGroupSetter", "props": { "dataSource": [{ "label": "中", "value": "medium" }, { "label": "大", "value": "large" }], "options": [{ "label": "中", "value": "medium" }, { "label": "大", "value": "large" }] }, "initialValue": "medium" } }] }, { "name": "InteractionSetting", "title": "交互设置", "type": "group", "display": "block", "items": [{ "name": "queryAttributeBar", "title": { "label": { "type": "i18n", "en-US": "Query Attribute Bar", "zh-CN": "查询属性栏" }, "tip": { "type": "i18n", "zh_CN": "属性: queryAttributeBar | 说明: 查询属性栏", "en_US": "prop: queryAttributeBar | description: Query Attribute Bar" } }, "description": "查询属性栏", "setter": { "componentName": "SlotSetter", "isRequired": true, "initialValue": { "type": "JSSlot", "params": ["value", "index", "record"], "value": [] } }, "condition": function condition() { return true; } }, { "title": { "label": { "type": "i18n", "en-US": "disabled", "zh-CN": "是否禁用" }, "tip": "disabled | 是否禁用" }, "name": "disabled", "description": "是否禁用", "setter": { "componentName": "BoolSetter", "isRequired": false, "initialValue": false } }] }], "supports": { "events": ["onClick"], "style": true }, "component": { "isContainer": true }, "advanced": { "callbacks": { "onNodeAdd": function onNodeAdd(dragment, currentNode) { console.log('OadpEntityButtonReadCondition onNodeAdd with ', dragment, currentNode); // 检查 dragment 是否为 null if (!dragment) { console.error('dragment is null'); return; } // 检查 currentNode 是否为 null if (!currentNode) { console.error('currentNode is null'); return; } // 检查 currentNode.document 是否为 null if (!currentNode.document) { console.error('currentNode.document is null'); return; } var dragmentSchema = dragment === null || dragment === void 0 ? void 0 : dragment.exportSchema(common.designerCabin.TransformStage.Save); console.log('OadpEntityButtonReadCondition dragment.exportSchema()', dragmentSchema); if (dragmentSchema.componentName === 'OadpEntityButtonCreate' || dragmentSchema.componentName === 'OadpEntityButtonDelete' || dragmentSchema.componentName === 'OadpEntityButtonUpdate' || dragmentSchema.componentName === 'OadpEntityButtonReadFast' || dragmentSchema.componentName === 'OadpEntityButtonReadCondition' || dragmentSchema.componentName === 'OadpEntityButtonReadRule' || dragmentSchema.componentName === 'OadpEntityButtonBatchDelete' || dragmentSchema.componentName === 'OadpEntityButtonSettingTable' || dragmentSchema.componentName === 'OadpEntityPagination') { var _currentNodeSchema$pr; var currentNodeSchema = currentNode === null || currentNode === void 0 ? void 0 : currentNode.exportSchema(common.designerCabin.TransformStage.Save); console.log('OadpEntityButtonReadCondition currentNodeSchema ', currentNodeSchema); var entity = currentNodeSchema === null || currentNodeSchema === void 0 ? void 0 : (_currentNodeSchema$pr = currentNodeSchema.props) === null || _currentNodeSchema$pr === void 0 ? void 0 : _currentNodeSchema$pr.entity; dragment.setPropValue('entity', entity); dragment.setPropValue('tableComponentRefId', currentNodeSchema.id); console.log('OadpEntityButtonReadCondition dragment update exportSchema()', dragment === null || dragment === void 0 ? void 0 : dragment.exportSchema(common.designerCabin.TransformStage.Save)); } if (dragmentSchema.componentName === 'OadpAttribute') { var _dragmentSchema$props, _dragmentSchema$props2, _dragmentSchema$props3, _dragmentSchema$props4, _dragmentSchema$props5, _dragmentSchema$props6, _dragmentSchema$props7, _dragmentSchema$props8; var name = (_dragmentSchema$props = dragmentSchema === null || dragmentSchema === void 0 ? void 0 : (_dragmentSchema$props2 = dragmentSchema.props) === null || _dragmentSchema$props2 === void 0 ? void 0 : _dragmentSchema$props2.name) !== null && _dragmentSchema$props !== void 0 ? _dragmentSchema$props : "默认名称"; var logicalName = (_dragmentSchema$props3 = dragmentSchema === null || dragmentSchema === void 0 ? void 0 : (_dragmentSchema$props4 = dragmentSchema.props) === null || _dragmentSchema$props4 === void 0 ? void 0 : _dragmentSchema$props4.logicalName) !== null && _dragmentSchema$props3 !== void 0 ? _dragmentSchema$props3 : "默认逻辑名称"; var attributeType = (_dragmentSchema$props5 = dragmentSchema === null || dragmentSchema === void 0 ? void 0 : (_dragmentSchema$props6 = dragmentSchema.props) === null || _dragmentSchema$props6 === void 0 ? void 0 : _dragmentSchema$props6.attributeType) !== null && _dragmentSchema$props5 !== void 0 ? _dragmentSchema$props5 : "STRING"; var referEntity = dragmentSchema === null || dragmentSchema === void 0 ? void 0 : (_dragmentSchema$props7 = dragmentSchema.props) === null || _dragmentSchema$props7 === void 0 ? void 0 : _dragmentSchema$props7.referEntity; var referAttribute = dragmentSchema === null || dragmentSchema === void 0 ? void 0 : (_dragmentSchema$props8 = dragmentSchema.props) === null || _dragmentSchema$props8 === void 0 ? void 0 : _dragmentSchema$props8.referAttribute; var dataIndex = logicalName; if (attributeType === "REFER" && referAttribute && typeof referAttribute === 'object' && 'logicalName' in referAttribute) { dataIndex = logicalName + '.name'; } console.log('OadpEntityButtonReadCondition dragment.exportSchema() dataIndex', dataIndex); // 如果拖拽到表格内,需要转换元素为表格列 var layoutPNode = currentNode.document.createNode({ "componentName": "OadpTableColumn", "props": { "title": name, "dataIndex": dataIndex, "htmlTitle": logicalName, "alignHeader": "center", "width": 200, "align": "center", "wordBreak": "all" } }); console.log('OadpEntityButtonReadCondition onNodeAdd layoutPNode', layoutPNode); // 检查 layoutPNode 是否为 null if (!layoutPNode) { console.error('OadpEntityButtonReadCondition layoutPNode is null'); return; } console.log('OadpEntityButtonReadCondition onNodeAdd currentNode', currentNode); // 当前dragment还未添加入node子节点,需要setTimeout处理 setTimeout(function () { currentNode.replaceChild(dragment, layoutPNode.exportSchema(common.designerCabin.TransformStage.Save)); }, 1); } } } } } }; var snippets = [{ "title": "实体条件查询", "screenshot": "https://img.alicdn.com/imgextra/i1/O1CN01O4Oshp1RA6Z0sFZ6h_!!6000000002070-55-tps-56-56.svg", "schema": { "componentName": "OadpEntityButtonReadCondition", "props": { "label": "条件查询", "type": "primary", "size": "medium", "disabled": false, "onClick": { "type": "JSExpression", "value": "function() {\n const self = this;\n try {\n return (function (v,e){ return this.utils.eventUtil.onReadRule.apply(this,Array.prototype.slice.call(arguments).concat([{\n\t\"schema\": this.schema\n}])) }).apply(self, arguments);\n } catch(e) {\n console.warn('call function which parsed by lowcode failed: ', e);\n return e.message;\n }\n }" }, "__events": { "eventDataList": [{ "type": "componentEvent", "name": "onClick", "relatedEventName": "onClick", "paramStr": "{\n\t\"schema\": this.schema\n}" }], "eventList": [{ "name": "onClick", "disabled": true }] }, "style": { "marginRight": "5px" } }, "hidden": false, "title": "", "isLocked": false, "condition": true, "conditionGroup": "" } }]; export default _extends({}, OadpEntityButtonReadConditionMeta, { snippets: snippets });