@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.esm.js
CHANGED
|
@@ -444,7 +444,7 @@ function getLookupListView(refObjectConfig) {
|
|
|
444
444
|
* @Author: baozhoutao@steedos.com
|
|
445
445
|
* @Date: 2022-05-23 09:53:08
|
|
446
446
|
* @LastEditors: 殷亮辉 yinlianghui@hotoa.com
|
|
447
|
-
* @LastEditTime: 2023-
|
|
447
|
+
* @LastEditTime: 2023-09-19 14:38:39
|
|
448
448
|
* @Description:
|
|
449
449
|
*/
|
|
450
450
|
|
|
@@ -624,9 +624,13 @@ async function getLookupTpl(field, ctx){
|
|
|
624
624
|
}
|
|
625
625
|
|
|
626
626
|
function getSwitchTpl(field){
|
|
627
|
+
let fieldDataStrTpl = `data._display.${field.name}`;
|
|
628
|
+
if(field.isTableField){
|
|
629
|
+
fieldDataStrTpl = `data.${field.name}`;
|
|
630
|
+
}
|
|
627
631
|
return `<% if (data.${field.name}) { %>
|
|
628
|
-
<span class="slds-icon_container slds-icon-utility-check slds-current-color" title="
|
|
629
|
-
<span ><%=
|
|
632
|
+
<span class="slds-icon_container slds-icon-utility-check slds-current-color" title="<%=${fieldDataStrTpl}%>">
|
|
633
|
+
<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>
|
|
630
634
|
</span>
|
|
631
635
|
<% } %>`
|
|
632
636
|
}
|
|
@@ -5319,12 +5323,22 @@ function getObjectFooterToolbar(mainObject, formFactor, options) {
|
|
|
5319
5323
|
// return [
|
|
5320
5324
|
// "load-more",
|
|
5321
5325
|
// ]
|
|
5322
|
-
|
|
5323
|
-
|
|
5324
|
-
"
|
|
5325
|
-
|
|
5326
|
-
|
|
5327
|
-
|
|
5326
|
+
if(options.displayAs === 'split'){
|
|
5327
|
+
return [
|
|
5328
|
+
"switch-per-page",
|
|
5329
|
+
{
|
|
5330
|
+
"type": "pagination",
|
|
5331
|
+
"maxButtons": 5
|
|
5332
|
+
}
|
|
5333
|
+
]
|
|
5334
|
+
}else {
|
|
5335
|
+
return [
|
|
5336
|
+
{
|
|
5337
|
+
"type": "pagination",
|
|
5338
|
+
"maxButtons": 5
|
|
5339
|
+
}
|
|
5340
|
+
]
|
|
5341
|
+
}
|
|
5328
5342
|
}
|
|
5329
5343
|
else {
|
|
5330
5344
|
if(options && options.isRelated){
|
|
@@ -5950,8 +5964,13 @@ async function lookupToAmisPicker(field, readonly, ctx){
|
|
|
5950
5964
|
|
|
5951
5965
|
let pickerSchema = null;
|
|
5952
5966
|
{
|
|
5967
|
+
let labelFieldName = refObjectConfig.NAME_FIELD_KEY || 'name';
|
|
5968
|
+
// organizations 对象的历史遗留问题, fullname 被标记为了 名称字段. 在此处特殊处理.
|
|
5969
|
+
if(refObjectConfig.name === 'organizations'){
|
|
5970
|
+
labelFieldName = 'name';
|
|
5971
|
+
}
|
|
5953
5972
|
pickerSchema = await getTableSchema$1(tableFields, {
|
|
5954
|
-
labelFieldName
|
|
5973
|
+
labelFieldName,
|
|
5955
5974
|
top: top,
|
|
5956
5975
|
isLookup: true,
|
|
5957
5976
|
...ctx
|
|
@@ -5996,12 +6015,12 @@ async function lookupToAmisPicker(field, readonly, ctx){
|
|
|
5996
6015
|
|
|
5997
6016
|
pickerSchema.onEvent[`@data.changed.${refObjectConfig.name}`] = {
|
|
5998
6017
|
"actions": [
|
|
5999
|
-
|
|
6000
|
-
|
|
6001
|
-
|
|
6002
|
-
|
|
6003
|
-
|
|
6004
|
-
|
|
6018
|
+
{
|
|
6019
|
+
"actionType": "reload"
|
|
6020
|
+
},
|
|
6021
|
+
{
|
|
6022
|
+
"actionType": "custom",
|
|
6023
|
+
"script": `
|
|
6005
6024
|
const masterRecord = event.data._master && event.data._master.record;
|
|
6006
6025
|
const fieldConfig = ${JSON.stringify(field)};
|
|
6007
6026
|
let reference_to = fieldConfig.reference_to;
|
|
@@ -6050,9 +6069,9 @@ async function lookupToAmisPicker(field, readonly, ctx){
|
|
|
6050
6069
|
}
|
|
6051
6070
|
});
|
|
6052
6071
|
`
|
|
6053
|
-
|
|
6072
|
+
}
|
|
6054
6073
|
]
|
|
6055
|
-
|
|
6074
|
+
};
|
|
6056
6075
|
}
|
|
6057
6076
|
|
|
6058
6077
|
if(field.pickerSchema){
|
|
@@ -6324,7 +6343,9 @@ async function lookupToAmis(field, readonly, ctx){
|
|
|
6324
6343
|
}
|
|
6325
6344
|
|
|
6326
6345
|
if(referenceTo.objectName === "space_users" && field.reference_to_field === "user"){
|
|
6327
|
-
ctx
|
|
6346
|
+
ctx = Object.assign({}, ctx, {
|
|
6347
|
+
onlyDisplayLookLabel: true
|
|
6348
|
+
});
|
|
6328
6349
|
if(ctx.idsDependOn){
|
|
6329
6350
|
// ids人员点选模式
|
|
6330
6351
|
return await lookupToAmisIdsPicker(field, readonly, ctx);
|
|
@@ -7312,7 +7333,7 @@ async function convertSFieldToAmisField(field, readonly, ctx) {
|
|
|
7312
7333
|
label: subField.label,
|
|
7313
7334
|
quickEdit: readonly ? false : gridSub
|
|
7314
7335
|
};
|
|
7315
|
-
if(subField.type
|
|
7336
|
+
if(["lookup", "boolean", "toggle"].indexOf(subField.type) > -1){
|
|
7316
7337
|
gridItemSchema.type = gridSub.type;
|
|
7317
7338
|
gridItemSchema.tpl = gridSub.tpl;
|
|
7318
7339
|
}
|
|
@@ -7839,7 +7860,9 @@ async function getTableColumns(fields, options){
|
|
|
7839
7860
|
const quickEditSchema = allowEdit ? await getQuickEditSchema(field, options) : allowEdit;
|
|
7840
7861
|
let className = "";
|
|
7841
7862
|
if(field.wrap != true){
|
|
7842
|
-
className += " whitespace-nowrap";
|
|
7863
|
+
className += " whitespace-nowrap ";
|
|
7864
|
+
}else {
|
|
7865
|
+
className += " break-all ";
|
|
7843
7866
|
}
|
|
7844
7867
|
let columnItem;
|
|
7845
7868
|
if((field.is_name || field.name === options.labelFieldName) && options.objectName === 'cms_files'){
|
|
@@ -7967,7 +7990,8 @@ async function getTableColumns(fields, options){
|
|
|
7967
7990
|
}
|
|
7968
7991
|
}
|
|
7969
7992
|
// columns.push(getOperation(fields));
|
|
7970
|
-
if(!_$1.some(columns, { name: options.labelFieldName })){
|
|
7993
|
+
if(!options.isLookup && !_$1.some(columns, { name: options.labelFieldName })){
|
|
7994
|
+
// 没有名称字段时显示序号字段为链接,lookup弹出的picker不需要此功能
|
|
7971
7995
|
const href = Router.getObjectDetailPath({
|
|
7972
7996
|
...options, formFactor: options.formFactor, appId: "${appId}", objectName: options.objectName || "${objectName}", recordId: `\${${options.idFieldName}}`
|
|
7973
7997
|
});
|
|
@@ -8066,7 +8090,9 @@ async function getMobileTableColumns(fields, options){
|
|
|
8066
8090
|
let tpl = "";
|
|
8067
8091
|
if(field.is_name || field.name === options.labelFieldName){
|
|
8068
8092
|
nameField = field;
|
|
8069
|
-
options
|
|
8093
|
+
options = Object.assign({}, options, {
|
|
8094
|
+
onlyDisplayLookLabel: true
|
|
8095
|
+
});
|
|
8070
8096
|
tpl = await getFieldTpl(field, options);
|
|
8071
8097
|
}
|
|
8072
8098
|
else if(field.type === 'avatar' || field.type === 'image' || field.type === 'file'){
|
|
@@ -8075,7 +8101,9 @@ async function getMobileTableColumns(fields, options){
|
|
|
8075
8101
|
}
|
|
8076
8102
|
else {
|
|
8077
8103
|
if(field.type === 'lookup' || field.type === 'master_detail'){
|
|
8078
|
-
options
|
|
8104
|
+
options = Object.assign({}, options, {
|
|
8105
|
+
onlyDisplayLookLabel: true
|
|
8106
|
+
});
|
|
8079
8107
|
}
|
|
8080
8108
|
tpl = await getFieldTpl(field, options);
|
|
8081
8109
|
}
|
|
@@ -8271,11 +8299,10 @@ async function getTableOperation(ctx){
|
|
|
8271
8299
|
}
|
|
8272
8300
|
|
|
8273
8301
|
async function getTableSchema$1(fields, options){
|
|
8274
|
-
let isLookup = options && options.isLookup;
|
|
8275
|
-
let hiddenColumnOperation = options && options.hiddenColumnOperation;
|
|
8276
8302
|
if(!options){
|
|
8277
8303
|
options = {};
|
|
8278
8304
|
}
|
|
8305
|
+
let { isLookup, hiddenColumnOperation } = options;
|
|
8279
8306
|
let columns = [];
|
|
8280
8307
|
let useMobileColumns = options.formFactor === 'SMALL' || ["split"].indexOf(options.displayAs) > -1;
|
|
8281
8308
|
if(isLookup){
|
|
@@ -8287,6 +8314,7 @@ async function getTableSchema$1(fields, options){
|
|
|
8287
8314
|
}
|
|
8288
8315
|
else {
|
|
8289
8316
|
columns = await getTableColumns(fields, options);
|
|
8317
|
+
|
|
8290
8318
|
if(!isLookup && !hiddenColumnOperation){
|
|
8291
8319
|
columns.push(await getTableOperation(options));
|
|
8292
8320
|
}
|
|
@@ -9591,11 +9619,166 @@ async function getObjectCalendar(objectSchema, calendarOptions, options) {
|
|
|
9591
9619
|
return amisSchema;
|
|
9592
9620
|
}
|
|
9593
9621
|
|
|
9622
|
+
/******************************************************************************
|
|
9623
|
+
Copyright (c) Microsoft Corporation.
|
|
9624
|
+
|
|
9625
|
+
Permission to use, copy, modify, and/or distribute this software for any
|
|
9626
|
+
purpose with or without fee is hereby granted.
|
|
9627
|
+
|
|
9628
|
+
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
9629
|
+
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
9630
|
+
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
9631
|
+
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
9632
|
+
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
9633
|
+
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
9634
|
+
PERFORMANCE OF THIS SOFTWARE.
|
|
9635
|
+
***************************************************************************** */
|
|
9636
|
+
|
|
9637
|
+
var __assign = function() {
|
|
9638
|
+
__assign = Object.assign || function __assign(t) {
|
|
9639
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
9640
|
+
s = arguments[i];
|
|
9641
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
|
|
9642
|
+
}
|
|
9643
|
+
return t;
|
|
9644
|
+
};
|
|
9645
|
+
return __assign.apply(this, arguments);
|
|
9646
|
+
};
|
|
9647
|
+
|
|
9648
|
+
/**
|
|
9649
|
+
* 将例如像 a.b.c 或 a[1].b 的字符串转换为路径数组
|
|
9650
|
+
*
|
|
9651
|
+
* @param string 要转换的字符串
|
|
9652
|
+
*/
|
|
9653
|
+
var keyToPath = function (string) {
|
|
9654
|
+
var result = [];
|
|
9655
|
+
if (string.charCodeAt(0) === '.'.charCodeAt(0)) {
|
|
9656
|
+
result.push('');
|
|
9657
|
+
}
|
|
9658
|
+
string.replace(new RegExp('[^.[\\]]+|\\[(?:([^"\'][^[]*)|(["\'])((?:(?!\\2)[^\\\\]|\\\\.)*?)\\2)\\]|(?=(?:\\.|\\[\\])(?:\\.|\\[\\]|$))', 'g'), function (match, expression, quote, subString) {
|
|
9659
|
+
var key = match;
|
|
9660
|
+
if (quote) {
|
|
9661
|
+
key = subString.replace(/\\(\\)?/g, '$1');
|
|
9662
|
+
}
|
|
9663
|
+
else if (expression) {
|
|
9664
|
+
key = expression.trim();
|
|
9665
|
+
}
|
|
9666
|
+
result.push(key);
|
|
9667
|
+
return '';
|
|
9668
|
+
});
|
|
9669
|
+
return result;
|
|
9670
|
+
};
|
|
9671
|
+
|
|
9672
|
+
// 方便取值的时候能够把上层的取到,但是获取的时候不会全部把所有的数据获取到。
|
|
9673
|
+
function createObject(superProps, props, properties) {
|
|
9674
|
+
if (superProps && Object.isFrozen(superProps)) {
|
|
9675
|
+
superProps = cloneObject(superProps);
|
|
9676
|
+
}
|
|
9677
|
+
var obj = superProps
|
|
9678
|
+
? Object.create(superProps, __assign(__assign({}, properties), { __super: {
|
|
9679
|
+
value: superProps,
|
|
9680
|
+
writable: false,
|
|
9681
|
+
enumerable: false
|
|
9682
|
+
} }))
|
|
9683
|
+
: Object.create(Object.prototype, properties);
|
|
9684
|
+
props &&
|
|
9685
|
+
isObject(props) &&
|
|
9686
|
+
Object.keys(props).forEach(function (key) { return (obj[key] = props[key]); });
|
|
9687
|
+
return obj;
|
|
9688
|
+
}
|
|
9689
|
+
function cloneObject(target, persistOwnProps) {
|
|
9690
|
+
if (persistOwnProps === void 0) { persistOwnProps = true; }
|
|
9691
|
+
var obj = target && target.__super
|
|
9692
|
+
? Object.create(target.__super, {
|
|
9693
|
+
__super: {
|
|
9694
|
+
value: target.__super,
|
|
9695
|
+
writable: false,
|
|
9696
|
+
enumerable: false
|
|
9697
|
+
}
|
|
9698
|
+
})
|
|
9699
|
+
: Object.create(Object.prototype);
|
|
9700
|
+
persistOwnProps &&
|
|
9701
|
+
target &&
|
|
9702
|
+
Object.keys(target).forEach(function (key) { return (obj[key] = target[key]); });
|
|
9703
|
+
return obj;
|
|
9704
|
+
}
|
|
9705
|
+
function extendObject(target, src, persistOwnProps) {
|
|
9706
|
+
if (persistOwnProps === void 0) { persistOwnProps = true; }
|
|
9707
|
+
var obj = cloneObject(target, persistOwnProps);
|
|
9708
|
+
src && Object.keys(src).forEach(function (key) { return (obj[key] = src[key]); });
|
|
9709
|
+
return obj;
|
|
9710
|
+
}
|
|
9711
|
+
function isObject(obj) {
|
|
9712
|
+
var typename = typeof obj;
|
|
9713
|
+
return (obj &&
|
|
9714
|
+
typename !== 'string' &&
|
|
9715
|
+
typename !== 'number' &&
|
|
9716
|
+
typename !== 'boolean' &&
|
|
9717
|
+
typename !== 'function' &&
|
|
9718
|
+
!Array.isArray(obj));
|
|
9719
|
+
}
|
|
9720
|
+
function setVariable(data, key, value, convertKeyToPath) {
|
|
9721
|
+
data = data || {};
|
|
9722
|
+
if (key in data) {
|
|
9723
|
+
data[key] = value;
|
|
9724
|
+
return;
|
|
9725
|
+
}
|
|
9726
|
+
var parts = convertKeyToPath !== false ? keyToPath(key) : [key];
|
|
9727
|
+
var last = parts.pop();
|
|
9728
|
+
while (parts.length) {
|
|
9729
|
+
var key_1 = parts.shift();
|
|
9730
|
+
if (isPlainObject(data[key_1])) {
|
|
9731
|
+
data = data[key_1] = __assign({}, data[key_1]);
|
|
9732
|
+
}
|
|
9733
|
+
else if (Array.isArray(data[key_1])) {
|
|
9734
|
+
data[key_1] = data[key_1].concat();
|
|
9735
|
+
data = data[key_1];
|
|
9736
|
+
}
|
|
9737
|
+
else if (data[key_1]) {
|
|
9738
|
+
// throw new Error(`目标路径不是纯对象,不能覆盖`);
|
|
9739
|
+
// 强行转成对象
|
|
9740
|
+
data[key_1] = {};
|
|
9741
|
+
data = data[key_1];
|
|
9742
|
+
}
|
|
9743
|
+
else {
|
|
9744
|
+
data[key_1] = {};
|
|
9745
|
+
data = data[key_1];
|
|
9746
|
+
}
|
|
9747
|
+
}
|
|
9748
|
+
data[last] = value;
|
|
9749
|
+
}
|
|
9750
|
+
function deleteVariable(data, key) {
|
|
9751
|
+
if (!data) {
|
|
9752
|
+
return;
|
|
9753
|
+
}
|
|
9754
|
+
else if (data.hasOwnProperty(key)) {
|
|
9755
|
+
delete data[key];
|
|
9756
|
+
return;
|
|
9757
|
+
}
|
|
9758
|
+
var parts = keyToPath(key);
|
|
9759
|
+
var last = parts.pop();
|
|
9760
|
+
while (parts.length) {
|
|
9761
|
+
var key_2 = parts.shift();
|
|
9762
|
+
if (isPlainObject(data[key_2])) {
|
|
9763
|
+
data = data[key_2] = __assign({}, data[key_2]);
|
|
9764
|
+
}
|
|
9765
|
+
else if (data[key_2]) {
|
|
9766
|
+
throw new Error("\u76EE\u6807\u8DEF\u5F84\u4E0D\u662F\u7EAF\u5BF9\u8C61\uFF0C\u4E0D\u80FD\u4FEE\u6539");
|
|
9767
|
+
}
|
|
9768
|
+
else {
|
|
9769
|
+
break;
|
|
9770
|
+
}
|
|
9771
|
+
}
|
|
9772
|
+
if (data && data.hasOwnProperty && data.hasOwnProperty(last)) {
|
|
9773
|
+
delete data[last];
|
|
9774
|
+
}
|
|
9775
|
+
}
|
|
9776
|
+
|
|
9594
9777
|
/*
|
|
9595
9778
|
* @Author: baozhoutao@steedos.com
|
|
9596
9779
|
* @Date: 2022-05-26 16:02:08
|
|
9597
9780
|
* @LastEditors: 殷亮辉 yinlianghui@hotoa.com
|
|
9598
|
-
* @LastEditTime: 2023-09-
|
|
9781
|
+
* @LastEditTime: 2023-09-15 15:36:17
|
|
9599
9782
|
* @Description:
|
|
9600
9783
|
*/
|
|
9601
9784
|
|
|
@@ -9685,6 +9868,25 @@ const getSection = async (formFields, permissionFields, fieldSchemaArray, sectio
|
|
|
9685
9868
|
if (sectionFieldsVisibleOn.length > 0 && fieldSetBody.length === sectionFieldsVisibleOn.length) {
|
|
9686
9869
|
section.visibleOn = `${sectionFieldsVisibleOn.join(" || ")}`;
|
|
9687
9870
|
}
|
|
9871
|
+
|
|
9872
|
+
const fieldGroups = ctx.fieldGroups;
|
|
9873
|
+
const group = fieldGroups && fieldGroups.find(function(groupItem){
|
|
9874
|
+
return groupItem.group_name == sectionName;
|
|
9875
|
+
});
|
|
9876
|
+
let groupVisibleOn = group && group.visible_on;
|
|
9877
|
+
if (groupVisibleOn) {
|
|
9878
|
+
if (groupVisibleOn.startsWith("{{")) {
|
|
9879
|
+
groupVisibleOn = `${groupVisibleOn.substring(2, groupVisibleOn.length - 2).replace(/formData./g, 'data.')}`;
|
|
9880
|
+
} else {
|
|
9881
|
+
groupVisibleOn = `${groupVisibleOn.replace(/formData./g, 'data.')}`;
|
|
9882
|
+
}
|
|
9883
|
+
if (section.visibleOn) {
|
|
9884
|
+
section.visibleOn = `${section.visibleOn + " && " + groupVisibleOn}`;
|
|
9885
|
+
}
|
|
9886
|
+
else {
|
|
9887
|
+
section.visibleOn = groupVisibleOn;
|
|
9888
|
+
}
|
|
9889
|
+
}
|
|
9688
9890
|
return section
|
|
9689
9891
|
};
|
|
9690
9892
|
|
|
@@ -9812,9 +10014,30 @@ function getBulkActions(objectSchema){
|
|
|
9812
10014
|
]
|
|
9813
10015
|
}
|
|
9814
10016
|
|
|
10017
|
+
async function getCrudSchemaWithDataFilter(crud, options = {}){
|
|
10018
|
+
const { crudDataFilter, amisData, env } = options;
|
|
10019
|
+
let onCrudDataFilter = options.onCrudDataFilter;
|
|
10020
|
+
if (!onCrudDataFilter && typeof crudDataFilter === 'string') {
|
|
10021
|
+
onCrudDataFilter = new Function(
|
|
10022
|
+
'crud',
|
|
10023
|
+
'env',
|
|
10024
|
+
'data',
|
|
10025
|
+
crudDataFilter
|
|
10026
|
+
);
|
|
10027
|
+
}
|
|
10028
|
+
|
|
10029
|
+
try {
|
|
10030
|
+
onCrudDataFilter && (crud = await onCrudDataFilter(crud, env, amisData) || crud);
|
|
10031
|
+
} catch (e) {
|
|
10032
|
+
console.warn(e);
|
|
10033
|
+
}
|
|
10034
|
+
return crud;
|
|
10035
|
+
}
|
|
10036
|
+
|
|
9815
10037
|
async function getObjectCRUD(objectSchema, fields, options){
|
|
9816
10038
|
// console.time('getObjectCRUD');
|
|
9817
|
-
const { top, perPage, showDisplayAs = false, displayAs, crudClassName = ""
|
|
10039
|
+
const { top, perPage, showDisplayAs = false, displayAs, crudClassName = "",
|
|
10040
|
+
crudDataFilter, onCrudDataFilter, amisData, env } = options;
|
|
9818
10041
|
const nonpaged = objectSchema.paging && objectSchema.paging.enabled === false;
|
|
9819
10042
|
const isTreeObject = objectSchema.enable_tree;
|
|
9820
10043
|
const bulkActions = getBulkActions(objectSchema);
|
|
@@ -9855,6 +10078,14 @@ async function getObjectCRUD(objectSchema, fields, options){
|
|
|
9855
10078
|
filterVisible: options.filterVisible
|
|
9856
10079
|
});
|
|
9857
10080
|
|
|
10081
|
+
options.amisData = createObject(options.amisData, {
|
|
10082
|
+
objectName: objectSchema.name,
|
|
10083
|
+
// _id: null,
|
|
10084
|
+
recordPermissions: objectSchema.permissions,
|
|
10085
|
+
uiSchema: objectSchema,
|
|
10086
|
+
// loaded: false //crud接收适配器中设置为true,否则就是刷新浏览器第一次加载
|
|
10087
|
+
});
|
|
10088
|
+
|
|
9858
10089
|
|
|
9859
10090
|
let body = null;
|
|
9860
10091
|
const id = `listview_${objectSchema.name}`;
|
|
@@ -9880,7 +10111,12 @@ async function getObjectCRUD(objectSchema, fields, options){
|
|
|
9880
10111
|
if(objectSchema.name === 'organizations'){
|
|
9881
10112
|
labelFieldName = 'name';
|
|
9882
10113
|
}
|
|
9883
|
-
|
|
10114
|
+
let tableOptions = Object.assign({
|
|
10115
|
+
idFieldName: objectSchema.idFieldName, labelFieldName: labelFieldName,
|
|
10116
|
+
permissions:objectSchema.permissions,enable_inline_edit:objectSchema.enable_inline_edit
|
|
10117
|
+
}, options);
|
|
10118
|
+
tableOptions.amisData = createObject(options.amisData || {}, {}).__super;
|
|
10119
|
+
const table = await getTableSchema$1(fields, tableOptions);
|
|
9884
10120
|
delete table.mode;
|
|
9885
10121
|
//image与avatar需要在提交修改时特别处理
|
|
9886
10122
|
const imageNames = ___default.compact(___default.map(___default.filter(fields, (field) => ["image","avatar"].includes(field.type)), 'name'));
|
|
@@ -9940,9 +10176,9 @@ async function getObjectCRUD(objectSchema, fields, options){
|
|
|
9940
10176
|
requestAdaptor: quickSaveApiRequestAdaptor,
|
|
9941
10177
|
},
|
|
9942
10178
|
rowClassNameExpr: options.rowClassNameExpr
|
|
9943
|
-
},
|
|
9944
|
-
|
|
9945
|
-
|
|
10179
|
+
}, bodyProps);
|
|
10180
|
+
|
|
10181
|
+
body = await getCrudSchemaWithDataFilter(body, { crudDataFilter, onCrudDataFilter, amisData, env });
|
|
9946
10182
|
}
|
|
9947
10183
|
|
|
9948
10184
|
const defaults = options.defaults;
|
|
@@ -9977,16 +10213,10 @@ async function getObjectCRUD(objectSchema, fields, options){
|
|
|
9977
10213
|
return {
|
|
9978
10214
|
type: 'service',
|
|
9979
10215
|
className: '',
|
|
9980
|
-
//目前crud的service层id不认用户自定义id,只支持默认规则id
|
|
10216
|
+
//目前crud的service层id不认用户自定义id,只支持默认规则id,许多地方的格式都写死了service_listview_${objectname}
|
|
9981
10217
|
id: `service_${id}`,
|
|
9982
10218
|
name: `page`,
|
|
9983
|
-
data:
|
|
9984
|
-
objectName: objectSchema.name,
|
|
9985
|
-
// _id: null,
|
|
9986
|
-
recordPermissions: objectSchema.permissions,
|
|
9987
|
-
uiSchema: objectSchema,
|
|
9988
|
-
// loaded: false //crud接收适配器中设置为true,否则就是刷新浏览器第一次加载
|
|
9989
|
-
},
|
|
10219
|
+
data: options.amisData,
|
|
9990
10220
|
body: body
|
|
9991
10221
|
}
|
|
9992
10222
|
}
|
|
@@ -10077,7 +10307,7 @@ async function getObjectForm(objectSchema, ctx){
|
|
|
10077
10307
|
submitText: "", // amis 表单不显示提交按钮, 表单提交由项目代码接管
|
|
10078
10308
|
api: await getSaveApi(objectSchema, recordId, fields, ctx),
|
|
10079
10309
|
initFetch: recordId != 'new',
|
|
10080
|
-
body: await getFormBody(fields, formFields, ctx),
|
|
10310
|
+
body: await getFormBody(fields, formFields, Object.assign({}, ctx, {fieldGroups: objectSchema.field_groups})),
|
|
10081
10311
|
panelClassName:'m-0 sm:rounded-lg shadow-none border-none',
|
|
10082
10312
|
bodyClassName: 'p-0',
|
|
10083
10313
|
className: 'steedos-amis-form',
|
|
@@ -10152,7 +10382,7 @@ async function getObjectDetail(objectSchema, recordId, ctx){
|
|
|
10152
10382
|
"formData": "$$"
|
|
10153
10383
|
},
|
|
10154
10384
|
wrapWithPanel: false,
|
|
10155
|
-
body: await getFormBody(map(fields, (field)=>{field.readonly = true; return field;}), map(formFields, (field)=>{field.readonly = true; return field;}), Object.assign({}, ctx, {showSystemFields: true})),
|
|
10385
|
+
body: await getFormBody(map(fields, (field)=>{field.readonly = true; return field;}), map(formFields, (field)=>{field.readonly = true; return field;}), Object.assign({}, ctx, {showSystemFields: true,fieldGroups: objectSchema.field_groups})),
|
|
10156
10386
|
className: 'steedos-amis-form bg-white',
|
|
10157
10387
|
actions: [], // 不显示表单默认的提交按钮
|
|
10158
10388
|
onEvent: {
|
|
@@ -10638,7 +10868,7 @@ async function getRelatedListSchema(
|
|
|
10638
10868
|
* @Author: baozhoutao@steedos.com
|
|
10639
10869
|
* @Date: 2022-07-05 15:55:39
|
|
10640
10870
|
* @LastEditors: 殷亮辉 yinlianghui@hotoa.com
|
|
10641
|
-
* @LastEditTime: 2023-09-
|
|
10871
|
+
* @LastEditTime: 2023-09-15 09:04:49
|
|
10642
10872
|
* @Description:
|
|
10643
10873
|
*/
|
|
10644
10874
|
|
|
@@ -10971,7 +11201,9 @@ async function getListSchema(
|
|
|
10971
11201
|
"adaptor": listView.adaptor,
|
|
10972
11202
|
"headerToolbarItems": ctx.headerToolbarItems,
|
|
10973
11203
|
"filterVisible": ctx.filterVisible,
|
|
10974
|
-
"rowClassNameExpr": ctx.rowClassNameExpr
|
|
11204
|
+
"rowClassNameExpr": ctx.rowClassNameExpr,
|
|
11205
|
+
"crudDataFilter": ctx.crudDataFilter,
|
|
11206
|
+
"onCrudDataFilter": ctx.onCrudDataFilter
|
|
10975
11207
|
};
|
|
10976
11208
|
// console.log(`getListSchema===>`,amisSchema)
|
|
10977
11209
|
return {
|
|
@@ -11074,7 +11306,7 @@ async function getTableSchema(
|
|
|
11074
11306
|
fields = fields.concat(extraFields);
|
|
11075
11307
|
}
|
|
11076
11308
|
|
|
11077
|
-
|
|
11309
|
+
let crudOptions = {
|
|
11078
11310
|
tabId: objectName,
|
|
11079
11311
|
appId: appName,
|
|
11080
11312
|
objectName: objectName,
|
|
@@ -11083,8 +11315,9 @@ async function getTableSchema(
|
|
|
11083
11315
|
sort,
|
|
11084
11316
|
headerToolbarItems: ctx.headerToolbarItems,
|
|
11085
11317
|
buttons: await getListViewItemButtons(uiSchema, ctx)
|
|
11086
|
-
}
|
|
11087
|
-
|
|
11318
|
+
};
|
|
11319
|
+
crudOptions.amisData = createObject(ctx.amisData || {}, {}).__super;
|
|
11320
|
+
const amisSchema = await getObjectCRUD(uiSchema, fields, crudOptions);
|
|
11088
11321
|
// console.timeEnd('getTableSchema');
|
|
11089
11322
|
return {
|
|
11090
11323
|
uiSchema,
|
|
@@ -11868,161 +12101,6 @@ const registerRemoteAssets = async (assetUrls)=>{
|
|
|
11868
12101
|
}
|
|
11869
12102
|
};
|
|
11870
12103
|
|
|
11871
|
-
/******************************************************************************
|
|
11872
|
-
Copyright (c) Microsoft Corporation.
|
|
11873
|
-
|
|
11874
|
-
Permission to use, copy, modify, and/or distribute this software for any
|
|
11875
|
-
purpose with or without fee is hereby granted.
|
|
11876
|
-
|
|
11877
|
-
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
11878
|
-
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
11879
|
-
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
11880
|
-
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
11881
|
-
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
11882
|
-
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
11883
|
-
PERFORMANCE OF THIS SOFTWARE.
|
|
11884
|
-
***************************************************************************** */
|
|
11885
|
-
|
|
11886
|
-
var __assign = function() {
|
|
11887
|
-
__assign = Object.assign || function __assign(t) {
|
|
11888
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
11889
|
-
s = arguments[i];
|
|
11890
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
|
|
11891
|
-
}
|
|
11892
|
-
return t;
|
|
11893
|
-
};
|
|
11894
|
-
return __assign.apply(this, arguments);
|
|
11895
|
-
};
|
|
11896
|
-
|
|
11897
|
-
/**
|
|
11898
|
-
* 将例如像 a.b.c 或 a[1].b 的字符串转换为路径数组
|
|
11899
|
-
*
|
|
11900
|
-
* @param string 要转换的字符串
|
|
11901
|
-
*/
|
|
11902
|
-
var keyToPath = function (string) {
|
|
11903
|
-
var result = [];
|
|
11904
|
-
if (string.charCodeAt(0) === '.'.charCodeAt(0)) {
|
|
11905
|
-
result.push('');
|
|
11906
|
-
}
|
|
11907
|
-
string.replace(new RegExp('[^.[\\]]+|\\[(?:([^"\'][^[]*)|(["\'])((?:(?!\\2)[^\\\\]|\\\\.)*?)\\2)\\]|(?=(?:\\.|\\[\\])(?:\\.|\\[\\]|$))', 'g'), function (match, expression, quote, subString) {
|
|
11908
|
-
var key = match;
|
|
11909
|
-
if (quote) {
|
|
11910
|
-
key = subString.replace(/\\(\\)?/g, '$1');
|
|
11911
|
-
}
|
|
11912
|
-
else if (expression) {
|
|
11913
|
-
key = expression.trim();
|
|
11914
|
-
}
|
|
11915
|
-
result.push(key);
|
|
11916
|
-
return '';
|
|
11917
|
-
});
|
|
11918
|
-
return result;
|
|
11919
|
-
};
|
|
11920
|
-
|
|
11921
|
-
// 方便取值的时候能够把上层的取到,但是获取的时候不会全部把所有的数据获取到。
|
|
11922
|
-
function createObject(superProps, props, properties) {
|
|
11923
|
-
if (superProps && Object.isFrozen(superProps)) {
|
|
11924
|
-
superProps = cloneObject(superProps);
|
|
11925
|
-
}
|
|
11926
|
-
var obj = superProps
|
|
11927
|
-
? Object.create(superProps, __assign(__assign({}, properties), { __super: {
|
|
11928
|
-
value: superProps,
|
|
11929
|
-
writable: false,
|
|
11930
|
-
enumerable: false
|
|
11931
|
-
} }))
|
|
11932
|
-
: Object.create(Object.prototype, properties);
|
|
11933
|
-
props &&
|
|
11934
|
-
isObject(props) &&
|
|
11935
|
-
Object.keys(props).forEach(function (key) { return (obj[key] = props[key]); });
|
|
11936
|
-
return obj;
|
|
11937
|
-
}
|
|
11938
|
-
function cloneObject(target, persistOwnProps) {
|
|
11939
|
-
if (persistOwnProps === void 0) { persistOwnProps = true; }
|
|
11940
|
-
var obj = target && target.__super
|
|
11941
|
-
? Object.create(target.__super, {
|
|
11942
|
-
__super: {
|
|
11943
|
-
value: target.__super,
|
|
11944
|
-
writable: false,
|
|
11945
|
-
enumerable: false
|
|
11946
|
-
}
|
|
11947
|
-
})
|
|
11948
|
-
: Object.create(Object.prototype);
|
|
11949
|
-
persistOwnProps &&
|
|
11950
|
-
target &&
|
|
11951
|
-
Object.keys(target).forEach(function (key) { return (obj[key] = target[key]); });
|
|
11952
|
-
return obj;
|
|
11953
|
-
}
|
|
11954
|
-
function extendObject(target, src, persistOwnProps) {
|
|
11955
|
-
if (persistOwnProps === void 0) { persistOwnProps = true; }
|
|
11956
|
-
var obj = cloneObject(target, persistOwnProps);
|
|
11957
|
-
src && Object.keys(src).forEach(function (key) { return (obj[key] = src[key]); });
|
|
11958
|
-
return obj;
|
|
11959
|
-
}
|
|
11960
|
-
function isObject(obj) {
|
|
11961
|
-
var typename = typeof obj;
|
|
11962
|
-
return (obj &&
|
|
11963
|
-
typename !== 'string' &&
|
|
11964
|
-
typename !== 'number' &&
|
|
11965
|
-
typename !== 'boolean' &&
|
|
11966
|
-
typename !== 'function' &&
|
|
11967
|
-
!Array.isArray(obj));
|
|
11968
|
-
}
|
|
11969
|
-
function setVariable(data, key, value, convertKeyToPath) {
|
|
11970
|
-
data = data || {};
|
|
11971
|
-
if (key in data) {
|
|
11972
|
-
data[key] = value;
|
|
11973
|
-
return;
|
|
11974
|
-
}
|
|
11975
|
-
var parts = convertKeyToPath !== false ? keyToPath(key) : [key];
|
|
11976
|
-
var last = parts.pop();
|
|
11977
|
-
while (parts.length) {
|
|
11978
|
-
var key_1 = parts.shift();
|
|
11979
|
-
if (isPlainObject(data[key_1])) {
|
|
11980
|
-
data = data[key_1] = __assign({}, data[key_1]);
|
|
11981
|
-
}
|
|
11982
|
-
else if (Array.isArray(data[key_1])) {
|
|
11983
|
-
data[key_1] = data[key_1].concat();
|
|
11984
|
-
data = data[key_1];
|
|
11985
|
-
}
|
|
11986
|
-
else if (data[key_1]) {
|
|
11987
|
-
// throw new Error(`目标路径不是纯对象,不能覆盖`);
|
|
11988
|
-
// 强行转成对象
|
|
11989
|
-
data[key_1] = {};
|
|
11990
|
-
data = data[key_1];
|
|
11991
|
-
}
|
|
11992
|
-
else {
|
|
11993
|
-
data[key_1] = {};
|
|
11994
|
-
data = data[key_1];
|
|
11995
|
-
}
|
|
11996
|
-
}
|
|
11997
|
-
data[last] = value;
|
|
11998
|
-
}
|
|
11999
|
-
function deleteVariable(data, key) {
|
|
12000
|
-
if (!data) {
|
|
12001
|
-
return;
|
|
12002
|
-
}
|
|
12003
|
-
else if (data.hasOwnProperty(key)) {
|
|
12004
|
-
delete data[key];
|
|
12005
|
-
return;
|
|
12006
|
-
}
|
|
12007
|
-
var parts = keyToPath(key);
|
|
12008
|
-
var last = parts.pop();
|
|
12009
|
-
while (parts.length) {
|
|
12010
|
-
var key_2 = parts.shift();
|
|
12011
|
-
if (isPlainObject(data[key_2])) {
|
|
12012
|
-
data = data[key_2] = __assign({}, data[key_2]);
|
|
12013
|
-
}
|
|
12014
|
-
else if (data[key_2]) {
|
|
12015
|
-
throw new Error("\u76EE\u6807\u8DEF\u5F84\u4E0D\u662F\u7EAF\u5BF9\u8C61\uFF0C\u4E0D\u80FD\u4FEE\u6539");
|
|
12016
|
-
}
|
|
12017
|
-
else {
|
|
12018
|
-
break;
|
|
12019
|
-
}
|
|
12020
|
-
}
|
|
12021
|
-
if (data && data.hasOwnProperty && data.hasOwnProperty(last)) {
|
|
12022
|
-
delete data[last];
|
|
12023
|
-
}
|
|
12024
|
-
}
|
|
12025
|
-
|
|
12026
12104
|
/*
|
|
12027
12105
|
* @Author: baozhoutao@steedos.com
|
|
12028
12106
|
* @Date: 2022-12-17 17:03:40
|