@steedos-widgets/amis-object 1.2.26 → 1.2.27

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.
@@ -1213,7 +1213,10 @@ body {
1213
1213
  height: 50px;
1214
1214
  }
1215
1215
 
1216
- .select_left .antd-Select-popover {
1216
+ .lookup-left {
1217
+ max-width: 50% !important;
1218
+ }
1219
+ .lookup-left .antd-Select-popover {
1217
1220
  width: auto !important;
1218
1221
  }
1219
1222
 
@@ -108,18 +108,6 @@ function __generator(thisArg, body) {
108
108
  }
109
109
  }
110
110
 
111
- function __values(o) {
112
- var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
113
- if (m) return m.call(o);
114
- if (o && typeof o.length === "number") return {
115
- next: function () {
116
- if (o && i >= o.length) o = void 0;
117
- return { value: o && o[i++], done: !o };
118
- }
119
- };
120
- throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
121
- }
122
-
123
111
  function __read(o, n) {
124
112
  var m = typeof Symbol === "function" && o[Symbol.iterator];
125
113
  if (!m) return o;
@@ -3828,6 +3816,10 @@ async function getFieldsTemplate(fields, expand){
3828
3816
  if(___default.includes(['percent','time','filesize','date','datetime','boolean','number','currency', 'select', 'file', 'image', 'avatar', 'formula', 'summary', 'object', 'grid'], field.type)){
3829
3817
  displayFields.push(`${field.name}`);
3830
3818
  }
3819
+ }else {
3820
+ objectFieldName = field.name.split('.')[0];
3821
+ fieldsName.push(objectFieldName);
3822
+ displayFields.push(objectFieldName);
3831
3823
  }
3832
3824
  }
3833
3825
 
@@ -11103,6 +11095,7 @@ async function getTableApi(mainObject, fields, options){
11103
11095
  let valueField = mainObject.key_field || '_id';
11104
11096
  const api = await getApi(mainObject, null, fields, {count: options.queryCount, alias: 'rows', limit: top, queryOptions: `filters: {__filters}, top: {__top}, skip: {__skip}, sort: "{__sort}"`});
11105
11097
 
11098
+ api.url += "&objectName=${objectName}";//设计器上对象表格组件需要切换对象重新请求列表数据
11106
11099
  if(options.isRelated){
11107
11100
  api.url += "&recordId=${_master.recordId}";
11108
11101
  }
@@ -11432,12 +11425,18 @@ function getReadonlyFormAdaptor(object, fields, options){
11432
11425
  // }
11433
11426
  // })
11434
11427
 
11428
+ var fieldNames = ___default__namespace.map(fields, function(n){return n.name});
11435
11429
  return `
11436
11430
  if(payload.data.data.length === 0){
11437
11431
  var isEditor = !!${options && options.isEditor};
11438
11432
  if(isEditor){
11433
+ var fieldNames = ${JSON.stringify(fieldNames)};
11434
+ var emptyDoc = {};//这里如果不把每个字段值设置为空的话,表单上会显示上一次表单上的字段值
11435
+ fieldNames.forEach(function(n){
11436
+ emptyDoc[n] = null;
11437
+ });
11439
11438
  // 设计器中始终显示表单,有记录则显示第一条记录,没记录时显示为空表单
11440
- payload.data.data = [{}];
11439
+ payload.data.data = [emptyDoc];
11441
11440
  }
11442
11441
  else{
11443
11442
  return {
@@ -16779,85 +16778,71 @@ var index_esm$1 = /*#__PURE__*/Object.freeze({
16779
16778
  });
16780
16779
 
16781
16780
  var getSchema = function (field, value, ctx) { return __awaiter(void 0, void 0, void 0, function () {
16782
- var refTo, leftName, options, refTo_1, refTo_1_1, item, refObject_1, e_1_1, refObject, rightSchema;
16783
- var e_1, _a;
16784
- return __generator(this, function (_b) {
16785
- switch (_b.label) {
16781
+ var refTo, leftName, refObject, rightSchema;
16782
+ return __generator(this, function (_a) {
16783
+ switch (_a.label) {
16786
16784
  case 0:
16787
16785
  refTo = field.reference_to;
16788
16786
  if (refTo && ___default.isFunction(refTo)) {
16789
16787
  refTo = refTo();
16790
16788
  }
16791
16789
  leftName = "".concat(field.name, "__left");
16792
- options = [];
16793
- _b.label = 1;
16794
- case 1:
16795
- _b.trys.push([1, 6, 7, 8]);
16796
- refTo_1 = __values(refTo), refTo_1_1 = refTo_1.next();
16797
- _b.label = 2;
16798
- case 2:
16799
- if (!!refTo_1_1.done) return [3 /*break*/, 5];
16800
- item = refTo_1_1.value;
16801
- return [4 /*yield*/, getUISchema(item, false)];
16802
- case 3:
16803
- refObject_1 = _b.sent();
16804
- options.push({
16805
- label: refObject_1.label,
16806
- value: item,
16807
- icon: refObject_1.icon
16808
- });
16809
- _b.label = 4;
16810
- case 4:
16811
- refTo_1_1 = refTo_1.next();
16812
- return [3 /*break*/, 2];
16813
- case 5: return [3 /*break*/, 8];
16814
- case 6:
16815
- e_1_1 = _b.sent();
16816
- e_1 = { error: e_1_1 };
16817
- return [3 /*break*/, 8];
16818
- case 7:
16819
- try {
16820
- if (refTo_1_1 && !refTo_1_1.done && (_a = refTo_1.return)) _a.call(refTo_1);
16821
- }
16822
- finally { if (e_1) throw e_1.error; }
16823
- return [7 /*endfinally*/];
16824
- case 8:
16790
+ // const options = [];
16791
+ // for (const item of refTo) {
16792
+ // const refObject = await getUISchema(item, false);
16793
+ // options.push({
16794
+ // label: refObject.label,
16795
+ // value: item,
16796
+ // icon: refObject.icon
16797
+ // });
16798
+ // }
16825
16799
  // console.log(`getSchema refTo`, refTo);
16826
16800
  // console.log(`getSchema options`, options);
16827
16801
  // console.log(`getSchema value=========>`, value);
16828
16802
  if (!value || !value.o) {
16829
16803
  value = {
16830
- o: options[0].value,
16804
+ o: refTo[0],
16831
16805
  ids: []
16832
16806
  };
16833
16807
  }
16834
16808
  return [4 /*yield*/, getUISchema(value.o, false)];
16835
- case 9:
16836
- refObject = _b.sent();
16809
+ case 1:
16810
+ refObject = _a.sent();
16837
16811
  rightSchema = null;
16838
- if (!(refObject.enable_enhanced_lookup == true)) return [3 /*break*/, 11];
16812
+ if (!(refObject.enable_enhanced_lookup == true)) return [3 /*break*/, 3];
16839
16813
  return [4 /*yield*/, lookupToAmisPicker(Object.assign({}, field, { reference_to: value.o }), false, ctx)];
16840
- case 10:
16841
- rightSchema = _b.sent();
16842
- return [3 /*break*/, 13];
16843
- case 11:
16814
+ case 2:
16815
+ rightSchema = _a.sent();
16816
+ return [3 /*break*/, 5];
16817
+ case 3:
16844
16818
  if (!ctx) {
16845
16819
  ctx = {};
16846
16820
  }
16847
16821
  ctx.isRefToMutiple = ___default.isArray(refTo);
16848
16822
  return [4 /*yield*/, lookupToAmisSelect(Object.assign({}, field, { reference_to: value.o }), false, ctx)];
16849
- case 12:
16850
- rightSchema = _b.sent();
16851
- _b.label = 13;
16852
- case 13: return [2 /*return*/, {
16823
+ case 4:
16824
+ rightSchema = _a.sent();
16825
+ _a.label = 5;
16826
+ case 5: return [2 /*return*/, {
16853
16827
  "type": "input-group",
16854
16828
  "label": false,
16855
16829
  "body": [
16856
16830
  {
16857
16831
  "type": "select",
16858
- "inputClassName": "select_left",
16832
+ "inputClassName": "lookup-left",
16859
16833
  "name": leftName,
16860
- "options": options,
16834
+ // "options": options,
16835
+ "source": {
16836
+ "method": "post",
16837
+ "url": "${context.rootUrl}/graphql",
16838
+ "data": {
16839
+ "query": "{options:objects(filters: {__filters}, top: {__top}, sort: \"{__sort}\"){_id label:label value:name icon},count:objects__count(filters:{__filters})}"
16840
+ },
16841
+ "headers": {
16842
+ "Authorization": "Bearer ${context.tenantId},${context.authToken}"
16843
+ },
16844
+ "requestAdaptor": "\nvar filters = [\"name\",\"in\", ".concat(JSON.stringify(refTo), "]; \nvar top = ").concat(JSON.stringify(refTo), ".length;\n\nvar sort = \"\";\napi.data.query = api.data.query.replace(/{__filters}/g, JSON.stringify(filters)).replace('{__top}', top).replace('{__sort}', sort.trim());\nreturn api;"),
16845
+ },
16861
16846
  "value": "".concat(value.o)
16862
16847
  },
16863
16848
  Object.assign({}, rightSchema, {
@@ -17402,7 +17387,8 @@ var AmisObjectListView = function (props) { return __awaiter(void 0, void 0, voi
17402
17387
  {
17403
17388
  "type": "service",
17404
17389
  "schemaApi": {
17405
- "url": "${context.rootUrl}/graphql?listName=${listName}&display=${display}",
17390
+ // 这里url上加objectApiName属性是因为设计器中切换对象时不会变更列表视图界面,不可以用objectName=${objectName}使用作用域中objectName变量是因为设计器那边不会监听识别data变化来render组件
17391
+ "url": "${context.rootUrl}/graphql?objectName=" + objectApiName + "&listName=${listName}&display=${display}",
17406
17392
  "method": "post",
17407
17393
  "messages": {},
17408
17394
  "headers": {
@@ -17496,7 +17482,11 @@ var AmisObjectTable = function (props) { return __awaiter(void 0, void 0, void 0
17496
17482
  case 1:
17497
17483
  amisSchema = (_d.sent()).amisSchema;
17498
17484
  amisSchema.data = Object.assign({}, amisSchema.data, amisSchemaData);
17485
+ if (___default.has(props, 'objectApiName')) {
17486
+ amisSchema.data.objectName = objectApiName;
17487
+ }
17499
17488
  amisSchema.className = "steedos-object-table h-full flex flex-col ".concat(className);
17489
+ amisSchema.objectApiName = objectApiName; //设计器中切换对象时画布中显示的列未同步变更
17500
17490
  // console.log(`AmisObjectTable===>amisSchema`, amisSchema)
17501
17491
  // console.timeEnd('AmisObjectTable')
17502
17492
  return [2 /*return*/, amisSchema];