@steedos-widgets/amis-lib 1.3.2-beta.6 → 1.3.4-beta.1
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/cjs/tsconfig.tsbuildinfo +1 -1
- package/dist/index.cjs.js +280 -202
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm.js +280 -202
- package/dist/index.esm.js.map +1 -1
- package/dist/index.umd.js +116 -115
- package/dist/index.umd.js.map +1 -1
- package/dist/types/lib/converter/amis/index.d.ts +2 -6
- package/dist/types/lib/converter/amis/toolbar.d.ts +2 -2
- package/dist/types/lib/objects.d.ts +6 -6
- package/package.json +2 -2
package/dist/index.cjs.js
CHANGED
|
@@ -471,7 +471,7 @@ function getLookupListView(refObjectConfig) {
|
|
|
471
471
|
* @Author: baozhoutao@steedos.com
|
|
472
472
|
* @Date: 2022-05-23 09:53:08
|
|
473
473
|
* @LastEditors: 殷亮辉 yinlianghui@hotoa.com
|
|
474
|
-
* @LastEditTime: 2023-
|
|
474
|
+
* @LastEditTime: 2023-09-19 14:38:39
|
|
475
475
|
* @Description:
|
|
476
476
|
*/
|
|
477
477
|
|
|
@@ -651,9 +651,13 @@ async function getLookupTpl(field, ctx){
|
|
|
651
651
|
}
|
|
652
652
|
|
|
653
653
|
function getSwitchTpl(field){
|
|
654
|
+
let fieldDataStrTpl = `data._display.${field.name}`;
|
|
655
|
+
if(field.isTableField){
|
|
656
|
+
fieldDataStrTpl = `data.${field.name}`;
|
|
657
|
+
}
|
|
654
658
|
return `<% if (data.${field.name}) { %>
|
|
655
|
-
<span class="slds-icon_container slds-icon-utility-check slds-current-color" title="
|
|
656
|
-
<span ><%=
|
|
659
|
+
<span class="slds-icon_container slds-icon-utility-check slds-current-color" title="<%=${fieldDataStrTpl}%>">
|
|
660
|
+
<span ><%= ${fieldDataStrTpl} === "√" ? "<svg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke-width='1.5' stroke='currentColor' class='w-4 h-4'><path stroke-linecap='round' stroke-linejoin='round' d='M4.5 12.75l6 6 9-13.5' /></svg>" : ${fieldDataStrTpl} %></span>
|
|
657
661
|
</span>
|
|
658
662
|
<% } %>`
|
|
659
663
|
}
|
|
@@ -5346,12 +5350,22 @@ function getObjectFooterToolbar(mainObject, formFactor, options) {
|
|
|
5346
5350
|
// return [
|
|
5347
5351
|
// "load-more",
|
|
5348
5352
|
// ]
|
|
5349
|
-
|
|
5350
|
-
|
|
5351
|
-
"
|
|
5352
|
-
|
|
5353
|
-
|
|
5354
|
-
|
|
5353
|
+
if(options.displayAs === 'split'){
|
|
5354
|
+
return [
|
|
5355
|
+
"switch-per-page",
|
|
5356
|
+
{
|
|
5357
|
+
"type": "pagination",
|
|
5358
|
+
"maxButtons": 5
|
|
5359
|
+
}
|
|
5360
|
+
]
|
|
5361
|
+
}else {
|
|
5362
|
+
return [
|
|
5363
|
+
{
|
|
5364
|
+
"type": "pagination",
|
|
5365
|
+
"maxButtons": 5
|
|
5366
|
+
}
|
|
5367
|
+
]
|
|
5368
|
+
}
|
|
5355
5369
|
}
|
|
5356
5370
|
else {
|
|
5357
5371
|
if(options && options.isRelated){
|
|
@@ -5977,8 +5991,13 @@ async function lookupToAmisPicker(field, readonly, ctx){
|
|
|
5977
5991
|
|
|
5978
5992
|
let pickerSchema = null;
|
|
5979
5993
|
{
|
|
5994
|
+
let labelFieldName = refObjectConfig.NAME_FIELD_KEY || 'name';
|
|
5995
|
+
// organizations 对象的历史遗留问题, fullname 被标记为了 名称字段. 在此处特殊处理.
|
|
5996
|
+
if(refObjectConfig.name === 'organizations'){
|
|
5997
|
+
labelFieldName = 'name';
|
|
5998
|
+
}
|
|
5980
5999
|
pickerSchema = await getTableSchema$1(tableFields, {
|
|
5981
|
-
labelFieldName
|
|
6000
|
+
labelFieldName,
|
|
5982
6001
|
top: top,
|
|
5983
6002
|
isLookup: true,
|
|
5984
6003
|
...ctx
|
|
@@ -6023,12 +6042,12 @@ async function lookupToAmisPicker(field, readonly, ctx){
|
|
|
6023
6042
|
|
|
6024
6043
|
pickerSchema.onEvent[`@data.changed.${refObjectConfig.name}`] = {
|
|
6025
6044
|
"actions": [
|
|
6026
|
-
|
|
6027
|
-
|
|
6028
|
-
|
|
6029
|
-
|
|
6030
|
-
|
|
6031
|
-
|
|
6045
|
+
{
|
|
6046
|
+
"actionType": "reload"
|
|
6047
|
+
},
|
|
6048
|
+
{
|
|
6049
|
+
"actionType": "custom",
|
|
6050
|
+
"script": `
|
|
6032
6051
|
const masterRecord = event.data._master && event.data._master.record;
|
|
6033
6052
|
const fieldConfig = ${JSON.stringify(field)};
|
|
6034
6053
|
let reference_to = fieldConfig.reference_to;
|
|
@@ -6077,9 +6096,9 @@ async function lookupToAmisPicker(field, readonly, ctx){
|
|
|
6077
6096
|
}
|
|
6078
6097
|
});
|
|
6079
6098
|
`
|
|
6080
|
-
|
|
6099
|
+
}
|
|
6081
6100
|
]
|
|
6082
|
-
|
|
6101
|
+
};
|
|
6083
6102
|
}
|
|
6084
6103
|
|
|
6085
6104
|
if(field.pickerSchema){
|
|
@@ -6351,7 +6370,9 @@ async function lookupToAmis(field, readonly, ctx){
|
|
|
6351
6370
|
}
|
|
6352
6371
|
|
|
6353
6372
|
if(referenceTo.objectName === "space_users" && field.reference_to_field === "user"){
|
|
6354
|
-
ctx
|
|
6373
|
+
ctx = Object.assign({}, ctx, {
|
|
6374
|
+
onlyDisplayLookLabel: true
|
|
6375
|
+
});
|
|
6355
6376
|
if(ctx.idsDependOn){
|
|
6356
6377
|
// ids人员点选模式
|
|
6357
6378
|
return await lookupToAmisIdsPicker(field, readonly, ctx);
|
|
@@ -7339,7 +7360,7 @@ async function convertSFieldToAmisField(field, readonly, ctx) {
|
|
|
7339
7360
|
label: subField.label,
|
|
7340
7361
|
quickEdit: readonly ? false : gridSub
|
|
7341
7362
|
};
|
|
7342
|
-
if(subField.type
|
|
7363
|
+
if(["lookup", "boolean", "toggle"].indexOf(subField.type) > -1){
|
|
7343
7364
|
gridItemSchema.type = gridSub.type;
|
|
7344
7365
|
gridItemSchema.tpl = gridSub.tpl;
|
|
7345
7366
|
}
|
|
@@ -7866,7 +7887,9 @@ async function getTableColumns(fields, options){
|
|
|
7866
7887
|
const quickEditSchema = allowEdit ? await getQuickEditSchema(field, options) : allowEdit;
|
|
7867
7888
|
let className = "";
|
|
7868
7889
|
if(field.wrap != true){
|
|
7869
|
-
className += " whitespace-nowrap";
|
|
7890
|
+
className += " whitespace-nowrap ";
|
|
7891
|
+
}else {
|
|
7892
|
+
className += " break-all ";
|
|
7870
7893
|
}
|
|
7871
7894
|
let columnItem;
|
|
7872
7895
|
if((field.is_name || field.name === options.labelFieldName) && options.objectName === 'cms_files'){
|
|
@@ -7994,7 +8017,8 @@ async function getTableColumns(fields, options){
|
|
|
7994
8017
|
}
|
|
7995
8018
|
}
|
|
7996
8019
|
// columns.push(getOperation(fields));
|
|
7997
|
-
if(!___namespace.some(columns, { name: options.labelFieldName })){
|
|
8020
|
+
if(!options.isLookup && !___namespace.some(columns, { name: options.labelFieldName })){
|
|
8021
|
+
// 没有名称字段时显示序号字段为链接,lookup弹出的picker不需要此功能
|
|
7998
8022
|
const href = Router.getObjectDetailPath({
|
|
7999
8023
|
...options, formFactor: options.formFactor, appId: "${appId}", objectName: options.objectName || "${objectName}", recordId: `\${${options.idFieldName}}`
|
|
8000
8024
|
});
|
|
@@ -8093,7 +8117,9 @@ async function getMobileTableColumns(fields, options){
|
|
|
8093
8117
|
let tpl = "";
|
|
8094
8118
|
if(field.is_name || field.name === options.labelFieldName){
|
|
8095
8119
|
nameField = field;
|
|
8096
|
-
options
|
|
8120
|
+
options = Object.assign({}, options, {
|
|
8121
|
+
onlyDisplayLookLabel: true
|
|
8122
|
+
});
|
|
8097
8123
|
tpl = await getFieldTpl(field, options);
|
|
8098
8124
|
}
|
|
8099
8125
|
else if(field.type === 'avatar' || field.type === 'image' || field.type === 'file'){
|
|
@@ -8102,7 +8128,9 @@ async function getMobileTableColumns(fields, options){
|
|
|
8102
8128
|
}
|
|
8103
8129
|
else {
|
|
8104
8130
|
if(field.type === 'lookup' || field.type === 'master_detail'){
|
|
8105
|
-
options
|
|
8131
|
+
options = Object.assign({}, options, {
|
|
8132
|
+
onlyDisplayLookLabel: true
|
|
8133
|
+
});
|
|
8106
8134
|
}
|
|
8107
8135
|
tpl = await getFieldTpl(field, options);
|
|
8108
8136
|
}
|
|
@@ -8298,11 +8326,10 @@ async function getTableOperation(ctx){
|
|
|
8298
8326
|
}
|
|
8299
8327
|
|
|
8300
8328
|
async function getTableSchema$1(fields, options){
|
|
8301
|
-
let isLookup = options && options.isLookup;
|
|
8302
|
-
let hiddenColumnOperation = options && options.hiddenColumnOperation;
|
|
8303
8329
|
if(!options){
|
|
8304
8330
|
options = {};
|
|
8305
8331
|
}
|
|
8332
|
+
let { isLookup, hiddenColumnOperation } = options;
|
|
8306
8333
|
let columns = [];
|
|
8307
8334
|
let useMobileColumns = options.formFactor === 'SMALL' || ["split"].indexOf(options.displayAs) > -1;
|
|
8308
8335
|
if(isLookup){
|
|
@@ -8314,6 +8341,7 @@ async function getTableSchema$1(fields, options){
|
|
|
8314
8341
|
}
|
|
8315
8342
|
else {
|
|
8316
8343
|
columns = await getTableColumns(fields, options);
|
|
8344
|
+
|
|
8317
8345
|
if(!isLookup && !hiddenColumnOperation){
|
|
8318
8346
|
columns.push(await getTableOperation(options));
|
|
8319
8347
|
}
|
|
@@ -9618,11 +9646,166 @@ async function getObjectCalendar(objectSchema, calendarOptions, options) {
|
|
|
9618
9646
|
return amisSchema;
|
|
9619
9647
|
}
|
|
9620
9648
|
|
|
9649
|
+
/******************************************************************************
|
|
9650
|
+
Copyright (c) Microsoft Corporation.
|
|
9651
|
+
|
|
9652
|
+
Permission to use, copy, modify, and/or distribute this software for any
|
|
9653
|
+
purpose with or without fee is hereby granted.
|
|
9654
|
+
|
|
9655
|
+
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
9656
|
+
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
9657
|
+
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
9658
|
+
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
9659
|
+
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
9660
|
+
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
9661
|
+
PERFORMANCE OF THIS SOFTWARE.
|
|
9662
|
+
***************************************************************************** */
|
|
9663
|
+
|
|
9664
|
+
var __assign = function() {
|
|
9665
|
+
__assign = Object.assign || function __assign(t) {
|
|
9666
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
9667
|
+
s = arguments[i];
|
|
9668
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
|
|
9669
|
+
}
|
|
9670
|
+
return t;
|
|
9671
|
+
};
|
|
9672
|
+
return __assign.apply(this, arguments);
|
|
9673
|
+
};
|
|
9674
|
+
|
|
9675
|
+
/**
|
|
9676
|
+
* 将例如像 a.b.c 或 a[1].b 的字符串转换为路径数组
|
|
9677
|
+
*
|
|
9678
|
+
* @param string 要转换的字符串
|
|
9679
|
+
*/
|
|
9680
|
+
var keyToPath = function (string) {
|
|
9681
|
+
var result = [];
|
|
9682
|
+
if (string.charCodeAt(0) === '.'.charCodeAt(0)) {
|
|
9683
|
+
result.push('');
|
|
9684
|
+
}
|
|
9685
|
+
string.replace(new RegExp('[^.[\\]]+|\\[(?:([^"\'][^[]*)|(["\'])((?:(?!\\2)[^\\\\]|\\\\.)*?)\\2)\\]|(?=(?:\\.|\\[\\])(?:\\.|\\[\\]|$))', 'g'), function (match, expression, quote, subString) {
|
|
9686
|
+
var key = match;
|
|
9687
|
+
if (quote) {
|
|
9688
|
+
key = subString.replace(/\\(\\)?/g, '$1');
|
|
9689
|
+
}
|
|
9690
|
+
else if (expression) {
|
|
9691
|
+
key = expression.trim();
|
|
9692
|
+
}
|
|
9693
|
+
result.push(key);
|
|
9694
|
+
return '';
|
|
9695
|
+
});
|
|
9696
|
+
return result;
|
|
9697
|
+
};
|
|
9698
|
+
|
|
9699
|
+
// 方便取值的时候能够把上层的取到,但是获取的时候不会全部把所有的数据获取到。
|
|
9700
|
+
function createObject(superProps, props, properties) {
|
|
9701
|
+
if (superProps && Object.isFrozen(superProps)) {
|
|
9702
|
+
superProps = cloneObject(superProps);
|
|
9703
|
+
}
|
|
9704
|
+
var obj = superProps
|
|
9705
|
+
? Object.create(superProps, __assign(__assign({}, properties), { __super: {
|
|
9706
|
+
value: superProps,
|
|
9707
|
+
writable: false,
|
|
9708
|
+
enumerable: false
|
|
9709
|
+
} }))
|
|
9710
|
+
: Object.create(Object.prototype, properties);
|
|
9711
|
+
props &&
|
|
9712
|
+
isObject(props) &&
|
|
9713
|
+
Object.keys(props).forEach(function (key) { return (obj[key] = props[key]); });
|
|
9714
|
+
return obj;
|
|
9715
|
+
}
|
|
9716
|
+
function cloneObject(target, persistOwnProps) {
|
|
9717
|
+
if (persistOwnProps === void 0) { persistOwnProps = true; }
|
|
9718
|
+
var obj = target && target.__super
|
|
9719
|
+
? Object.create(target.__super, {
|
|
9720
|
+
__super: {
|
|
9721
|
+
value: target.__super,
|
|
9722
|
+
writable: false,
|
|
9723
|
+
enumerable: false
|
|
9724
|
+
}
|
|
9725
|
+
})
|
|
9726
|
+
: Object.create(Object.prototype);
|
|
9727
|
+
persistOwnProps &&
|
|
9728
|
+
target &&
|
|
9729
|
+
Object.keys(target).forEach(function (key) { return (obj[key] = target[key]); });
|
|
9730
|
+
return obj;
|
|
9731
|
+
}
|
|
9732
|
+
function extendObject(target, src, persistOwnProps) {
|
|
9733
|
+
if (persistOwnProps === void 0) { persistOwnProps = true; }
|
|
9734
|
+
var obj = cloneObject(target, persistOwnProps);
|
|
9735
|
+
src && Object.keys(src).forEach(function (key) { return (obj[key] = src[key]); });
|
|
9736
|
+
return obj;
|
|
9737
|
+
}
|
|
9738
|
+
function isObject(obj) {
|
|
9739
|
+
var typename = typeof obj;
|
|
9740
|
+
return (obj &&
|
|
9741
|
+
typename !== 'string' &&
|
|
9742
|
+
typename !== 'number' &&
|
|
9743
|
+
typename !== 'boolean' &&
|
|
9744
|
+
typename !== 'function' &&
|
|
9745
|
+
!Array.isArray(obj));
|
|
9746
|
+
}
|
|
9747
|
+
function setVariable(data, key, value, convertKeyToPath) {
|
|
9748
|
+
data = data || {};
|
|
9749
|
+
if (key in data) {
|
|
9750
|
+
data[key] = value;
|
|
9751
|
+
return;
|
|
9752
|
+
}
|
|
9753
|
+
var parts = convertKeyToPath !== false ? keyToPath(key) : [key];
|
|
9754
|
+
var last = parts.pop();
|
|
9755
|
+
while (parts.length) {
|
|
9756
|
+
var key_1 = parts.shift();
|
|
9757
|
+
if (isPlainObject__default["default"](data[key_1])) {
|
|
9758
|
+
data = data[key_1] = __assign({}, data[key_1]);
|
|
9759
|
+
}
|
|
9760
|
+
else if (Array.isArray(data[key_1])) {
|
|
9761
|
+
data[key_1] = data[key_1].concat();
|
|
9762
|
+
data = data[key_1];
|
|
9763
|
+
}
|
|
9764
|
+
else if (data[key_1]) {
|
|
9765
|
+
// throw new Error(`目标路径不是纯对象,不能覆盖`);
|
|
9766
|
+
// 强行转成对象
|
|
9767
|
+
data[key_1] = {};
|
|
9768
|
+
data = data[key_1];
|
|
9769
|
+
}
|
|
9770
|
+
else {
|
|
9771
|
+
data[key_1] = {};
|
|
9772
|
+
data = data[key_1];
|
|
9773
|
+
}
|
|
9774
|
+
}
|
|
9775
|
+
data[last] = value;
|
|
9776
|
+
}
|
|
9777
|
+
function deleteVariable(data, key) {
|
|
9778
|
+
if (!data) {
|
|
9779
|
+
return;
|
|
9780
|
+
}
|
|
9781
|
+
else if (data.hasOwnProperty(key)) {
|
|
9782
|
+
delete data[key];
|
|
9783
|
+
return;
|
|
9784
|
+
}
|
|
9785
|
+
var parts = keyToPath(key);
|
|
9786
|
+
var last = parts.pop();
|
|
9787
|
+
while (parts.length) {
|
|
9788
|
+
var key_2 = parts.shift();
|
|
9789
|
+
if (isPlainObject__default["default"](data[key_2])) {
|
|
9790
|
+
data = data[key_2] = __assign({}, data[key_2]);
|
|
9791
|
+
}
|
|
9792
|
+
else if (data[key_2]) {
|
|
9793
|
+
throw new Error("\u76EE\u6807\u8DEF\u5F84\u4E0D\u662F\u7EAF\u5BF9\u8C61\uFF0C\u4E0D\u80FD\u4FEE\u6539");
|
|
9794
|
+
}
|
|
9795
|
+
else {
|
|
9796
|
+
break;
|
|
9797
|
+
}
|
|
9798
|
+
}
|
|
9799
|
+
if (data && data.hasOwnProperty && data.hasOwnProperty(last)) {
|
|
9800
|
+
delete data[last];
|
|
9801
|
+
}
|
|
9802
|
+
}
|
|
9803
|
+
|
|
9621
9804
|
/*
|
|
9622
9805
|
* @Author: baozhoutao@steedos.com
|
|
9623
9806
|
* @Date: 2022-05-26 16:02:08
|
|
9624
9807
|
* @LastEditors: 殷亮辉 yinlianghui@hotoa.com
|
|
9625
|
-
* @LastEditTime: 2023-09-
|
|
9808
|
+
* @LastEditTime: 2023-09-15 15:36:17
|
|
9626
9809
|
* @Description:
|
|
9627
9810
|
*/
|
|
9628
9811
|
|
|
@@ -9712,6 +9895,25 @@ const getSection = async (formFields, permissionFields, fieldSchemaArray, sectio
|
|
|
9712
9895
|
if (sectionFieldsVisibleOn.length > 0 && fieldSetBody.length === sectionFieldsVisibleOn.length) {
|
|
9713
9896
|
section.visibleOn = `${sectionFieldsVisibleOn.join(" || ")}`;
|
|
9714
9897
|
}
|
|
9898
|
+
|
|
9899
|
+
const fieldGroups = ctx.fieldGroups;
|
|
9900
|
+
const group = fieldGroups && fieldGroups.find(function(groupItem){
|
|
9901
|
+
return groupItem.group_name == sectionName;
|
|
9902
|
+
});
|
|
9903
|
+
let groupVisibleOn = group && group.visible_on;
|
|
9904
|
+
if (groupVisibleOn) {
|
|
9905
|
+
if (groupVisibleOn.startsWith("{{")) {
|
|
9906
|
+
groupVisibleOn = `${groupVisibleOn.substring(2, groupVisibleOn.length - 2).replace(/formData./g, 'data.')}`;
|
|
9907
|
+
} else {
|
|
9908
|
+
groupVisibleOn = `${groupVisibleOn.replace(/formData./g, 'data.')}`;
|
|
9909
|
+
}
|
|
9910
|
+
if (section.visibleOn) {
|
|
9911
|
+
section.visibleOn = `${section.visibleOn + " && " + groupVisibleOn}`;
|
|
9912
|
+
}
|
|
9913
|
+
else {
|
|
9914
|
+
section.visibleOn = groupVisibleOn;
|
|
9915
|
+
}
|
|
9916
|
+
}
|
|
9715
9917
|
return section
|
|
9716
9918
|
};
|
|
9717
9919
|
|
|
@@ -9839,9 +10041,30 @@ function getBulkActions(objectSchema){
|
|
|
9839
10041
|
]
|
|
9840
10042
|
}
|
|
9841
10043
|
|
|
10044
|
+
async function getCrudSchemaWithDataFilter(crud, options = {}){
|
|
10045
|
+
const { crudDataFilter, amisData, env } = options;
|
|
10046
|
+
let onCrudDataFilter = options.onCrudDataFilter;
|
|
10047
|
+
if (!onCrudDataFilter && typeof crudDataFilter === 'string') {
|
|
10048
|
+
onCrudDataFilter = new Function(
|
|
10049
|
+
'crud',
|
|
10050
|
+
'env',
|
|
10051
|
+
'data',
|
|
10052
|
+
crudDataFilter
|
|
10053
|
+
);
|
|
10054
|
+
}
|
|
10055
|
+
|
|
10056
|
+
try {
|
|
10057
|
+
onCrudDataFilter && (crud = await onCrudDataFilter(crud, env, amisData) || crud);
|
|
10058
|
+
} catch (e) {
|
|
10059
|
+
console.warn(e);
|
|
10060
|
+
}
|
|
10061
|
+
return crud;
|
|
10062
|
+
}
|
|
10063
|
+
|
|
9842
10064
|
async function getObjectCRUD(objectSchema, fields, options){
|
|
9843
10065
|
// console.time('getObjectCRUD');
|
|
9844
|
-
const { top, perPage, showDisplayAs = false, displayAs, crudClassName = ""
|
|
10066
|
+
const { top, perPage, showDisplayAs = false, displayAs, crudClassName = "",
|
|
10067
|
+
crudDataFilter, onCrudDataFilter, amisData, env } = options;
|
|
9845
10068
|
const nonpaged = objectSchema.paging && objectSchema.paging.enabled === false;
|
|
9846
10069
|
const isTreeObject = objectSchema.enable_tree;
|
|
9847
10070
|
const bulkActions = getBulkActions(objectSchema);
|
|
@@ -9882,6 +10105,14 @@ async function getObjectCRUD(objectSchema, fields, options){
|
|
|
9882
10105
|
filterVisible: options.filterVisible
|
|
9883
10106
|
});
|
|
9884
10107
|
|
|
10108
|
+
options.amisData = createObject(options.amisData, {
|
|
10109
|
+
objectName: objectSchema.name,
|
|
10110
|
+
// _id: null,
|
|
10111
|
+
recordPermissions: objectSchema.permissions,
|
|
10112
|
+
uiSchema: objectSchema,
|
|
10113
|
+
// loaded: false //crud接收适配器中设置为true,否则就是刷新浏览器第一次加载
|
|
10114
|
+
});
|
|
10115
|
+
|
|
9885
10116
|
|
|
9886
10117
|
let body = null;
|
|
9887
10118
|
const id = `listview_${objectSchema.name}`;
|
|
@@ -9907,7 +10138,12 @@ async function getObjectCRUD(objectSchema, fields, options){
|
|
|
9907
10138
|
if(objectSchema.name === 'organizations'){
|
|
9908
10139
|
labelFieldName = 'name';
|
|
9909
10140
|
}
|
|
9910
|
-
|
|
10141
|
+
let tableOptions = Object.assign({
|
|
10142
|
+
idFieldName: objectSchema.idFieldName, labelFieldName: labelFieldName,
|
|
10143
|
+
permissions:objectSchema.permissions,enable_inline_edit:objectSchema.enable_inline_edit
|
|
10144
|
+
}, options);
|
|
10145
|
+
tableOptions.amisData = createObject(options.amisData || {}, {}).__super;
|
|
10146
|
+
const table = await getTableSchema$1(fields, tableOptions);
|
|
9911
10147
|
delete table.mode;
|
|
9912
10148
|
//image与avatar需要在提交修改时特别处理
|
|
9913
10149
|
const imageNames = ___default["default"].compact(___default["default"].map(___default["default"].filter(fields, (field) => ["image","avatar"].includes(field.type)), 'name'));
|
|
@@ -9967,9 +10203,9 @@ async function getObjectCRUD(objectSchema, fields, options){
|
|
|
9967
10203
|
requestAdaptor: quickSaveApiRequestAdaptor,
|
|
9968
10204
|
},
|
|
9969
10205
|
rowClassNameExpr: options.rowClassNameExpr
|
|
9970
|
-
},
|
|
9971
|
-
|
|
9972
|
-
|
|
10206
|
+
}, bodyProps);
|
|
10207
|
+
|
|
10208
|
+
body = await getCrudSchemaWithDataFilter(body, { crudDataFilter, onCrudDataFilter, amisData, env });
|
|
9973
10209
|
}
|
|
9974
10210
|
|
|
9975
10211
|
const defaults = options.defaults;
|
|
@@ -10004,16 +10240,10 @@ async function getObjectCRUD(objectSchema, fields, options){
|
|
|
10004
10240
|
return {
|
|
10005
10241
|
type: 'service',
|
|
10006
10242
|
className: '',
|
|
10007
|
-
//目前crud的service层id不认用户自定义id,只支持默认规则id
|
|
10243
|
+
//目前crud的service层id不认用户自定义id,只支持默认规则id,许多地方的格式都写死了service_listview_${objectname}
|
|
10008
10244
|
id: `service_${id}`,
|
|
10009
10245
|
name: `page`,
|
|
10010
|
-
data:
|
|
10011
|
-
objectName: objectSchema.name,
|
|
10012
|
-
// _id: null,
|
|
10013
|
-
recordPermissions: objectSchema.permissions,
|
|
10014
|
-
uiSchema: objectSchema,
|
|
10015
|
-
// loaded: false //crud接收适配器中设置为true,否则就是刷新浏览器第一次加载
|
|
10016
|
-
},
|
|
10246
|
+
data: options.amisData,
|
|
10017
10247
|
body: body
|
|
10018
10248
|
}
|
|
10019
10249
|
}
|
|
@@ -10104,7 +10334,7 @@ async function getObjectForm(objectSchema, ctx){
|
|
|
10104
10334
|
submitText: "", // amis 表单不显示提交按钮, 表单提交由项目代码接管
|
|
10105
10335
|
api: await getSaveApi(objectSchema, recordId, fields, ctx),
|
|
10106
10336
|
initFetch: recordId != 'new',
|
|
10107
|
-
body: await getFormBody(fields, formFields, ctx),
|
|
10337
|
+
body: await getFormBody(fields, formFields, Object.assign({}, ctx, {fieldGroups: objectSchema.field_groups})),
|
|
10108
10338
|
panelClassName:'m-0 sm:rounded-lg shadow-none border-none',
|
|
10109
10339
|
bodyClassName: 'p-0',
|
|
10110
10340
|
className: 'steedos-amis-form',
|
|
@@ -10179,7 +10409,7 @@ async function getObjectDetail(objectSchema, recordId, ctx){
|
|
|
10179
10409
|
"formData": "$$"
|
|
10180
10410
|
},
|
|
10181
10411
|
wrapWithPanel: false,
|
|
10182
|
-
body: await getFormBody(_$1.map(fields, (field)=>{field.readonly = true; return field;}), _$1.map(formFields, (field)=>{field.readonly = true; return field;}), Object.assign({}, ctx, {showSystemFields: true})),
|
|
10412
|
+
body: await getFormBody(_$1.map(fields, (field)=>{field.readonly = true; return field;}), _$1.map(formFields, (field)=>{field.readonly = true; return field;}), Object.assign({}, ctx, {showSystemFields: true,fieldGroups: objectSchema.field_groups})),
|
|
10183
10413
|
className: 'steedos-amis-form bg-white',
|
|
10184
10414
|
actions: [], // 不显示表单默认的提交按钮
|
|
10185
10415
|
onEvent: {
|
|
@@ -10665,7 +10895,7 @@ async function getRelatedListSchema(
|
|
|
10665
10895
|
* @Author: baozhoutao@steedos.com
|
|
10666
10896
|
* @Date: 2022-07-05 15:55:39
|
|
10667
10897
|
* @LastEditors: 殷亮辉 yinlianghui@hotoa.com
|
|
10668
|
-
* @LastEditTime: 2023-09-
|
|
10898
|
+
* @LastEditTime: 2023-09-15 09:04:49
|
|
10669
10899
|
* @Description:
|
|
10670
10900
|
*/
|
|
10671
10901
|
|
|
@@ -10998,7 +11228,9 @@ async function getListSchema(
|
|
|
10998
11228
|
"adaptor": listView.adaptor,
|
|
10999
11229
|
"headerToolbarItems": ctx.headerToolbarItems,
|
|
11000
11230
|
"filterVisible": ctx.filterVisible,
|
|
11001
|
-
"rowClassNameExpr": ctx.rowClassNameExpr
|
|
11231
|
+
"rowClassNameExpr": ctx.rowClassNameExpr,
|
|
11232
|
+
"crudDataFilter": ctx.crudDataFilter,
|
|
11233
|
+
"onCrudDataFilter": ctx.onCrudDataFilter
|
|
11002
11234
|
};
|
|
11003
11235
|
// console.log(`getListSchema===>`,amisSchema)
|
|
11004
11236
|
return {
|
|
@@ -11101,7 +11333,7 @@ async function getTableSchema(
|
|
|
11101
11333
|
fields = fields.concat(extraFields);
|
|
11102
11334
|
}
|
|
11103
11335
|
|
|
11104
|
-
|
|
11336
|
+
let crudOptions = {
|
|
11105
11337
|
tabId: objectName,
|
|
11106
11338
|
appId: appName,
|
|
11107
11339
|
objectName: objectName,
|
|
@@ -11110,8 +11342,9 @@ async function getTableSchema(
|
|
|
11110
11342
|
sort,
|
|
11111
11343
|
headerToolbarItems: ctx.headerToolbarItems,
|
|
11112
11344
|
buttons: await getListViewItemButtons(uiSchema, ctx)
|
|
11113
|
-
}
|
|
11114
|
-
|
|
11345
|
+
};
|
|
11346
|
+
crudOptions.amisData = createObject(ctx.amisData || {}, {}).__super;
|
|
11347
|
+
const amisSchema = await getObjectCRUD(uiSchema, fields, crudOptions);
|
|
11115
11348
|
// console.timeEnd('getTableSchema');
|
|
11116
11349
|
return {
|
|
11117
11350
|
uiSchema,
|
|
@@ -11895,161 +12128,6 @@ const registerRemoteAssets = async (assetUrls)=>{
|
|
|
11895
12128
|
}
|
|
11896
12129
|
};
|
|
11897
12130
|
|
|
11898
|
-
/******************************************************************************
|
|
11899
|
-
Copyright (c) Microsoft Corporation.
|
|
11900
|
-
|
|
11901
|
-
Permission to use, copy, modify, and/or distribute this software for any
|
|
11902
|
-
purpose with or without fee is hereby granted.
|
|
11903
|
-
|
|
11904
|
-
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
11905
|
-
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
11906
|
-
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
11907
|
-
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
11908
|
-
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
11909
|
-
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
11910
|
-
PERFORMANCE OF THIS SOFTWARE.
|
|
11911
|
-
***************************************************************************** */
|
|
11912
|
-
|
|
11913
|
-
var __assign = function() {
|
|
11914
|
-
__assign = Object.assign || function __assign(t) {
|
|
11915
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
11916
|
-
s = arguments[i];
|
|
11917
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
|
|
11918
|
-
}
|
|
11919
|
-
return t;
|
|
11920
|
-
};
|
|
11921
|
-
return __assign.apply(this, arguments);
|
|
11922
|
-
};
|
|
11923
|
-
|
|
11924
|
-
/**
|
|
11925
|
-
* 将例如像 a.b.c 或 a[1].b 的字符串转换为路径数组
|
|
11926
|
-
*
|
|
11927
|
-
* @param string 要转换的字符串
|
|
11928
|
-
*/
|
|
11929
|
-
var keyToPath = function (string) {
|
|
11930
|
-
var result = [];
|
|
11931
|
-
if (string.charCodeAt(0) === '.'.charCodeAt(0)) {
|
|
11932
|
-
result.push('');
|
|
11933
|
-
}
|
|
11934
|
-
string.replace(new RegExp('[^.[\\]]+|\\[(?:([^"\'][^[]*)|(["\'])((?:(?!\\2)[^\\\\]|\\\\.)*?)\\2)\\]|(?=(?:\\.|\\[\\])(?:\\.|\\[\\]|$))', 'g'), function (match, expression, quote, subString) {
|
|
11935
|
-
var key = match;
|
|
11936
|
-
if (quote) {
|
|
11937
|
-
key = subString.replace(/\\(\\)?/g, '$1');
|
|
11938
|
-
}
|
|
11939
|
-
else if (expression) {
|
|
11940
|
-
key = expression.trim();
|
|
11941
|
-
}
|
|
11942
|
-
result.push(key);
|
|
11943
|
-
return '';
|
|
11944
|
-
});
|
|
11945
|
-
return result;
|
|
11946
|
-
};
|
|
11947
|
-
|
|
11948
|
-
// 方便取值的时候能够把上层的取到,但是获取的时候不会全部把所有的数据获取到。
|
|
11949
|
-
function createObject(superProps, props, properties) {
|
|
11950
|
-
if (superProps && Object.isFrozen(superProps)) {
|
|
11951
|
-
superProps = cloneObject(superProps);
|
|
11952
|
-
}
|
|
11953
|
-
var obj = superProps
|
|
11954
|
-
? Object.create(superProps, __assign(__assign({}, properties), { __super: {
|
|
11955
|
-
value: superProps,
|
|
11956
|
-
writable: false,
|
|
11957
|
-
enumerable: false
|
|
11958
|
-
} }))
|
|
11959
|
-
: Object.create(Object.prototype, properties);
|
|
11960
|
-
props &&
|
|
11961
|
-
isObject(props) &&
|
|
11962
|
-
Object.keys(props).forEach(function (key) { return (obj[key] = props[key]); });
|
|
11963
|
-
return obj;
|
|
11964
|
-
}
|
|
11965
|
-
function cloneObject(target, persistOwnProps) {
|
|
11966
|
-
if (persistOwnProps === void 0) { persistOwnProps = true; }
|
|
11967
|
-
var obj = target && target.__super
|
|
11968
|
-
? Object.create(target.__super, {
|
|
11969
|
-
__super: {
|
|
11970
|
-
value: target.__super,
|
|
11971
|
-
writable: false,
|
|
11972
|
-
enumerable: false
|
|
11973
|
-
}
|
|
11974
|
-
})
|
|
11975
|
-
: Object.create(Object.prototype);
|
|
11976
|
-
persistOwnProps &&
|
|
11977
|
-
target &&
|
|
11978
|
-
Object.keys(target).forEach(function (key) { return (obj[key] = target[key]); });
|
|
11979
|
-
return obj;
|
|
11980
|
-
}
|
|
11981
|
-
function extendObject(target, src, persistOwnProps) {
|
|
11982
|
-
if (persistOwnProps === void 0) { persistOwnProps = true; }
|
|
11983
|
-
var obj = cloneObject(target, persistOwnProps);
|
|
11984
|
-
src && Object.keys(src).forEach(function (key) { return (obj[key] = src[key]); });
|
|
11985
|
-
return obj;
|
|
11986
|
-
}
|
|
11987
|
-
function isObject(obj) {
|
|
11988
|
-
var typename = typeof obj;
|
|
11989
|
-
return (obj &&
|
|
11990
|
-
typename !== 'string' &&
|
|
11991
|
-
typename !== 'number' &&
|
|
11992
|
-
typename !== 'boolean' &&
|
|
11993
|
-
typename !== 'function' &&
|
|
11994
|
-
!Array.isArray(obj));
|
|
11995
|
-
}
|
|
11996
|
-
function setVariable(data, key, value, convertKeyToPath) {
|
|
11997
|
-
data = data || {};
|
|
11998
|
-
if (key in data) {
|
|
11999
|
-
data[key] = value;
|
|
12000
|
-
return;
|
|
12001
|
-
}
|
|
12002
|
-
var parts = convertKeyToPath !== false ? keyToPath(key) : [key];
|
|
12003
|
-
var last = parts.pop();
|
|
12004
|
-
while (parts.length) {
|
|
12005
|
-
var key_1 = parts.shift();
|
|
12006
|
-
if (isPlainObject__default["default"](data[key_1])) {
|
|
12007
|
-
data = data[key_1] = __assign({}, data[key_1]);
|
|
12008
|
-
}
|
|
12009
|
-
else if (Array.isArray(data[key_1])) {
|
|
12010
|
-
data[key_1] = data[key_1].concat();
|
|
12011
|
-
data = data[key_1];
|
|
12012
|
-
}
|
|
12013
|
-
else if (data[key_1]) {
|
|
12014
|
-
// throw new Error(`目标路径不是纯对象,不能覆盖`);
|
|
12015
|
-
// 强行转成对象
|
|
12016
|
-
data[key_1] = {};
|
|
12017
|
-
data = data[key_1];
|
|
12018
|
-
}
|
|
12019
|
-
else {
|
|
12020
|
-
data[key_1] = {};
|
|
12021
|
-
data = data[key_1];
|
|
12022
|
-
}
|
|
12023
|
-
}
|
|
12024
|
-
data[last] = value;
|
|
12025
|
-
}
|
|
12026
|
-
function deleteVariable(data, key) {
|
|
12027
|
-
if (!data) {
|
|
12028
|
-
return;
|
|
12029
|
-
}
|
|
12030
|
-
else if (data.hasOwnProperty(key)) {
|
|
12031
|
-
delete data[key];
|
|
12032
|
-
return;
|
|
12033
|
-
}
|
|
12034
|
-
var parts = keyToPath(key);
|
|
12035
|
-
var last = parts.pop();
|
|
12036
|
-
while (parts.length) {
|
|
12037
|
-
var key_2 = parts.shift();
|
|
12038
|
-
if (isPlainObject__default["default"](data[key_2])) {
|
|
12039
|
-
data = data[key_2] = __assign({}, data[key_2]);
|
|
12040
|
-
}
|
|
12041
|
-
else if (data[key_2]) {
|
|
12042
|
-
throw new Error("\u76EE\u6807\u8DEF\u5F84\u4E0D\u662F\u7EAF\u5BF9\u8C61\uFF0C\u4E0D\u80FD\u4FEE\u6539");
|
|
12043
|
-
}
|
|
12044
|
-
else {
|
|
12045
|
-
break;
|
|
12046
|
-
}
|
|
12047
|
-
}
|
|
12048
|
-
if (data && data.hasOwnProperty && data.hasOwnProperty(last)) {
|
|
12049
|
-
delete data[last];
|
|
12050
|
-
}
|
|
12051
|
-
}
|
|
12052
|
-
|
|
12053
12131
|
/*
|
|
12054
12132
|
* @Author: baozhoutao@steedos.com
|
|
12055
12133
|
* @Date: 2022-12-17 17:03:40
|