@steedos-widgets/amis-lib 3.6.2-beta.7 → 3.6.2-beta.9
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 +222 -73
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm.js +223 -74
- package/dist/index.esm.js.map +1 -1
- package/dist/index.umd.js +80 -42
- package/dist/index.umd.js.map +1 -1
- package/dist/types/lib/converter/amis/api.d.ts +4 -0
- package/dist/types/lib/converter/amis/fields/lookup.d.ts +0 -1
- package/dist/types/lib/objects.d.ts +1 -0
- package/package.json +2 -2
package/dist/index.cjs.js
CHANGED
|
@@ -367,22 +367,26 @@ const getSteedosAuth = () => {
|
|
|
367
367
|
* @Description:
|
|
368
368
|
*/
|
|
369
369
|
|
|
370
|
-
|
|
371
370
|
const Router = {
|
|
372
371
|
getTabDisplayAs(tab_id){
|
|
372
|
+
const uiSchema = getUISchemaSync$1(tab_id, false);
|
|
373
373
|
var urlSearch = new URLSearchParams(document.location.search);
|
|
374
374
|
if(urlSearch.has('display')){
|
|
375
375
|
return urlSearch.get('display')
|
|
376
376
|
}
|
|
377
377
|
const key = `tab_${tab_id}_display`;
|
|
378
378
|
// const key = `page_display`;
|
|
379
|
-
const value =
|
|
380
|
-
|
|
379
|
+
const value = sessionStorage.getItem(key);
|
|
380
|
+
let defaultDisplay = "grid";
|
|
381
|
+
if(uiSchema.enable_split){
|
|
382
|
+
defaultDisplay = "split";
|
|
383
|
+
}
|
|
384
|
+
return value ? value : defaultDisplay;
|
|
381
385
|
},
|
|
382
386
|
|
|
383
387
|
setTabDisplayAs(tab_id, displayAs){
|
|
384
388
|
const key = `tab_${tab_id}_display`;
|
|
385
|
-
|
|
389
|
+
sessionStorage.setItem(key, displayAs);
|
|
386
390
|
},
|
|
387
391
|
getAppPath({formFactor, appId}){
|
|
388
392
|
return `/app/${appId}`;
|
|
@@ -486,7 +490,7 @@ function getComparableAmisVersion() {
|
|
|
486
490
|
* @Author: baozhoutao@steedos.com
|
|
487
491
|
* @Date: 2022-05-23 09:53:08
|
|
488
492
|
* @LastEditors: liaodaxue
|
|
489
|
-
* @LastEditTime:
|
|
493
|
+
* @LastEditTime: 2024-01-17 16:00:27
|
|
490
494
|
* @Description:
|
|
491
495
|
*/
|
|
492
496
|
|
|
@@ -558,7 +562,7 @@ function getSelectMap(selectOptions){
|
|
|
558
562
|
|
|
559
563
|
function getNameTplUrl(field, ctx){
|
|
560
564
|
if(ctx.objectName === 'cms_files'){
|
|
561
|
-
return
|
|
565
|
+
return "${(versions[0] && versions[0].url) ? versions[0].url+'?download=true' : context.rootUrl+'/api/files/files/'+versions[0]+'?download=true'}"
|
|
562
566
|
}
|
|
563
567
|
const href = Router.getObjectDetailPath({
|
|
564
568
|
...ctx, formFactor: ctx.formFactor, appId: "${appId}", objectName: ctx.objectName || "${objectName}", recordId: `\${${ctx.idFieldName}}`
|
|
@@ -2087,7 +2091,11 @@ async function getTableColumns(fields, options){
|
|
|
2087
2091
|
const quickEditSchema = allowEdit ? await getQuickEditSchema(field, options) : allowEdit;
|
|
2088
2092
|
let className = "";
|
|
2089
2093
|
if(field.wrap != true){
|
|
2090
|
-
|
|
2094
|
+
if(field.wrap != false && field.is_wide){
|
|
2095
|
+
className += " break-words ";
|
|
2096
|
+
}else {
|
|
2097
|
+
className += " whitespace-nowrap ";
|
|
2098
|
+
}
|
|
2091
2099
|
}else {
|
|
2092
2100
|
className += " break-words ";
|
|
2093
2101
|
}
|
|
@@ -2186,12 +2194,12 @@ async function getTableColumns(fields, options){
|
|
|
2186
2194
|
if(field.type === 'textarea'){
|
|
2187
2195
|
className += 'min-w-56';
|
|
2188
2196
|
}
|
|
2189
|
-
if(field.type === 'date'){
|
|
2190
|
-
|
|
2191
|
-
}
|
|
2192
|
-
if(field.type === 'datetime'){
|
|
2193
|
-
|
|
2194
|
-
}
|
|
2197
|
+
// if(field.type === 'date'){
|
|
2198
|
+
// className += 'date-min-w';
|
|
2199
|
+
// }
|
|
2200
|
+
// if(field.type === 'datetime'){
|
|
2201
|
+
// className += 'datetime-min-w';
|
|
2202
|
+
// }
|
|
2195
2203
|
|
|
2196
2204
|
//field上的amis属性里的clssname需要单独判断类型合并
|
|
2197
2205
|
if (typeof field.amis?.className == "object") {
|
|
@@ -2286,7 +2294,7 @@ function getMobileLines(tpls){
|
|
|
2286
2294
|
}
|
|
2287
2295
|
if(isLeft){
|
|
2288
2296
|
// 左侧半行
|
|
2289
|
-
lineChildrenClassName = "steedos-listview-item-left truncate";
|
|
2297
|
+
lineChildrenClassName = "steedos-listview-item-left truncate h-5";
|
|
2290
2298
|
if(item.field.is_wide){
|
|
2291
2299
|
// 左侧全行样式可以单独写,如果需要配置两行省略号效果,可以加样式类 two-lines-truncate
|
|
2292
2300
|
lineChildrenClassName = "steedos-listview-item-wide";
|
|
@@ -2298,7 +2306,7 @@ function getMobileLines(tpls){
|
|
|
2298
2306
|
}
|
|
2299
2307
|
else {
|
|
2300
2308
|
// 右侧半行,这里加样式类 flex flex-shrink-0,是为了省略号只显示在左半行,右半行文字一般比较短,如果也加省略号效果的话,左侧文字多的话,右侧没几个字就显示省略号了
|
|
2301
|
-
lineChildrenClassName = "steedos-listview-item-right truncate ml-2 flex flex-shrink-0";
|
|
2309
|
+
lineChildrenClassName = "steedos-listview-item-right truncate ml-2 flex flex-shrink-0 h-5";
|
|
2302
2310
|
}
|
|
2303
2311
|
//支持字段amis属性配置classname,识别classname的类型,与原样式合并
|
|
2304
2312
|
var className;
|
|
@@ -2409,7 +2417,15 @@ async function getMobileTableColumns(fields, options){
|
|
|
2409
2417
|
"actions": [
|
|
2410
2418
|
{
|
|
2411
2419
|
"script": `
|
|
2412
|
-
let cms_url =
|
|
2420
|
+
let cms_url = '';
|
|
2421
|
+
let value = event.data.versions[0];
|
|
2422
|
+
if(value){
|
|
2423
|
+
if(value.url){
|
|
2424
|
+
cms_url = value.url;
|
|
2425
|
+
}else{
|
|
2426
|
+
cms_url = "/api/files/files/"+value+"?download=true"
|
|
2427
|
+
}
|
|
2428
|
+
}
|
|
2413
2429
|
Steedos.cordovaDownload(encodeURI(Steedos.absoluteUrl(cms_url)), event.data.name);
|
|
2414
2430
|
`,
|
|
2415
2431
|
"actionType": "custom"
|
|
@@ -3041,12 +3057,15 @@ async function getTableApi(mainObject, fields, options){
|
|
|
3041
3057
|
}
|
|
3042
3058
|
// SteedosUI.getRef(api.body.$self.$scopeId)?.parent?.getComponentById(setDataToComponentId)?.setData({$count: payload.data.count})
|
|
3043
3059
|
};
|
|
3044
|
-
|
|
3045
|
-
|
|
3046
|
-
|
|
3047
|
-
|
|
3048
|
-
|
|
3049
|
-
|
|
3060
|
+
let formFactor = "${options.formFactor}";
|
|
3061
|
+
if(formFactor !== "SMALL"){
|
|
3062
|
+
const listviewComponent = $(".steedos-object-listview .antd-Table-table");
|
|
3063
|
+
const firstListviewComponent = listviewComponent && listviewComponent[0];
|
|
3064
|
+
if(firstListviewComponent){
|
|
3065
|
+
setTimeout(()=>{
|
|
3066
|
+
firstListviewComponent.scrollIntoView();
|
|
3067
|
+
}, 600);
|
|
3068
|
+
}
|
|
3050
3069
|
}
|
|
3051
3070
|
${options.adaptor || ''}
|
|
3052
3071
|
return payload;
|
|
@@ -3391,17 +3410,16 @@ async function getEditFormInitApi(object, recordId, fields, options){
|
|
|
3391
3410
|
}
|
|
3392
3411
|
// data下的变量需要在保存接口(getSaveApi)中被删除。
|
|
3393
3412
|
payload.data = {
|
|
3394
|
-
...initialValues
|
|
3395
|
-
editFormInited: true
|
|
3413
|
+
...initialValues
|
|
3396
3414
|
}
|
|
3397
3415
|
${options.initApiAdaptor || ''}
|
|
3398
3416
|
// console.log('getEditFormInitApi======>', payload);
|
|
3399
3417
|
return payload;
|
|
3400
3418
|
`,
|
|
3401
|
-
|
|
3402
|
-
|
|
3403
|
-
|
|
3404
|
-
|
|
3419
|
+
responseData: {
|
|
3420
|
+
"&": "$$",
|
|
3421
|
+
editFormInited: true
|
|
3422
|
+
},
|
|
3405
3423
|
data: data,
|
|
3406
3424
|
headers: {
|
|
3407
3425
|
Authorization: "Bearer ${context.tenantId},${context.authToken}"
|
|
@@ -4244,7 +4262,7 @@ async function getListBody(fields, options){
|
|
|
4244
4262
|
|
|
4245
4263
|
function getDefaultParams(options){
|
|
4246
4264
|
return {
|
|
4247
|
-
perPage: options.top || options.perPage ||
|
|
4265
|
+
perPage: options.top || options.perPage || 20
|
|
4248
4266
|
}
|
|
4249
4267
|
}
|
|
4250
4268
|
|
|
@@ -4447,7 +4465,6 @@ const getSchema$5 = async (uiSchema, ctx) => {
|
|
|
4447
4465
|
"objectApiName": "\${objectName}",
|
|
4448
4466
|
"recordId": "",
|
|
4449
4467
|
"mode": "edit",
|
|
4450
|
-
"layout": "normal"
|
|
4451
4468
|
};
|
|
4452
4469
|
|
|
4453
4470
|
if (payload && payload.schema) {
|
|
@@ -6719,7 +6736,7 @@ async function getObjectRecordDetailHeader(objectSchema, recordId, options) {
|
|
|
6719
6736
|
let body = [
|
|
6720
6737
|
{
|
|
6721
6738
|
"type": "wrapper",
|
|
6722
|
-
"className": "p-4 bg-gray-100 border-b
|
|
6739
|
+
"className": "p-4 bg-gray-100 border-b",
|
|
6723
6740
|
"body": [
|
|
6724
6741
|
{
|
|
6725
6742
|
"type": "grid",
|
|
@@ -6749,8 +6766,27 @@ async function getObjectRecordDetailHeader(objectSchema, recordId, options) {
|
|
|
6749
6766
|
let max = 10;
|
|
6750
6767
|
if(options.formFactor === 'SMALL'){
|
|
6751
6768
|
max = 4;
|
|
6769
|
+
}else {
|
|
6770
|
+
|
|
6771
|
+
let divWidth = window.innerWidth;
|
|
6772
|
+
|
|
6773
|
+
if(options.display === 'split'){
|
|
6774
|
+
divWidth = divWidth - 388;
|
|
6775
|
+
}
|
|
6776
|
+
|
|
6777
|
+
if(document.body.classList.contains('sidebar')){
|
|
6778
|
+
divWidth = divWidth - 210;
|
|
6779
|
+
}
|
|
6780
|
+
|
|
6781
|
+
// 根据屏幕宽度计算显示数量, 使高亮字段只占1行
|
|
6782
|
+
max = Math.trunc(divWidth / 200 );
|
|
6783
|
+
if(max > 10){
|
|
6784
|
+
max = 10;
|
|
6785
|
+
}
|
|
6752
6786
|
}
|
|
6753
6787
|
|
|
6788
|
+
// console.log('=======================max=========================', max)
|
|
6789
|
+
|
|
6754
6790
|
if(objectSchema.compactLayouts){
|
|
6755
6791
|
const details = [];
|
|
6756
6792
|
_.each(_.slice(_.difference(objectSchema.compactLayouts, [objectSchema.NAME_FIELD_KEY]), 0, max), (fieldName)=>{
|
|
@@ -6764,13 +6800,32 @@ async function getObjectRecordDetailHeader(objectSchema, recordId, options) {
|
|
|
6764
6800
|
}
|
|
6765
6801
|
});
|
|
6766
6802
|
|
|
6803
|
+
// 注意: 以下注释不能删除. tailwind css 动态编译时会识别以下注释, 生成对应的样式
|
|
6804
|
+
// xl:grid-cols-1
|
|
6805
|
+
// xl:grid-cols-2
|
|
6806
|
+
// xl:grid-cols-3
|
|
6807
|
+
// xl:grid-cols-4
|
|
6808
|
+
// xl:grid-cols-5
|
|
6809
|
+
// xl:grid-cols-6
|
|
6810
|
+
// xl:grid-cols-7
|
|
6811
|
+
// xl:grid-cols-8
|
|
6812
|
+
// xl:grid-cols-9
|
|
6813
|
+
// xl:grid-cols-10
|
|
6814
|
+
// xl:grid-cols-11
|
|
6815
|
+
// xl:grid-cols-12
|
|
6816
|
+
|
|
6767
6817
|
body.push({
|
|
6768
|
-
"type": "
|
|
6769
|
-
"
|
|
6770
|
-
|
|
6771
|
-
|
|
6772
|
-
|
|
6773
|
-
|
|
6818
|
+
"type": "wrapper",
|
|
6819
|
+
"body": {
|
|
6820
|
+
"type": "form",
|
|
6821
|
+
// "className": "gap-2 grid grid-cols-1 sm:grid-cols-2 md:grid-cols-3 lg:grid-cols-4 xl:grid-cols-5 2xl:grid-cols-5 3xl:grid-cols-8 4xl:grid-cols-8 5xl:grid-cols-10", //max-h-12 overflow-hidden
|
|
6822
|
+
"className": `gap-2 grid grid-cols-1 sm:grid-cols-2 md:grid-cols-3 lg:grid-cols-5 xl:grid-cols-${max}`,
|
|
6823
|
+
"wrapWithPanel": false,
|
|
6824
|
+
"actions": [],
|
|
6825
|
+
"body": details,
|
|
6826
|
+
"hiddenOn": "${recordLoaded != true}"
|
|
6827
|
+
},
|
|
6828
|
+
"className": "steedos-record-compact-layouts p-4 bg-white compact-layouts border-b"
|
|
6774
6829
|
});
|
|
6775
6830
|
}
|
|
6776
6831
|
|
|
@@ -6849,7 +6904,7 @@ async function getObjectRecordDetailRelatedListHeader(relatedObjectSchema, relat
|
|
|
6849
6904
|
"className": "flex justify-between"
|
|
6850
6905
|
}
|
|
6851
6906
|
],
|
|
6852
|
-
"className": "
|
|
6907
|
+
"className": "steedos-record-related-header py-2 px-0"
|
|
6853
6908
|
};
|
|
6854
6909
|
return recordRelatedListHeader;
|
|
6855
6910
|
}
|
|
@@ -7834,14 +7889,14 @@ const getDisplayAsButton = function(objectName, showDisplayAs){
|
|
|
7834
7889
|
{
|
|
7835
7890
|
"type": "button",
|
|
7836
7891
|
"label": i18next__default["default"].t('frontend_display_type_is_table'),
|
|
7837
|
-
"onClick": "const key = 'tab_"+objectName+"_display';
|
|
7892
|
+
"onClick": "const key = 'tab_"+objectName+"_display';sessionStorage.setItem(key, 'grid');let url = document.location.pathname; var urlSearch = new URLSearchParams(document.location.search); if(urlSearch.get(\"side_object\") && urlSearch.get(\"side_listview_id\")){url=`/app/${props.data.appId}/${urlSearch.get(\"side_object\")}/grid/${urlSearch.get(\"side_listview_id\")}`;}; props.env.jumpTo(url + '?display=grid');",
|
|
7838
7893
|
"rightIcon": displayAs != 'split' ? "fa fa-check" : null,
|
|
7839
7894
|
"rightIconClassName": "m-l-sm"
|
|
7840
7895
|
},
|
|
7841
7896
|
{
|
|
7842
7897
|
"type": "button",
|
|
7843
7898
|
"label": i18next__default["default"].t('frontend_display_type_is_split'),
|
|
7844
|
-
"onClick": "const key = 'tab_"+objectName+"_display';
|
|
7899
|
+
"onClick": "const key = 'tab_"+objectName+"_display';sessionStorage.setItem(key, 'split');const url = document.location.pathname + '?display=split'; props.env.jumpTo(url);",
|
|
7845
7900
|
"rightIcon": displayAs === 'split' ? "fa fa-check" : null,
|
|
7846
7901
|
"rightIconClassName": "m-l-sm"
|
|
7847
7902
|
}
|
|
@@ -8565,7 +8620,7 @@ async function getObjectCRUD(objectSchema, fields, options){
|
|
|
8565
8620
|
// "is-steedos-crud-data-empty": "${!items || COUNT(items) == 0}"
|
|
8566
8621
|
// },
|
|
8567
8622
|
bodyClassName: {
|
|
8568
|
-
"
|
|
8623
|
+
"mb-0": true,
|
|
8569
8624
|
"is-steedos-crud-data-empty": "${!items || COUNT(items) == 0}"
|
|
8570
8625
|
},
|
|
8571
8626
|
crudClassName: crudClassName,
|
|
@@ -8721,7 +8776,7 @@ async function getFormSchemaWithDataFilter(form, options = {}){
|
|
|
8721
8776
|
}
|
|
8722
8777
|
|
|
8723
8778
|
async function getObjectForm(objectSchema, ctx){
|
|
8724
|
-
const { recordId, formFactor, layout = formFactor === 'SMALL' ? 'normal' : "
|
|
8779
|
+
const { recordId, formFactor, layout = formFactor === 'SMALL' ? 'normal' : "horizontal", labelAlign, tabId, appId, defaults, submitSuccActions = [],
|
|
8725
8780
|
formDataFilter, onFormDataFilter, amisData, env } = ctx;
|
|
8726
8781
|
const fields = ___default["default"].values(objectSchema.fields);
|
|
8727
8782
|
const formFields = getFormFields$1(objectSchema, ctx);
|
|
@@ -8815,7 +8870,7 @@ async function getObjectForm(objectSchema, ctx){
|
|
|
8815
8870
|
}
|
|
8816
8871
|
|
|
8817
8872
|
async function getObjectDetail(objectSchema, recordId, ctx){
|
|
8818
|
-
const { formFactor, layout = formFactor === 'SMALL' ? 'normal' : "
|
|
8873
|
+
const { formFactor, layout = formFactor === 'SMALL' ? 'normal' : "horizontal", labelAlign,
|
|
8819
8874
|
formDataFilter, onFormDataFilter, amisData, env } = ctx;
|
|
8820
8875
|
const fields = ___default["default"].values(objectSchema.fields);
|
|
8821
8876
|
const formFields = getFormFields$1(objectSchema, ctx);
|
|
@@ -9140,7 +9195,7 @@ async function getRecordDetailRelatedListSchema(objectName, recordId, relatedObj
|
|
|
9140
9195
|
setDataToComponentId: componentId,
|
|
9141
9196
|
// tableHiddenOn: hiddenEmptyTable ? "this.$count === 0" : null,
|
|
9142
9197
|
appId: appId,
|
|
9143
|
-
crudClassName: '
|
|
9198
|
+
crudClassName: 'steedos-record-related-crud hidden',
|
|
9144
9199
|
refField,
|
|
9145
9200
|
...ctx
|
|
9146
9201
|
};
|
|
@@ -9153,7 +9208,7 @@ async function getRecordDetailRelatedListSchema(objectName, recordId, relatedObj
|
|
|
9153
9208
|
amisSchema: {
|
|
9154
9209
|
type: "service",
|
|
9155
9210
|
id: componentId,
|
|
9156
|
-
className: `steedos-record-related-list
|
|
9211
|
+
className: `steedos-record-related-list py-2 first:pt-0 border-b last:border-b-0 ${componentId} ${className}`,
|
|
9157
9212
|
data: {
|
|
9158
9213
|
relatedKey: relatedKey,
|
|
9159
9214
|
listViewId: `amis-\${appId}-${relatedObjectName}-listview`,
|
|
@@ -9899,7 +9954,8 @@ async function getRecordDetailSchema(objectName, appId, props = {}){
|
|
|
9899
9954
|
};
|
|
9900
9955
|
const content = {
|
|
9901
9956
|
"type": "tabs",
|
|
9902
|
-
"className": "steedos-record-tabs p-4 m-0",
|
|
9957
|
+
"className": "steedos-record-tabs bg-white p-4 m-0 mt-2 border-y",
|
|
9958
|
+
"contentClassName": "bg-none",
|
|
9903
9959
|
"tabs": [
|
|
9904
9960
|
detailed
|
|
9905
9961
|
],
|
|
@@ -9907,7 +9963,7 @@ async function getRecordDetailSchema(objectName, appId, props = {}){
|
|
|
9907
9963
|
if(relatedLists.length){
|
|
9908
9964
|
content.tabs.push(related);
|
|
9909
9965
|
}
|
|
9910
|
-
content.tabs =
|
|
9966
|
+
// content.tabs = reverse(content.tabs)
|
|
9911
9967
|
return {
|
|
9912
9968
|
uiSchema,
|
|
9913
9969
|
amisSchema: {
|
|
@@ -11187,8 +11243,7 @@ async function lookupToAmisPicker(field, readonly, ctx){
|
|
|
11187
11243
|
labelField: referenceTo.labelField.name,
|
|
11188
11244
|
valueField: referenceTo.valueField.name,
|
|
11189
11245
|
// disabledOn: this._master目的是相关表新建时禁止编辑关联字段; this.relatedKey目的是相关表编辑时禁止编辑关联字段,多选字段可以编辑。
|
|
11190
|
-
disabledOn: `${readonly}`,
|
|
11191
|
-
hiddenOn: `( (this._master && (this._master.relatedKey ==='${field.name}')) || ((this.relatedKey ==='${field.name}') && (${field.multiple} != true)) )`,
|
|
11246
|
+
disabledOn: `${readonly} || ( (this._master && (this._master.relatedKey ==='${field.name}')) || ((this.relatedKey ==='${field.name}') && (${field.multiple} != true)) )`,
|
|
11192
11247
|
modalMode: 'dialog', //TODO 设置 dialog 或者 drawer,用来配置弹出方式
|
|
11193
11248
|
source: source,
|
|
11194
11249
|
size: "lg",
|
|
@@ -11431,16 +11486,18 @@ async function lookupToAmis(field, readonly, ctx){
|
|
|
11431
11486
|
}
|
|
11432
11487
|
// console.log(`lookupToAmis====`, field, readonly, ctx)
|
|
11433
11488
|
if(readonly){
|
|
11434
|
-
|
|
11435
|
-
|
|
11436
|
-
|
|
11437
|
-
|
|
11489
|
+
if(field.reference_to){
|
|
11490
|
+
return {
|
|
11491
|
+
type: 'steedos-field',
|
|
11492
|
+
config: field,
|
|
11493
|
+
static: true
|
|
11494
|
+
}
|
|
11495
|
+
}else {
|
|
11496
|
+
return {
|
|
11497
|
+
type: getAmisStaticFieldType('picker', readonly),
|
|
11498
|
+
tpl: getRelatedFieldTpl(field, ctx)
|
|
11499
|
+
}
|
|
11438
11500
|
}
|
|
11439
|
-
|
|
11440
|
-
// return {
|
|
11441
|
-
// type: Field.getAmisStaticFieldType('picker', readonly),
|
|
11442
|
-
// tpl: Tpl.getRelatedFieldTpl(field, ctx)
|
|
11443
|
-
// }
|
|
11444
11501
|
}
|
|
11445
11502
|
if(field.reference_to && !___namespace.isString(field.reference_to) && !readonly){
|
|
11446
11503
|
return {
|
|
@@ -12487,7 +12544,7 @@ async function convertSFieldToAmisField(field, readonly, ctx) {
|
|
|
12487
12544
|
if(field.is_wide || convertData.type === 'group'){
|
|
12488
12545
|
convertData.className = 'col-span-2 m-0';
|
|
12489
12546
|
}else {
|
|
12490
|
-
convertData.className = 'm-
|
|
12547
|
+
convertData.className = 'm-0';
|
|
12491
12548
|
}
|
|
12492
12549
|
if(readonly){
|
|
12493
12550
|
convertData.className = `${convertData.className} border-b`;
|
|
@@ -12512,6 +12569,10 @@ async function convertSFieldToAmisField(field, readonly, ctx) {
|
|
|
12512
12569
|
}
|
|
12513
12570
|
}
|
|
12514
12571
|
|
|
12572
|
+
if(ctx.amisData && ctx.amisData._master && ctx.amisData._master.relatedKey === field.name){
|
|
12573
|
+
convertData.className = `${convertData.className || ''} hidden`;
|
|
12574
|
+
}
|
|
12575
|
+
|
|
12515
12576
|
if(___namespace.isString(baseData.required)){
|
|
12516
12577
|
if(baseData.required.startsWith("{{")){
|
|
12517
12578
|
baseData.requiredOn = `${baseData.required.substring(2, baseData.required.length -2).replace(/formData./g, 'data.')}`;
|
|
@@ -12893,9 +12954,61 @@ async function getFormBody(permissionFields, formFields, ctx){
|
|
|
12893
12954
|
* @Author: 殷亮辉 yinlianghui@hotoa.com
|
|
12894
12955
|
* @Date: 2023-11-15 09:50:22
|
|
12895
12956
|
* @LastEditors: 殷亮辉 yinlianghui@hotoa.com
|
|
12896
|
-
* @LastEditTime: 2024-01-
|
|
12957
|
+
* @LastEditTime: 2024-01-18 10:29:57
|
|
12897
12958
|
*/
|
|
12898
12959
|
|
|
12960
|
+
/**
|
|
12961
|
+
* 子表组件字段值中每行数据的键值key移除指定前缀
|
|
12962
|
+
* @param {*} value 子表组件字段值,数组
|
|
12963
|
+
* @param {*} fieldPrefix 字段前缀
|
|
12964
|
+
* @returns 转换后的子表组件字段值
|
|
12965
|
+
*/
|
|
12966
|
+
function getTableValueWithoutFieldPrefix(value, fieldPrefix){
|
|
12967
|
+
let convertedValue = [];
|
|
12968
|
+
(value || []).forEach((itemValue)=>{
|
|
12969
|
+
var newItemValue = {};
|
|
12970
|
+
for(let n in itemValue){
|
|
12971
|
+
newItemValue[n.replace(new RegExp(`^${fieldPrefix}`), "")] = itemValue[n];
|
|
12972
|
+
}
|
|
12973
|
+
convertedValue.push(newItemValue);
|
|
12974
|
+
});
|
|
12975
|
+
return convertedValue;
|
|
12976
|
+
}
|
|
12977
|
+
|
|
12978
|
+
/**
|
|
12979
|
+
* 子表组件字段值中每行数据的键值key补上指定前缀
|
|
12980
|
+
* @param {*} value 子表组件字段值,数组
|
|
12981
|
+
* @param {*} fieldPrefix 字段前缀
|
|
12982
|
+
* @returns 转换后的子表组件字段值
|
|
12983
|
+
*/
|
|
12984
|
+
function getTableValuePrependFieldPrefix(value, fieldPrefix){
|
|
12985
|
+
let convertedValue = [];
|
|
12986
|
+
(value || []).forEach((itemValue)=>{
|
|
12987
|
+
var newItemValue = {};
|
|
12988
|
+
for(let n in itemValue){
|
|
12989
|
+
if(typeof itemValue[n] !== undefined){
|
|
12990
|
+
newItemValue[`${fieldPrefix}${n}`] = itemValue[n];
|
|
12991
|
+
}
|
|
12992
|
+
}
|
|
12993
|
+
convertedValue.push(newItemValue);
|
|
12994
|
+
});
|
|
12995
|
+
return convertedValue;
|
|
12996
|
+
}
|
|
12997
|
+
|
|
12998
|
+
/**
|
|
12999
|
+
* 子表组件字段集合属性中每个字段name移除指定前缀
|
|
13000
|
+
* @param {*} fields 子表组件字段集合,数组
|
|
13001
|
+
* @param {*} fieldPrefix 字段前缀
|
|
13002
|
+
* @returns 转换后的子表组件字段值
|
|
13003
|
+
*/
|
|
13004
|
+
function getTableFieldsWithoutFieldPrefix(fields, fieldPrefix){
|
|
13005
|
+
return (fields || []).map((item) => {
|
|
13006
|
+
const newItem = _$1.clone(item);//这里不clone的话,会造成子表组件重新render,从而审批王那边点开子表行编辑窗口时报错
|
|
13007
|
+
newItem.name = newItem.name.replace(new RegExp(`^${fieldPrefix}`), "");
|
|
13008
|
+
return newItem;
|
|
13009
|
+
});
|
|
13010
|
+
}
|
|
13011
|
+
|
|
12899
13012
|
/**
|
|
12900
13013
|
* @param {*} props
|
|
12901
13014
|
* @param {*} mode edit/new/readonly
|
|
@@ -13172,7 +13285,7 @@ function getFormPaginationWrapper(props, form, mode) {
|
|
|
13172
13285
|
{
|
|
13173
13286
|
"type": "wrapper",
|
|
13174
13287
|
"size": "none",
|
|
13175
|
-
"className": "flex justify-end sticky top-0 right-0 left-0 z-20 bg-white
|
|
13288
|
+
"className": "flex justify-end sticky top-0 right-0 left-0 z-20 bg-white",
|
|
13176
13289
|
"body": [
|
|
13177
13290
|
getFormPagination(props, mode)
|
|
13178
13291
|
]
|
|
@@ -13188,16 +13301,8 @@ function getFormPaginationWrapper(props, form, mode) {
|
|
|
13188
13301
|
}
|
|
13189
13302
|
];
|
|
13190
13303
|
let onServiceInitedScript = `
|
|
13191
|
-
|
|
13192
|
-
|
|
13193
|
-
if(parent){
|
|
13194
|
-
// 如果是子行,即在节点嵌套情况下,当前节点如果是children属性下的子节点时,则算出其所属父行的索引值
|
|
13195
|
-
var primaryKey = "${props.primaryKey}";
|
|
13196
|
-
event.data.__parentIndex = _.findIndex(fieldValue, function(item){
|
|
13197
|
-
return item[primaryKey] == parent[primaryKey];
|
|
13198
|
-
});
|
|
13199
|
-
}
|
|
13200
|
-
// 以下脚本是为了解决有时弹出编辑表单时,表单中的值比最后一次编辑保存的值会延迟一拍。
|
|
13304
|
+
|
|
13305
|
+
// 以下脚本解决了有时弹出编辑表单时,表单中的值比最后一次编辑保存的值会延迟一拍。
|
|
13201
13306
|
// 比如:inlineEditMode模式时,用户在表格单元格中直接修改数据,然后弹出的表单form中并没有包含单元格中修改的内容
|
|
13202
13307
|
// 另外有的地方在非inlineEditMode模式时也会有这种延迟一拍问题,比如对象字段中下拉框类型字段的”选择项“属性
|
|
13203
13308
|
// 再比如工作流规则详细页面修改了子表字段”时间触发器“值后,在只读界面点击查看按钮弹出的表单中__tableItems值是修改前的值
|
|
@@ -13210,6 +13315,11 @@ function getFormPaginationWrapper(props, form, mode) {
|
|
|
13210
13315
|
// 这里不可以用event.data["${props.name}"]因为amis input talbe有一层单独的作用域,其值会延迟一拍
|
|
13211
13316
|
// 这里如果不.clone的话,在弹出窗口中显示的子表组件,添加行后点窗口的取消按钮关闭窗口后无法把之前的操作还原,即把之前添加的行自动移除
|
|
13212
13317
|
let lastestFieldValue = _.clone(wrapperServiceData["${props.name}"] || []);
|
|
13318
|
+
let fieldPrefix = "${props.fieldPrefix}";
|
|
13319
|
+
if(fieldPrefix){
|
|
13320
|
+
let getTableValueWithoutFieldPrefix = new Function('v', 'f', "return (" + ${getTableValueWithoutFieldPrefix.toString()} + ")(v, f)");
|
|
13321
|
+
lastestFieldValue = getTableValueWithoutFieldPrefix(lastestFieldValue, fieldPrefix);
|
|
13322
|
+
}
|
|
13213
13323
|
//不可以直接像event.data.__tableItems = lastestFieldValue; 这样整个赋值,否则作用域会断
|
|
13214
13324
|
let mode = "${mode}";
|
|
13215
13325
|
if(mode === "new"){
|
|
@@ -13232,6 +13342,16 @@ function getFormPaginationWrapper(props, form, mode) {
|
|
|
13232
13342
|
event.data.__tableItems.forEach(function(n,i){
|
|
13233
13343
|
event.data.__tableItems[i] = lastestFieldValue[i];
|
|
13234
13344
|
});
|
|
13345
|
+
|
|
13346
|
+
var parent = event.data.parent;
|
|
13347
|
+
var fieldValue = event.data.__tableItems;
|
|
13348
|
+
if(parent){
|
|
13349
|
+
// 如果是子行,即在节点嵌套情况下,当前节点如果是children属性下的子节点时,则算出其所属父行的索引值
|
|
13350
|
+
var primaryKey = "${props.primaryKey}";
|
|
13351
|
+
event.data.__parentIndex = _.findIndex(fieldValue, function(item){
|
|
13352
|
+
return item[primaryKey] == parent[primaryKey];
|
|
13353
|
+
});
|
|
13354
|
+
}
|
|
13235
13355
|
`;
|
|
13236
13356
|
let schema = {
|
|
13237
13357
|
"type": "service",
|
|
@@ -13834,6 +13954,10 @@ const getAmisInputTableSchema = async (props) => {
|
|
|
13834
13954
|
if(showOperation !== false){
|
|
13835
13955
|
showOperation = true;
|
|
13836
13956
|
}
|
|
13957
|
+
// props.fieldPrefix = "project_milestone_";
|
|
13958
|
+
if (props.fieldPrefix) {
|
|
13959
|
+
props.fields = getTableFieldsWithoutFieldPrefix(props.fields, props.fieldPrefix);
|
|
13960
|
+
}
|
|
13837
13961
|
let serviceId = getComponentId("table_service", props.id);
|
|
13838
13962
|
let buttonsForColumnOperations = [];
|
|
13839
13963
|
let inlineEditMode = props.inlineEditMode;
|
|
@@ -13869,6 +13993,7 @@ const getAmisInputTableSchema = async (props) => {
|
|
|
13869
13993
|
buttonsForColumnOperations.push(buttonDeleteSchema);
|
|
13870
13994
|
}
|
|
13871
13995
|
}
|
|
13996
|
+
let amis = props["input-table"] || props.amis;//额外支持"input-table"代替amis属性,是因为在字段yml文件中用amis作为key不好理解
|
|
13872
13997
|
let inputTableSchema = {
|
|
13873
13998
|
"type": "input-table",
|
|
13874
13999
|
"label": props.label,
|
|
@@ -13888,12 +14013,35 @@ const getAmisInputTableSchema = async (props) => {
|
|
|
13888
14013
|
"showFooterAddBtn": false,
|
|
13889
14014
|
"className": props.tableClassName,
|
|
13890
14015
|
"pipeOut": (value, data) => {
|
|
13891
|
-
|
|
14016
|
+
value = (value || []).map(function(item){
|
|
13892
14017
|
delete item.__fix_rerender_after_children_modified_tag;
|
|
13893
14018
|
return item;
|
|
13894
14019
|
});
|
|
14020
|
+
if(props.fieldPrefix){
|
|
14021
|
+
value = getTableValuePrependFieldPrefix(value, props.fieldPrefix);
|
|
14022
|
+
}
|
|
14023
|
+
if(amis.pipeOut){
|
|
14024
|
+
if(typeof amis.pipeOut === 'function'){
|
|
14025
|
+
return amis.pipeOut(value, data);
|
|
14026
|
+
}
|
|
14027
|
+
}
|
|
14028
|
+
return value;
|
|
13895
14029
|
}
|
|
13896
14030
|
};
|
|
14031
|
+
if(amis.pipeIn){
|
|
14032
|
+
inputTableSchema.pipeIn = amis.pipeIn;
|
|
14033
|
+
}
|
|
14034
|
+
if(props.fieldPrefix){
|
|
14035
|
+
inputTableSchema.pipeIn = (value, data) => {
|
|
14036
|
+
value = getTableValueWithoutFieldPrefix(value, props.fieldPrefix);
|
|
14037
|
+
if(amis.pipeIn){
|
|
14038
|
+
if(typeof amis.pipeIn === 'function'){
|
|
14039
|
+
return amis.pipeIn(value, data);
|
|
14040
|
+
}
|
|
14041
|
+
}
|
|
14042
|
+
return value;
|
|
14043
|
+
};
|
|
14044
|
+
}
|
|
13897
14045
|
if (buttonsForColumnOperations.length) {
|
|
13898
14046
|
inputTableSchema.columns.push({
|
|
13899
14047
|
"name": "__op__",
|
|
@@ -13905,10 +14053,11 @@ const getAmisInputTableSchema = async (props) => {
|
|
|
13905
14053
|
if (showAsInlineEditMode) {
|
|
13906
14054
|
inputTableSchema.needConfirm = false;
|
|
13907
14055
|
}
|
|
13908
|
-
let amis = props["input-table"] || props.amis;//额外支持"input-table"代替amis属性,是因为在字段yml文件中用amis作为key不好理解
|
|
13909
14056
|
if (amis) {
|
|
13910
14057
|
// 支持配置amis属性重写或添加最终生成的input-table中任何属性。
|
|
13911
14058
|
delete amis.id;//如果steedos-input-table组件配置了amis.id属性,会造成新建编辑行功能不生效
|
|
14059
|
+
delete amis.pipeIn;//该属性在上面合并过了
|
|
14060
|
+
delete amis.pipeOut;//该属性在上面合并过了
|
|
13912
14061
|
Object.assign(inputTableSchema, amis);
|
|
13913
14062
|
}
|
|
13914
14063
|
const isAnyFieldHasDependOn = (props.fields || []).find(function (item) {
|