@steedos-widgets/amis-object 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.
@@ -1,4 +1,4 @@
1
- import './AmisSelectFlow.less';
1
+ import "./AmisSelectFlow.less";
2
2
  /**
3
3
  *
4
4
  * @css
@@ -6521,7 +6521,7 @@ async function getObjectFieldsFilterBarSchema(objectSchema, ctx) {
6521
6521
  if(!event.data.isLookup){
6522
6522
  // 刷新浏览器后,filterFormValues值是空的,只能从本地存储中取出并重置为空值
6523
6523
  const listViewId = event.data.listViewId;
6524
- const listViewPropsStoreKey = location.pathname + "/crud/" + listViewId ;
6524
+ const listViewPropsStoreKey = location.pathname + "/crud/" + (listViewId || "");
6525
6525
  let localListViewProps = sessionStorage.getItem(listViewPropsStoreKey);
6526
6526
  if(localListViewProps){
6527
6527
  localListViewProps = JSON.parse(localListViewProps);
@@ -6553,7 +6553,7 @@ async function getObjectFieldsFilterBarSchema(objectSchema, ctx) {
6553
6553
  searchableFieldsStoreKey += "lookup/" + objectName;
6554
6554
  }
6555
6555
  else{
6556
- searchableFieldsStoreKey += listViewId;
6556
+ searchableFieldsStoreKey += (listViewId || "");
6557
6557
  }
6558
6558
  let defaultSearchableFields = sessionStorage.getItem(searchableFieldsStoreKey);
6559
6559
  if(defaultSearchableFields){
@@ -6580,7 +6580,9 @@ async function getObjectFieldsFilterBarSchema(objectSchema, ctx) {
6580
6580
  setData({ showFieldsFilter: false });
6581
6581
  }
6582
6582
  else{
6583
- const listViewPropsStoreKey = location.pathname + "/crud/" + data.listViewId ;
6583
+ console.log("===listViewPropsStoreKey=data==", data);
6584
+ const listViewPropsStoreKey = location.pathname + "/crud/" + (data.listViewId || "");
6585
+ console.log("===listViewPropsStoreKey=122==", listViewPropsStoreKey);
6584
6586
  let localListViewProps = sessionStorage.getItem(listViewPropsStoreKey);
6585
6587
  if(localListViewProps){
6586
6588
  localListViewProps = JSON.parse(localListViewProps);
@@ -6626,7 +6628,7 @@ async function getObjectFieldsFilterBarSchema(objectSchema, ctx) {
6626
6628
  searchableFieldsStoreKey += "lookup/" + objectName;
6627
6629
  }
6628
6630
  else{
6629
- searchableFieldsStoreKey += listViewId;
6631
+ searchableFieldsStoreKey += (listViewId || "");
6630
6632
  }
6631
6633
  sessionStorage.setItem(searchableFieldsStoreKey, value);
6632
6634
 
@@ -6684,7 +6686,7 @@ async function getObjectFieldsFilterBarSchema(objectSchema, ctx) {
6684
6686
  }
6685
6687
 
6686
6688
  // 列表视图crud支持本地缓存,所以需要进一步清除浏览器本地缓存里面用户在可搜索项中移除的字段值
6687
- const listViewPropsStoreKey = location.pathname + "/crud/" + listViewId ;
6689
+ const listViewPropsStoreKey = location.pathname + "/crud/" + (listViewId || "");
6688
6690
  let localListViewProps = sessionStorage.getItem(listViewPropsStoreKey);
6689
6691
  if(localListViewProps){
6690
6692
  localListViewProps = JSON.parse(localListViewProps);
@@ -6803,7 +6805,8 @@ async function getObjectFieldsFilterBarSchema(objectSchema, ctx) {
6803
6805
  const fields = uiSchema.fields;
6804
6806
  const options = (payload.data?.options || []).filter(function(item){
6805
6807
  let field = fields[item.value];
6806
- return !!field && window.isFieldTypeSearchable(field.type)
6808
+ // TODO: 暂时禁用location类型字段的列表搜索
6809
+ return !!field && window.isFieldTypeSearchable(field.type) && field.type !== 'location'
6807
6810
  });
6808
6811
  payload.data = {
6809
6812
  "options": options
@@ -8406,6 +8409,7 @@ crudService && crudService.setData({showFieldsFilter: toShowFieldsFilter});
8406
8409
 
8407
8410
  function getObjectHeaderToolbar(mainObject, formFactor, {showDisplayAs = false, hiddenCount = false, headerToolbarItems, filterVisible = true} = {}){
8408
8411
  // console.log(`getObjectHeaderToolbar====>`, filterVisible)
8412
+ console.log(`getObjectHeaderToolbar`, mainObject);
8409
8413
  const isMobile = window.innerWidth < 768;
8410
8414
  if(isMobile){
8411
8415
  showDisplayAs = false;
@@ -8505,7 +8509,7 @@ function getObjectHeaderToolbar(mainObject, formFactor, {showDisplayAs = false,
8505
8509
  "className": "bg-white p-2 rounded border-gray-300 text-gray-500"
8506
8510
  },
8507
8511
  // getExportExcelToolbarButtonSchema(),
8508
- getSettingListviewToolbarButtonSchema(),
8512
+ mainObject?.permissions?.allowCreateListViews ? getSettingListviewToolbarButtonSchema() : {},
8509
8513
  getDisplayAsButton(mainObject?.name),
8510
8514
  filterVisible ? {
8511
8515
  "label": instance.t('frontend_button_search_tooltip'),
@@ -10345,12 +10349,35 @@ async function convertSFieldToAmisField(field, readonly, ctx) {
10345
10349
  }
10346
10350
  }
10347
10351
 
10352
+ const coordinatesType = field.coordinatesType || "bd09";
10348
10353
  convertData = {
10349
10354
  type: getAmisStaticFieldType('location', readonly),
10350
10355
  tpl: readonly ? getLocationTpl(field) : null,
10351
10356
  ak,
10352
10357
  vendor,
10353
- label: field.label
10358
+ clearable: true,
10359
+ coordinatesType,
10360
+ label: field.label,
10361
+ pipeOut: (value, oldValue, data) => {
10362
+ if (value) {
10363
+ const lng = value.lng;
10364
+ const lat = value.lat;
10365
+ let coordinates = [lng,lat];
10366
+ if(window.coordtransform){
10367
+ if(coordinatesType.toLowerCase() === 'bd09'){
10368
+ const bd09togcj02 = window.coordtransform.bd09togcj02(lng,lat);
10369
+ coordinates = window.coordtransform.gcj02towgs84(bd09togcj02[0],bd09togcj02[1]);
10370
+ }else if(coordinatesType.toLowerCase() === 'gcj02'){
10371
+ coordinates = window.coordtransform.gcj02towgs84(lng,lat);
10372
+ }
10373
+ }
10374
+ value.wgs84 = {
10375
+ type: "Point",
10376
+ coordinates
10377
+ };
10378
+ return value; // 切换到数字之后的默认值
10379
+ }
10380
+ }
10354
10381
  };
10355
10382
  break;
10356
10383
  case 'avatar':
@@ -10818,6 +10845,10 @@ async function getQuickEditSchema(field, options){
10818
10845
  if(field.type == "file" && field.multiple){
10819
10846
  quickEditSchema = false;
10820
10847
  }
10848
+ //TODO:location字段在列表中快速编辑后存在bug,保存时可能会丢失部分数据,暂时禁用
10849
+ if(field.type == "location"){
10850
+ quickEditSchema = false;
10851
+ }
10821
10852
  }
10822
10853
  return quickEditSchema;
10823
10854
  }
@@ -11372,7 +11403,7 @@ async function getTableApi(mainObject, fields, options){
11372
11403
  try{
11373
11404
  // TODO: 不应该直接在这里取localStorage,应该从外面传入
11374
11405
  const listViewId = api.data.listViewId;
11375
- const listViewPropsStoreKey = location.pathname + "/crud/" + listViewId ;
11406
+ const listViewPropsStoreKey = location.pathname + "/crud/" + (listViewId || "");
11376
11407
  let localListViewProps = sessionStorage.getItem(listViewPropsStoreKey);
11377
11408
  if(localListViewProps){
11378
11409
  localListViewProps = JSON.parse(localListViewProps);
@@ -11573,7 +11604,7 @@ async function getTableApi(mainObject, fields, options){
11573
11604
  try{
11574
11605
  // TODO: 不应该直接在这里取localStorage,应该从外面传入
11575
11606
  const listViewId = api.body.listViewId;
11576
- const listViewPropsStoreKey = location.pathname + "/crud/" + listViewId ;
11607
+ const listViewPropsStoreKey = location.pathname + "/crud/" + (listViewId || "");
11577
11608
  /**
11578
11609
  * localListViewProps规范来自crud请求api中api.data.$self参数值的。
11579
11610
  * 比如:{"perPage":20,"page":1,"__searchable__name":"7","__searchable__between__n1__c":[null,null],"filter":[["name","contains","a"]]}
@@ -13541,8 +13572,8 @@ async function getRelatedListSchema(
13541
13572
  /*
13542
13573
  * @Author: baozhoutao@steedos.com
13543
13574
  * @Date: 2022-07-05 15:55:39
13544
- * @LastEditors: baozhoutao@steedos.com
13545
- * @LastEditTime: 2023-07-29 13:58:07
13575
+ * @LastEditors: 殷亮辉 yinlianghui@hotoa.com
13576
+ * @LastEditTime: 2023-08-01 14:50:23
13546
13577
  * @Description:
13547
13578
  */
13548
13579
 
@@ -13807,7 +13838,7 @@ async function getListSchema(
13807
13838
  * 本次存储代码段
13808
13839
  */
13809
13840
  try {
13810
- const listViewPropsStoreKey = location.pathname + "/crud/" + ctx.listViewId;
13841
+ const listViewPropsStoreKey = location.pathname + "/crud/" + (ctx.listViewId || "");
13811
13842
  let localListViewProps = sessionStorage.getItem(listViewPropsStoreKey);
13812
13843
  /**
13813
13844
  * localListViewProps规范来自crud请求api中api.data.$self参数值的。
@@ -19249,46 +19280,153 @@ var AmisSteedosField = function (props) { return __awaiter(void 0, void 0, void
19249
19280
  * @Author: baozhoutao@steedos.com
19250
19281
  * @Date: 2023-01-14 16:41:24
19251
19282
  * @LastEditors: baozhoutao@steedos.com
19252
- * @LastEditTime: 2023-04-21 11:50:26
19283
+ * @LastEditTime: 2023-07-31 10:22:56
19253
19284
  * @Description:
19254
19285
  */
19255
19286
  var getSelectFlowSchema = function (id, props) {
19256
- var label = props.label, data = props.data, name = props.name, required = props.required, _a = props.action, action = _a === void 0 ? 'query' : _a, _b = props.distributeInstanceId, distributeInstanceId = _b === void 0 ? "" : _b, _c = props.distributeStepId, distributeStepId = _c === void 0 ? "" : _c, _d = props.mode, mode = _d === void 0 ? 'input-tree' : _d, className = props.className, onEvent = props.onEvent, _e = props.multiple, multiple = _e === void 0 ? false : _e, delimiter = props.delimiter, joinValues = props.joinValues, extractValue = props.extractValue, searchable = props.searchable, _f = props.showIcon, showIcon = _f === void 0 ? true : _f, _g = props.showRadio, showRadio = _g === void 0 ? false : _g, showOutline = props.showOutline, initiallyOpen = props.initiallyOpen, unfoldedLevel = props.unfoldedLevel, treeContainerClassName = props.treeContainerClassName, _h = props.amis, amis = _h === void 0 ? {} : _h;
19257
- console.log("=====onEvent", onEvent);
19258
- return __assign$2({ "type": mode, "id": id, "label": label, "name": name, "options": [], "multiple": multiple, "delimiter": delimiter, "joinValues": joinValues, "extractValue": extractValue, "searchable": searchable, "showOutline": showOutline, "initiallyOpen": initiallyOpen, "unfoldedLevel": unfoldedLevel, "className": className, "required": required, "treeContainerClassName": treeContainerClassName, "heightAuto": true,
19259
- // "menuTpl": {
19260
- // // type: "button",
19261
- // type: "tpl",
19262
- // tpl: "<div class='flex justify-between'><span>${label}</span><span class='rounded p-1 text-xs text-center w-14 ${children != null ? \'hidden\' : \'\'}'><button><i class='fa-regular fa-star'></i></button></span></div>",
19263
- // "onEvent": {
19264
- // "click": {
19265
- // "weight": 0,
19266
- // "actions": [
19267
- // {
19268
- // actionType: 'custom',
19269
- // script: "console.log('====event', event), event.preventDefault(); event.stopPropagation()"
19270
- // },
19271
- // {
19272
- // "args": {
19273
- // "api": {
19274
- // "url": "/aaa",
19275
- // "method": "get",
19276
- // "messages": {
19277
- // }
19278
- // }
19279
- // },
19280
- // "actionType": "download",
19281
- // "stopPropagation": true
19282
- // }
19283
- // ]
19284
- // }
19285
- // }
19286
- // },
19287
- "source": {
19288
- "method": "post",
19289
- "url": "${context.rootUrl}/graphql?keywords=${keywords}",
19290
- "requestAdaptor": "\n const keywords = api.body.keywords || '';\n const appId = '".concat(data.app_id || '', "';\n api.data = {\n query: `\n {\n options: flows__getList(action: \"").concat(action, "\", keywords: \"${keywords}\", appId: \"${appId}\", distributeInstanceId: \"").concat(distributeInstanceId, "\", distributeStepId: \"").concat(distributeStepId, "\"){\n value:_id\n label:name\n children: flows{\n value: _id,\n label: name\n }\n }\n }\n `\n }\n "),
19291
- "adaptor": "\n payload.data.options?.forEach(function(item,index) {\n if(!item.children || item.children.length == 0){\n payload.data.options.splice(index,1)\n }\n })\n return payload;\n ",
19287
+ var label = props.label, data = props.data, name = props.name, required = props.required, _a = props.action, action = _a === void 0 ? "query" : _a, _b = props.distributeInstanceId, distributeInstanceId = _b === void 0 ? "" : _b, _c = props.distributeStepId, distributeStepId = _c === void 0 ? "" : _c, _d = props.mode, mode = _d === void 0 ? "input-tree" : _d, className = props.className, onEvent = props.onEvent, _e = props.multiple, multiple = _e === void 0 ? false : _e, delimiter = props.delimiter, joinValues = props.joinValues, extractValue = props.extractValue, searchable = props.searchable, _f = props.showIcon, showIcon = _f === void 0 ? true : _f, _g = props.showRadio, showRadio = _g === void 0 ? false : _g, showOutline = props.showOutline, initiallyOpen = props.initiallyOpen, unfoldedLevel = props.unfoldedLevel, treeContainerClassName = props.treeContainerClassName, _h = props.amis, amis = _h === void 0 ? {} : _h;
19288
+ // console.log(`=====onEvent`, onEvent)
19289
+ return __assign$2({ type: mode, id: id, label: label, name: name, options: [], multiple: multiple, delimiter: delimiter, joinValues: joinValues, extractValue: extractValue, searchable: searchable, showOutline: showOutline, initiallyOpen: initiallyOpen, unfoldedLevel: unfoldedLevel, className: "overflow-y-auto " + className, required: required, treeContainerClassName: treeContainerClassName, heightAuto: true, menuTpl: mode === 'input-tree' ? {
19290
+ type: "tpl",
19291
+ tpl: "<div class='flex'><span>${label}</span><span class='rounded p-1 text-xs text-center w-14 ${value == 'startFlows' ? '' : 'hidden'}'><button class='antd-Button antd-Button--link m-none p-none'>设置</button></span></div>",
19292
+ onEvent: {
19293
+ click: {
19294
+ weight: 0,
19295
+ actions: [
19296
+ {
19297
+ actionType: "dialog",
19298
+ dialog: {
19299
+ type: "dialog",
19300
+ size: "lg",
19301
+ title: {
19302
+ type: "tpl",
19303
+ id: "u:0bce3c33b6e5",
19304
+ tpl: '<p>设置星标流程</p>',
19305
+ },
19306
+ body: [
19307
+ {
19308
+ type: "form",
19309
+ title: "表单",
19310
+ debug: false,
19311
+ body: [
19312
+ {
19313
+ type: "steedos-field",
19314
+ name: "startFlows",
19315
+ field: {
19316
+ name: "startFlows",
19317
+ type: 'lookup',
19318
+ label: "流程名称",
19319
+ required: true,
19320
+ reference_to: 'flows',
19321
+ multiple: true,
19322
+ },
19323
+ // type: "steedos-select-flow",
19324
+ // label: "流程名称",
19325
+ // name: "startFlows",
19326
+ // id: "startFlows",
19327
+ // multiple: true,
19328
+ // mode: "tree-select",
19329
+ // required: true,
19330
+ // options: [],
19331
+ // searchable: true,
19332
+ // amis: {
19333
+ // autoFill: {
19334
+ // users: [],
19335
+ // },
19336
+ // },
19337
+ // onlyLeaf: true
19338
+ }
19339
+ ],
19340
+ id: "u:742f9c0dc8a1",
19341
+ mode: "normal",
19342
+ initApi: {
19343
+ url: "${context.rootUrl}/api/steedos_keyvalues/startFlows",
19344
+ method: "get",
19345
+ dataType: "json",
19346
+ headers: {
19347
+ Authorization: "Bearer ${context.tenantId},${context.authToken}",
19348
+ },
19349
+ },
19350
+ api: {
19351
+ url: "${context.rootUrl}/api/steedos_keyvalues/startFlows",
19352
+ method: "post",
19353
+ dataType: "json",
19354
+ data: {
19355
+ "startFlows": "${startFlows}",
19356
+ },
19357
+ headers: {
19358
+ Authorization: "Bearer ${context.tenantId},${context.authToken}",
19359
+ },
19360
+ messages: {
19361
+ success: "设置成功!",
19362
+ failed: "设置失败",
19363
+ },
19364
+ },
19365
+ onEvent: {
19366
+ submitSucc: {
19367
+ actions: [
19368
+ {
19369
+ componentId: "",
19370
+ args: {},
19371
+ actionType: "closeDialog",
19372
+ },
19373
+ ],
19374
+ }
19375
+ },
19376
+ },
19377
+ ],
19378
+ id: "u:519ca64b1934",
19379
+ actions: [
19380
+ {
19381
+ type: "button",
19382
+ label: "取消",
19383
+ onEvent: {
19384
+ click: {
19385
+ actions: [
19386
+ {
19387
+ componentId: "",
19388
+ args: {},
19389
+ actionType: "closeDialog",
19390
+ },
19391
+ ],
19392
+ },
19393
+ },
19394
+ id: "u:1d0d136fe2f0",
19395
+ },
19396
+ {
19397
+ type: "button",
19398
+ label: "确定",
19399
+ onEvent: {
19400
+ click: {
19401
+ actions: [
19402
+ {
19403
+ args: {},
19404
+ actionType: "validate",
19405
+ componentId: "u:742f9c0dc8a1",
19406
+ },
19407
+ {
19408
+ componentId: "u:742f9c0dc8a1",
19409
+ args: {},
19410
+ actionType: "submit",
19411
+ },
19412
+ ],
19413
+ },
19414
+ },
19415
+ id: "u:f7f767bed23f",
19416
+ level: "primary",
19417
+ },
19418
+ ],
19419
+ },
19420
+ expression: "${event.data.value === 'startFlows' ? true : false}",
19421
+ },
19422
+ ],
19423
+ },
19424
+ },
19425
+ } : '', source: {
19426
+ method: "post",
19427
+ url: "${context.rootUrl}/graphql?keywords=${keywords}",
19428
+ requestAdaptor: "\n const keywords = api.body.keywords || '';\n const appId = '".concat(data.app_id || "", "';\n api.data = {\n query: `\n {\n options: flows__getList(action: \"").concat(action, "\", keywords: \"${keywords}\", appId: \"${appId}\", distributeInstanceId: \"").concat(distributeInstanceId, "\", distributeStepId: \"").concat(distributeStepId, "\"){\n value:_id\n label:name\n children: flows{\n value: _id,\n label: name\n }\n }\n }\n `\n }\n "),
19429
+ adaptor: "\n payload.data.options?.forEach(function(item,index) {\n if(item.value != 'startFlows' && (!item.children || item.children.length == 0)){\n payload.data.options.splice(index,1)\n }\n })\n return payload;\n ",
19292
19430
  "headers": {
19293
19431
  "Authorization": "Bearer ${context.tenantId},${context.authToken}"
19294
19432
  }
@@ -19303,45 +19441,45 @@ var getSelectFlowSchema = function (id, props) {
19303
19441
  */
19304
19442
  var AmisSelectFlow = function (props) {
19305
19443
  //mode: "input-tree" | "tree-select"
19306
- var _a = props.mode, mode = _a === void 0 ? 'input-tree' : _a, _b = props.id, id = _b === void 0 ? 'selectFlow' + ___default.random(10000, 99999) : _b;
19444
+ var _a = props.mode, mode = _a === void 0 ? "input-tree" : _a, _b = props.id, id = _b === void 0 ? "selectFlow" + ___default.random(10000, 99999) : _b;
19307
19445
  console.log("AmisSelectFlow props", props);
19308
19446
  var inputId = "".concat(id, "_input");
19309
19447
  var flowSchema = getSelectFlowSchema(inputId, props);
19310
- if (mode === 'tree-select') {
19448
+ if (mode === "tree-select") {
19311
19449
  return flowSchema;
19312
19450
  }
19313
19451
  return {
19314
- "type": "service",
19315
- "id": "selectFlowService",
19316
- "className": "steedos-select-flow-service",
19317
- "body": [
19452
+ type: "service",
19453
+ id: "selectFlowService",
19454
+ className: "steedos-select-flow-service",
19455
+ body: [
19318
19456
  {
19319
- "type": "search-box",
19320
- "className": "!w-full mb-2",
19321
- "name": "keywords",
19322
- "enhance": true,
19323
- "onEvent": {
19324
- "search": {
19325
- "actions": [
19457
+ type: "search-box",
19458
+ className: "!w-full mb-2",
19459
+ name: "keywords",
19460
+ enhance: true,
19461
+ onEvent: {
19462
+ search: {
19463
+ actions: [
19326
19464
  {
19327
- "actionType": "setValue",
19328
- "componentId": "selectFlowService",
19329
- "args": {
19330
- "value": {
19331
- "keywords": "${event.data.keywords}",
19332
- }
19333
- }
19465
+ actionType: "setValue",
19466
+ componentId: "selectFlowService",
19467
+ args: {
19468
+ value: {
19469
+ keywords: "${event.data.keywords}",
19470
+ },
19471
+ },
19334
19472
  },
19335
19473
  {
19336
- "componentId": inputId,
19337
- "actionType": "reload"
19338
- }
19339
- ]
19340
- }
19341
- }
19474
+ componentId: inputId,
19475
+ actionType: "reload",
19476
+ },
19477
+ ],
19478
+ },
19479
+ },
19342
19480
  },
19343
- flowSchema
19344
- ]
19481
+ flowSchema,
19482
+ ],
19345
19483
  };
19346
19484
  };
19347
19485