@steedos-widgets/amis-lib 1.2.6 → 1.2.7
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 +199 -29
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm.js +200 -30
- package/dist/index.esm.js.map +1 -1
- package/dist/index.umd.js +199 -29
- package/dist/index.umd.js.map +1 -1
- package/dist/types/lib/converter/amis/fields_filter.d.ts +3 -0
- package/dist/types/lib/converter/amis/header.d.ts +3 -0
- package/dist/types/lib/converter/amis/toolbar.d.ts +3 -0
- package/dist/types/lib/converter/amis/util.d.ts +1 -0
- package/package.json +2 -2
package/dist/index.esm.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as _$1 from 'lodash';
|
|
2
|
-
import ___default, { isEmpty, isArray, each, find, endsWith, cloneDeep, includes, get, map, toArray, mergeWith, isBoolean, omitBy, isNil, isString, union, has, slice, defaultsDeep as defaultsDeep$1, isObject as isObject$1, filter, startsWith } from 'lodash';
|
|
2
|
+
import ___default, { isEmpty, isArray, each, find, endsWith, cloneDeep, includes, get, map, toArray, mergeWith, forEach, isBoolean, omitBy, isNil, isString, union, has, slice, defaultsDeep as defaultsDeep$1, isObject as isObject$1, filter, startsWith } from 'lodash';
|
|
3
3
|
import { Router as Router$1, getSteedosAuth as getSteedosAuth$1, lookupToAmis as lookupToAmis$1, fetchAPI as fetchAPI$1 } from '@steedos-widgets/amis-lib';
|
|
4
4
|
import isPlainObject from 'lodash/isPlainObject';
|
|
5
5
|
|
|
@@ -2658,7 +2658,7 @@ async function getObjectFieldsFilterBarSchema(objectSchema, ctx) {
|
|
|
2658
2658
|
// }
|
|
2659
2659
|
// listView.handleFilterSubmit(Object.assign({}, removedValues, filterFormValues));
|
|
2660
2660
|
`;
|
|
2661
|
-
const
|
|
2661
|
+
const onCancelScript = `
|
|
2662
2662
|
const scope = event.context.scoped;
|
|
2663
2663
|
var filterForm = scope.parent.parent.getComponents().find(function(n){
|
|
2664
2664
|
return n.props.type === "form";
|
|
@@ -2686,6 +2686,14 @@ async function getObjectFieldsFilterBarSchema(objectSchema, ctx) {
|
|
|
2686
2686
|
}
|
|
2687
2687
|
}
|
|
2688
2688
|
listView.handleFilterSubmit(removedValues);
|
|
2689
|
+
const filterService = filterForm.context.getComponents().find(function(n){
|
|
2690
|
+
return n.props.type === "service";
|
|
2691
|
+
});
|
|
2692
|
+
filterService.setData({showFieldsFilter: !!!filterService.props.data.showFieldsFilter});
|
|
2693
|
+
//触发amis crud 高度重算
|
|
2694
|
+
setTimeout(()=>{
|
|
2695
|
+
window.dispatchEvent(new Event("resize"))
|
|
2696
|
+
}, 100);
|
|
2689
2697
|
`;
|
|
2690
2698
|
const dataProviderInited = `
|
|
2691
2699
|
const objectName = data.objectName;
|
|
@@ -2882,14 +2890,15 @@ async function getObjectFieldsFilterBarSchema(objectSchema, ctx) {
|
|
|
2882
2890
|
},
|
|
2883
2891
|
{
|
|
2884
2892
|
"type": "button",
|
|
2885
|
-
"label": "
|
|
2893
|
+
"label": "取消",
|
|
2894
|
+
"name": "btn_filter_form_cancel",
|
|
2886
2895
|
"visibleOn": "this.filterFormSearchableFields && this.filterFormSearchableFields.length",
|
|
2887
2896
|
"onEvent": {
|
|
2888
2897
|
"click": {
|
|
2889
2898
|
"actions": [
|
|
2890
2899
|
{
|
|
2891
2900
|
"actionType": "custom",
|
|
2892
|
-
"script":
|
|
2901
|
+
"script": onCancelScript
|
|
2893
2902
|
}
|
|
2894
2903
|
]
|
|
2895
2904
|
}
|
|
@@ -3493,11 +3502,26 @@ const filterForm = scope.getComponents().find(function(n){
|
|
|
3493
3502
|
const filterService = filterForm.context.getComponents().find(function(n){
|
|
3494
3503
|
return n.props.type === "service";
|
|
3495
3504
|
});
|
|
3496
|
-
filterService.setData({showFieldsFilter: !!!filterService.props.data.showFieldsFilter});
|
|
3497
|
-
|
|
3498
|
-
|
|
3499
|
-
|
|
3500
|
-
|
|
3505
|
+
// filterService.setData({showFieldsFilter: !!!filterService.props.data.showFieldsFilter});
|
|
3506
|
+
let resizeWindow = function(){
|
|
3507
|
+
//触发amis crud 高度重算
|
|
3508
|
+
setTimeout(()=>{
|
|
3509
|
+
window.dispatchEvent(new Event("resize"))
|
|
3510
|
+
}, 500);
|
|
3511
|
+
}
|
|
3512
|
+
if(filterService.props.data.showFieldsFilter){
|
|
3513
|
+
let buttonCancel = SteedosUI.getClosestAmisComponentByType(filterForm.context, "button", {
|
|
3514
|
+
direction: "down",
|
|
3515
|
+
name: "btn_filter_form_cancel"
|
|
3516
|
+
});
|
|
3517
|
+
buttonCancel.props.dispatchEvent('click', {}).then(function(){
|
|
3518
|
+
resizeWindow();
|
|
3519
|
+
});
|
|
3520
|
+
}
|
|
3521
|
+
else{
|
|
3522
|
+
filterService.setData({showFieldsFilter: true});
|
|
3523
|
+
resizeWindow();
|
|
3524
|
+
}
|
|
3501
3525
|
`;
|
|
3502
3526
|
|
|
3503
3527
|
function getExportApiRequestAdaptorScript(){
|
|
@@ -4236,8 +4260,8 @@ function getObjectFooterToolbar(mainObject, formFactor) {
|
|
|
4236
4260
|
}
|
|
4237
4261
|
else {
|
|
4238
4262
|
return [
|
|
4263
|
+
"switch-per-page",
|
|
4239
4264
|
"statistics",
|
|
4240
|
-
// "switch-per-page",
|
|
4241
4265
|
"pagination"
|
|
4242
4266
|
]
|
|
4243
4267
|
}
|
|
@@ -5429,6 +5453,23 @@ const getAmisFileSchema = (steedosField, readonly)=>{
|
|
|
5429
5453
|
return readonly ? getAmisFileReadonlySchema(steedosField) : getAmisFileEditSchema(steedosField);
|
|
5430
5454
|
};
|
|
5431
5455
|
|
|
5456
|
+
/*
|
|
5457
|
+
* @Author: baozhoutao@steedos.com
|
|
5458
|
+
* @Date: 2022-07-20 16:29:22
|
|
5459
|
+
* @LastEditors: Please set LastEditors
|
|
5460
|
+
* @LastEditTime: 2023-05-11 11:19:54
|
|
5461
|
+
* @Description:
|
|
5462
|
+
*/
|
|
5463
|
+
|
|
5464
|
+
function getContrastColor(bgColor) {
|
|
5465
|
+
var backgroundColor = (bgColor.charAt(0) === '#') ? bgColor.substring(1, 7) : bgColor;
|
|
5466
|
+
var r = parseInt(backgroundColor.substr(0, 2), 16);
|
|
5467
|
+
var g = parseInt(backgroundColor.substr(2, 2), 16);
|
|
5468
|
+
var b = parseInt(backgroundColor.substr(4, 2), 16);
|
|
5469
|
+
var brightness = (r * 299 + g * 587 + b * 114) / 1000;
|
|
5470
|
+
return brightness >= 128 ? "#000000" : "#ffffff";
|
|
5471
|
+
}
|
|
5472
|
+
|
|
5432
5473
|
const OMIT_FIELDS = ['created', 'created_by', 'modified', 'modified_by'];
|
|
5433
5474
|
// const Lookup = require('./lookup');
|
|
5434
5475
|
|
|
@@ -5582,6 +5623,8 @@ function getSelectFieldOptions(field){
|
|
|
5582
5623
|
}
|
|
5583
5624
|
|
|
5584
5625
|
async function convertSFieldToAmisField(field, readonly, ctx) {
|
|
5626
|
+
// console.log('convertSFieldToAmisField====>', field, readonly, ctx)
|
|
5627
|
+
const isMobile = window.innerWidth <= 768;
|
|
5585
5628
|
// 创建人和修改人、创建时间和修改时间不显示
|
|
5586
5629
|
if(_$1.includes(OMIT_FIELDS, field.name) && ctx.showSystemFields != true){
|
|
5587
5630
|
return;
|
|
@@ -5616,20 +5659,42 @@ async function convertSFieldToAmisField(field, readonly, ctx) {
|
|
|
5616
5659
|
// }
|
|
5617
5660
|
// break;
|
|
5618
5661
|
case 'select':
|
|
5619
|
-
|
|
5620
|
-
|
|
5621
|
-
|
|
5622
|
-
|
|
5623
|
-
|
|
5624
|
-
|
|
5625
|
-
|
|
5626
|
-
|
|
5627
|
-
|
|
5628
|
-
|
|
5629
|
-
|
|
5630
|
-
|
|
5631
|
-
|
|
5662
|
+
if(readonly){
|
|
5663
|
+
const selectOptions = field.options;
|
|
5664
|
+
let map = {};
|
|
5665
|
+
_$1.forEach(selectOptions,(option)=>{
|
|
5666
|
+
const optionValue = option.value + '';
|
|
5667
|
+
if(option.color){
|
|
5668
|
+
const background = '#'+option.color;
|
|
5669
|
+
const color = getContrastColor(background);
|
|
5670
|
+
const optionColorStyle = 'background:'+background+';color:'+color;
|
|
5671
|
+
map[optionValue] = `<span class="rounded-xl px-2 py-1" style='${optionColorStyle}'>${option.label}</span>`;
|
|
5672
|
+
}else {
|
|
5673
|
+
map[optionValue] = option.label;
|
|
5674
|
+
}
|
|
5675
|
+
});
|
|
5676
|
+
convertData = {
|
|
5677
|
+
type: "static-mapping",
|
|
5678
|
+
name: field.name,
|
|
5679
|
+
label: field.label,
|
|
5680
|
+
map: map
|
|
5681
|
+
};
|
|
5682
|
+
}else {
|
|
5683
|
+
convertData = {
|
|
5684
|
+
type: getAmisStaticFieldType('select', readonly),
|
|
5685
|
+
joinValues: false,
|
|
5686
|
+
options: getSelectFieldOptions(field),
|
|
5687
|
+
extractValue: true,
|
|
5688
|
+
clearable: true,
|
|
5689
|
+
labelField: 'label',
|
|
5690
|
+
valueField: 'value'
|
|
5691
|
+
};
|
|
5692
|
+
if(field.multiple){
|
|
5693
|
+
convertData.multiple = true;
|
|
5694
|
+
convertData.extractValue = true;
|
|
5695
|
+
}
|
|
5632
5696
|
}
|
|
5697
|
+
|
|
5633
5698
|
break;
|
|
5634
5699
|
case 'boolean':
|
|
5635
5700
|
convertData = {
|
|
@@ -5649,7 +5714,26 @@ async function convertSFieldToAmisField(field, readonly, ctx) {
|
|
|
5649
5714
|
};
|
|
5650
5715
|
break;
|
|
5651
5716
|
case 'date':
|
|
5652
|
-
convertData = {
|
|
5717
|
+
convertData = isMobile && !readonly ? {
|
|
5718
|
+
type: "native-date",
|
|
5719
|
+
pipeIn: (value, data) => {
|
|
5720
|
+
if (value) {
|
|
5721
|
+
value = moment(value).utc().format('YYYY-MM-DD');
|
|
5722
|
+
return value;
|
|
5723
|
+
} else {
|
|
5724
|
+
return "";
|
|
5725
|
+
}
|
|
5726
|
+
|
|
5727
|
+
},
|
|
5728
|
+
pipeOut: (value, oldValue, data) => {
|
|
5729
|
+
if (value) {
|
|
5730
|
+
value = moment(value).format('YYYY-MM-DDT00:00:00.000[Z]');
|
|
5731
|
+
return value;
|
|
5732
|
+
} else {
|
|
5733
|
+
return "";
|
|
5734
|
+
}
|
|
5735
|
+
}
|
|
5736
|
+
} : {
|
|
5653
5737
|
type: getAmisStaticFieldType('date', readonly),
|
|
5654
5738
|
inputFormat: "YYYY-MM-DD",
|
|
5655
5739
|
format:'YYYY-MM-DDT00:00:00.000[Z]',
|
|
@@ -5668,12 +5752,48 @@ async function convertSFieldToAmisField(field, readonly, ctx) {
|
|
|
5668
5752
|
};
|
|
5669
5753
|
break;
|
|
5670
5754
|
case 'datetime':
|
|
5671
|
-
convertData = {
|
|
5755
|
+
convertData = isMobile && !readonly ? {
|
|
5756
|
+
type: "combo",
|
|
5757
|
+
pipeIn: (value, data) => {
|
|
5758
|
+
let revalue = {};
|
|
5759
|
+
if (value && value != "Invalid date") {
|
|
5760
|
+
value = moment(value).format('YYYY-MM-DD HH:mm:ss');
|
|
5761
|
+
revalue[field.name + "-native-date"] = value.split(' ')[0];
|
|
5762
|
+
revalue[field.name + "-native-time"] = value.split(' ')[1];
|
|
5763
|
+
} else {
|
|
5764
|
+
revalue[field.name + "-native-date"] = "";
|
|
5765
|
+
revalue[field.name + "-native-time"] = "";
|
|
5766
|
+
}
|
|
5767
|
+
return revalue;
|
|
5768
|
+
},
|
|
5769
|
+
pipeOut: (value, oldValue, data) => {
|
|
5770
|
+
let revalue = "";
|
|
5771
|
+
if (value[field.name + "-native-date"] && value[field.name + "-native-time"]) {
|
|
5772
|
+
revalue = value[field.name + "-native-date"] + " " + value[field.name + "-native-time"];
|
|
5773
|
+
revalue = moment(revalue).utc().format('YYYY-MM-DDTHH:mm:ss.SSS[Z]');
|
|
5774
|
+
}
|
|
5775
|
+
return revalue;
|
|
5776
|
+
},
|
|
5777
|
+
items: [
|
|
5778
|
+
{
|
|
5779
|
+
type: "native-date",
|
|
5780
|
+
name: field.name + "-native-date",
|
|
5781
|
+
className: "steedos-native-date",
|
|
5782
|
+
value: ""
|
|
5783
|
+
},
|
|
5784
|
+
{
|
|
5785
|
+
type: "native-time",
|
|
5786
|
+
name: field.name + "-native-time",
|
|
5787
|
+
className: "steedos-native-time",
|
|
5788
|
+
value: ""
|
|
5789
|
+
}
|
|
5790
|
+
]
|
|
5791
|
+
} : {
|
|
5672
5792
|
type: getAmisStaticFieldType('datetime', readonly),
|
|
5673
5793
|
inputFormat: 'YYYY-MM-DD HH:mm',
|
|
5674
|
-
format:'YYYY-MM-DDTHH:mm:ss.SSSZ',
|
|
5794
|
+
format: 'YYYY-MM-DDTHH:mm:ss.SSSZ',
|
|
5675
5795
|
tpl: readonly ? getDateTimeTpl(field) : null,
|
|
5676
|
-
utc: true
|
|
5796
|
+
utc: true,
|
|
5677
5797
|
};
|
|
5678
5798
|
break;
|
|
5679
5799
|
case 'input-time-range':
|
|
@@ -5688,7 +5808,26 @@ async function convertSFieldToAmisField(field, readonly, ctx) {
|
|
|
5688
5808
|
};
|
|
5689
5809
|
break;
|
|
5690
5810
|
case 'time':
|
|
5691
|
-
convertData = {
|
|
5811
|
+
convertData = isMobile && !readonly ? {
|
|
5812
|
+
type: "native-time",
|
|
5813
|
+
pipeIn: (value, data) => {
|
|
5814
|
+
if (value) {
|
|
5815
|
+
value = moment(value).utc().format('HH:mm');
|
|
5816
|
+
return value;
|
|
5817
|
+
} else {
|
|
5818
|
+
return "";
|
|
5819
|
+
}
|
|
5820
|
+
|
|
5821
|
+
},
|
|
5822
|
+
pipeOut: (value, oldValue, data) => {
|
|
5823
|
+
if (value) {
|
|
5824
|
+
value = moment('1970-01-01 ' + value).format('1970-01-01THH:mm:00.000[Z]');
|
|
5825
|
+
return value;
|
|
5826
|
+
} else {
|
|
5827
|
+
return "";
|
|
5828
|
+
}
|
|
5829
|
+
}
|
|
5830
|
+
} : {
|
|
5692
5831
|
type: getAmisStaticFieldType('time', readonly),
|
|
5693
5832
|
inputFormat: 'HH:mm',
|
|
5694
5833
|
timeFormat:'HH:mm',
|
|
@@ -5892,6 +6031,13 @@ async function convertSFieldToAmisField(field, readonly, ctx) {
|
|
|
5892
6031
|
convertData.quickEdit = false;
|
|
5893
6032
|
}
|
|
5894
6033
|
|
|
6034
|
+
let fieldTypeClassName = ' steedos-' + convertData.type + (readonly ? '-readonly' : '-edit');
|
|
6035
|
+
if (convertData.className) {
|
|
6036
|
+
convertData.className = convertData.className + fieldTypeClassName;
|
|
6037
|
+
} else {
|
|
6038
|
+
convertData.className = fieldTypeClassName;
|
|
6039
|
+
}
|
|
6040
|
+
|
|
5895
6041
|
if(field.visible_on){
|
|
5896
6042
|
// convertData.visibleOn = `\$${field.visible_on.substring(1, field.visible_on.length -1).replace(/formData./g, '')}`;
|
|
5897
6043
|
if(field.visible_on.startsWith("{{")){
|
|
@@ -6575,7 +6721,7 @@ async function getObjectCRUD(objectSchema, fields, options){
|
|
|
6575
6721
|
api: await getTableApi(objectSchema, fields, options),
|
|
6576
6722
|
hiddenOn: options.tableHiddenOn,
|
|
6577
6723
|
autoFillHeight: options.isRelated ? false : true,
|
|
6578
|
-
className: `flex-auto ${crudClassName || ""}`,
|
|
6724
|
+
className: `flex-auto bg-white ${crudClassName || ""}`,
|
|
6579
6725
|
crudClassName: crudClassName,
|
|
6580
6726
|
},
|
|
6581
6727
|
bodyProps,
|
|
@@ -6921,7 +7067,31 @@ async function getTableColumns(fields, options){
|
|
|
6921
7067
|
...getAmisFileReadonlySchema(field)
|
|
6922
7068
|
}, field.amis, {name: field.name}));
|
|
6923
7069
|
}
|
|
6924
|
-
|
|
7070
|
+
else if(field.type === 'select'){
|
|
7071
|
+
const selectOptions = field.options;
|
|
7072
|
+
let map = {};
|
|
7073
|
+
forEach(selectOptions,(option)=>{
|
|
7074
|
+
const optionValue = option.value + '';
|
|
7075
|
+
if(option.color){
|
|
7076
|
+
const background = '#'+option.color;
|
|
7077
|
+
const color = getContrastColor(background);
|
|
7078
|
+
const optionColorStyle = 'background:'+background+';color:'+color;
|
|
7079
|
+
map[optionValue] = `<span class="rounded-xl px-2 py-1" style='${optionColorStyle}'>${option.label}</span>`;
|
|
7080
|
+
}else {
|
|
7081
|
+
map[optionValue] = option.label;
|
|
7082
|
+
}
|
|
7083
|
+
});
|
|
7084
|
+
columns.push(Object.assign({}, {
|
|
7085
|
+
type: "mapping",
|
|
7086
|
+
name: field.name,
|
|
7087
|
+
label: field.label,
|
|
7088
|
+
map: map,
|
|
7089
|
+
sortable: field.sortable,
|
|
7090
|
+
width: field.width,
|
|
7091
|
+
toggled: field.toggled,
|
|
7092
|
+
className:"whitespace-nowrap",
|
|
7093
|
+
}, field.amis, {name: field.name}));
|
|
7094
|
+
}
|
|
6925
7095
|
else {
|
|
6926
7096
|
const tpl = await getFieldTpl(field, options);
|
|
6927
7097
|
|