-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
d8e60ef
commit 9300d94
Showing
6 changed files
with
179 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,8 @@ | ||
/* | ||
* @Author: [email protected] | ||
* @Date: 2022-07-05 15:55:39 | ||
* @LastEditors: baozhoutao@steedos.com | ||
* @LastEditTime: 2023-04-12 14:24:09 | ||
* @LastEditors: 殷亮辉 yinlianghui@hotoa.com | ||
* @LastEditTime: 2023-04-12 23:24:23 | ||
* @Description: | ||
*/ | ||
import { fetchAPI, getUserId } from "./steedos.client"; | ||
|
@@ -503,6 +503,37 @@ export async function getRecordDetailSchema(objectName, appId, props = {}){ | |
} | ||
} | ||
|
||
export async function getRecordServiceSchema(objectName, appId, props = {}) { | ||
const uiSchema = await getUISchema(objectName); | ||
return { | ||
uiSchema, | ||
amisSchema: { | ||
"type": "service", | ||
"body": [], | ||
data: { | ||
"_master.objectName": "${objectName}", | ||
"_master.recordId": "${recordId}" | ||
}, | ||
onEvent: { | ||
"recordLoaded": { | ||
"actions": [ | ||
{ | ||
"actionType": "reload", | ||
"data": { | ||
"name": `\${record.${uiSchema.NAME_FIELD_KEY || 'name'}}`, | ||
"_master.record": `\${record}`, | ||
// 不清楚reload 如何给对象下的某个key复制, 所以此处重复设置_master的objectName、recordId | ||
"_master.objectName": "${objectName}", | ||
"_master.recordId": "${recordId}" | ||
} | ||
} | ||
] | ||
}, | ||
...props.onEvent | ||
} | ||
} | ||
} | ||
} | ||
|
||
// 获取单个相关表 | ||
export async function getObjectRelated( | ||
|
20 changes: 20 additions & 0 deletions
20
packages/@steedos-widgets/amis-object/src/amis/AmisRecordService.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
/* | ||
* @Author: [email protected] | ||
* @Date: 2022-12-08 10:32:17 | ||
* @LastEditors: 殷亮辉 [email protected] | ||
* @LastEditTime: 2023-04-12 23:59:26 | ||
* @Description: | ||
*/ | ||
|
||
import { getRecordServiceSchema } from '@steedos-widgets/amis-lib' | ||
|
||
export const AmisRecordService = async (props) => { | ||
// console.log(`AmisRecordService======>`, props) | ||
const { className, $schema, appId, objectApiName = "space_users", recordId, fields, body } = props; | ||
const schema = (await getRecordServiceSchema(objectApiName, appId)).amisSchema; | ||
schema.className = className; | ||
if (body) { | ||
schema.body = body; | ||
} | ||
return schema | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,8 @@ | ||
/* | ||
* @Author: [email protected] | ||
* @Date: 2022-08-31 16:32:35 | ||
* @LastEditors: baozhoutao@steedos.com | ||
* @LastEditTime: 2023-02-08 13:17:16 | ||
* @LastEditors: 殷亮辉 yinlianghui@hotoa.com | ||
* @LastEditTime: 2023-04-12 23:45:54 | ||
* @Description: | ||
*/ | ||
import './AmisObjectForm.less' | ||
|
@@ -13,6 +13,7 @@ export * from './AmisObjectTable'; | |
export * from './AmisObjectCalendar'; | ||
export * from './AmisRecordDetailHeader'; | ||
export * from './AmisRecordDetail'; | ||
export * from './AmisRecordService'; | ||
export * from './AmisRecordDetailRelatedList'; | ||
export * from './AmisRecordDetailRelatedLists'; | ||
export * from './AmisSelectUser'; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,8 @@ | ||
/* | ||
* @Author: [email protected] | ||
* @Date: 2022-08-31 16:32:35 | ||
* @LastEditors: baozhoutao@steedos.com | ||
* @LastEditTime: 2023-04-07 18:23:05 | ||
* @LastEditors: 殷亮辉 yinlianghui@hotoa.com | ||
* @LastEditTime: 2023-04-12 23:32:03 | ||
* @Description: | ||
*/ | ||
// import Hello from "./metas/Hello"; | ||
|
@@ -12,6 +12,7 @@ import AmisObjectCalendar from "./metas/AmisObjectCalendar"; | |
import AmisObjectTable from "./metas/AmisObjectTable"; | ||
import AmisRecordDetailHeader from "./metas/AmisRecordDetailHeader"; | ||
import AmisRecordDetail from "./metas/AmisRecordDetail"; | ||
import AmisRecordService from "./metas/AmisRecordService"; | ||
import AmisSelectUser from "./metas/AmisSelectUser"; | ||
import AmisRecordDetailRelatedList from "./metas/AmisRecordDetailRelatedList"; | ||
import AmisRecordDetailRelatedLists from "./metas/AmisRecordDetailRelatedLists"; | ||
|
@@ -59,7 +60,8 @@ const components = [ | |
AmisObjectTable, | ||
AmisRecordDetailRelatedList, | ||
AmisRecordDetailRelatedLists, | ||
AmisRecordDetail, | ||
AmisRecordDetail, | ||
AmisRecordService, | ||
AmisObjectCalendar, | ||
AmisObjectButton, | ||
AmisObjectFieldLookup, | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,7 +2,7 @@ | |
* @Author: [email protected] | ||
* @Date: 2022-08-31 16:32:35 | ||
* @LastEditors: 殷亮辉 [email protected] | ||
* @LastEditTime: 2023-04-10 22:41:41 | ||
* @LastEditTime: 2023-04-12 23:29:24 | ||
* @Description: | ||
*/ | ||
const config: any = { | ||
|
@@ -62,7 +62,7 @@ export default { | |
weight: 1, | ||
framework: "react" | ||
}, | ||
plugin: { | ||
plugin__disable: { | ||
rendererName: config.amis.name, | ||
$schema: '/schemas/UnkownSchema.json', | ||
name: config.title, | ||
|
116 changes: 116 additions & 0 deletions
116
packages/@steedos-widgets/amis-object/src/metas/AmisRecordService.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,116 @@ | ||
const config: any = { | ||
componentType: 'amisSchema', // amisSchema || react | ||
group: "华炎魔方", | ||
componentName: "AmisRecordService", | ||
title: "记录数据", | ||
docUrl: "", | ||
screenshot: "", | ||
npm: { | ||
package: "@steedos-widgets/amis-object", | ||
version: "{{version}}", | ||
exportName: "AmisRecordService", | ||
main: "", | ||
destructuring: true, | ||
subName: "" | ||
}, | ||
props: [ | ||
{ | ||
name: "objectApiName", | ||
propType: "string", | ||
description: '对象名称', | ||
}, | ||
{ | ||
name: "recordId", | ||
propType: "string", | ||
description: '记录Id', | ||
} | ||
], | ||
preview: { | ||
}, | ||
targets: ["steedos__RecordPage", "steedos__AppPage", "steedos__HomePage"], | ||
engines: ["amis"], | ||
// settings for amis. | ||
amis: { | ||
name: 'steedos-record-service', | ||
icon: "fa-fw fa fa-list-alt" | ||
} | ||
}; | ||
|
||
export default { | ||
...config, | ||
snippets: [ | ||
{ | ||
title: config.title, | ||
screenshot: "", | ||
schema: { | ||
componentName: config.componentName, | ||
props: config.preview | ||
} | ||
} | ||
], | ||
amis: { | ||
render: { | ||
type: config.amis.name, | ||
usage: "renderer", | ||
weight: 1, | ||
framework: "react" | ||
}, | ||
plugin: { | ||
rendererName: config.amis.name, | ||
$schema: '/schemas/UnkownSchema.json', | ||
name: config.title, | ||
description: config.title, | ||
tags: [config.group], | ||
order: -9999, | ||
icon: config.amis.icon, | ||
scaffold: { | ||
type: config.amis.name, | ||
body: [],// 容器类字段 | ||
label: config.title, | ||
objectApiName: "${objectName}", | ||
recordId: "${recordId}" | ||
}, | ||
regions: [ | ||
{ | ||
key: 'body', | ||
label: '内容区' | ||
} | ||
], | ||
previewSchema: { | ||
type: config.amis.name, | ||
objectApiName: 'space_users' | ||
}, | ||
panelTitle: "设置", | ||
panelControls: [ | ||
{ | ||
"type": "select", | ||
"label": "对象", | ||
"name": "objectApiName", | ||
"searchable": true, | ||
"multiple": false, | ||
"source": { | ||
"method": "get", | ||
"url": "/service/api/amis-design/objects", | ||
"requestAdaptor": "api.url = Builder.settings.rootUrl + api.url; if(!api.headers){api.headers = {}};api.headers.Authorization='Bearer ' + Builder.settings.tenantId + ',' + Builder.settings.authToken ;return api;", | ||
"adaptor": ` | ||
let data = payload.data; | ||
payload.unshift({ | ||
label: "当前对象", | ||
name: "\${objectName}" | ||
}); | ||
return payload; | ||
` | ||
}, | ||
"labelField": "label", | ||
"valueField": "name", | ||
"menuTpl": "" | ||
}, | ||
{ | ||
type: "text", | ||
name: "recordId", | ||
label: "记录ID" | ||
} | ||
] | ||
} | ||
} | ||
}; |