@steedos-widgets/amis-object 3.6.4-beta.2 → 3.6.4-beta.3

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.
@@ -13853,7 +13853,22 @@ async function getSelectUserSchema(field, readonly, ctx) {
13853
13853
  async function getSource(field, ctx) {
13854
13854
  // data.query 最终格式 "{ \tleftOptions:organizations(filters: {__filters}){value:_id,label:name,children}, children:organizations(filters: {__filters}){ref:_id,children}, defaultValueOptions:space_users(filters: {__options_filters}){user,name} }"
13855
13855
  const refObjectName = ctx.objectName;
13856
- const data = await getFindQuery({ name: refObjectName }, null, [{ name: ctx.valueField, alias: "value" }, { name: ctx.labelField, alias: "label" }, { name: "children" }], {
13856
+ let optionQueryFields = [{ name: ctx.valueField, alias: "value" }, { name: ctx.labelField, alias: "label" }, { name: "children" }];
13857
+ let defaultOptionQueryFields = optionQueryFields.filter(function (f) { return f.name !== "children" });
13858
+
13859
+ // 把自动填充规则中依赖的字段也加到api请求中
13860
+ let autoFillMapping = !field.multiple && field.auto_fill_mapping;
13861
+ if (autoFillMapping && autoFillMapping.length) {
13862
+ autoFillMapping.forEach(function (item) {
13863
+ if(item.from !== "children"){
13864
+ optionQueryFields.push({ name: item.from });
13865
+ }
13866
+ defaultOptionQueryFields.push({ name: item.from });
13867
+ });
13868
+ }
13869
+
13870
+ const data = await getFindQuery({ name: refObjectName }, null, optionQueryFields, {
13871
+ expand: false,
13857
13872
  alias: "options",
13858
13873
  filters: "{__filters}"
13859
13874
  });
@@ -13864,7 +13879,8 @@ async function getSource(field, ctx) {
13864
13879
  // });
13865
13880
  // childrenData.query = childrenData.query.replace(/,count\:.+/, "}");
13866
13881
  // data.query = data.query.replace(/}$/, "," + childrenData.query.replace(/{(.+)}/, "$1}"));
13867
- const defaultValueOptionsData = await getFindQuery({ name: refObjectName }, null, [{ name: ctx.valueField, alias: "value" }, { name: ctx.labelField, alias: "label" }], {
13882
+ const defaultValueOptionsData = await getFindQuery({ name: refObjectName }, null, defaultOptionQueryFields, {
13883
+ expand: false,
13868
13884
  alias: "defaultValueOptions",
13869
13885
  filters: "{__options_filters}"
13870
13886
  });
@@ -13931,7 +13947,20 @@ async function getSource(field, ctx) {
13931
13947
  async function getDeferApi(field, ctx) {
13932
13948
  // data.query 最终格式 "{ \toptions:{__object_name}(filters:{__filters}){{__fields}} }"
13933
13949
  const refObjectName = ctx.objectName;
13934
- const data = await getFindQuery({ name: "{__object_name}" }, null, [], {
13950
+ let optionQueryFields = [{ name: ctx.valueField, alias: "value" }, { name: ctx.labelField, alias: "label" }, { name: "children" }];
13951
+
13952
+ // 把自动填充规则中依赖的字段也加到api请求中
13953
+ let autoFillMapping = !field.multiple && field.auto_fill_mapping;
13954
+ if (autoFillMapping && autoFillMapping.length) {
13955
+ autoFillMapping.forEach(function (item) {
13956
+ if(item.from !== "children"){
13957
+ optionQueryFields.push({ name: item.from });
13958
+ }
13959
+ });
13960
+ }
13961
+
13962
+ const data = await getFindQuery({ name: "{__object_name}" }, null, optionQueryFields, {
13963
+ expand: false,
13935
13964
  alias: "options",
13936
13965
  // filters: "{__filters}",
13937
13966
  queryOptions: `filters: {__filters}, sort: "{__sort}"`
@@ -13946,8 +13975,6 @@ async function getDeferApi(field, ctx) {
13946
13975
  filters = filters(field);
13947
13976
  }
13948
13977
  data.query = data.query.replace(/,count\:.+/, "}");
13949
- // 字段要根据请求参数动态生成,写死为__fields后续在发送适配器中替换
13950
- data.query = data.query.replace("{_id}", "{{__fields}}");
13951
13978
  const requestAdaptor = `
13952
13979
  var dep = api.query.dep;
13953
13980
  var term = api.query.term;
@@ -13957,11 +13984,10 @@ async function getDeferApi(field, ctx) {
13957
13984
  var sort = "";
13958
13985
  if (dep) {
13959
13986
  objectName = "${refObjectName}";
13960
- fields = "_id,value:${ctx.valueField},label:${ctx.labelField},children";
13961
13987
  filters = [['parent', '=', dep]];
13962
13988
  sort = "${ctx.sort}";
13963
13989
  }
13964
- api.data.query = api.data.query.replace(/{__object_name}/g, objectName).replace(/{__fields}/g, fields).replace(/{__filters}/g, JSON.stringify(filters)).replace('{__sort}', sort.trim());
13990
+ api.data.query = api.data.query.replace(/{__object_name}/g, objectName).replace(/{__filters}/g, JSON.stringify(filters)).replace('{__sort}', sort.trim());
13965
13991
  return api;
13966
13992
  `;
13967
13993
  const adaptor = `
@@ -14315,6 +14341,18 @@ async function lookupToAmisPicker(field, readonly, ctx){
14315
14341
  }
14316
14342
  });
14317
14343
 
14344
+ // 把自动填充规则中依赖的字段也加到api请求中
14345
+ let autoFillMapping = !field.multiple && field.auto_fill_mapping;
14346
+ if (autoFillMapping && autoFillMapping.length) {
14347
+ autoFillMapping.forEach(function (item) {
14348
+ if(!_$1__namespace.find(tableFields, function(f){
14349
+ return f.name === item.from
14350
+ })){
14351
+ tableFields.push(refObjectConfig.fields[item.from]);
14352
+ }
14353
+ });
14354
+ }
14355
+
14318
14356
  _$1__namespace.each(refObjectConfig.fields, function (field) {
14319
14357
  if(isFieldQuickSearchable(field, refObjectConfig.NAME_FIELD_KEY)){
14320
14358
  searchableFields.push(field.name);
@@ -14746,22 +14784,31 @@ async function lookupToAmisSelect(field, readonly, ctx){
14746
14784
 
14747
14785
  let apiInfo;
14748
14786
  let defaultValueOptionsQueryData;
14787
+ const refObjectConfig = referenceTo && await getUISchema(referenceTo.objectName);
14749
14788
  if(referenceTo){
14750
- // 字段值单独走一个请求合并到source的同一个GraphQL接口中
14751
- defaultValueOptionsQueryData = await getFindQuery({ name: referenceTo.objectName }, null, [
14789
+ let queryFields = [
14752
14790
  Object.assign({}, referenceTo.labelField, {alias: 'label'}),
14753
14791
  Object.assign({}, referenceTo.valueField, {alias: 'value'})
14754
- ], {
14792
+ ];
14793
+
14794
+ // 把自动填充规则中依赖的字段也加到api请求中
14795
+ let autoFillMapping = !field.multiple && field.auto_fill_mapping;
14796
+ if (autoFillMapping && autoFillMapping.length) {
14797
+ autoFillMapping.forEach(function (item) {
14798
+ queryFields.push(refObjectConfig.fields[item.from]);
14799
+ });
14800
+ }
14801
+
14802
+ // 字段值单独走一个请求合并到source的同一个GraphQL接口中
14803
+ defaultValueOptionsQueryData = await getFindQuery({ name: referenceTo.objectName }, null, queryFields, {
14804
+ expand: false,
14755
14805
  alias: "defaultValueOptions",
14756
14806
  filters: "{__options_filters}",
14757
14807
  count: false
14758
14808
  });
14759
14809
  apiInfo = await getApi({
14760
14810
  name: referenceTo.objectName
14761
- }, null, [
14762
- Object.assign({}, referenceTo.labelField, {alias: 'label'}),
14763
- Object.assign({}, referenceTo.valueField, {alias: 'value'})
14764
- ], {expand: false, alias: 'options', queryOptions: `filters: {__filters}, top: {__top}, sort: "{__sort}"`});
14811
+ }, null, queryFields, {expand: false, alias: 'options', queryOptions: `filters: {__filters}, top: {__top}, sort: "{__sort}"`});
14765
14812
 
14766
14813
  apiInfo.adaptor = `
14767
14814
  const data = payload.data;
@@ -14785,7 +14832,6 @@ async function lookupToAmisSelect(field, readonly, ctx){
14785
14832
  };
14786
14833
  }
14787
14834
 
14788
- const refObjectConfig = referenceTo && await getUISchema(referenceTo.objectName);
14789
14835
  let listView = getLookupListView(refObjectConfig);
14790
14836
 
14791
14837
  let listviewFilter = getListViewFilter(listView);
@@ -14971,13 +15017,13 @@ async function getApi(object, recordId, fields, options){
14971
15017
  }
14972
15018
 
14973
15019
  async function getAutoFill(field, refObject) {
14974
- let autoFillMapping = field.auto_fill_mapping;
15020
+ let autoFillMapping = !field.multiple && field.auto_fill_mapping;
14975
15021
  if (autoFillMapping && autoFillMapping.length) {
14976
15022
  let fillMapping = {};
14977
- let fieldsForApi = [];
15023
+ // let fieldsForApi = [];
14978
15024
  autoFillMapping.forEach(function (item) {
14979
15025
  fillMapping[item.to] = `\${${item.from}}`;
14980
- fieldsForApi.push(item.from);
15026
+ // fieldsForApi.push(item.from);
14981
15027
  });
14982
15028
  // let api = {
14983
15029
  // // "url": "/amis/api/mock2/form/autoUpdate?browser=${browser}&version=${version}",
@@ -17312,6 +17358,7 @@ async function getForm(props, mode = "edit", formId) {
17312
17358
  async function getButtonActions(props, mode) {
17313
17359
  let actions = [];
17314
17360
  let primaryKey = getTablePrimaryKey(props);
17361
+ let tableServiceId = getComponentId("table_service", props.id);
17315
17362
  let formId = getComponentId("form", props.id);
17316
17363
  let dialogId = getComponentId("dialog", props.id);
17317
17364
  let buttonNextId = getComponentId("button_next", props.id);
@@ -17628,7 +17675,30 @@ async function getButtonActions(props, mode) {
17628
17675
  // };
17629
17676
  // 新增行时不需要在弹出编辑表单前先加一行,因为会在编辑表单所在service初始化时判断到是新增就自动增加一行,因为这里拿不到event.data.__tableItems,也无法变更其值
17630
17677
  // actions = [actionNewLine, actionShowEditDialog];
17631
- actions = [actionShowEditDialog];
17678
+ if (props.enableDialog === false) {
17679
+ actions = [
17680
+ {
17681
+ "actionType": "custom",
17682
+ "script": `
17683
+ let scope = event.context.scoped;
17684
+ let __wrapperServiceId = "${tableServiceId}";
17685
+ let wrapperService = scope.getComponentById(__wrapperServiceId);
17686
+ let wrapperServiceData = wrapperService.getData();
17687
+ let lastestFieldValue = _.clone(wrapperServiceData["${props.name}"] || []);
17688
+ lastestFieldValue.push({})
17689
+ doAction({
17690
+ "componentId": "${props.id}",
17691
+ "actionType": "setValue",
17692
+ "args": {
17693
+ "value": lastestFieldValue
17694
+ }
17695
+ });
17696
+ `
17697
+ }
17698
+ ];
17699
+ }else {
17700
+ actions = [actionShowEditDialog];
17701
+ }
17632
17702
  }
17633
17703
  else if (mode == "edit") {
17634
17704
  actions = [actionShowEditDialog];
@@ -17860,31 +17930,34 @@ const getAmisInputTableSchema = async (props) => {
17860
17930
  let inlineEditMode = props.inlineEditMode;
17861
17931
  let showAsInlineEditMode = inlineEditMode && props.editable;
17862
17932
  if (showOperation) {
17863
- if (props.editable) {
17864
- let showEditButton = true;
17865
- if (showAsInlineEditMode) {
17866
- // 始终显示弹出子表表单按钮,如果需要判断只在有列被隐藏时才需要显示弹出表单按钮放开下面的if逻辑就好
17867
- showEditButton = true;
17868
- // // inline edit模式下只在有列被隐藏时才需要显示编辑按钮
17869
- // if (props.columns && props.columns.length > 0 && props.columns.length < fields.length) {
17870
- // showEditButton = true;
17871
- // }
17872
- // else {
17873
- // showEditButton = false;
17874
- // }
17933
+ if (props.enableDialog !== false) {
17934
+ if (props.editable) {
17935
+ let showEditButton = true;
17936
+ if (showAsInlineEditMode) {
17937
+ // 始终显示弹出子表表单按钮,如果需要判断只在有列被隐藏时才需要显示弹出表单按钮放开下面的if逻辑就好
17938
+ showEditButton = true;
17939
+ // // inline edit模式下只在有列被隐藏时才需要显示编辑按钮
17940
+ // if (props.columns && props.columns.length > 0 && props.columns.length < fields.length) {
17941
+ // showEditButton = true;
17942
+ // }
17943
+ // else {
17944
+ // showEditButton = false;
17945
+ // }
17946
+ }
17947
+ // 编辑时显示编辑按钮
17948
+ if (showEditButton) {
17949
+ let buttonEditSchema = await getButtonEdit(props, showAsInlineEditMode);
17950
+ buttonsForColumnOperations.push(buttonEditSchema);
17951
+ }
17875
17952
  }
17876
- // 编辑时显示编辑按钮
17877
- if (showEditButton) {
17878
- let buttonEditSchema = await getButtonEdit(props, showAsInlineEditMode);
17879
- buttonsForColumnOperations.push(buttonEditSchema);
17953
+ else {
17954
+ // 只读时显示查看按钮
17955
+ // 如果想只在有列被隐藏时才需要显示查看按钮可以加上判断:if (props.columns && props.columns.length > 0 && props.columns.length < fields.length)
17956
+ let buttonViewSchema = await getButtonView(props);
17957
+ buttonsForColumnOperations.push(buttonViewSchema);
17880
17958
  }
17881
17959
  }
17882
- else {
17883
- // 只读时显示查看按钮
17884
- // 如果想只在有列被隐藏时才需要显示查看按钮可以加上判断:if (props.columns && props.columns.length > 0 && props.columns.length < fields.length)
17885
- let buttonViewSchema = await getButtonView(props);
17886
- buttonsForColumnOperations.push(buttonViewSchema);
17887
- }
17960
+
17888
17961
  if (props.removable) {
17889
17962
  let buttonDeleteSchema = await getButtonDelete(props);
17890
17963
  buttonsForColumnOperations.push(buttonDeleteSchema);
@@ -23949,13 +24022,16 @@ var AmisInputTable = function (props) { return __awaiter(void 0, void 0, void 0,
23949
24022
  return __generator(this, function (_a) {
23950
24023
  switch (_a.label) {
23951
24024
  case 0:
23952
- props.$schema, props.fields, props.name, props.id, props.data, props.columns, props.amis, props.className, props.tableClassName, props.headerToolbar, props.footerToolbar, props.inlineEditMode, props.strictMode, props.dialog, props.primaryKey, props.showOperation, props.fieldPrefix, props.autoGeneratePrimaryKeyValue, props.mode, props.disabledOn, props.disabled, props.visibleOn, props.visible, props.hiddenOn, props.hidden;
24025
+ props.$schema, props.fields, props.name, props.id, props.data, props.columns, props.amis, props.className, props.tableClassName, props.headerToolbar, props.footerToolbar, props.inlineEditMode, props.strictMode, props.dialog, props.primaryKey, props.showOperation, props.fieldPrefix, props.autoGeneratePrimaryKeyValue, props.mode, props.disabledOn, props.disabled, props.visibleOn, props.visible, props.hiddenOn, props.hidden, props.enableDialog;
23953
24026
  extendProps = {};
23954
24027
  if (props.disabledOn || props.disabled) {
23955
24028
  extendProps["addable"] = false;
23956
24029
  extendProps["editable"] = false;
23957
24030
  extendProps["removable"] = false;
23958
24031
  }
24032
+ if (props.enableDialog === false) {
24033
+ extendProps["inlineEditMode"] = true;
24034
+ }
23959
24035
  return [4 /*yield*/, getAmisInputTableSchema(Object.assign({}, props, extendProps))];
23960
24036
  case 1:
23961
24037
  amisSchema = _a.sent();