@steedos-widgets/amis-lib 1.1.0-beta.1 → 1.1.0

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
@@ -901,7 +901,7 @@ function getRecordPermissionsQuery(object, recordId, options){
901
901
  function getApi$2 (isMobile){
902
902
  if(isMobile);else {
903
903
  // return __meteor_runtime_config__.ROOT_URL_PATH_PREFIX + "/graphql"
904
- return `\${context.rootUrl}/graphql`
904
+ return `\${context.rootUrl}/graphql?reload=\${additionalFilters}`
905
905
  }
906
906
  }
907
907
 
@@ -1048,6 +1048,7 @@ async function getSource$1(field, ctx) {
1048
1048
  }
1049
1049
  data.$value = `$${valueField}`;
1050
1050
  // data["&"] = "$$";
1051
+
1051
1052
  const requestAdaptor = `
1052
1053
  var filters = [['parent', '=', null]];
1053
1054
  api.data.query = api.data.query.replace(/{__filters}/g, JSON.stringify(filters));
@@ -1160,7 +1161,7 @@ async function getDeferApi$1(field, ctx) {
1160
1161
  `;
1161
1162
  return {
1162
1163
  "method": "post",
1163
- "url": getApi$2() + "?ref=${ref}&dep=${value}",
1164
+ "url": getApi$2() + "&ref=${ref}&dep=${value}",
1164
1165
  "requestAdaptor": requestAdaptor,
1165
1166
  "adaptor": adaptor,
1166
1167
  "data": data,
@@ -1269,6 +1270,11 @@ async function getSelectUserSchema(field, readonly, ctx) {
1269
1270
  if (typeof amisSchema.searchable !== "boolean") {
1270
1271
  amisSchema.searchable = true;
1271
1272
  }
1273
+
1274
+ if(ctx.value){
1275
+ amisSchema.value = ctx.value;
1276
+ }
1277
+
1272
1278
  const onEvent = field.onEvent;
1273
1279
  if (onEvent) {
1274
1280
  amisSchema.onEvent = onEvent;
@@ -3668,7 +3674,7 @@ async function getDeferApi(field, ctx) {
3668
3674
  `;
3669
3675
  return {
3670
3676
  "method": "post",
3671
- "url": getApi$2() + "?dep=${value}",
3677
+ "url": getApi$2() + "&dep=${value}",
3672
3678
  "requestAdaptor": requestAdaptor,
3673
3679
  "adaptor": adaptor,
3674
3680
  "data": data,
@@ -4177,6 +4183,7 @@ async function lookupToAmisSelect(field, readonly, ctx){
4177
4183
  type: getAmisStaticFieldType('select', readonly),
4178
4184
  joinValues: false,
4179
4185
  extractValue: true,
4186
+ clearable: true,
4180
4187
  // labelField: labelField,
4181
4188
  // valueField: valueField,
4182
4189
  source: apiInfo,
@@ -4238,21 +4245,20 @@ async function lookupToAmis(field, readonly, ctx){
4238
4245
  // return await lookupToAmisGroup(field, readonly, ctx);
4239
4246
  }
4240
4247
 
4241
- if(ctx.ids || ctx.idsTrackOn){
4242
- return await lookupToAmisIdsPicker(field, readonly, ctx);
4243
- }
4244
-
4245
4248
  let referenceTo = await getReferenceTo(field);
4246
4249
  if(!referenceTo){
4247
4250
  return await lookupToAmisSelect(field, readonly, ctx);
4248
4251
  }
4249
4252
 
4250
- const refObject = await getUISchema(referenceTo.objectName);
4251
-
4252
4253
  if(referenceTo.objectName === "space_users" && field.reference_to_field === "user"){
4254
+ if(ctx.idsDependOn || field.amis){
4255
+ return await lookupToAmisIdsPicker(field, readonly, ctx);
4256
+ }
4253
4257
  return await lookupToAmisSelectUser(field, readonly, ctx);
4254
4258
  }
4255
4259
 
4260
+ const refObject = await getUISchema(referenceTo.objectName);
4261
+
4256
4262
  // 此处不参考 steedos 的 enable_enhanced_lookup 规则. 如果默认是开启弹出选择,用户选择过程操作太繁琐, 所以默认是关闭弹出选择.
4257
4263
  // 由于amis picker 目前不支持联动, 配置了depend_on时, 使用使用select ,以支持联动
4258
4264
  // TODO: 确认 amis picker 支持联动时, 清理field.depend_on判断
@@ -4287,7 +4293,7 @@ async function getIdsPickerSchema(field, readonly, ctx){
4287
4293
  }
4288
4294
  const refObjectConfig = await getUISchema(referenceTo.objectName);
4289
4295
 
4290
- const { ids, idsTrackOn } = ctx;
4296
+ const { idsDependOn } = ctx;
4291
4297
 
4292
4298
  const fields = {
4293
4299
  [referenceTo.labelField.name]: referenceTo.labelField,
@@ -4301,14 +4307,9 @@ async function getIdsPickerSchema(field, readonly, ctx){
4301
4307
  source.data.$term = "$term";
4302
4308
  source.data.$self = "$$";
4303
4309
 
4304
- if(ids && ids.length){
4305
- source.sendOn = true;
4306
- }
4307
- else {
4308
- source.sendOn = false;
4309
- }
4310
- if(idsTrackOn){
4311
- source.sendOn = `\${${idsTrackOn} && ${idsTrackOn}.length}`;
4310
+ if(idsDependOn && source.url){
4311
+ source.sendOn = `\${${idsDependOn} && ${idsDependOn}.length}`;
4312
+ source.url = `${source.url}&depend_on_${idsDependOn}=\${${idsDependOn}|join}`;
4312
4313
  }
4313
4314
 
4314
4315
  source.requestAdaptor = `
@@ -4325,10 +4326,10 @@ async function getIdsPickerSchema(field, readonly, ctx){
4325
4326
  }
4326
4327
  }
4327
4328
 
4328
- var ids = ${JSON.stringify(ids)};
4329
- var idsTrackOn = "${idsTrackOn}";
4330
- if(idsTrackOn){
4331
- ids = api.data.$self[idsTrackOn];
4329
+ var ids;
4330
+ var idsDependOn = "${idsDependOn}";
4331
+ if(idsDependOn){
4332
+ ids = api.data.$self[idsDependOn];
4332
4333
  }
4333
4334
  if(ids && ids.length){
4334
4335
  filters.push(["${referenceTo.valueField.name}", "=", ids]);
@@ -4371,6 +4372,14 @@ async function getIdsPickerSchema(field, readonly, ctx){
4371
4372
  data.extractValue = true;
4372
4373
  }
4373
4374
 
4375
+ if(ctx.value){
4376
+ data.value = ctx.value;
4377
+ }
4378
+
4379
+ if(ctx.selectFirst != undefined){
4380
+ data.selectFirst = ctx.selectFirst;
4381
+ }
4382
+
4374
4383
  if(readonly){
4375
4384
  data.tpl = await getLookupTpl(field, ctx);
4376
4385
  }
@@ -5345,15 +5354,17 @@ async function getEditFormInitApi(object, recordId, fields){
5345
5354
  const dataKeys = _.keys(data);
5346
5355
  const uiSchema = api.body.uiSchema;
5347
5356
  const fieldKeys = uiSchema && _.keys(uiSchema.fields);
5348
- _.each(dataKeys, function(key){
5349
- if(fieldKeys.indexOf(key)<0){
5350
- delete data[key];
5351
- }
5352
- })
5353
5357
 
5354
5358
  if(data){
5355
5359
  ${getScriptForAddUrlPrefixForImgFields(fields)}
5356
5360
  ${getScriptForRewriteValueForFileFields(fields)}
5361
+
5362
+ _.each(dataKeys, function(key){
5363
+ if(fieldKeys.indexOf(key)<0){
5364
+ delete data[key];
5365
+ }
5366
+ })
5367
+
5357
5368
  //初始化接口返回的字段移除字段值为null的字段
5358
5369
  for (key in data){
5359
5370
  if(data[key] === null){
@@ -6434,6 +6445,10 @@ async function getTableApi(mainObject, fields, options){
6434
6445
 
6435
6446
  if(!_.isEmpty(systemFilters)){
6436
6447
  filters = systemFilters;
6448
+ };
6449
+
6450
+ if(api.data.$self.additionalFilters){
6451
+ userFilters.push(api.data.$self.additionalFilters)
6437
6452
  }
6438
6453
 
6439
6454
  if(!_.isEmpty(userFilters)){
@@ -6850,7 +6865,7 @@ async function getObjectCalendar(objectSchema, calendarOptions, options) {
6850
6865
  initialView = "dayGridMonth";
6851
6866
  break;
6852
6867
  case "agenda":
6853
- initialView = "timeGridDay";
6868
+ initialView = "listWeek";
6854
6869
  break;
6855
6870
  }
6856
6871
  }
@@ -7072,6 +7087,30 @@ async function getObjectCalendar(objectSchema, calendarOptions, options) {
7072
7087
  }
7073
7088
  ]
7074
7089
  },
7090
+ "eventDidMount": {
7091
+ "weight": 0,
7092
+ "actions": [
7093
+ {
7094
+ "componentId": "",
7095
+ "args": {
7096
+ },
7097
+ "actionType": "custom",
7098
+ "script": "console.log('eventDidMount'); console.log(event);"
7099
+ }
7100
+ ]
7101
+ },
7102
+ "eventWillUnmount": {
7103
+ "weight": 0,
7104
+ "actions": [
7105
+ {
7106
+ "componentId": "",
7107
+ "args": {
7108
+ },
7109
+ "actionType": "custom",
7110
+ "script": "console.log('eventWillUnmount'); console.log(event);"
7111
+ }
7112
+ ]
7113
+ },
7075
7114
  }
7076
7115
  };
7077
7116
  return amisSchema;
@@ -8902,7 +8941,6 @@ const getJudgeInput = async (instance) => {
8902
8941
  "args": {
8903
8942
  "value": {
8904
8943
  new_judge: "${event.data.value}",
8905
- new_next_step: undefined,
8906
8944
  next_step: undefined,
8907
8945
  }
8908
8946
  },
@@ -8954,6 +8992,11 @@ const getNextStepInput = async (instance) => {
8954
8992
  id: "u:next_step",
8955
8993
  multiple: false,
8956
8994
  required: true,
8995
+ // selectFirst: true,
8996
+ autoFill: {
8997
+ "new_next_step": "${step}",
8998
+ "next_users": null
8999
+ },
8957
9000
  "source": {
8958
9001
  "url": "${context.rootUrl}/api/workflow/v2/nextStep?judge=${new_judge}",
8959
9002
  "headers": {
@@ -8965,10 +9008,12 @@ const getNextStepInput = async (instance) => {
8965
9008
  "requestAdaptor": "let { context, judge } = api.data; if(!judge){judge='approved'}\nconst formValues = SteedosUI.getRef(api.data.$scopeId).getComponentById(\"instance_form\").getValues();\n\napi.data = {\nflowVersionId: context.flowVersion._id,\n instanceId: context._id,\n flowId: context.flow._id,\n step: context.step,\n judge: judge,\n values: formValues\n}\n\n\n return api;",
8966
9009
  "adaptor": `
8967
9010
  payload.data = {
9011
+ value: payload.nextSteps.length === 1 ? payload.nextSteps[0]._id : null,
8968
9012
  options: _.map(payload.nextSteps, (item)=>{
8969
9013
  return {
8970
9014
  label: item.name,
8971
- value: item
9015
+ value: item._id,
9016
+ step: item
8972
9017
  }
8973
9018
  })
8974
9019
  };
@@ -8981,44 +9026,29 @@ const getNextStepInput = async (instance) => {
8981
9026
  "judge": "${new_judge}",
8982
9027
  }
8983
9028
  },
8984
- // "labelField": "name",
8985
- // "valueField": "_id",
8986
- "onEvent": {
8987
- // "change": {
8988
- // "weight": 0,
8989
- // "actions": [
8990
- // {
8991
- // "componentId": "u:next_users",
8992
- // "args": {
8993
- // },
8994
- // "actionType": "reload"
8995
- // }
8996
- // ]
8997
- // },
8998
- "change": {
8999
- "weight": 0,
9000
- "actions": [
9001
- {
9002
- "componentId": "instance_approval",
9003
- "args": {
9004
- "value": {
9005
- new_next_step: "${event.data.value}",
9006
- }
9007
- },
9008
- "actionType": "setValue"
9009
- },
9010
- {
9011
- // "componentId": "u:next_step",
9012
- "args": {
9013
- next_step: "${event.data.value}",
9014
- },
9015
- "actionType": "broadcast",
9016
- eventName: "approve_next_step_change"
9017
- },
9018
- ]
9019
- }
9020
-
9021
- }
9029
+ // "onEvent": {
9030
+ // "change": {
9031
+ // "weight": 0,
9032
+ // "actions": [
9033
+ // {
9034
+ // "componentId": "instance_approval",
9035
+ // "args": {
9036
+ // "value": {
9037
+ // new_next_step: "${event.data.value}",
9038
+ // }
9039
+ // },
9040
+ // "actionType": "setValue"
9041
+ // },
9042
+ // // {
9043
+ // // "args": {
9044
+ // // next_step: "${event.data.value}",
9045
+ // // },
9046
+ // // "actionType": "broadcast",
9047
+ // // eventName: "approve_next_step_change"
9048
+ // // },
9049
+ // ]
9050
+ // }
9051
+ // }
9022
9052
  },
9023
9053
  ],
9024
9054
  id: "u:4d3a884b437c",
@@ -9056,56 +9086,44 @@ const getNextStepUsersInput = async (instance) => {
9056
9086
  body: [
9057
9087
  // TODO 处理下一步处理人默认值
9058
9088
  Object.assign({},
9059
- // await lookupToAmisPicker(
9060
- // {
9061
- // name: "next_users",
9062
- // label: false,
9063
- // reference_to: "space_users",
9064
- // reference_to_field: 'user',
9065
- // multiple: false,
9066
- // },
9067
- // false,
9068
- // {}
9069
- // ),
9070
9089
  {
9071
9090
  "type": "steedos-select-user"
9072
9091
  },
9073
-
9074
9092
  {
9075
9093
  name: "next_users",
9076
- // value: "",
9077
9094
  hiddenOn: "this.new_next_step.deal_type != 'pickupAtRuntime'",
9078
9095
  required: true
9079
9096
  }),
9080
9097
  {
9081
- type: "list-select",
9098
+ type: "steedos-select-user",
9082
9099
  label: "",
9083
9100
  name: "next_users",
9084
- // options: await getNextStepOptions(instance),
9085
9101
  id: "u:next_users",
9086
9102
  required: true,
9087
- multiple: "this.new_next_step.deal_type === 'counterSign'",
9088
- "source": {
9089
- "url": "${context.rootUrl}/api/workflow/v2/nextStepUsers",
9090
- "method": "post",
9091
- "sendOn": "!!this.new_next_step && this.new_next_step.step_type != 'end'",
9092
- "headers": {
9093
- "Authorization": "Bearer ${context.tenantId},${context.authToken}"
9094
- },
9095
- "messages": {
9103
+ hiddenOn: "this.new_next_step.deal_type === 'pickupAtRuntime'",
9104
+ amis: {
9105
+ multiple: "this.new_next_step.deal_type === 'counterSign'",
9106
+ "source": {
9107
+ "url": "${context.rootUrl}/api/workflow/v2/nextStepUsers",
9108
+ "method": "post",
9109
+ "sendOn": "!!this.new_next_step && this.new_next_step.step_type != 'end'",
9110
+ "headers": {
9111
+ "Authorization": "Bearer ${context.tenantId},${context.authToken}"
9112
+ },
9113
+ "messages": {
9114
+ },
9115
+ "requestAdaptor": "\nconst { context, next_step, $scopeId } = api.data;\nconst formValues = SteedosUI.getRef($scopeId).getComponentById(\"instance_form\").getValues();\n\napi.data = {\n instanceId: context._id,\n nextStepId: next_step._id,\n values: formValues\n}\n\n\n return api;",
9116
+ "adaptor": "\npayload.data = {value: payload.nextStepUsers.length === 1 ? payload.nextStepUsers[0].id : null, options: payload.nextStepUsers};\nreturn payload;",
9117
+ "data": {
9118
+ "&": "$$",
9119
+ "$scopeId": "$scopeId",
9120
+ "context": "${context}",
9121
+ "next_step": "${new_next_step}",
9122
+ }
9096
9123
  },
9097
- "requestAdaptor": "console.log('======requestAdaptor====');\nconst { context, next_step, $scopeId } = api.data;\nconst formValues = SteedosUI.getRef($scopeId).getComponentById(\"instance_form\").getValues();\n\napi.data = {\n instanceId: context._id,\n nextStepId: next_step._id,\n values: formValues\n}\n\n\n return api;",
9098
- "adaptor": "\npayload.data = payload.nextStepUsers;\nreturn payload;",
9099
- "data": {
9100
- "&": "$$",
9101
- "$scopeId": "$scopeId",
9102
- "context": "${context}",
9103
- "next_step": "${new_next_step}",
9104
- }
9105
- },
9106
- "labelField": "name",
9107
- "valueField": "id",
9108
- hiddenOn: "this.new_next_step.deal_type === 'pickupAtRuntime'"
9124
+ "labelField": "name",
9125
+ "valueField": "id",
9126
+ }
9109
9127
  }
9110
9128
  ],
9111
9129
  id: "u:81a4913c61cc",
@@ -9292,6 +9310,9 @@ const getApprovalDrawerSchema = async (instance) => {
9292
9310
  size: "sm",
9293
9311
  title: `${instance.step.name}`,
9294
9312
  className: "approval-drawer absolute",
9313
+ headerClassName: 'p-2',
9314
+ bodyClassName: 'p-2',
9315
+ footerClassName: 'p-2 pt-0',
9295
9316
  drawerContainer: ()=>{
9296
9317
  return window.$(".antd-Page-content",window.$(".steedos-instance-wrapper"))[0];
9297
9318
  },
@@ -9304,6 +9325,10 @@ const getApprovalDrawerSchema = async (instance) => {
9304
9325
  clearPersistDataAfterSubmit: true,
9305
9326
  persistData: `workflow_approve_form_${instance.approve._id}`,
9306
9327
  body: [
9328
+ {
9329
+ type: 'hidden',
9330
+ name: 'new_next_step'
9331
+ },
9307
9332
  await getJudgeInput(instance),
9308
9333
  {
9309
9334
  type: "textarea",
@@ -9334,7 +9359,7 @@ const getApprovalDrawerSchema = async (instance) => {
9334
9359
  // {
9335
9360
  // "actionType": "reload",
9336
9361
  // "componentId": "u:nex_users",
9337
- // "args": {t
9362
+ // "args": {
9338
9363
  // }
9339
9364
  // }
9340
9365
  // ]
@@ -9645,7 +9670,7 @@ const getInstanceApprovalHistory = async ()=>{
9645
9670
  * @Author: baozhoutao@steedos.com
9646
9671
  * @Date: 2022-09-07 16:20:45
9647
9672
  * @LastEditors: baozhoutao@steedos.com
9648
- * @LastEditTime: 2023-03-18 17:29:01
9673
+ * @LastEditTime: 2023-03-23 16:49:44
9649
9674
  * @Description:
9650
9675
  */
9651
9676
 
@@ -10209,7 +10234,6 @@ const getFormTableView = async (instance) => {
10209
10234
  trs: await getFormTrs(instance),
10210
10235
  id: "u:047f3669468b",
10211
10236
  };
10212
- console.log(`getFormTableView formSchema=====>`, formSchema);
10213
10237
  return formSchema;
10214
10238
  };
10215
10239
 
@@ -10358,6 +10382,7 @@ const getFlowFormSchema = async (instance, box) => {
10358
10382
  type: "page",
10359
10383
  name: "instancePage",
10360
10384
  className: "steedos-amis-instance-view",
10385
+ bodyClassName: "overflow-y-auto h-full",
10361
10386
  "title": {
10362
10387
  "type": "steedos-record-detail-header",
10363
10388
  "label": "标题面板",