@steedos-widgets/sortable 3.6.4-beta.2 → 3.6.4-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.
@@ -54992,7 +54992,8 @@ instance
54992
54992
  }
54993
54993
  });
54994
54994
 
54995
- async function getQuickEditSchema(field, options){
54995
+ async function getQuickEditSchema(object, columnField, options){
54996
+ let field = object.fields[columnField.name];
54996
54997
  //判断在amis3.2以上环境下,放开批量编辑与lookup的单元格编辑
54997
54998
  let isAmisVersionforBatchEdit = false;
54998
54999
  if(window.amisRequire && window.amisRequire('amis')){
@@ -55460,7 +55461,7 @@ function getFieldWidth(width){
55460
55461
  }
55461
55462
  }
55462
55463
 
55463
- async function getTableColumns(fields, options){
55464
+ async function getTableColumns(object, fields, options){
55464
55465
  const columns = [];
55465
55466
  if(!options.isLookup && !options.isInputTable){
55466
55467
  if(!options.enable_tree){
@@ -55474,7 +55475,7 @@ async function getTableColumns(fields, options){
55474
55475
  continue;
55475
55476
  }
55476
55477
  //增加quickEdit属性,实现快速编辑
55477
- const quickEditSchema = allowEdit ? await getQuickEditSchema(field, options) : allowEdit;
55478
+ const quickEditSchema = allowEdit ? await getQuickEditSchema(object, field, options) : allowEdit;
55478
55479
  let className = "";
55479
55480
  const bowserType = getBowserType();
55480
55481
  if(bowserType === "Safari"){
@@ -56046,7 +56047,7 @@ async function getDefaultCrudCard(columns, options) {
56046
56047
  return card;
56047
56048
  }
56048
56049
 
56049
- async function getTableSchema$1(fields, options){
56050
+ async function getTableSchema$1(object, fields, options){
56050
56051
  if(!options){
56051
56052
  options = {};
56052
56053
  }
@@ -56068,7 +56069,7 @@ async function getTableSchema$1(fields, options){
56068
56069
  columns = await getMobileTableColumns(fields, options);
56069
56070
  }
56070
56071
  else {
56071
- columns = await getTableColumns(fields, options);
56072
+ columns = await getTableColumns(object, fields, options);
56072
56073
 
56073
56074
  if(listSchema.mode === "cards"){
56074
56075
  let card = listSchema.card;
@@ -58703,8 +58704,8 @@ async function getObjectFilter(objectSchema, fields, options) {
58703
58704
  /*
58704
58705
  * @Author: baozhoutao@steedos.com
58705
58706
  * @Date: 2022-07-05 15:55:39
58706
- * @LastEditors: baozhoutao@steedos.com
58707
- * @LastEditTime: 2024-02-18 16:05:21
58707
+ * @LastEditors: 殷亮辉 yinlianghui@hotoa.com
58708
+ * @LastEditTime: 2024-02-23 16:37:06
58708
58709
  * @Description:
58709
58710
  */
58710
58711
 
@@ -59026,7 +59027,22 @@ if(typeof window != 'undefined'){
59026
59027
  async function getSource(field, ctx) {
59027
59028
  // 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} }"
59028
59029
  const refObjectName = ctx.objectName;
59029
- const data = await getFindQuery({ name: refObjectName }, null, [{ name: ctx.valueField, alias: "value" }, { name: ctx.labelField, alias: "label" }, { name: "children" }], {
59030
+ let optionQueryFields = [{ name: ctx.valueField, alias: "value" }, { name: ctx.labelField, alias: "label" }, { name: "children" }];
59031
+ let defaultOptionQueryFields = optionQueryFields.filter(function (f) { return f.name !== "children" });
59032
+
59033
+ // 把自动填充规则中依赖的字段也加到api请求中
59034
+ let autoFillMapping = !field.multiple && field.auto_fill_mapping;
59035
+ if (autoFillMapping && autoFillMapping.length) {
59036
+ autoFillMapping.forEach(function (item) {
59037
+ if(item.from !== "children"){
59038
+ optionQueryFields.push({ name: item.from });
59039
+ }
59040
+ defaultOptionQueryFields.push({ name: item.from });
59041
+ });
59042
+ }
59043
+
59044
+ const data = await getFindQuery({ name: refObjectName }, null, optionQueryFields, {
59045
+ expand: false,
59030
59046
  alias: "options",
59031
59047
  filters: "{__filters}"
59032
59048
  });
@@ -59037,7 +59053,8 @@ async function getSource(field, ctx) {
59037
59053
  // });
59038
59054
  // childrenData.query = childrenData.query.replace(/,count\:.+/, "}");
59039
59055
  // data.query = data.query.replace(/}$/, "," + childrenData.query.replace(/{(.+)}/, "$1}"));
59040
- const defaultValueOptionsData = await getFindQuery({ name: refObjectName }, null, [{ name: ctx.valueField, alias: "value" }, { name: ctx.labelField, alias: "label" }], {
59056
+ const defaultValueOptionsData = await getFindQuery({ name: refObjectName }, null, defaultOptionQueryFields, {
59057
+ expand: false,
59041
59058
  alias: "defaultValueOptions",
59042
59059
  filters: "{__options_filters}"
59043
59060
  });
@@ -59104,7 +59121,20 @@ async function getSource(field, ctx) {
59104
59121
  async function getDeferApi(field, ctx) {
59105
59122
  // data.query 最终格式 "{ \toptions:{__object_name}(filters:{__filters}){{__fields}} }"
59106
59123
  const refObjectName = ctx.objectName;
59107
- const data = await getFindQuery({ name: "{__object_name}" }, null, [], {
59124
+ let optionQueryFields = [{ name: ctx.valueField, alias: "value" }, { name: ctx.labelField, alias: "label" }, { name: "children" }];
59125
+
59126
+ // 把自动填充规则中依赖的字段也加到api请求中
59127
+ let autoFillMapping = !field.multiple && field.auto_fill_mapping;
59128
+ if (autoFillMapping && autoFillMapping.length) {
59129
+ autoFillMapping.forEach(function (item) {
59130
+ if(item.from !== "children"){
59131
+ optionQueryFields.push({ name: item.from });
59132
+ }
59133
+ });
59134
+ }
59135
+
59136
+ const data = await getFindQuery({ name: "{__object_name}" }, null, optionQueryFields, {
59137
+ expand: false,
59108
59138
  alias: "options",
59109
59139
  // filters: "{__filters}",
59110
59140
  queryOptions: `filters: {__filters}, sort: "{__sort}"`
@@ -59119,8 +59149,6 @@ async function getDeferApi(field, ctx) {
59119
59149
  filters = filters(field);
59120
59150
  }
59121
59151
  data.query = data.query.replace(/,count\:.+/, "}");
59122
- // 字段要根据请求参数动态生成,写死为__fields后续在发送适配器中替换
59123
- data.query = data.query.replace("{_id}", "{{__fields}}");
59124
59152
  const requestAdaptor = `
59125
59153
  var dep = api.query.dep;
59126
59154
  var term = api.query.term;
@@ -59130,11 +59158,10 @@ async function getDeferApi(field, ctx) {
59130
59158
  var sort = "";
59131
59159
  if (dep) {
59132
59160
  objectName = "${refObjectName}";
59133
- fields = "_id,value:${ctx.valueField},label:${ctx.labelField},children";
59134
59161
  filters = [['parent', '=', dep]];
59135
59162
  sort = "${ctx.sort}";
59136
59163
  }
59137
- 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());
59164
+ api.data.query = api.data.query.replace(/{__object_name}/g, objectName).replace(/{__filters}/g, JSON.stringify(filters)).replace('{__sort}', sort.trim());
59138
59165
  return api;
59139
59166
  `;
59140
59167
  const adaptor = `
@@ -59488,6 +59515,18 @@ async function lookupToAmisPicker(field, readonly, ctx){
59488
59515
  }
59489
59516
  });
59490
59517
 
59518
+ // 把自动填充规则中依赖的字段也加到api请求中
59519
+ let autoFillMapping = !field.multiple && field.auto_fill_mapping;
59520
+ if (autoFillMapping && autoFillMapping.length) {
59521
+ autoFillMapping.forEach(function (item) {
59522
+ if(!lodash.exports.find(tableFields, function(f){
59523
+ return f.name === item.from
59524
+ })){
59525
+ tableFields.push(refObjectConfig.fields[item.from]);
59526
+ }
59527
+ });
59528
+ }
59529
+
59491
59530
  lodash.exports.each(refObjectConfig.fields, function (field) {
59492
59531
  if(isFieldQuickSearchable(field, refObjectConfig.NAME_FIELD_KEY)){
59493
59532
  searchableFields.push(field.name);
@@ -59744,7 +59783,7 @@ async function lookupToAmisPicker(field, readonly, ctx){
59744
59783
  if(refObjectConfig.name === 'organizations'){
59745
59784
  labelFieldName = 'name';
59746
59785
  }
59747
- pickerSchema = await getTableSchema$1(tableFields, {
59786
+ pickerSchema = await getTableSchema$1(refObjectConfig, tableFields, {
59748
59787
  labelFieldName,
59749
59788
  top: top,
59750
59789
  isLookup: true,
@@ -59919,22 +59958,31 @@ async function lookupToAmisSelect(field, readonly, ctx){
59919
59958
 
59920
59959
  let apiInfo;
59921
59960
  let defaultValueOptionsQueryData;
59961
+ const refObjectConfig = referenceTo && await getUISchema(referenceTo.objectName);
59922
59962
  if(referenceTo){
59923
- // 字段值单独走一个请求合并到source的同一个GraphQL接口中
59924
- defaultValueOptionsQueryData = await getFindQuery({ name: referenceTo.objectName }, null, [
59963
+ let queryFields = [
59925
59964
  Object.assign({}, referenceTo.labelField, {alias: 'label'}),
59926
59965
  Object.assign({}, referenceTo.valueField, {alias: 'value'})
59927
- ], {
59966
+ ];
59967
+
59968
+ // 把自动填充规则中依赖的字段也加到api请求中
59969
+ let autoFillMapping = !field.multiple && field.auto_fill_mapping;
59970
+ if (autoFillMapping && autoFillMapping.length) {
59971
+ autoFillMapping.forEach(function (item) {
59972
+ queryFields.push(refObjectConfig.fields[item.from]);
59973
+ });
59974
+ }
59975
+
59976
+ // 字段值单独走一个请求合并到source的同一个GraphQL接口中
59977
+ defaultValueOptionsQueryData = await getFindQuery({ name: referenceTo.objectName }, null, queryFields, {
59978
+ expand: false,
59928
59979
  alias: "defaultValueOptions",
59929
59980
  filters: "{__options_filters}",
59930
59981
  count: false
59931
59982
  });
59932
59983
  apiInfo = await getApi({
59933
59984
  name: referenceTo.objectName
59934
- }, null, [
59935
- Object.assign({}, referenceTo.labelField, {alias: 'label'}),
59936
- Object.assign({}, referenceTo.valueField, {alias: 'value'})
59937
- ], {expand: false, alias: 'options', queryOptions: `filters: {__filters}, top: {__top}, sort: "{__sort}"`});
59985
+ }, null, queryFields, {expand: false, alias: 'options', queryOptions: `filters: {__filters}, top: {__top}, sort: "{__sort}"`});
59938
59986
 
59939
59987
  apiInfo.adaptor = `
59940
59988
  const data = payload.data;
@@ -59958,7 +60006,6 @@ async function lookupToAmisSelect(field, readonly, ctx){
59958
60006
  };
59959
60007
  }
59960
60008
 
59961
- const refObjectConfig = referenceTo && await getUISchema(referenceTo.objectName);
59962
60009
  let listView = getLookupListView(refObjectConfig);
59963
60010
 
59964
60011
  let listviewFilter = getListViewFilter(listView);
@@ -60144,13 +60191,13 @@ async function getApi(object, recordId, fields, options){
60144
60191
  }
60145
60192
 
60146
60193
  async function getAutoFill(field, refObject) {
60147
- let autoFillMapping = field.auto_fill_mapping;
60194
+ let autoFillMapping = !field.multiple && field.auto_fill_mapping;
60148
60195
  if (autoFillMapping && autoFillMapping.length) {
60149
60196
  let fillMapping = {};
60150
- let fieldsForApi = [];
60197
+ // let fieldsForApi = [];
60151
60198
  autoFillMapping.forEach(function (item) {
60152
60199
  fillMapping[item.to] = `\${${item.from}}`;
60153
- fieldsForApi.push(item.from);
60200
+ // fieldsForApi.push(item.from);
60154
60201
  });
60155
60202
  // let api = {
60156
60203
  // // "url": "/amis/api/mock2/form/autoUpdate?browser=${browser}&version=${version}",
@@ -60340,7 +60387,7 @@ async function getIdsPickerSchema(field, readonly, ctx){
60340
60387
  actions: false
60341
60388
  });
60342
60389
  }else {
60343
- pickerSchema = await getTableSchema$1(tableFields, {
60390
+ pickerSchema = await getTableSchema$1(refObjectConfig, tableFields, {
60344
60391
  labelFieldName: refObjectConfig.NAME_FIELD_KEY,
60345
60392
  top: top,
60346
60393
  isLookup: true,