update event bind schema

This commit is contained in:
zude.hzd 2020-07-23 11:42:12 +08:00
parent 448a0affe8
commit f9bfb0a7c7
3 changed files with 116 additions and 108 deletions

View File

@ -5,7 +5,7 @@
"ref":"outterView", "ref":"outterView",
"autoLoading":true, "autoLoading":true,
"style":{ "style":{
"padding": "0 5px 0 5px" "padding":"0 5px 0 5px"
} }
}, },
"fileName":"test", "fileName":"test",
@ -14,7 +14,8 @@
] ]
}, },
"state":{ "state":{
"text":"outter" "text":"outter",
"isShowDialog":false
}, },
"css":"body {font-size: 12px;} .botton{width:100px;color:#ff00ff}", "css":"body {font-size: 12px;} .botton{width:100px;color:#ff00ff}",
"lifeCycles":{ "lifeCycles":{
@ -34,13 +35,13 @@
}, },
"onClick":{ "onClick":{
"type":"JSFunction", "type":"JSFunction",
"value":"function(){\n\t}" "value":"function(){\n this.setState({\n isShowDialog:true\n })\n\t}"
} }
}, },
"children":[ "children":[
{ {
"componentName":"Box", "componentName":"Box",
"id":"node_dockcviv8fo2k", "id":"node_dockcy8n9xed",
"props":{ "props":{
"style":{ "style":{
"backgroundColor":"rgba(31,56,88,0.1)", "backgroundColor":"rgba(31,56,88,0.1)",
@ -50,7 +51,7 @@
"children":[ "children":[
{ {
"componentName":"Box", "componentName":"Box",
"id":"node_dockcviv8fo2l", "id":"node_dockcy8n9xee",
"props":{ "props":{
"style":{ "style":{
"padding":"12px 12px 12px 12px", "padding":"12px 12px 12px 12px",
@ -60,7 +61,7 @@
"children":[ "children":[
{ {
"componentName":"Breadcrumb", "componentName":"Breadcrumb",
"id":"node_dockcviv8fo2m", "id":"node_dockcy8n9xef",
"props":{ "props":{
"prefix":"next-", "prefix":"next-",
"maxNode":100, "maxNode":100,
@ -69,49 +70,45 @@
"children":[ "children":[
{ {
"componentName":"Breadcrumb.Item", "componentName":"Breadcrumb.Item",
"id":"node_dockcviv8fo2n", "id":"node_dockcy8n9xeg",
"props":{ "props":{
"prefix":"next-" "prefix":"next-"
}, },
"children":[ "children":[
"首页" "首页"]
]
}, },
{ {
"componentName":"Breadcrumb.Item", "componentName":"Breadcrumb.Item",
"id":"node_dockcviv8fo2q", "id":"node_dockcy8n9xei",
"props":{ "props":{
"prefix":"next-" "prefix":"next-"
}, },
"children":[ "children":[
"品质中台" "品质中台"]
]
}, },
{ {
"componentName":"Breadcrumb.Item", "componentName":"Breadcrumb.Item",
"id":"node_dockcviv8fo2t", "id":"node_dockcy8n9xek",
"props":{ "props":{
"prefix":"next-" "prefix":"next-"
}, },
"children":[ "children":[
"商家品质页面管理" "商家品质页面管理"]
]
}, },
{ {
"componentName":"Breadcrumb.Item", "componentName":"Breadcrumb.Item",
"id":"node_dockcy8n9xem",
"props":{ "props":{
"prefix":"next-" "prefix":"next-"
}, },
"children":[ "children":[
"质检知识条配置" "质检知识条配置"]
] }]
}
]
}] }]
}, },
{ {
"componentName":"Box", "componentName":"Box",
"id":"node_dockcviv8fo2w", "id":"node_dockcy8n9xeo",
"props":{ "props":{
"style":{ "style":{
"marginTop":"12px", "marginTop":"12px",
@ -121,29 +118,31 @@
"children":[ "children":[
{ {
"componentName":"Form", "componentName":"Form",
"id":"node_dockcviv8fo2x", "id":"node_dockcy8n9xep",
"props":{ "props":{
"inline":true, "inline":true,
"style":{ "style":{
"marginTop":"12px", "marginTop":"12px",
"marginRight":"12px", "marginRight":"12px",
"marginLeft":"12px" "marginLeft":"12px"
} },
"__events":[
]
}, },
"children":[ "children":[
{ {
"componentName":"Form.Item", "componentName":"Form.Item",
"id":"node_dockcviv8fo2y", "id":"node_dockcy8n9xeq",
"props":{ "props":{
"style":{ "style":{
"margin-bottom": "0" "margin-bottom":"0"
}, },
"label":"类目名:" "label":"类目名:"
}, },
"children":[ "children":[
{ {
"componentName":"Select", "componentName":"Select",
"id":"node_dockcviv8fo2z", "id":"node_dockcy8n9xer",
"props":{ "props":{
"mode":"single", "mode":"single",
"hasArrow":true, "hasArrow":true,
@ -156,17 +155,17 @@
}, },
{ {
"componentName":"Form.Item", "componentName":"Form.Item",
"id":"node_dockcviv8fo30", "id":"node_dockcy8n9xes",
"props":{ "props":{
"style":{ "style":{
"margin-bottom": "0" "margin-bottom":"0"
}, },
"label":"项目类型:" "label":"项目类型:"
}, },
"children":[ "children":[
{ {
"componentName":"Select", "componentName":"Select",
"id":"node_dockcviv8fo31", "id":"node_dockcy8n9xet",
"props":{ "props":{
"mode":"single", "mode":"single",
"hasArrow":true, "hasArrow":true,
@ -179,17 +178,17 @@
}, },
{ {
"componentName":"Form.Item", "componentName":"Form.Item",
"id":"node_dockcviv8fo32", "id":"node_dockcy8n9xeu",
"props":{ "props":{
"style":{ "style":{
"margin-bottom": "0" "margin-bottom":"0"
}, },
"label":"项目 ID" "label":"项目 ID"
}, },
"children":[ "children":[
{ {
"componentName":"Input", "componentName":"Input",
"id":"node_dockcviv8fo33", "id":"node_dockcy8n9xev",
"props":{ "props":{
"hasBorder":true, "hasBorder":true,
"size":"medium", "size":"medium",
@ -202,13 +201,13 @@
}, },
{ {
"componentName":"Button.Group", "componentName":"Button.Group",
"id":"node_dockcviv8fo34", "id":"node_dockcy8n9xew",
"props":{ "props":{
}, },
"children":[ "children":[
{ {
"componentName":"Button", "componentName":"Button",
"id":"node_dockcviv8fo35", "id":"node_dockcy8n9xex",
"props":{ "props":{
"type":"primary", "type":"primary",
"style":{ "style":{
@ -219,7 +218,7 @@
"children":[ "children":[
{ {
"componentName":"Icon", "componentName":"Icon",
"id":"node_dockcviv8fo36", "id":"node_dockcy8n9xey",
"props":{ "props":{
"type":"success" "type":"success"
} }
@ -228,7 +227,7 @@
}, },
{ {
"componentName":"Button", "componentName":"Button",
"id":"node_dockcviv8fo38", "id":"node_dockcy8n9xe10",
"props":{ "props":{
"type":"normal", "type":"normal",
"style":{ "style":{
@ -244,7 +243,7 @@
}, },
{ {
"componentName":"Box", "componentName":"Box",
"id":"node_dockcviv8fo3a", "id":"node_dockcy8n9xe12",
"props":{ "props":{
"style":{ "style":{
"justifyContent":"flex-end", "justifyContent":"flex-end",
@ -257,7 +256,7 @@
"children":[ "children":[
{ {
"componentName":"Button", "componentName":"Button",
"id":"node_dockcviv8fo3b", "id":"node_dockcy8n9xe13",
"props":{ "props":{
"prefix":"next-", "prefix":"next-",
"type":"primary", "type":"primary",
@ -277,6 +276,16 @@
"relatedEventName":"onClick" "relatedEventName":"onClick"
} }
} }
},
"__events":[
{
"type":"componentEvent",
"name":"onClick",
"relatedEventName":"onClick"
}],
"onClick":{
"type":"JSFunction",
"value":"function(){ this.onClick() }"
} }
}, },
"children":[ "children":[
@ -285,7 +294,7 @@
}, },
{ {
"componentName":"Box", "componentName":"Box",
"id":"node_dockcviv8fo3d", "id":"node_dockcy8n9xe15",
"props":{ "props":{
"style":{ "style":{
"backgroundColor":"#ffffff" "backgroundColor":"#ffffff"
@ -294,29 +303,29 @@
"children":[ "children":[
{ {
"componentName":"Table", "componentName":"Table",
"id":"node_dockcviv8fo3e", "id":"node_dockcy8n9xe16",
"props":{ "props":{
"dataSource":[ "dataSource":[
{ {
"firstCategory": "其他", "firstCategory":"其他",
"secondCategory": "新品预览", "secondCategory":"新品预览",
"leafCategory": "", "leafCategory":"",
"projectType": "标识判断", "projectType":"标识判断",
"projectId": "", "projectId":"",
"title": "其他类目->新品预览类目类型知识库", "title":"其他类目->新品预览类目类型知识库",
"url": "其他", "url":"其他",
"operation": "编辑" "operation":"编辑"
},{ },
"firstCategory": "其他", {
"secondCategory": "新品预览", "firstCategory":"其他",
"leafCategory": "", "secondCategory":"新品预览",
"projectType": "", "leafCategory":"",
"projectId": "1", "projectType":"",
"title": "其他类目->新品预览项目Id知识库", "projectId":"1",
"url": "其他", "title":"其他类目->新品预览项目Id知识库",
"operation": "编辑" "url":"其他",
} "operation":"编辑"
], }],
"size":"medium", "size":"medium",
"prefix":"next-", "prefix":"next-",
"hasBorder":true, "hasBorder":true,
@ -334,67 +343,73 @@
"children":[ "children":[
{ {
"componentName":"Table.Column", "componentName":"Table.Column",
"id":"node_dockcviv8fo3f", "id":"node_dockcy8n9xe17",
"props":{ "props":{
"title":"一级类目", "title":"一级类目",
"dataIndex": "firstCategory" "dataIndex":"firstCategory"
} }
},{ },
{
"componentName":"Table.Column", "componentName":"Table.Column",
"id":"node_dockcviv8fo41", "id":"node_dockcy8n9xe18",
"props":{ "props":{
"title":"二级类目", "title":"二级类目",
"dataIndex": "secondCategory" "dataIndex":"secondCategory"
} }
},{ },
{
"componentName":"Table.Column", "componentName":"Table.Column",
"id":"node_dockcviv8fo42", "id":"node_dockcy8n9xe19",
"props":{ "props":{
"title":"叶子类目", "title":"叶子类目",
"dataIndex": "leafCategory" "dataIndex":"leafCategory"
} }
},{ },
{
"componentName":"Table.Column", "componentName":"Table.Column",
"id":"node_dockcviv8fo43", "id":"node_dockcy8n9xe1a",
"props":{ "props":{
"title":"项目类型", "title":"项目类型",
"dataIndex": "projectType" "dataIndex":"projectType"
} }
},{ },
{
"componentName":"Table.Column", "componentName":"Table.Column",
"id":"node_dockcviv8fo44", "id":"node_dockcy8n9xe1b",
"props":{ "props":{
"title":"项目 ID", "title":"项目 ID",
"dataIndex": "projectId" "dataIndex":"projectId"
} }
},{ },
{
"componentName":"Table.Column", "componentName":"Table.Column",
"id":"node_dockcviv8fo45", "id":"node_dockcy8n9xe1c",
"props":{ "props":{
"title":"知识条标题", "title":"知识条标题",
"dataIndex": "title" "dataIndex":"title"
} }
},{ },
{
"componentName":"Table.Column", "componentName":"Table.Column",
"id":"node_dockcviv8fo46", "id":"node_dockcy8n9xe1d",
"props":{ "props":{
"title":"知识条链接", "title":"知识条链接",
"dataIndex": "url" "dataIndex":"url"
} }
},{ },
{
"componentName":"Table.Column", "componentName":"Table.Column",
"id":"node_dockcviv8fo47", "id":"node_dockcy8n9xe1e",
"props":{ "props":{
"title":"操作", "title":"操作",
"dataIndex": "operation" "dataIndex":"operation"
} }
} }]
]
}] }]
}, },
{ {
"componentName":"Box", "componentName":"Box",
"id":"node_dockcviv8fo3g", "id":"node_dockcy8n9xe1f",
"props":{ "props":{
"style":{ "style":{
"backgroundColor":"#ffffff", "backgroundColor":"#ffffff",
@ -404,7 +419,7 @@
"children":[ "children":[
{ {
"componentName":"Pagination", "componentName":"Pagination",
"id":"node_dockcviv8fo3h", "id":"node_dockcy8n9xe1g",
"props":{ "props":{
"prefix":"next-", "prefix":"next-",
"type":"normal", "type":"normal",
@ -426,7 +441,7 @@
}, },
{ {
"componentName":"Dialog", "componentName":"Dialog",
"id":"node_dockcviv8fo3i", "id":"node_dockcy8n9xe1h",
"props":{ "props":{
"prefix":"next-", "prefix":"next-",
"footerAlign":"right", "footerAlign":"right",
@ -437,7 +452,10 @@
"hasMask":true, "hasMask":true,
"align":"cc cc", "align":"cc cc",
"minMargin":40, "minMargin":40,
"visible":false, "visible":{
"type":"JSExpression",
"value":"this.state.isShowDialog"
},
"children":{ "children":{
"type":"JSSlot" "type":"JSSlot"
}, },

View File

@ -186,7 +186,7 @@ export default function(metadata: TransformedComponentMetadata): TransformedComp
title: { type: 'i18n', 'zh-CN': '事件', 'en-US': 'Events' }, title: { type: 'i18n', 'zh-CN': '事件', 'en-US': 'Events' },
items: [ items: [
{ {
name: 'events', name: '__events',
title: { type: 'i18n', 'zh-CN': '事件设置', 'en-US': 'Events' }, title: { type: 'i18n', 'zh-CN': '事件设置', 'en-US': 'Events' },
setter: { setter: {
componentName: 'EventsSetter', componentName: 'EventsSetter',
@ -195,25 +195,17 @@ export default function(metadata: TransformedComponentMetadata): TransformedComp
}, },
}, },
getValue(field: SettingTarget, val?: any[]) { getValue(field: SettingTarget, val?: any[]) {
let eventDataList = [] return val;
for (let key in val){
if (val[key].__eventData){
eventDataList.push(val[key].__eventData)
}
}
return eventDataList;
}, },
setValue(field: SettingTarget, eventDataList: any[]) { setValue(field: SettingTarget, eventDataList: any[]) {
eventDataList.map((item)=>{ eventDataList.map((item)=>{
field.setPropValue(item.name,{ field.parent.setPropValue(item.name,{
type: 'JSFunction', type: 'JSFunction',
value: `function(){ this.${item.relatedEventName}() }`, value: `function(){ this.${item.relatedEventName}() }`
__eventData:item
}) })
return item; return item;
}) })
return; return;
}, },
}, },

View File

@ -109,15 +109,13 @@ class Renderer extends Component<{ renderer: SimulatorRenderer }> {
viewProps._leaf = leaf; viewProps._leaf = leaf;
viewProps._componentName = leaf?.componentName; viewProps._componentName = leaf?.componentName;
// 如果是容器 && 无children && 高宽为空 增加一个占位容器,方便拖动 // 如果是容器 && 无children && 高宽为空 增加一个占位容器,方便拖动
if (leaf?.isContainer() && children == null && !viewProps.style){ if (leaf?.isContainer() && children == null){
Object.assign(viewProps, { children = <div style={{
style:{ height:'100px',
height:'100px', backgroundColor:'#f0f0f0',
backgroundColor:'#f0f0f0', borderColor:'#666666',
borderColor:'#666666', border: '1px dotted'
border: '1px dotted' }}></div>
}
})
} }
if (viewProps._componentName === 'Menu') { if (viewProps._componentName === 'Menu') {