@steedos-widgets/amis-object 1.2.1 → 1.2.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/amis/AmisRecordService.d.ts +10 -0
- package/dist/amis/index.d.ts +1 -0
- package/dist/amis-object.cjs.js +151 -15
- package/dist/amis-object.cjs.js.map +1 -1
- package/dist/amis-object.esm.js +151 -16
- package/dist/amis-object.esm.js.map +1 -1
- package/dist/amis-object.umd.js +151 -15
- package/dist/amis-object.umd.js.map +1 -1
- package/dist/assets.json +11 -11
- package/dist/meta.js +185 -80
- package/dist/metas/AmisRecordService.d.ts +2 -0
- package/package.json +3 -3
package/dist/amis-object.umd.js
CHANGED
|
@@ -1748,8 +1748,8 @@
|
|
|
1748
1748
|
/*
|
|
1749
1749
|
* @Author: baozhoutao@steedos.com
|
|
1750
1750
|
* @Date: 2022-11-01 15:51:00
|
|
1751
|
-
* @LastEditors:
|
|
1752
|
-
* @LastEditTime: 2023-04-
|
|
1751
|
+
* @LastEditors: 殷亮辉 yinlianghui@hotoa.com
|
|
1752
|
+
* @LastEditTime: 2023-04-16 17:04:16
|
|
1753
1753
|
* @Description:
|
|
1754
1754
|
*/
|
|
1755
1755
|
|
|
@@ -1827,6 +1827,7 @@
|
|
|
1827
1827
|
"context": "${context}",
|
|
1828
1828
|
"global": "${global}",
|
|
1829
1829
|
"listViewId": "${listViewId}",
|
|
1830
|
+
"displayAs": "${displayAs}",
|
|
1830
1831
|
"uiSchema": "${uiSchema}",
|
|
1831
1832
|
"isLookup": "${isLookup}",
|
|
1832
1833
|
"listName": "${listName}"
|
|
@@ -4125,7 +4126,7 @@ setTimeout(()=>{
|
|
|
4125
4126
|
{
|
|
4126
4127
|
"type": "button",
|
|
4127
4128
|
"label": "重命名",
|
|
4128
|
-
"
|
|
4129
|
+
"disabledOn": "!((global.user.is_space_admin || global.userId == uiSchema.list_views[listName].owner) && !!uiSchema.list_views[listName].owner)",
|
|
4129
4130
|
"onEvent": {
|
|
4130
4131
|
"click": {
|
|
4131
4132
|
"weight": 0,
|
|
@@ -4180,7 +4181,7 @@ setTimeout(()=>{
|
|
|
4180
4181
|
{
|
|
4181
4182
|
"type": "button",
|
|
4182
4183
|
"label": "共享设置",
|
|
4183
|
-
"
|
|
4184
|
+
"disabledOn": "!(global.user.is_space_admin && !!uiSchema.list_views[listName].owner)",
|
|
4184
4185
|
"onEvent": {
|
|
4185
4186
|
"click": {
|
|
4186
4187
|
"weight": 0,
|
|
@@ -4220,7 +4221,7 @@ setTimeout(()=>{
|
|
|
4220
4221
|
{
|
|
4221
4222
|
"type": "button",
|
|
4222
4223
|
"label": "过滤设置",
|
|
4223
|
-
"
|
|
4224
|
+
"disabledOn": "!((global.user.is_space_admin || global.userId == uiSchema.list_views[listName].owner) && !!uiSchema.list_views[listName].owner)",
|
|
4224
4225
|
"onEvent": {
|
|
4225
4226
|
"click": {
|
|
4226
4227
|
"weight": 0,
|
|
@@ -4282,7 +4283,7 @@ setTimeout(()=>{
|
|
|
4282
4283
|
{
|
|
4283
4284
|
"type": "button",
|
|
4284
4285
|
"label": "显示的列",
|
|
4285
|
-
"
|
|
4286
|
+
"disabledOn": "!((global.user.is_space_admin || global.userId == uiSchema.list_views[listName].owner) && !!uiSchema.list_views[listName].owner)",
|
|
4286
4287
|
"onEvent": {
|
|
4287
4288
|
"click": {
|
|
4288
4289
|
"weight": 0,
|
|
@@ -4341,10 +4342,74 @@ setTimeout(()=>{
|
|
|
4341
4342
|
}
|
|
4342
4343
|
}
|
|
4343
4344
|
},
|
|
4345
|
+
{
|
|
4346
|
+
"type": "button",
|
|
4347
|
+
"label": "默认排序规则",
|
|
4348
|
+
"disabledOn": "!((global.user.is_space_admin || global.userId == uiSchema.list_views[listName].owner) && !!uiSchema.list_views[listName].owner)",
|
|
4349
|
+
"onEvent": {
|
|
4350
|
+
"click": {
|
|
4351
|
+
"weight": 0,
|
|
4352
|
+
"actions": [
|
|
4353
|
+
{
|
|
4354
|
+
"dialog": {
|
|
4355
|
+
"type": "dialog",
|
|
4356
|
+
"title": "弹框标题",
|
|
4357
|
+
"data": {
|
|
4358
|
+
"&": "$$",
|
|
4359
|
+
"objectName": "${objectName}",
|
|
4360
|
+
"recordId": "${uiSchema.list_views[listName]._id}",
|
|
4361
|
+
"listName": "${listName}",
|
|
4362
|
+
"appId": "${appId}"
|
|
4363
|
+
},
|
|
4364
|
+
"body": [
|
|
4365
|
+
{
|
|
4366
|
+
"type": "steedos-object-form",
|
|
4367
|
+
"label": "对象表单",
|
|
4368
|
+
"objectApiName": "object_listviews",
|
|
4369
|
+
"recordId": "${recordId}",
|
|
4370
|
+
"className": "",
|
|
4371
|
+
"id": "u:061f158b4c5a",
|
|
4372
|
+
"mode": "edit",
|
|
4373
|
+
"fields": [
|
|
4374
|
+
"sort",
|
|
4375
|
+
"sort.$.field_name",
|
|
4376
|
+
"sort.$.order"
|
|
4377
|
+
],
|
|
4378
|
+
"onEvent": {
|
|
4379
|
+
"submitSucc": {
|
|
4380
|
+
"weight": 0,
|
|
4381
|
+
"actions": [
|
|
4382
|
+
{
|
|
4383
|
+
"args": {
|
|
4384
|
+
"url": "${context.rootUrl}/app/${appId}/${objectName}/grid/${listName}",
|
|
4385
|
+
"blank": false
|
|
4386
|
+
},
|
|
4387
|
+
"actionType": "url"
|
|
4388
|
+
}
|
|
4389
|
+
]
|
|
4390
|
+
}
|
|
4391
|
+
},
|
|
4392
|
+
"fieldsExtend": "{\n \"sort\": {\n \"amis\": {\n \"type\": \"tabs-transfer\",\n \"sortable\": true,\n \"searchable\": true,\n \"source\": {\n \"method\": \"get\",\n \"url\": \"${context.rootUrl}/service/api/amis-metadata-objects/objects/${objectName}/sortFields/options\",\n \"headers\": {\n \"Authorization\": \"Bearer ${context.tenantId},${context.authToken}\"\n }\n }\n }\n }\n}",
|
|
4393
|
+
"initApiAdaptor": "let sort;\nif (recordId) {\n sort = payload.data.initialValues.sort;\n //数据格式转换\n if (sort instanceof Array) {\n sort = lodash.map(sort, (item) => {\n return item.field_name + ':' + (item.order || 'asc')\n });\n }\n}\npayload.data.initialValues.sort = sort;\ndelete payload.extensions;",
|
|
4394
|
+
"apiRequestAdaptor": "const recordId = api.body.recordId;\n//数据格式转换\nif (typeof formData.sort == 'string') {\n formData.sort = formData.sort?.split(',');\n}\nformData.sort = lodash.map(formData.sort, (item) => {\n const arr = item.split(':');\n return { field_name: arr[0], order: arr[1] };\n});\nif (recordId) {\n query = 'mutation{record: ' + objectName + '__update(id: \"' + recordId + '\", doc: {__saveData}){_id}}';\n}\n__saveData = JSON.stringify(JSON.stringify(formData));\napi.data = { query: query.replace('{__saveData}', __saveData) };\n"
|
|
4395
|
+
}
|
|
4396
|
+
],
|
|
4397
|
+
"showCloseButton": true,
|
|
4398
|
+
"showErrorMsg": true,
|
|
4399
|
+
"showLoading": true,
|
|
4400
|
+
"id": "u:d3f6947b6acf",
|
|
4401
|
+
"size": "lg"
|
|
4402
|
+
},
|
|
4403
|
+
"actionType": "dialog"
|
|
4404
|
+
}
|
|
4405
|
+
]
|
|
4406
|
+
}
|
|
4407
|
+
}
|
|
4408
|
+
},
|
|
4344
4409
|
{
|
|
4345
4410
|
"type": "button",
|
|
4346
4411
|
"label": "删除",
|
|
4347
|
-
"
|
|
4412
|
+
"disabledOn": "!((global.user.is_space_admin || global.userId == uiSchema.list_views[listName].owner) && !!uiSchema.list_views[listName].owner)",
|
|
4348
4413
|
"confirmText": "如果您删除此列表视图,该视图将为所有具备访问权限的用户永久删除。是否确定要删除?",
|
|
4349
4414
|
"onEvent": {
|
|
4350
4415
|
"click": {
|
|
@@ -4705,7 +4770,6 @@ setTimeout(()=>{
|
|
|
4705
4770
|
{
|
|
4706
4771
|
"actionType": "custom",
|
|
4707
4772
|
"script": `
|
|
4708
|
-
debugger;
|
|
4709
4773
|
const scope = event.context.scoped;
|
|
4710
4774
|
//TODO: 将form中的value一同加入筛选内
|
|
4711
4775
|
// var filterForm = scope.parent.parent.getComponents().find(function(n){
|
|
@@ -6189,7 +6253,7 @@ setTimeout(()=>{
|
|
|
6189
6253
|
|
|
6190
6254
|
const API_CACHE = 100;
|
|
6191
6255
|
|
|
6192
|
-
function getReadonlyFormAdaptor(fields){
|
|
6256
|
+
function getReadonlyFormAdaptor(object, fields){
|
|
6193
6257
|
let scriptStr = '';
|
|
6194
6258
|
const selectFields = ___default__namespace.filter(fields, function(field){return field.name.indexOf('.') < 0 && ((field.type == 'select' && field.options) || ((field.type == 'lookup' || field.type == 'master_detail') && !field.reference_to))});
|
|
6195
6259
|
const gridAndObjectFieldsName = ___default__namespace.map(___default__namespace.filter(fields, function(field){return field.name.indexOf('.') < 0 && (field.type === 'object' || field.type === 'grid')}), 'name');
|
|
@@ -6248,6 +6312,7 @@ setTimeout(()=>{
|
|
|
6248
6312
|
console.error(e)
|
|
6249
6313
|
}
|
|
6250
6314
|
payload.data = data;
|
|
6315
|
+
payload.data.__objectName = "${object.name}";
|
|
6251
6316
|
payload.data.__record = record;
|
|
6252
6317
|
window.postMessage(Object.assign({type: "record.loaded"}, {record: record}), "*")
|
|
6253
6318
|
}
|
|
@@ -6265,7 +6330,7 @@ setTimeout(()=>{
|
|
|
6265
6330
|
url: getApi$2()+"&recordId=${recordId}",
|
|
6266
6331
|
cache: API_CACHE,
|
|
6267
6332
|
// requestAdaptor: "console.log('getReadonlyFormInitApi requestAdaptor', api);return api;",
|
|
6268
|
-
adaptor: getReadonlyFormAdaptor(fields),
|
|
6333
|
+
adaptor: getReadonlyFormAdaptor(object, fields),
|
|
6269
6334
|
data: await getFindOneQuery$1(object, recordId, fields, options),
|
|
6270
6335
|
headers: {
|
|
6271
6336
|
Authorization: "Bearer ${context.tenantId},${context.authToken}"
|
|
@@ -6983,6 +7048,7 @@ setTimeout(()=>{
|
|
|
6983
7048
|
eventName: "recordLoaded"
|
|
6984
7049
|
},
|
|
6985
7050
|
data: {
|
|
7051
|
+
objectName: "${event.data.__objectName}",
|
|
6986
7052
|
record: "${event.data.__record}"
|
|
6987
7053
|
}
|
|
6988
7054
|
},
|
|
@@ -7419,7 +7485,7 @@ setTimeout(()=>{
|
|
|
7419
7485
|
const api = await getApi(mainObject, null, fields, {count: options.queryCount, alias: 'rows', limit: top, queryOptions: `filters: {__filters}, top: {__top}, skip: {__skip}, sort: "{__sort}"`});
|
|
7420
7486
|
|
|
7421
7487
|
if(options.isRelated){
|
|
7422
|
-
api.url += "&recordId=${recordId}";
|
|
7488
|
+
api.url += "&recordId=${_master.recordId}";
|
|
7423
7489
|
}
|
|
7424
7490
|
|
|
7425
7491
|
api.data.$term = "$term";
|
|
@@ -8663,8 +8729,8 @@ setTimeout(()=>{
|
|
|
8663
8729
|
/*
|
|
8664
8730
|
* @Author: baozhoutao@steedos.com
|
|
8665
8731
|
* @Date: 2022-07-05 15:55:39
|
|
8666
|
-
* @LastEditors:
|
|
8667
|
-
* @LastEditTime: 2023-04-
|
|
8732
|
+
* @LastEditors: 殷亮辉 yinlianghui@hotoa.com
|
|
8733
|
+
* @LastEditTime: 2023-04-14 11:10:07
|
|
8668
8734
|
* @Description:
|
|
8669
8735
|
*/
|
|
8670
8736
|
|
|
@@ -9150,6 +9216,41 @@ setTimeout(()=>{
|
|
|
9150
9216
|
}
|
|
9151
9217
|
}
|
|
9152
9218
|
|
|
9219
|
+
async function getRecordServiceSchema(objectName, appId, props = {}) {
|
|
9220
|
+
const uiSchema = await getUISchema(objectName);
|
|
9221
|
+
return {
|
|
9222
|
+
uiSchema,
|
|
9223
|
+
amisSchema: {
|
|
9224
|
+
"type": "service",
|
|
9225
|
+
"body": [],
|
|
9226
|
+
data: {
|
|
9227
|
+
"_master.objectName": "${objectName}",
|
|
9228
|
+
"_master.recordId": "${recordId}"
|
|
9229
|
+
},
|
|
9230
|
+
"style": {
|
|
9231
|
+
"padding": "var(--Page-body-padding)",
|
|
9232
|
+
...props.style
|
|
9233
|
+
},
|
|
9234
|
+
onEvent: {
|
|
9235
|
+
"recordLoaded": {
|
|
9236
|
+
"actions": [
|
|
9237
|
+
{
|
|
9238
|
+
"actionType": "reload",
|
|
9239
|
+
"data": {
|
|
9240
|
+
"name": `\${record.${uiSchema.NAME_FIELD_KEY || 'name'}}`,
|
|
9241
|
+
"_master.record": `\${record}`,
|
|
9242
|
+
// 不清楚reload 如何给对象下的某个key复制, 所以此处重复设置_master的objectName、recordId
|
|
9243
|
+
"_master.objectName": "${objectName}",
|
|
9244
|
+
"_master.recordId": "${recordId}"
|
|
9245
|
+
}
|
|
9246
|
+
}
|
|
9247
|
+
]
|
|
9248
|
+
},
|
|
9249
|
+
...props.onEvent
|
|
9250
|
+
}
|
|
9251
|
+
}
|
|
9252
|
+
}
|
|
9253
|
+
}
|
|
9153
9254
|
|
|
9154
9255
|
// 获取单个相关表
|
|
9155
9256
|
async function getObjectRelated(
|
|
@@ -12069,6 +12170,7 @@ setTimeout(()=>{
|
|
|
12069
12170
|
getRecordDetailSchema: getRecordDetailSchema,
|
|
12070
12171
|
getRecordPageInitSchema: getRecordPageInitSchema,
|
|
12071
12172
|
getRecordPermissions: getRecordPermissions,
|
|
12173
|
+
getRecordServiceSchema: getRecordServiceSchema,
|
|
12072
12174
|
getRelatedFieldValue: getRelatedFieldValue,
|
|
12073
12175
|
getRelatedListSchema: getRelatedListSchema,
|
|
12074
12176
|
getRelatedsCount: getRelatedsCount,
|
|
@@ -12548,6 +12650,8 @@ setTimeout(()=>{
|
|
|
12548
12650
|
schema = _d.sent();
|
|
12549
12651
|
amisSchema = schema.amisSchema;
|
|
12550
12652
|
if (defaultData) {
|
|
12653
|
+
// 让ObjectForm支持props中的dafaultData属性与上层组件配置的defaultData混合
|
|
12654
|
+
// 为了解决相关表新建时如果是表单类型微页面,因为找不到ObjectForm在哪层而造成无法设置ObjectForm的defaultData的问题
|
|
12551
12655
|
amisSchema.data.defaultData = __assign$2({ "&": "${defaultData}" }, defaultData);
|
|
12552
12656
|
}
|
|
12553
12657
|
uiSchema = schema.uiSchema;
|
|
@@ -12643,7 +12747,7 @@ setTimeout(()=>{
|
|
|
12643
12747
|
},
|
|
12644
12748
|
{
|
|
12645
12749
|
"actionType": "reload",
|
|
12646
|
-
"expression": "${(event.data.recordId || event.data.__deletedRecord === true) && event.data._isRelated != true}" //不是新建, 则刷新列表
|
|
12750
|
+
"expression": "${(event.data.recordId || event.data.__deletedRecord === true || event.data.displayAs === 'split') && event.data._isRelated != true}" //不是新建, 或分栏模式下新建主对象记录, 则刷新列表
|
|
12647
12751
|
}
|
|
12648
12752
|
]
|
|
12649
12753
|
};
|
|
@@ -12837,7 +12941,8 @@ setTimeout(()=>{
|
|
|
12837
12941
|
"_id": "\${event.data.record._id}",
|
|
12838
12942
|
"recordId": "\${event.data.record._id}",
|
|
12839
12943
|
"recordLoaded": true,
|
|
12840
|
-
}
|
|
12944
|
+
},
|
|
12945
|
+
"expression": "${event.data.objectName == '".concat(objectUiSchema === null || objectUiSchema === void 0 ? void 0 : objectUiSchema.name, "'}")
|
|
12841
12946
|
}
|
|
12842
12947
|
]
|
|
12843
12948
|
}
|
|
@@ -12884,6 +12989,36 @@ setTimeout(()=>{
|
|
|
12884
12989
|
});
|
|
12885
12990
|
}); };
|
|
12886
12991
|
|
|
12992
|
+
/*
|
|
12993
|
+
* @Author: baozhoutao@steedos.com
|
|
12994
|
+
* @Date: 2022-12-08 10:32:17
|
|
12995
|
+
* @LastEditors: 殷亮辉 yinlianghui@hotoa.com
|
|
12996
|
+
* @LastEditTime: 2023-04-14 11:30:21
|
|
12997
|
+
* @Description:
|
|
12998
|
+
*/
|
|
12999
|
+
var AmisRecordService = function (props) { return __awaiter(void 0, void 0, void 0, function () {
|
|
13000
|
+
var className, _a, objectApiName, body, style, schema;
|
|
13001
|
+
return __generator(this, function (_b) {
|
|
13002
|
+
switch (_b.label) {
|
|
13003
|
+
case 0:
|
|
13004
|
+
className = props.className, props.$schema, props.appId, _a = props.objectApiName, objectApiName = _a === void 0 ? "space_users" : _a, props.recordId, props.fields, body = props.body, style = props.style;
|
|
13005
|
+
return [4 /*yield*/, getRecordServiceSchema(objectApiName)];
|
|
13006
|
+
case 1:
|
|
13007
|
+
schema = (_b.sent()).amisSchema;
|
|
13008
|
+
if (body) {
|
|
13009
|
+
schema.body = body;
|
|
13010
|
+
}
|
|
13011
|
+
if (className) {
|
|
13012
|
+
schema.className = className;
|
|
13013
|
+
}
|
|
13014
|
+
if (style) {
|
|
13015
|
+
Object.assign(schema.style, style);
|
|
13016
|
+
}
|
|
13017
|
+
return [2 /*return*/, schema];
|
|
13018
|
+
}
|
|
13019
|
+
});
|
|
13020
|
+
}); };
|
|
13021
|
+
|
|
12887
13022
|
var AmisRecordDetailRelatedList = function (props) { return __awaiter(void 0, void 0, void 0, function () {
|
|
12888
13023
|
var objectApiName, recordId, relatedObjectApiName, relatedKey, top, perPage, appId, relatedLabel, _a, className, columns, sort, filters, visible_on, formFactor, schema;
|
|
12889
13024
|
return __generator(this, function (_b) {
|
|
@@ -14031,6 +14166,7 @@ setTimeout(()=>{
|
|
|
14031
14166
|
exports.AmisRecordDetailHeader = AmisRecordDetailHeader;
|
|
14032
14167
|
exports.AmisRecordDetailRelatedList = AmisRecordDetailRelatedList;
|
|
14033
14168
|
exports.AmisRecordDetailRelatedLists = AmisRecordDetailRelatedLists;
|
|
14169
|
+
exports.AmisRecordService = AmisRecordService;
|
|
14034
14170
|
exports.AmisSelectFlow = AmisSelectFlow;
|
|
14035
14171
|
exports.AmisSelectUser = AmisSelectUser;
|
|
14036
14172
|
exports.AmisSteedosField = AmisSteedosField;
|