@steedos-widgets/amis-lib 1.2.35-beta.2 → 1.2.35

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
@@ -3352,7 +3352,7 @@ async function getObjectFieldsFilterBarSchema(objectSchema, ctx) {
3352
3352
  if(!event.data.isLookup){
3353
3353
  // 刷新浏览器后,filterFormValues值是空的,只能从本地存储中取出并重置为空值
3354
3354
  const listViewId = event.data.listViewId;
3355
- const listViewPropsStoreKey = location.pathname + "/crud/" + listViewId ;
3355
+ const listViewPropsStoreKey = location.pathname + "/crud/" + (listViewId || "");
3356
3356
  let localListViewProps = sessionStorage.getItem(listViewPropsStoreKey);
3357
3357
  if(localListViewProps){
3358
3358
  localListViewProps = JSON.parse(localListViewProps);
@@ -3384,7 +3384,7 @@ async function getObjectFieldsFilterBarSchema(objectSchema, ctx) {
3384
3384
  searchableFieldsStoreKey += "lookup/" + objectName;
3385
3385
  }
3386
3386
  else{
3387
- searchableFieldsStoreKey += listViewId;
3387
+ searchableFieldsStoreKey += (listViewId || "");
3388
3388
  }
3389
3389
  let defaultSearchableFields = sessionStorage.getItem(searchableFieldsStoreKey);
3390
3390
  if(defaultSearchableFields){
@@ -3411,7 +3411,9 @@ async function getObjectFieldsFilterBarSchema(objectSchema, ctx) {
3411
3411
  setData({ showFieldsFilter: false });
3412
3412
  }
3413
3413
  else{
3414
- const listViewPropsStoreKey = location.pathname + "/crud/" + data.listViewId ;
3414
+ console.log("===listViewPropsStoreKey=data==", data);
3415
+ const listViewPropsStoreKey = location.pathname + "/crud/" + (data.listViewId || "");
3416
+ console.log("===listViewPropsStoreKey=122==", listViewPropsStoreKey);
3415
3417
  let localListViewProps = sessionStorage.getItem(listViewPropsStoreKey);
3416
3418
  if(localListViewProps){
3417
3419
  localListViewProps = JSON.parse(localListViewProps);
@@ -3457,7 +3459,7 @@ async function getObjectFieldsFilterBarSchema(objectSchema, ctx) {
3457
3459
  searchableFieldsStoreKey += "lookup/" + objectName;
3458
3460
  }
3459
3461
  else{
3460
- searchableFieldsStoreKey += listViewId;
3462
+ searchableFieldsStoreKey += (listViewId || "");
3461
3463
  }
3462
3464
  sessionStorage.setItem(searchableFieldsStoreKey, value);
3463
3465
 
@@ -3515,7 +3517,7 @@ async function getObjectFieldsFilterBarSchema(objectSchema, ctx) {
3515
3517
  }
3516
3518
 
3517
3519
  // 列表视图crud支持本地缓存,所以需要进一步清除浏览器本地缓存里面用户在可搜索项中移除的字段值
3518
- const listViewPropsStoreKey = location.pathname + "/crud/" + listViewId ;
3520
+ const listViewPropsStoreKey = location.pathname + "/crud/" + (listViewId || "");
3519
3521
  let localListViewProps = sessionStorage.getItem(listViewPropsStoreKey);
3520
3522
  if(localListViewProps){
3521
3523
  localListViewProps = JSON.parse(localListViewProps);
@@ -3634,7 +3636,8 @@ async function getObjectFieldsFilterBarSchema(objectSchema, ctx) {
3634
3636
  const fields = uiSchema.fields;
3635
3637
  const options = (payload.data?.options || []).filter(function(item){
3636
3638
  let field = fields[item.value];
3637
- return !!field && window.isFieldTypeSearchable(field.type)
3639
+ // TODO: 暂时禁用location类型字段的列表搜索
3640
+ return !!field && window.isFieldTypeSearchable(field.type) && field.type !== 'location'
3638
3641
  });
3639
3642
  payload.data = {
3640
3643
  "options": options
@@ -5237,6 +5240,7 @@ crudService && crudService.setData({showFieldsFilter: toShowFieldsFilter});
5237
5240
 
5238
5241
  function getObjectHeaderToolbar(mainObject, formFactor, {showDisplayAs = false, hiddenCount = false, headerToolbarItems, filterVisible = true} = {}){
5239
5242
  // console.log(`getObjectHeaderToolbar====>`, filterVisible)
5243
+ console.log(`getObjectHeaderToolbar`, mainObject);
5240
5244
  const isMobile = window.innerWidth < 768;
5241
5245
  if(isMobile){
5242
5246
  showDisplayAs = false;
@@ -5336,7 +5340,7 @@ function getObjectHeaderToolbar(mainObject, formFactor, {showDisplayAs = false,
5336
5340
  "className": "bg-white p-2 rounded border-gray-300 text-gray-500"
5337
5341
  },
5338
5342
  // getExportExcelToolbarButtonSchema(),
5339
- getSettingListviewToolbarButtonSchema(),
5343
+ mainObject?.permissions?.allowCreateListViews ? getSettingListviewToolbarButtonSchema() : {},
5340
5344
  getDisplayAsButton(mainObject?.name),
5341
5345
  filterVisible ? {
5342
5346
  "label": i18next.t('frontend_button_search_tooltip'),
@@ -7176,12 +7180,35 @@ async function convertSFieldToAmisField(field, readonly, ctx) {
7176
7180
  }
7177
7181
  }
7178
7182
 
7183
+ const coordinatesType = field.coordinatesType || "bd09";
7179
7184
  convertData = {
7180
7185
  type: getAmisStaticFieldType('location', readonly),
7181
7186
  tpl: readonly ? getLocationTpl(field) : null,
7182
7187
  ak,
7183
7188
  vendor,
7184
- label: field.label
7189
+ clearable: true,
7190
+ coordinatesType,
7191
+ label: field.label,
7192
+ pipeOut: (value, oldValue, data) => {
7193
+ if (value) {
7194
+ const lng = value.lng;
7195
+ const lat = value.lat;
7196
+ let coordinates = [lng,lat];
7197
+ if(window.coordtransform){
7198
+ if(coordinatesType.toLowerCase() === 'bd09'){
7199
+ const bd09togcj02 = window.coordtransform.bd09togcj02(lng,lat);
7200
+ coordinates = window.coordtransform.gcj02towgs84(bd09togcj02[0],bd09togcj02[1]);
7201
+ }else if(coordinatesType.toLowerCase() === 'gcj02'){
7202
+ coordinates = window.coordtransform.gcj02towgs84(lng,lat);
7203
+ }
7204
+ }
7205
+ value.wgs84 = {
7206
+ type: "Point",
7207
+ coordinates
7208
+ };
7209
+ return value; // 切换到数字之后的默认值
7210
+ }
7211
+ }
7185
7212
  };
7186
7213
  break;
7187
7214
  case 'avatar':
@@ -7649,6 +7676,10 @@ async function getQuickEditSchema(field, options){
7649
7676
  if(field.type == "file" && field.multiple){
7650
7677
  quickEditSchema = false;
7651
7678
  }
7679
+ //TODO:location字段在列表中快速编辑后存在bug,保存时可能会丢失部分数据,暂时禁用
7680
+ if(field.type == "location"){
7681
+ quickEditSchema = false;
7682
+ }
7652
7683
  }
7653
7684
  return quickEditSchema;
7654
7685
  }
@@ -8203,7 +8234,7 @@ async function getTableApi(mainObject, fields, options){
8203
8234
  try{
8204
8235
  // TODO: 不应该直接在这里取localStorage,应该从外面传入
8205
8236
  const listViewId = api.data.listViewId;
8206
- const listViewPropsStoreKey = location.pathname + "/crud/" + listViewId ;
8237
+ const listViewPropsStoreKey = location.pathname + "/crud/" + (listViewId || "");
8207
8238
  let localListViewProps = sessionStorage.getItem(listViewPropsStoreKey);
8208
8239
  if(localListViewProps){
8209
8240
  localListViewProps = JSON.parse(localListViewProps);
@@ -8404,7 +8435,7 @@ async function getTableApi(mainObject, fields, options){
8404
8435
  try{
8405
8436
  // TODO: 不应该直接在这里取localStorage,应该从外面传入
8406
8437
  const listViewId = api.body.listViewId;
8407
- const listViewPropsStoreKey = location.pathname + "/crud/" + listViewId ;
8438
+ const listViewPropsStoreKey = location.pathname + "/crud/" + (listViewId || "");
8408
8439
  /**
8409
8440
  * localListViewProps规范来自crud请求api中api.data.$self参数值的。
8410
8441
  * 比如:{"perPage":20,"page":1,"__searchable__name":"7","__searchable__between__n1__c":[null,null],"filter":[["name","contains","a"]]}
@@ -10372,8 +10403,8 @@ async function getRelatedListSchema(
10372
10403
  /*
10373
10404
  * @Author: baozhoutao@steedos.com
10374
10405
  * @Date: 2022-07-05 15:55:39
10375
- * @LastEditors: baozhoutao@steedos.com
10376
- * @LastEditTime: 2023-07-29 13:58:07
10406
+ * @LastEditors: 殷亮辉 yinlianghui@hotoa.com
10407
+ * @LastEditTime: 2023-08-01 14:50:23
10377
10408
  * @Description:
10378
10409
  */
10379
10410
 
@@ -10638,7 +10669,7 @@ async function getListSchema(
10638
10669
  * 本次存储代码段
10639
10670
  */
10640
10671
  try {
10641
- const listViewPropsStoreKey = location.pathname + "/crud/" + ctx.listViewId;
10672
+ const listViewPropsStoreKey = location.pathname + "/crud/" + (ctx.listViewId || "");
10642
10673
  let localListViewProps = sessionStorage.getItem(listViewPropsStoreKey);
10643
10674
  /**
10644
10675
  * localListViewProps规范来自crud请求api中api.data.$self参数值的。