@steedos-widgets/amis-object 1.3.0 → 1.3.2-beta.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-object.cjs.js +95 -53
- package/dist/amis-object.cjs.js.map +1 -1
- package/dist/amis-object.esm.js +96 -54
- package/dist/amis-object.esm.js.map +1 -1
- package/dist/amis-object.umd.js +54 -52
- package/dist/amis-object.umd.js.map +1 -1
- package/dist/assets.json +16 -16
- package/dist/pages/PageRecordDetail.d.ts +8 -0
- package/package.json +3 -3
package/dist/amis-object.esm.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React, { createContext, useState, useEffect, createElement } from 'react';
|
|
2
2
|
import * as _$1 from 'lodash';
|
|
3
|
-
import _$1__default, { isEmpty, isArray, each, find, endsWith, cloneDeep, includes, toArray, mergeWith, isString, union, has, slice, defaultsDeep as defaultsDeep$1,
|
|
3
|
+
import _$1__default, { isEmpty, isArray, each, find, endsWith, cloneDeep, includes, toArray, mergeWith, isString, union, has, slice, defaultsDeep as defaultsDeep$1, map, filter, get as get$1, isBoolean, omitBy, isNil, isObject as isObject$1, forEach, trimEnd, startsWith, isFunction, compact, difference, keys, pick, first, values, pickBy, random, assign } from 'lodash';
|
|
4
4
|
import { Dropdown, Tabs, Spin, Badge, Skeleton, Modal as Modal$1, message, notification, Button, Space, Drawer as Drawer$1 } from 'antd';
|
|
5
5
|
import ReactDOM, { createRoot } from 'react-dom';
|
|
6
6
|
|
|
@@ -3523,11 +3523,26 @@ const Router$1 = {
|
|
|
3523
3523
|
/*
|
|
3524
3524
|
* @Author: baozhoutao@steedos.com
|
|
3525
3525
|
* @Date: 2022-07-20 16:29:22
|
|
3526
|
-
* @LastEditors:
|
|
3527
|
-
* @LastEditTime: 2023-09-
|
|
3526
|
+
* @LastEditors: liaodaxue
|
|
3527
|
+
* @LastEditTime: 2023-09-11 17:19:53
|
|
3528
3528
|
* @Description:
|
|
3529
3529
|
*/
|
|
3530
3530
|
|
|
3531
|
+
function getImageFieldUrl(url) {
|
|
3532
|
+
if (window.Meteor && window.Meteor.isCordova != true) {
|
|
3533
|
+
// '//'的位置
|
|
3534
|
+
const doubleSlashIndex = url.indexOf('//');
|
|
3535
|
+
const urlIndex = url.indexOf('/', doubleSlashIndex + 2);
|
|
3536
|
+
const rootUrl = url.substring(urlIndex);
|
|
3537
|
+
return rootUrl;
|
|
3538
|
+
}
|
|
3539
|
+
return url;
|
|
3540
|
+
}
|
|
3541
|
+
|
|
3542
|
+
if(typeof window != 'undefined'){
|
|
3543
|
+
window.getImageFieldUrl = getImageFieldUrl;
|
|
3544
|
+
}
|
|
3545
|
+
|
|
3531
3546
|
function getContrastColor(bgColor) {
|
|
3532
3547
|
var backgroundColor = (bgColor.charAt(0) === '#') ? bgColor.substring(1, 7) : bgColor;
|
|
3533
3548
|
var r = parseInt(backgroundColor.substr(0, 2), 16);
|
|
@@ -3538,6 +3553,9 @@ function getContrastColor(bgColor) {
|
|
|
3538
3553
|
}
|
|
3539
3554
|
|
|
3540
3555
|
function getLookupListView(refObjectConfig) {
|
|
3556
|
+
if(!refObjectConfig){
|
|
3557
|
+
return null;
|
|
3558
|
+
}
|
|
3541
3559
|
const listNameAll = "all";
|
|
3542
3560
|
const listNameLookup = "lookup";
|
|
3543
3561
|
let listViewAll, listViewLookup;
|
|
@@ -11686,7 +11704,13 @@ async function getTableApi(mainObject, fields, options){
|
|
|
11686
11704
|
if(field.type === 'file'){
|
|
11687
11705
|
item[key] = value
|
|
11688
11706
|
}else{
|
|
11689
|
-
item[key] = _.map(value,
|
|
11707
|
+
item[key] = _.map(value, (item)=>{
|
|
11708
|
+
if(field.type === 'image'){
|
|
11709
|
+
const url = window.getImageFieldUrl(item.url);
|
|
11710
|
+
return url;
|
|
11711
|
+
}
|
|
11712
|
+
return item.url;
|
|
11713
|
+
})
|
|
11690
11714
|
}
|
|
11691
11715
|
}
|
|
11692
11716
|
})
|
|
@@ -11928,10 +11952,14 @@ function getScriptForAddUrlPrefixForImgFields(fields){
|
|
|
11928
11952
|
let fieldProps = imgFields[item];
|
|
11929
11953
|
if(fieldProps.multiple){
|
|
11930
11954
|
if(imgFieldDisplayValue instanceof Array){
|
|
11931
|
-
data[item] = imgFieldDisplayValue.map((i)=>{
|
|
11955
|
+
data[item] = imgFieldDisplayValue.map((i)=>{
|
|
11956
|
+
const url = window.getImageFieldUrl(i.url);
|
|
11957
|
+
return url;
|
|
11958
|
+
});
|
|
11932
11959
|
}
|
|
11933
11960
|
}else{
|
|
11934
|
-
|
|
11961
|
+
const url = imgFieldDisplayValue && window.getImageFieldUrl(imgFieldDisplayValue.url);
|
|
11962
|
+
data[item] = url;
|
|
11935
11963
|
}
|
|
11936
11964
|
}
|
|
11937
11965
|
})
|
|
@@ -14092,53 +14120,34 @@ async function getListSchema(
|
|
|
14092
14120
|
};
|
|
14093
14121
|
}
|
|
14094
14122
|
|
|
14095
|
-
|
|
14096
|
-
async function getTableSchema(
|
|
14097
|
-
appName,
|
|
14098
|
-
objectName,
|
|
14099
|
-
columns,
|
|
14100
|
-
ctx = {}
|
|
14101
|
-
) {
|
|
14102
|
-
// console.time('getTableSchema', columns);
|
|
14103
|
-
const uiSchema = await getUISchema(objectName);
|
|
14104
|
-
|
|
14105
|
-
let sort = ctx.sort;
|
|
14106
|
-
if(!sort){
|
|
14107
|
-
const sortField = ctx.sortField;
|
|
14108
|
-
const sortOrder = ctx.sortOrder;
|
|
14109
|
-
if(sortField){
|
|
14110
|
-
let sortStr = sortField + ' ' + sortOrder || 'asc';
|
|
14111
|
-
sort = sortStr;
|
|
14112
|
-
}
|
|
14113
|
-
}
|
|
14114
|
-
|
|
14123
|
+
async function convertColumnsToTableFields(columns, uiSchema, ctx = {}) {
|
|
14115
14124
|
let fields = [];
|
|
14116
|
-
for(const column of columns){
|
|
14125
|
+
for (const column of columns) {
|
|
14117
14126
|
if (isString(column)) {
|
|
14118
|
-
if(column.indexOf('.') > 0){
|
|
14127
|
+
if (column.indexOf('.') > 0) {
|
|
14119
14128
|
const fieldName = column.split('.')[0];
|
|
14120
14129
|
const displayName = column.split('.')[1];
|
|
14121
14130
|
const filedInfo = uiSchema.fields[fieldName];
|
|
14122
|
-
if(filedInfo && (filedInfo.type === 'lookup' || filedInfo.type === 'master_detail') && isString(filedInfo.reference_to)
|
|
14131
|
+
if (filedInfo && (filedInfo.type === 'lookup' || filedInfo.type === 'master_detail') && isString(filedInfo.reference_to)) {
|
|
14123
14132
|
const rfUiSchema = await getUISchema(filedInfo.reference_to);
|
|
14124
14133
|
const rfFieldInfo = rfUiSchema.fields[displayName];
|
|
14125
|
-
fields.push(Object.assign({}, rfFieldInfo, {name: `${fieldName}__expand.${displayName}`, expand: true, expandInfo: {fieldName, displayName}}));
|
|
14134
|
+
fields.push(Object.assign({}, rfFieldInfo, { name: `${fieldName}__expand.${displayName}`, expand: true, expandInfo: { fieldName, displayName } }, ctx));
|
|
14126
14135
|
}
|
|
14127
|
-
}else {
|
|
14128
|
-
if(uiSchema.fields[column]){
|
|
14129
|
-
fields.push(uiSchema.fields[column]);
|
|
14136
|
+
} else {
|
|
14137
|
+
if (uiSchema.fields[column]) {
|
|
14138
|
+
fields.push(Object.assign({}, uiSchema.fields[column], ctx));
|
|
14130
14139
|
}
|
|
14131
14140
|
}
|
|
14132
14141
|
} else if (isObject$1(column)) {
|
|
14133
|
-
if(column.field.indexOf('.') > 0){
|
|
14142
|
+
if (column.field.indexOf('.') > 0) {
|
|
14134
14143
|
const fieldName = column.field.split('.')[0];
|
|
14135
14144
|
const displayName = column.field.split('.')[1];
|
|
14136
14145
|
const filedInfo = uiSchema.fields[fieldName];
|
|
14137
|
-
if(filedInfo && (filedInfo.type === 'lookup' || filedInfo.type === 'master_detail') && isString(filedInfo.reference_to)
|
|
14146
|
+
if (filedInfo && (filedInfo.type === 'lookup' || filedInfo.type === 'master_detail') && isString(filedInfo.reference_to)) {
|
|
14138
14147
|
const rfUiSchema = await getUISchema(filedInfo.reference_to);
|
|
14139
14148
|
const rfFieldInfo = rfUiSchema.fields[displayName];
|
|
14140
|
-
fields.push(Object.assign({}, rfFieldInfo,
|
|
14141
|
-
{name: `${fieldName}__expand.${displayName}`, expand: true, expandInfo: {fieldName, displayName}},
|
|
14149
|
+
fields.push(Object.assign({}, rfFieldInfo, ctx,
|
|
14150
|
+
{ name: `${fieldName}__expand.${displayName}`, expand: true, expandInfo: { fieldName, displayName } },
|
|
14142
14151
|
{
|
|
14143
14152
|
width: column.width,
|
|
14144
14153
|
wrap: column.wrap, // wrap = true 是没效果的
|
|
@@ -14146,10 +14155,10 @@ async function getTableSchema(
|
|
|
14146
14155
|
}
|
|
14147
14156
|
));
|
|
14148
14157
|
}
|
|
14149
|
-
}else {
|
|
14150
|
-
if(uiSchema.fields[column.field]){
|
|
14158
|
+
} else {
|
|
14159
|
+
if (uiSchema.fields[column.field]) {
|
|
14151
14160
|
fields.push(
|
|
14152
|
-
Object.assign({}, uiSchema.fields[column.field], {
|
|
14161
|
+
Object.assign({}, uiSchema.fields[column.field], ctx, {
|
|
14153
14162
|
width: column.width,
|
|
14154
14163
|
wrap: column.wrap, // wrap = true 是没效果的
|
|
14155
14164
|
amis: column.amis
|
|
@@ -14159,17 +14168,36 @@ async function getTableSchema(
|
|
|
14159
14168
|
}
|
|
14160
14169
|
}
|
|
14161
14170
|
}
|
|
14171
|
+
return fields;
|
|
14172
|
+
}
|
|
14173
|
+
|
|
14174
|
+
// 获取对象表格
|
|
14175
|
+
async function getTableSchema(
|
|
14176
|
+
appName,
|
|
14177
|
+
objectName,
|
|
14178
|
+
columns,
|
|
14179
|
+
ctx = {}
|
|
14180
|
+
) {
|
|
14181
|
+
// console.time('getTableSchema', columns);
|
|
14182
|
+
const uiSchema = await getUISchema(objectName);
|
|
14183
|
+
|
|
14184
|
+
let sort = ctx.sort;
|
|
14185
|
+
if(!sort){
|
|
14186
|
+
const sortField = ctx.sortField;
|
|
14187
|
+
const sortOrder = ctx.sortOrder;
|
|
14188
|
+
if(sortField){
|
|
14189
|
+
let sortStr = sortField + ' ' + sortOrder || 'asc';
|
|
14190
|
+
sort = sortStr;
|
|
14191
|
+
}
|
|
14192
|
+
}
|
|
14193
|
+
|
|
14194
|
+
let fields = await convertColumnsToTableFields(columns, uiSchema);
|
|
14162
14195
|
|
|
14163
14196
|
const extraColumns = ctx.extraColumns;
|
|
14164
14197
|
|
|
14165
14198
|
if (extraColumns) {
|
|
14166
|
-
|
|
14167
|
-
|
|
14168
|
-
fields.push({ extra: true, name: column });
|
|
14169
|
-
} else if (isObject$1(column)) {
|
|
14170
|
-
fields.push({ extra: true, name: column.field });
|
|
14171
|
-
}
|
|
14172
|
-
});
|
|
14199
|
+
let extraFields = await convertColumnsToTableFields(extraColumns, uiSchema, {extra: true});
|
|
14200
|
+
fields = fields.concat(extraFields);
|
|
14173
14201
|
}
|
|
14174
14202
|
|
|
14175
14203
|
const amisSchema = await getObjectCRUD(uiSchema, fields, {
|
|
@@ -17786,6 +17814,8 @@ var AmisObjectListView = function (props) { return __awaiter(void 0, void 0, voi
|
|
|
17786
17814
|
return __generator(this, function (_j) {
|
|
17787
17815
|
switch (_j.label) {
|
|
17788
17816
|
case 0:
|
|
17817
|
+
// console.time('AmisObjectListView')
|
|
17818
|
+
console.log("AmisObjectListView props", props);
|
|
17789
17819
|
$schema = props.$schema, top = props.top, perPage = props.perPage, _a = props.showHeader, showHeader = _a === void 0 ? true : _a, data = props.data, defaultData = props.defaultData, _b = props.crud, crud = _b === void 0 ? {} : _b, _c = props.className, className = _c === void 0 ? "" : _c, crudClassName = props.crudClassName, _d = props.showDisplayAs, showDisplayAs = _d === void 0 ? false : _d, sideSchema = props.sideSchema, props.columnsTogglable, _f = props.filterVisible, filterVisible = _f === void 0 ? true : _f, headerToolbarItems = props.headerToolbarItems, rowClassNameExpr = props.rowClassNameExpr, _g = props.hiddenColumnOperation, hiddenColumnOperation = _g === void 0 ? false : _g;
|
|
17790
17820
|
headerSchema = props.headerSchema;
|
|
17791
17821
|
ctx = props.ctx;
|
|
@@ -17918,7 +17948,7 @@ var AmisObjectListView = function (props) { return __awaiter(void 0, void 0, voi
|
|
|
17918
17948
|
"Authorization": "Bearer ${context.tenantId},${context.authToken}"
|
|
17919
17949
|
},
|
|
17920
17950
|
"requestAdaptor": "api.data={query: '{spaces__findOne(id: \"none\"){_id,name}}'};return api;",
|
|
17921
|
-
"adaptor": "\n // console.log('service listview schemaApi adaptor....', api.body); \n let { appId, objectName, defaultListName: listName, display, formFactor: defaultFormFactor} = api.body;\n if(api.body.listName){\n listName = api.body.listName;\n }\n return new Promise((resolve)=>{\n const listViewSchemaProps = ".concat(JSON.stringify(listViewSchemaProps), ";\n const formFactor = ([\"split\"].indexOf(display) > -1) ? 'SMALL': defaultFormFactor;\n listViewSchemaProps.formFactor = formFactor;\n listViewSchemaProps.displayAs = display;\n
|
|
17951
|
+
"adaptor": "\n // console.log('service listview schemaApi adaptor....', api.body); \n let { appId, objectName, defaultListName: listName, display, formFactor: defaultFormFactor} = api.body;\n if(api.body.listName){\n listName = api.body.listName;\n }\n return new Promise((resolve)=>{\n const listViewSchemaProps = ".concat(JSON.stringify(listViewSchemaProps), ";\n const formFactor = ([\"split\"].indexOf(display) > -1) ? 'SMALL': defaultFormFactor;\n listViewSchemaProps.formFactor = formFactor;\n listViewSchemaProps.displayAs = display;\n \n window.getListSchema(appId, objectName, listName, listViewSchemaProps).then((schema)=>{\n try{\n const uiSchema = schema.uiSchema;\n const listView = _.find(\n uiSchema.list_views,\n (listView, name) => {\n // \u4F20\u5165listViewName\u7A7A\u503C\u5219\u53D6\u7B2C\u4E00\u4E2A\n if(!listName){\n listName = name;\n }\n return name === listName || listView._id === listName;\n }\n );\n if(listView){\n window.Steedos && window.Steedos.setDocumentTitle && window.Steedos.setDocumentTitle({pageName: listView.label || listView.name})\n }\n }catch(e){\n console.error(e)\n }\n payload.data = schema.amisSchema;\n // console.log(\"schema================>\", schema)\n resolve(payload)\n });\n });\n ")
|
|
17922
17952
|
},
|
|
17923
17953
|
// "body": body,
|
|
17924
17954
|
// "data": serviceData
|
|
@@ -18762,8 +18792,8 @@ var AmisGlobalFooter = function (props) { return __awaiter(void 0, void 0, void
|
|
|
18762
18792
|
/*
|
|
18763
18793
|
* @Author: baozhoutao@steedos.com
|
|
18764
18794
|
* @Date: 2022-09-01 14:44:57
|
|
18765
|
-
* @LastEditors:
|
|
18766
|
-
* @LastEditTime: 2023-08
|
|
18795
|
+
* @LastEditors: baozhoutao@steedos.com
|
|
18796
|
+
* @LastEditTime: 2023-09-08 17:54:54
|
|
18767
18797
|
* @Description:
|
|
18768
18798
|
*/
|
|
18769
18799
|
var AmisGlobalHeaderToolbar = function (props) { return __awaiter(void 0, void 0, void 0, function () {
|
|
@@ -18783,7 +18813,7 @@ var AmisGlobalHeaderToolbar = function (props) { return __awaiter(void 0, void 0
|
|
|
18783
18813
|
"body": __spreadArray(__spreadArray([], __read(customButtons), false), [
|
|
18784
18814
|
{
|
|
18785
18815
|
"type": "button",
|
|
18786
|
-
"hiddenOn": "window
|
|
18816
|
+
"hiddenOn": "${window:innerWidth < 768 || (window:Meteor.settings.public && window:Meteor.settings.public.platform && window:Meteor.settings.public.platform.is_oem)}",
|
|
18787
18817
|
"id": "u:267a7e84a89d",
|
|
18788
18818
|
"onEvent": {
|
|
18789
18819
|
"click": {
|
|
@@ -19098,6 +19128,7 @@ var AmisGlobalHeaderToolbar = function (props) { return __awaiter(void 0, void 0
|
|
|
19098
19128
|
"type": "button",
|
|
19099
19129
|
"label": instance.t('frontend_about'),
|
|
19100
19130
|
"className": "flex",
|
|
19131
|
+
"hiddenOn": "${window:Meteor.settings.public && window:Meteor.settings.public.platform && window:Meteor.settings.public.platform.is_oem}",
|
|
19101
19132
|
"onEvent": {
|
|
19102
19133
|
"click": {
|
|
19103
19134
|
"actions": [
|
|
@@ -19459,7 +19490,7 @@ var AmisSteedosField = function (props) { return __awaiter(void 0, void 0, void
|
|
|
19459
19490
|
* @Author: baozhoutao@steedos.com
|
|
19460
19491
|
* @Date: 2023-01-14 16:41:24
|
|
19461
19492
|
* @LastEditors: baozhoutao@steedos.com
|
|
19462
|
-
* @LastEditTime: 2023-09-
|
|
19493
|
+
* @LastEditTime: 2023-09-11 16:48:35
|
|
19463
19494
|
* @Description:
|
|
19464
19495
|
*/
|
|
19465
19496
|
var getSelectFlowSchema = function (id, props) {
|
|
@@ -19607,7 +19638,7 @@ var getSelectFlowSchema = function (id, props) {
|
|
|
19607
19638
|
method: "post",
|
|
19608
19639
|
url: "${context.rootUrl}/graphql?keywords=${keywords}",
|
|
19609
19640
|
requestAdaptor: "\n const keywords = api.body.keywords || '';\n const appId = '".concat(data.app_id || "", "';\n api.data = {\n query: `\n {\n options: flows__getList(action: \"").concat(action, "\", keywords: \"${keywords}\", appId: \"${appId}\", distributeInstanceId: \"").concat(distributeInstanceId, "\", distributeStepId: \"").concat(distributeStepId, "\"){\n value:_id\n label:name\n children: flows{\n value: _id,\n label: name\n }\n }\n }\n `\n }\n "),
|
|
19610
|
-
adaptor: "\n var options = payload.data.options;\n if(options){\n options.forEach(function(item,index) {\n if(item.value != 'startFlows' && (!item.children || item.children.length == 0)){\n payload.data.options.splice(index,1)\n }\n })\n }\n if(payload.data.options.length === 1 && payload.data.options[0].children.length === 1){\n
|
|
19641
|
+
adaptor: "\n var options = payload.data.options;\n if(options){\n options.forEach(function(item,index) {\n if(item.value != 'startFlows' && (!item.children || item.children.length == 0)){\n payload.data.options.splice(index,1)\n }\n })\n }\n // if(payload.data.options.length === 1 && payload.data.options[0].children.length === 1){\n // payload.data.value = payload.data.options[0].children[0].value\n // }\n return payload;\n ",
|
|
19611
19642
|
"headers": {
|
|
19612
19643
|
"Authorization": "Bearer ${context.tenantId},${context.authToken}"
|
|
19613
19644
|
}
|
|
@@ -19773,7 +19804,17 @@ var PageRecordDetail = function (props) { return __awaiter(void 0, void 0, void
|
|
|
19773
19804
|
case 2: return [2 /*return*/, {
|
|
19774
19805
|
type: 'service',
|
|
19775
19806
|
"className": 'h-full',
|
|
19776
|
-
body: recordSchema
|
|
19807
|
+
body: recordSchema,
|
|
19808
|
+
"onEvent": {
|
|
19809
|
+
"recordLoaded": {
|
|
19810
|
+
"actions": [
|
|
19811
|
+
{
|
|
19812
|
+
"actionType": "custom",
|
|
19813
|
+
"script": "window.Steedos && window.Steedos.setDocumentTitle && Steedos.setDocumentTitle({pageName: event.data.record.name})"
|
|
19814
|
+
}
|
|
19815
|
+
]
|
|
19816
|
+
}
|
|
19817
|
+
}
|
|
19777
19818
|
}];
|
|
19778
19819
|
}
|
|
19779
19820
|
});
|
|
@@ -19789,6 +19830,7 @@ var PageObject = function (props) { return __awaiter(void 0, void 0, void 0, fun
|
|
|
19789
19830
|
case 1:
|
|
19790
19831
|
uiSchema = _b.sent();
|
|
19791
19832
|
delete $schema.data.recordId;
|
|
19833
|
+
window.Steedos && window.Steedos.setDocumentTitle && window.Steedos.setDocumentTitle({ tabName: uiSchema.label || uiSchema.name });
|
|
19792
19834
|
// 最外层的data是render data, 会被updateProps data覆盖, 所以组件data需要单开一个数据域. 所以此处有2层service
|
|
19793
19835
|
return [2 /*return*/, {
|
|
19794
19836
|
type: "service",
|