@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.cjs.js
CHANGED
|
@@ -2685,7 +2685,7 @@ async function getObjectFieldsFilterBarSchema(objectSchema, ctx) {
|
|
|
2685
2685
|
// }
|
|
2686
2686
|
// listView.handleFilterSubmit(Object.assign({}, removedValues, filterFormValues));
|
|
2687
2687
|
`;
|
|
2688
|
-
const
|
|
2688
|
+
const onCancelScript = `
|
|
2689
2689
|
const scope = event.context.scoped;
|
|
2690
2690
|
var filterForm = scope.parent.parent.getComponents().find(function(n){
|
|
2691
2691
|
return n.props.type === "form";
|
|
@@ -2713,6 +2713,14 @@ async function getObjectFieldsFilterBarSchema(objectSchema, ctx) {
|
|
|
2713
2713
|
}
|
|
2714
2714
|
}
|
|
2715
2715
|
listView.handleFilterSubmit(removedValues);
|
|
2716
|
+
const filterService = filterForm.context.getComponents().find(function(n){
|
|
2717
|
+
return n.props.type === "service";
|
|
2718
|
+
});
|
|
2719
|
+
filterService.setData({showFieldsFilter: !!!filterService.props.data.showFieldsFilter});
|
|
2720
|
+
//触发amis crud 高度重算
|
|
2721
|
+
setTimeout(()=>{
|
|
2722
|
+
window.dispatchEvent(new Event("resize"))
|
|
2723
|
+
}, 100);
|
|
2716
2724
|
`;
|
|
2717
2725
|
const dataProviderInited = `
|
|
2718
2726
|
const objectName = data.objectName;
|
|
@@ -2909,14 +2917,15 @@ async function getObjectFieldsFilterBarSchema(objectSchema, ctx) {
|
|
|
2909
2917
|
},
|
|
2910
2918
|
{
|
|
2911
2919
|
"type": "button",
|
|
2912
|
-
"label": "
|
|
2920
|
+
"label": "取消",
|
|
2921
|
+
"name": "btn_filter_form_cancel",
|
|
2913
2922
|
"visibleOn": "this.filterFormSearchableFields && this.filterFormSearchableFields.length",
|
|
2914
2923
|
"onEvent": {
|
|
2915
2924
|
"click": {
|
|
2916
2925
|
"actions": [
|
|
2917
2926
|
{
|
|
2918
2927
|
"actionType": "custom",
|
|
2919
|
-
"script":
|
|
2928
|
+
"script": onCancelScript
|
|
2920
2929
|
}
|
|
2921
2930
|
]
|
|
2922
2931
|
}
|
|
@@ -3520,11 +3529,26 @@ const filterForm = scope.getComponents().find(function(n){
|
|
|
3520
3529
|
const filterService = filterForm.context.getComponents().find(function(n){
|
|
3521
3530
|
return n.props.type === "service";
|
|
3522
3531
|
});
|
|
3523
|
-
filterService.setData({showFieldsFilter: !!!filterService.props.data.showFieldsFilter});
|
|
3524
|
-
|
|
3525
|
-
|
|
3526
|
-
|
|
3527
|
-
|
|
3532
|
+
// filterService.setData({showFieldsFilter: !!!filterService.props.data.showFieldsFilter});
|
|
3533
|
+
let resizeWindow = function(){
|
|
3534
|
+
//触发amis crud 高度重算
|
|
3535
|
+
setTimeout(()=>{
|
|
3536
|
+
window.dispatchEvent(new Event("resize"))
|
|
3537
|
+
}, 500);
|
|
3538
|
+
}
|
|
3539
|
+
if(filterService.props.data.showFieldsFilter){
|
|
3540
|
+
let buttonCancel = SteedosUI.getClosestAmisComponentByType(filterForm.context, "button", {
|
|
3541
|
+
direction: "down",
|
|
3542
|
+
name: "btn_filter_form_cancel"
|
|
3543
|
+
});
|
|
3544
|
+
buttonCancel.props.dispatchEvent('click', {}).then(function(){
|
|
3545
|
+
resizeWindow();
|
|
3546
|
+
});
|
|
3547
|
+
}
|
|
3548
|
+
else{
|
|
3549
|
+
filterService.setData({showFieldsFilter: true});
|
|
3550
|
+
resizeWindow();
|
|
3551
|
+
}
|
|
3528
3552
|
`;
|
|
3529
3553
|
|
|
3530
3554
|
function getExportApiRequestAdaptorScript(){
|
|
@@ -4263,8 +4287,8 @@ function getObjectFooterToolbar(mainObject, formFactor) {
|
|
|
4263
4287
|
}
|
|
4264
4288
|
else {
|
|
4265
4289
|
return [
|
|
4290
|
+
"switch-per-page",
|
|
4266
4291
|
"statistics",
|
|
4267
|
-
// "switch-per-page",
|
|
4268
4292
|
"pagination"
|
|
4269
4293
|
]
|
|
4270
4294
|
}
|
|
@@ -5456,6 +5480,23 @@ const getAmisFileSchema = (steedosField, readonly)=>{
|
|
|
5456
5480
|
return readonly ? getAmisFileReadonlySchema(steedosField) : getAmisFileEditSchema(steedosField);
|
|
5457
5481
|
};
|
|
5458
5482
|
|
|
5483
|
+
/*
|
|
5484
|
+
* @Author: baozhoutao@steedos.com
|
|
5485
|
+
* @Date: 2022-07-20 16:29:22
|
|
5486
|
+
* @LastEditors: Please set LastEditors
|
|
5487
|
+
* @LastEditTime: 2023-05-11 11:19:54
|
|
5488
|
+
* @Description:
|
|
5489
|
+
*/
|
|
5490
|
+
|
|
5491
|
+
function getContrastColor(bgColor) {
|
|
5492
|
+
var backgroundColor = (bgColor.charAt(0) === '#') ? bgColor.substring(1, 7) : bgColor;
|
|
5493
|
+
var r = parseInt(backgroundColor.substr(0, 2), 16);
|
|
5494
|
+
var g = parseInt(backgroundColor.substr(2, 2), 16);
|
|
5495
|
+
var b = parseInt(backgroundColor.substr(4, 2), 16);
|
|
5496
|
+
var brightness = (r * 299 + g * 587 + b * 114) / 1000;
|
|
5497
|
+
return brightness >= 128 ? "#000000" : "#ffffff";
|
|
5498
|
+
}
|
|
5499
|
+
|
|
5459
5500
|
const OMIT_FIELDS = ['created', 'created_by', 'modified', 'modified_by'];
|
|
5460
5501
|
// const Lookup = require('./lookup');
|
|
5461
5502
|
|
|
@@ -5609,6 +5650,8 @@ function getSelectFieldOptions(field){
|
|
|
5609
5650
|
}
|
|
5610
5651
|
|
|
5611
5652
|
async function convertSFieldToAmisField(field, readonly, ctx) {
|
|
5653
|
+
// console.log('convertSFieldToAmisField====>', field, readonly, ctx)
|
|
5654
|
+
const isMobile = window.innerWidth <= 768;
|
|
5612
5655
|
// 创建人和修改人、创建时间和修改时间不显示
|
|
5613
5656
|
if(___namespace.includes(OMIT_FIELDS, field.name) && ctx.showSystemFields != true){
|
|
5614
5657
|
return;
|
|
@@ -5643,20 +5686,42 @@ async function convertSFieldToAmisField(field, readonly, ctx) {
|
|
|
5643
5686
|
// }
|
|
5644
5687
|
// break;
|
|
5645
5688
|
case 'select':
|
|
5646
|
-
|
|
5647
|
-
|
|
5648
|
-
|
|
5649
|
-
|
|
5650
|
-
|
|
5651
|
-
|
|
5652
|
-
|
|
5653
|
-
|
|
5654
|
-
|
|
5655
|
-
|
|
5656
|
-
|
|
5657
|
-
|
|
5658
|
-
|
|
5689
|
+
if(readonly){
|
|
5690
|
+
const selectOptions = field.options;
|
|
5691
|
+
let map = {};
|
|
5692
|
+
___namespace.forEach(selectOptions,(option)=>{
|
|
5693
|
+
const optionValue = option.value + '';
|
|
5694
|
+
if(option.color){
|
|
5695
|
+
const background = '#'+option.color;
|
|
5696
|
+
const color = getContrastColor(background);
|
|
5697
|
+
const optionColorStyle = 'background:'+background+';color:'+color;
|
|
5698
|
+
map[optionValue] = `<span class="rounded-xl px-2 py-1" style='${optionColorStyle}'>${option.label}</span>`;
|
|
5699
|
+
}else {
|
|
5700
|
+
map[optionValue] = option.label;
|
|
5701
|
+
}
|
|
5702
|
+
});
|
|
5703
|
+
convertData = {
|
|
5704
|
+
type: "static-mapping",
|
|
5705
|
+
name: field.name,
|
|
5706
|
+
label: field.label,
|
|
5707
|
+
map: map
|
|
5708
|
+
};
|
|
5709
|
+
}else {
|
|
5710
|
+
convertData = {
|
|
5711
|
+
type: getAmisStaticFieldType('select', readonly),
|
|
5712
|
+
joinValues: false,
|
|
5713
|
+
options: getSelectFieldOptions(field),
|
|
5714
|
+
extractValue: true,
|
|
5715
|
+
clearable: true,
|
|
5716
|
+
labelField: 'label',
|
|
5717
|
+
valueField: 'value'
|
|
5718
|
+
};
|
|
5719
|
+
if(field.multiple){
|
|
5720
|
+
convertData.multiple = true;
|
|
5721
|
+
convertData.extractValue = true;
|
|
5722
|
+
}
|
|
5659
5723
|
}
|
|
5724
|
+
|
|
5660
5725
|
break;
|
|
5661
5726
|
case 'boolean':
|
|
5662
5727
|
convertData = {
|
|
@@ -5676,7 +5741,26 @@ async function convertSFieldToAmisField(field, readonly, ctx) {
|
|
|
5676
5741
|
};
|
|
5677
5742
|
break;
|
|
5678
5743
|
case 'date':
|
|
5679
|
-
convertData = {
|
|
5744
|
+
convertData = isMobile && !readonly ? {
|
|
5745
|
+
type: "native-date",
|
|
5746
|
+
pipeIn: (value, data) => {
|
|
5747
|
+
if (value) {
|
|
5748
|
+
value = moment(value).utc().format('YYYY-MM-DD');
|
|
5749
|
+
return value;
|
|
5750
|
+
} else {
|
|
5751
|
+
return "";
|
|
5752
|
+
}
|
|
5753
|
+
|
|
5754
|
+
},
|
|
5755
|
+
pipeOut: (value, oldValue, data) => {
|
|
5756
|
+
if (value) {
|
|
5757
|
+
value = moment(value).format('YYYY-MM-DDT00:00:00.000[Z]');
|
|
5758
|
+
return value;
|
|
5759
|
+
} else {
|
|
5760
|
+
return "";
|
|
5761
|
+
}
|
|
5762
|
+
}
|
|
5763
|
+
} : {
|
|
5680
5764
|
type: getAmisStaticFieldType('date', readonly),
|
|
5681
5765
|
inputFormat: "YYYY-MM-DD",
|
|
5682
5766
|
format:'YYYY-MM-DDT00:00:00.000[Z]',
|
|
@@ -5695,12 +5779,48 @@ async function convertSFieldToAmisField(field, readonly, ctx) {
|
|
|
5695
5779
|
};
|
|
5696
5780
|
break;
|
|
5697
5781
|
case 'datetime':
|
|
5698
|
-
convertData = {
|
|
5782
|
+
convertData = isMobile && !readonly ? {
|
|
5783
|
+
type: "combo",
|
|
5784
|
+
pipeIn: (value, data) => {
|
|
5785
|
+
let revalue = {};
|
|
5786
|
+
if (value && value != "Invalid date") {
|
|
5787
|
+
value = moment(value).format('YYYY-MM-DD HH:mm:ss');
|
|
5788
|
+
revalue[field.name + "-native-date"] = value.split(' ')[0];
|
|
5789
|
+
revalue[field.name + "-native-time"] = value.split(' ')[1];
|
|
5790
|
+
} else {
|
|
5791
|
+
revalue[field.name + "-native-date"] = "";
|
|
5792
|
+
revalue[field.name + "-native-time"] = "";
|
|
5793
|
+
}
|
|
5794
|
+
return revalue;
|
|
5795
|
+
},
|
|
5796
|
+
pipeOut: (value, oldValue, data) => {
|
|
5797
|
+
let revalue = "";
|
|
5798
|
+
if (value[field.name + "-native-date"] && value[field.name + "-native-time"]) {
|
|
5799
|
+
revalue = value[field.name + "-native-date"] + " " + value[field.name + "-native-time"];
|
|
5800
|
+
revalue = moment(revalue).utc().format('YYYY-MM-DDTHH:mm:ss.SSS[Z]');
|
|
5801
|
+
}
|
|
5802
|
+
return revalue;
|
|
5803
|
+
},
|
|
5804
|
+
items: [
|
|
5805
|
+
{
|
|
5806
|
+
type: "native-date",
|
|
5807
|
+
name: field.name + "-native-date",
|
|
5808
|
+
className: "steedos-native-date",
|
|
5809
|
+
value: ""
|
|
5810
|
+
},
|
|
5811
|
+
{
|
|
5812
|
+
type: "native-time",
|
|
5813
|
+
name: field.name + "-native-time",
|
|
5814
|
+
className: "steedos-native-time",
|
|
5815
|
+
value: ""
|
|
5816
|
+
}
|
|
5817
|
+
]
|
|
5818
|
+
} : {
|
|
5699
5819
|
type: getAmisStaticFieldType('datetime', readonly),
|
|
5700
5820
|
inputFormat: 'YYYY-MM-DD HH:mm',
|
|
5701
|
-
format:'YYYY-MM-DDTHH:mm:ss.SSSZ',
|
|
5821
|
+
format: 'YYYY-MM-DDTHH:mm:ss.SSSZ',
|
|
5702
5822
|
tpl: readonly ? getDateTimeTpl(field) : null,
|
|
5703
|
-
utc: true
|
|
5823
|
+
utc: true,
|
|
5704
5824
|
};
|
|
5705
5825
|
break;
|
|
5706
5826
|
case 'input-time-range':
|
|
@@ -5715,7 +5835,26 @@ async function convertSFieldToAmisField(field, readonly, ctx) {
|
|
|
5715
5835
|
};
|
|
5716
5836
|
break;
|
|
5717
5837
|
case 'time':
|
|
5718
|
-
convertData = {
|
|
5838
|
+
convertData = isMobile && !readonly ? {
|
|
5839
|
+
type: "native-time",
|
|
5840
|
+
pipeIn: (value, data) => {
|
|
5841
|
+
if (value) {
|
|
5842
|
+
value = moment(value).utc().format('HH:mm');
|
|
5843
|
+
return value;
|
|
5844
|
+
} else {
|
|
5845
|
+
return "";
|
|
5846
|
+
}
|
|
5847
|
+
|
|
5848
|
+
},
|
|
5849
|
+
pipeOut: (value, oldValue, data) => {
|
|
5850
|
+
if (value) {
|
|
5851
|
+
value = moment('1970-01-01 ' + value).format('1970-01-01THH:mm:00.000[Z]');
|
|
5852
|
+
return value;
|
|
5853
|
+
} else {
|
|
5854
|
+
return "";
|
|
5855
|
+
}
|
|
5856
|
+
}
|
|
5857
|
+
} : {
|
|
5719
5858
|
type: getAmisStaticFieldType('time', readonly),
|
|
5720
5859
|
inputFormat: 'HH:mm',
|
|
5721
5860
|
timeFormat:'HH:mm',
|
|
@@ -5919,6 +6058,13 @@ async function convertSFieldToAmisField(field, readonly, ctx) {
|
|
|
5919
6058
|
convertData.quickEdit = false;
|
|
5920
6059
|
}
|
|
5921
6060
|
|
|
6061
|
+
let fieldTypeClassName = ' steedos-' + convertData.type + (readonly ? '-readonly' : '-edit');
|
|
6062
|
+
if (convertData.className) {
|
|
6063
|
+
convertData.className = convertData.className + fieldTypeClassName;
|
|
6064
|
+
} else {
|
|
6065
|
+
convertData.className = fieldTypeClassName;
|
|
6066
|
+
}
|
|
6067
|
+
|
|
5922
6068
|
if(field.visible_on){
|
|
5923
6069
|
// convertData.visibleOn = `\$${field.visible_on.substring(1, field.visible_on.length -1).replace(/formData./g, '')}`;
|
|
5924
6070
|
if(field.visible_on.startsWith("{{")){
|
|
@@ -6602,7 +6748,7 @@ async function getObjectCRUD(objectSchema, fields, options){
|
|
|
6602
6748
|
api: await getTableApi(objectSchema, fields, options),
|
|
6603
6749
|
hiddenOn: options.tableHiddenOn,
|
|
6604
6750
|
autoFillHeight: options.isRelated ? false : true,
|
|
6605
|
-
className: `flex-auto ${crudClassName || ""}`,
|
|
6751
|
+
className: `flex-auto bg-white ${crudClassName || ""}`,
|
|
6606
6752
|
crudClassName: crudClassName,
|
|
6607
6753
|
},
|
|
6608
6754
|
bodyProps,
|
|
@@ -6948,7 +7094,31 @@ async function getTableColumns(fields, options){
|
|
|
6948
7094
|
...getAmisFileReadonlySchema(field)
|
|
6949
7095
|
}, field.amis, {name: field.name}));
|
|
6950
7096
|
}
|
|
6951
|
-
|
|
7097
|
+
else if(field.type === 'select'){
|
|
7098
|
+
const selectOptions = field.options;
|
|
7099
|
+
let map = {};
|
|
7100
|
+
_$1.forEach(selectOptions,(option)=>{
|
|
7101
|
+
const optionValue = option.value + '';
|
|
7102
|
+
if(option.color){
|
|
7103
|
+
const background = '#'+option.color;
|
|
7104
|
+
const color = getContrastColor(background);
|
|
7105
|
+
const optionColorStyle = 'background:'+background+';color:'+color;
|
|
7106
|
+
map[optionValue] = `<span class="rounded-xl px-2 py-1" style='${optionColorStyle}'>${option.label}</span>`;
|
|
7107
|
+
}else {
|
|
7108
|
+
map[optionValue] = option.label;
|
|
7109
|
+
}
|
|
7110
|
+
});
|
|
7111
|
+
columns.push(Object.assign({}, {
|
|
7112
|
+
type: "mapping",
|
|
7113
|
+
name: field.name,
|
|
7114
|
+
label: field.label,
|
|
7115
|
+
map: map,
|
|
7116
|
+
sortable: field.sortable,
|
|
7117
|
+
width: field.width,
|
|
7118
|
+
toggled: field.toggled,
|
|
7119
|
+
className:"whitespace-nowrap",
|
|
7120
|
+
}, field.amis, {name: field.name}));
|
|
7121
|
+
}
|
|
6952
7122
|
else {
|
|
6953
7123
|
const tpl = await getFieldTpl(field, options);
|
|
6954
7124
|
|