low code平台建设的一些设计和思考
此篇来自我在团队内部做技术分享的文稿。
设计器画布
待补充ing
state: store.getState(), commit: store.commit, dispatch: store.dispatch, getters: store.getters,
vm.form.handleActionBefore({ actionType: "formSearch", targetWidget: item.options.target })
{
"key": "kuEXemrCZ",
"widget": "grid",
"hidden": false,
"option": {
"gutter": 0,
"align": "top",
"justify": "start"
},
"style": {
"margin-right": "auto",
"margin-left": "auto",
"background": [],
"container": {
"background-color": "",
"background": []
}
},
"label": {
"width": 80,
"position": "right",
"colon": false
},
"container": true,
"children": [
{
"span": 24,
"list": [
{
"key": "kab0Cd9ZP",
"widget": "select",
"hidden": false,
"option": {
"type": "static",
"url": "",
"adapter": "return data",
"dynamicData": [],
"data": [
{
"key": "A",
"value": "A"
},
{
"key": "B",
"value": "B"
}
],
"multiple": false,
"clearable": true
},
"style": {},
"name": "kab0Cd9ZP",
"type": "string",
"label": "下拉框",
"description": "",
"help": "",
"disabled": false,
"rules": [
{
"required": false,
"message": "必填",
"trigger": "change",
"type": "string"
}
],
"placeholder": "请选择",
"default": ""
},
{
"key": "k5G7mDbx3",
"widget": "button",
"hidden": false,
"option": {
"text": "提交",
"type": "primary",
"icon": "",
"long": false,
"ghost": false,
"shape": "square",
"script": ""
},
"style": {},
"disabled": false
}
]
}
],
"title": "",
"description": "",
"size": "default",
"logics": [
{
"type": "value",
"key": "kab0Cd9ZP",
"action": "=",
"value": "1",
"relation": "or",
"trigger": "prop",
"script": "",
"effects": [
{
"key": "k5G7mDbx3",
"properties": [
{
"key": "hidden",
"value": true
},
{
"key": "disabled",
"value": false
}
]
}
]
}
],
"store": {
"dicts": []
}
}
一个简单的递归渲染demo:
const render=(schema,params)=>{ schema=Array.isArray(schema)?schema:[schema]; const dom=schema.map((item,i)=>{ let {type,props,children}=item; type=(type||'div').trim(); const first=type.charAt(0); type=first.toUpperCase()===first?(components[type]||'div'):type; props={ key:i, ...formatProps(props,params), }; children=Array.isArray(children)?render(children,params):[formatChildren(children||props.children,params)??null]; return createElement(type,props,...children); }); return dom; }; <template> <div class="opes-form"> <component v-for="(formItem, index) in FormItems" :key="index + (formItem.gid ? formItem.gid : Math.random())" :is="formItem.type" :info="formItem" :taskId="taskId" :nodeId="nodeId" :processInstanceId="processInstanceId" :extraData="extraData" :commitInfoList="commitInfoList" @msg="$_msg(arguments[0], index, arguments[1])" ></component> </div> </template>