@steedos-widgets/amis-lib 6.3.17-beta.3 → 6.3.17-beta.4

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/index.esm.js CHANGED
@@ -3060,7 +3060,7 @@ async function getTableSchema$1(object, fields, options){
3060
3060
  */
3061
3061
  async function getTableApi(mainObject, fields, options){
3062
3062
  const searchableFields = [];
3063
- let { filter, filtersFunction, sort, top, setDataToComponentId = '' } = options;
3063
+ let { filter, filtersFunction, sort, top, setDataToComponentId = '', searchable_default: searchableDefault } = options;
3064
3064
 
3065
3065
  if(_$1.isArray(filter)){
3066
3066
  filter = _$1.map(filter, function(item){
@@ -3200,8 +3200,25 @@ async function getTableApi(mainObject, fields, options){
3200
3200
  }else if(selfData.op === 'loadOptions' && selfData.value){
3201
3201
  userFilters = [["${valueField.name}", "=", selfData.value]];
3202
3202
  }
3203
+
3204
+ let filterFormValues = {};
3205
+ if (selfData.op !== 'loadOptions'){
3206
+ filterFormValues = ${_$1.isObject(searchableDefault) ? JSON.stringify(searchableDefault) : ('"' + (searchableDefault || "") + '"')} || {};
3207
+ if (_.isObject(filterFormValues) || !_.isEmpty(filterFormValues)){
3208
+ _.each(filterFormValues, function(v, k){
3209
+ const isAmisFormulaValue = typeof v === "string" && v.indexOf("\${") > -1;
3210
+ if (isAmisFormulaValue){
3211
+ filterFormValues[k] = AmisCore.evaluate(v, context);
3212
+ }
3213
+ });
3214
+ let uiSchema = api.data.$self.uiSchema;
3215
+ let fields = uiSchema && uiSchema.fields;
3216
+ filterFormValues = SteedosUI.getSearchFilterFormValues(filterFormValues, fields);
3217
+ }
3218
+ }
3219
+
3220
+ var searchableFilter = SteedosUI.getSearchFilter(Object.assign({}, { ...filterFormValues }, selfData)) || [];
3203
3221
 
3204
- var searchableFilter = SteedosUI.getSearchFilter(selfData) || [];
3205
3222
  if(searchableFilter.length > 0){
3206
3223
  if(userFilters.length > 0 ){
3207
3224
  userFilters = [userFilters, 'and', searchableFilter];
@@ -6301,7 +6318,6 @@ async function getObjectFieldsFilterBarSchema(objectSchema, ctx) {
6301
6318
  crudService && crudService.setData({isFieldsFilterEmpty, showFieldsFilter});
6302
6319
  `;
6303
6320
  const onCancelScript = `
6304
- // console.log("===onCancelScript=form==");
6305
6321
  let isLookup = event.data.isLookup;
6306
6322
  let __lookupField = event.data.__lookupField;
6307
6323
  const scope = event.context.scoped;
@@ -6387,26 +6403,34 @@ async function getObjectFieldsFilterBarSchema(objectSchema, ctx) {
6387
6403
  crudService && crudService.setData({isFieldsFilterEmpty: true, showFieldsFilter: false});
6388
6404
  `;
6389
6405
  /**
6390
- 给lookup字段配置filter_form_data时可以配置为amis变量,也可以配置为事态key-value键值对象值:
6406
+ 给lookup字段或列表视图中配置 searchable_default 时可以配置为amis变量,也可以配置为静态key-value键值对象值:
6391
6407
  ```
6392
- "filter_form_data": "${selectedPublicGroupFilterFormData|toJson}"
6408
+ "searchable_default": {
6409
+ "start": "${[STARTOF(NOW(), 'month'),ENDOF(DATEMODIFY(NOW(), 3, 'month'), 'month')]}"
6410
+ }
6393
6411
  ```
6394
6412
  or
6395
6413
  ```
6396
- "filter_form_data": {
6414
+ "searchable_default": {
6397
6415
  "public_group_ids": [
6398
6416
  "67addbef39f9a4503789b38d"
6399
6417
  ]
6400
6418
  }
6419
+ ```
6420
+ 注意只能配置为json键值对格式,amis变量值只能分别配置到各个字段值中,不支持配置为amis变量的字符串形式,例如:
6421
+ ```
6422
+ "searchable_default": "${selectedPublicGroupFilterFormData|toJson}"
6401
6423
  ```
6402
6424
  */
6403
- const filterFormValues = ctx.filter_form_data;
6425
+ // 列表视图、对象表格组件或lookup字段上配置的searchable_default会传入到ctx
6426
+ const searchableDefault = ctx.searchable_default;
6404
6427
  const dataProviderInited = `
6405
6428
  const searchableFields = ${JSON.stringify(searchableFields)};
6406
6429
  const autoOpenFilter = ${autoOpenFilter};
6407
6430
  const objectName = data.objectName;
6408
6431
  const isLookup = data.isLookup;
6409
6432
  const listName = data.listName;
6433
+ const crudId = "${ctx.crudId || ""}" || "listview_" + objectName;
6410
6434
  let searchableFieldsStoreKey = location.pathname + "/searchable_fields";
6411
6435
  if(isLookup){
6412
6436
  searchableFieldsStoreKey += "/lookup/" + objectName;
@@ -6437,42 +6461,45 @@ async function getObjectFieldsFilterBarSchema(objectSchema, ctx) {
6437
6461
  );
6438
6462
  }
6439
6463
  setData({ filterFormSearchableFields: defaultSearchableFields });
6464
+
6465
+ let searchableFilterData = ${_.isObject(searchableDefault) ? JSON.stringify(searchableDefault) : ('"' + (searchableDefault || "") + '"')} || {};
6466
+ if (_.isObject(searchableFilterData) || !_.isEmpty(searchableFilterData)){
6467
+ _.each(searchableFilterData, function(v, k){
6468
+ const isAmisFormulaValue = typeof v === "string" && v.indexOf("\${") > -1;
6469
+ if (isAmisFormulaValue){
6470
+ searchableFilterData[k] = AmisCore.evaluate(v, data);
6471
+ }
6472
+ });
6473
+ let fields = data.uiSchema && data.uiSchema.fields;
6474
+ searchableFilterData = SteedosUI.getSearchFilterFormValues(searchableFilterData, fields);
6475
+ }
6440
6476
  if(isLookup){
6441
- let filterFormValues = ${_.isObject(filterFormValues) ? JSON.stringify(filterFormValues) : ('"' + filterFormValues + '"')} || {};
6442
- const isAmisFormula = typeof filterFormValues === "string" && filterFormValues.indexOf("\${") > -1;
6443
- if (isAmisFormula){
6444
- filterFormValues = AmisCore.evaluate(filterFormValues, data) || {};
6477
+ if (!_.isEmpty(searchableFilterData)){
6478
+ setData({ ...searchableFilterData });
6445
6479
  }
6446
- if (_.isObject(filterFormValues) || !_.isEmpty(filterFormValues)){
6447
- let fields = data.uiSchema && data.uiSchema.fields;
6448
- filterFormValues = SteedosUI.getSearchFilterFormValues(filterFormValues, fields);
6449
- setData({ ...filterFormValues });
6450
- }
6451
- // looup字段过滤器不在本地缓存记住过滤条件,所以初始始终隐藏过滤器
6480
+ // looup字段过滤器不在本地缓存记住过滤条件,只处理是否隐藏过滤器
6452
6481
  setData({ showFieldsFilter: autoOpenFilter });
6453
6482
  }
6454
6483
  else{
6455
6484
  const listViewPropsStoreKey = location.pathname + "/crud";
6456
6485
  let localListViewProps = sessionStorage.getItem(listViewPropsStoreKey);
6486
+ let localFilterFormValues;
6457
6487
  if(localListViewProps){
6458
6488
  localListViewProps = JSON.parse(localListViewProps);
6459
- let filterFormValues = _.pickBy(localListViewProps, function(n,k){
6489
+ localFilterFormValues = _.pickBy(localListViewProps, function(n,k){
6460
6490
  return /^__searchable__/g.test(k);
6461
6491
  });
6462
- if(!_.isEmpty(filterFormValues)){
6463
- setData({ ...filterFormValues });
6464
- const omitedEmptyFormValue = _.omitBy(filterFormValues, function(n){
6465
- return _.isNil(n)
6466
- || (_.isObject(n) && _.isEmpty(n))
6467
- || (_.isArray(n) && _.isEmpty(n.filter(function(item){return !_.isNil(item)})))
6468
- || (_.isString(n) && n.length === 0);
6469
- });
6470
- // 有过滤条件时只显示搜索按钮上的红点,不自动展开搜索栏
6471
- if(!_.isEmpty(omitedEmptyFormValue)){
6472
- let crudService = SteedosUI.getRef(data.$scopeId).parent.getComponentById("service_listview_" + data.objectName)
6473
- crudService && crudService.setData({isFieldsFilterEmpty: false});
6474
- // setData({ showFieldsFilter: true });//自动展开搜索栏
6475
- }
6492
+ }
6493
+ let filterFormValues = Object.assign({}, searchableFilterData, localFilterFormValues);
6494
+ if(!_.isEmpty(filterFormValues)){
6495
+ setData({ ...filterFormValues });
6496
+ let isFieldsFilterEmpty = SteedosUI.isFilterFormValuesEmpty(filterFormValues);
6497
+ // 有过滤条件时只显示搜索按钮上的红点,不自动展开搜索栏
6498
+ if(!isFieldsFilterEmpty){
6499
+ let crud = SteedosUI.getRef(data.$scopeId).getComponentById(crudId);
6500
+ let crudService = crud && SteedosUI.getClosestAmisComponentByType(crud.context, "service", {name: "service_object_table_crud"});
6501
+ crudService && crudService.setData({isFieldsFilterEmpty: false});
6502
+ // setData({ showFieldsFilter: true });//自动展开搜索栏
6476
6503
  }
6477
6504
  }
6478
6505
  }
@@ -10582,8 +10609,8 @@ async function getObjectRelatedListsMiniSchema(objectApiName){
10582
10609
  /*
10583
10610
  * @Author: baozhoutao@steedos.com
10584
10611
  * @Date: 2022-07-05 15:55:39
10585
- * @LastEditors: 殷亮辉 yinlianghui@hotoa.com
10586
- * @LastEditTime: 2025-05-20 16:56:55
10612
+ * @LastEditors: yinlianghui yinlianghui@hotoa.com
10613
+ * @LastEditTime: 2025-12-25 16:41:00
10587
10614
  * @Description:
10588
10615
  */
10589
10616
 
@@ -10923,7 +10950,8 @@ async function getListSchema(
10923
10950
  "filterVisible": ctx.filterVisible,
10924
10951
  "rowClassNameExpr": ctx.rowClassNameExpr,
10925
10952
  "crudDataFilter": ctx.crudDataFilter,
10926
- "onCrudDataFilter": ctx.onCrudDataFilter
10953
+ "onCrudDataFilter": ctx.onCrudDataFilter,
10954
+ "searchable_default": listView.searchable_default
10927
10955
  };
10928
10956
  // console.log(`getListSchema===>`,amisSchema)
10929
10957
  return {
@@ -12194,7 +12222,8 @@ async function lookupToAmisPicker(field, readonly, ctx){
12194
12222
  // field.name可能是带点的名称,比如审批王中子表字段'instances.instances_submitter',如果不替换掉点,会造成审批王表单中新建子表行时报错
12195
12223
  let keywordsSearchBoxName = `__keywords_lookup__${field.name.replace(/\./g, "_")}__to__${refObjectConfig.name}`;
12196
12224
 
12197
- const filterFormValues = field.filter_form_data;
12225
+ // 优先认lookup字段上配置的searchable_default,没有时再使用lookup字段关联对象对应的Lookup列表视图上的searchable_default配置
12226
+ const searchableDefault = field.searchable_default || listView.searchable_default;
12198
12227
  source.requestAdaptor = `
12199
12228
  let __changedFilterFormValuesKey = "__changedFilterFormValues";
12200
12229
  let __lookupField = api.data.$self.__lookupField;
@@ -12239,12 +12268,14 @@ async function lookupToAmisPicker(field, readonly, ctx){
12239
12268
 
12240
12269
  let filterFormValues = {};
12241
12270
  if (selfData.op !== 'loadOptions'){
12242
- filterFormValues = ${_$1.isObject(filterFormValues) ? JSON.stringify(filterFormValues) : ('"' + filterFormValues + '"')} || {};
12243
- const isAmisFormula = typeof filterFormValues === "string" && filterFormValues.indexOf("\${") > -1;
12244
- if (isAmisFormula){
12245
- filterFormValues = AmisCore.evaluate(filterFormValues, context) || {};
12246
- }
12271
+ filterFormValues = ${_$1.isObject(searchableDefault) ? JSON.stringify(searchableDefault) : ('"' + (searchableDefault || "") + '"')} || {};
12247
12272
  if (_.isObject(filterFormValues) || !_.isEmpty(filterFormValues)){
12273
+ _.each(filterFormValues, function(v, k){
12274
+ const isAmisFormulaValue = typeof v === "string" && v.indexOf("\${") > -1;
12275
+ if (isAmisFormulaValue){
12276
+ filterFormValues[k] = AmisCore.evaluate(v, context);
12277
+ }
12278
+ });
12248
12279
  let fields = api.data.$self.uiSchema && api.data.$self.uiSchema.fields;
12249
12280
  filterFormValues = SteedosUI.getSearchFilterFormValues(filterFormValues, fields);
12250
12281
  }
@@ -12490,8 +12521,8 @@ async function lookupToAmisPicker(field, readonly, ctx){
12490
12521
  keywordsSearchBoxName,
12491
12522
  searchable_fields: field.searchable_fields,
12492
12523
  auto_open_filter: field.auto_open_filter,
12493
- show_left_filter: field.show_left_filter,
12494
- filter_form_data: field.filter_form_data
12524
+ searchable_default: searchableDefault,
12525
+ show_left_filter: field.show_left_filter
12495
12526
  });
12496
12527
  }
12497
12528
  pickerSchema.data = Object.assign({}, pickerSchema.data, {