@steedos-widgets/amis-lib 1.1.0-beta.2 → 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.cjs.js CHANGED
@@ -1076,17 +1076,10 @@ async function getSource$1(field, ctx) {
1076
1076
  data.$value = `$${valueField}`;
1077
1077
  // data["&"] = "$$";
1078
1078
 
1079
- const fieldValue = ctx.value;
1080
-
1081
1079
  const requestAdaptor = `
1082
1080
  var filters = [['parent', '=', null]];
1083
1081
  api.data.query = api.data.query.replace(/{__filters}/g, JSON.stringify(filters));
1084
1082
  var defaultValue = api.data.$value;
1085
- var fieldValue = ${JSON.stringify(fieldValue)};
1086
- if(!defaultValue && fieldValue){
1087
- // 如果表单中没有字段值,则认字段上配置的value属性
1088
- defaultValue = fieldValue;
1089
- }
1090
1083
  var optionsFiltersOp = "${field.multiple ? "in" : "="}";
1091
1084
  var optionsFilters = [["user", optionsFiltersOp, []]];
1092
1085
  if (defaultValue) {
@@ -4279,21 +4272,20 @@ async function lookupToAmis(field, readonly, ctx){
4279
4272
  // return await lookupToAmisGroup(field, readonly, ctx);
4280
4273
  }
4281
4274
 
4282
- if(ctx.ids || ctx.idsTrackOn){
4283
- return await lookupToAmisIdsPicker(field, readonly, ctx);
4284
- }
4285
-
4286
4275
  let referenceTo = await getReferenceTo(field);
4287
4276
  if(!referenceTo){
4288
4277
  return await lookupToAmisSelect(field, readonly, ctx);
4289
4278
  }
4290
4279
 
4291
- const refObject = await getUISchema(referenceTo.objectName);
4292
-
4293
4280
  if(referenceTo.objectName === "space_users" && field.reference_to_field === "user"){
4281
+ if(ctx.idsDependOn || field.amis){
4282
+ return await lookupToAmisIdsPicker(field, readonly, ctx);
4283
+ }
4294
4284
  return await lookupToAmisSelectUser(field, readonly, ctx);
4295
4285
  }
4296
4286
 
4287
+ const refObject = await getUISchema(referenceTo.objectName);
4288
+
4297
4289
  // 此处不参考 steedos 的 enable_enhanced_lookup 规则. 如果默认是开启弹出选择,用户选择过程操作太繁琐, 所以默认是关闭弹出选择.
4298
4290
  // 由于amis picker 目前不支持联动, 配置了depend_on时, 使用使用select ,以支持联动
4299
4291
  // TODO: 确认 amis picker 支持联动时, 清理field.depend_on判断
@@ -4328,7 +4320,7 @@ async function getIdsPickerSchema(field, readonly, ctx){
4328
4320
  }
4329
4321
  const refObjectConfig = await getUISchema(referenceTo.objectName);
4330
4322
 
4331
- const { ids, idsTrackOn } = ctx;
4323
+ const { idsDependOn } = ctx;
4332
4324
 
4333
4325
  const fields = {
4334
4326
  [referenceTo.labelField.name]: referenceTo.labelField,
@@ -4342,14 +4334,9 @@ async function getIdsPickerSchema(field, readonly, ctx){
4342
4334
  source.data.$term = "$term";
4343
4335
  source.data.$self = "$$";
4344
4336
 
4345
- if(ids && ids.length){
4346
- source.sendOn = true;
4347
- }
4348
- else {
4349
- source.sendOn = false;
4350
- }
4351
- if(idsTrackOn){
4352
- source.sendOn = `\${${idsTrackOn} && ${idsTrackOn}.length}`;
4337
+ if(idsDependOn && source.url){
4338
+ source.sendOn = `\${${idsDependOn} && ${idsDependOn}.length}`;
4339
+ source.url = `${source.url}&depend_on_${idsDependOn}=\${${idsDependOn}|join}`;
4353
4340
  }
4354
4341
 
4355
4342
  source.requestAdaptor = `
@@ -4366,10 +4353,10 @@ async function getIdsPickerSchema(field, readonly, ctx){
4366
4353
  }
4367
4354
  }
4368
4355
 
4369
- var ids = ${JSON.stringify(ids)};
4370
- var idsTrackOn = "${idsTrackOn}";
4371
- if(idsTrackOn){
4372
- ids = api.data.$self[idsTrackOn];
4356
+ var ids;
4357
+ var idsDependOn = "${idsDependOn}";
4358
+ if(idsDependOn){
4359
+ ids = api.data.$self[idsDependOn];
4373
4360
  }
4374
4361
  if(ids && ids.length){
4375
4362
  filters.push(["${referenceTo.valueField.name}", "=", ids]);
@@ -6905,7 +6892,7 @@ async function getObjectCalendar(objectSchema, calendarOptions, options) {
6905
6892
  initialView = "dayGridMonth";
6906
6893
  break;
6907
6894
  case "agenda":
6908
- initialView = "timeGridDay";
6895
+ initialView = "listWeek";
6909
6896
  break;
6910
6897
  }
6911
6898
  }
@@ -7127,6 +7114,30 @@ async function getObjectCalendar(objectSchema, calendarOptions, options) {
7127
7114
  }
7128
7115
  ]
7129
7116
  },
7117
+ "eventDidMount": {
7118
+ "weight": 0,
7119
+ "actions": [
7120
+ {
7121
+ "componentId": "",
7122
+ "args": {
7123
+ },
7124
+ "actionType": "custom",
7125
+ "script": "console.log('eventDidMount'); console.log(event);"
7126
+ }
7127
+ ]
7128
+ },
7129
+ "eventWillUnmount": {
7130
+ "weight": 0,
7131
+ "actions": [
7132
+ {
7133
+ "componentId": "",
7134
+ "args": {
7135
+ },
7136
+ "actionType": "custom",
7137
+ "script": "console.log('eventWillUnmount'); console.log(event);"
7138
+ }
7139
+ ]
7140
+ },
7130
7141
  }
7131
7142
  };
7132
7143
  return amisSchema;
@@ -8957,7 +8968,6 @@ const getJudgeInput = async (instance) => {
8957
8968
  "args": {
8958
8969
  "value": {
8959
8970
  new_judge: "${event.data.value}",
8960
- new_next_step: undefined,
8961
8971
  next_step: undefined,
8962
8972
  }
8963
8973
  },
@@ -9009,7 +9019,11 @@ const getNextStepInput = async (instance) => {
9009
9019
  id: "u:next_step",
9010
9020
  multiple: false,
9011
9021
  required: true,
9012
- selectFirst: true,
9022
+ // selectFirst: true,
9023
+ autoFill: {
9024
+ "new_next_step": "${step}",
9025
+ "next_users": null
9026
+ },
9013
9027
  "source": {
9014
9028
  "url": "${context.rootUrl}/api/workflow/v2/nextStep?judge=${new_judge}",
9015
9029
  "headers": {
@@ -9021,10 +9035,12 @@ const getNextStepInput = async (instance) => {
9021
9035
  "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;",
9022
9036
  "adaptor": `
9023
9037
  payload.data = {
9038
+ value: payload.nextSteps.length === 1 ? payload.nextSteps[0]._id : null,
9024
9039
  options: _.map(payload.nextSteps, (item)=>{
9025
9040
  return {
9026
9041
  label: item.name,
9027
- value: item
9042
+ value: item._id,
9043
+ step: item
9028
9044
  }
9029
9045
  })
9030
9046
  };
@@ -9037,29 +9053,29 @@ const getNextStepInput = async (instance) => {
9037
9053
  "judge": "${new_judge}",
9038
9054
  }
9039
9055
  },
9040
- "onEvent": {
9041
- "change": {
9042
- "weight": 0,
9043
- "actions": [
9044
- {
9045
- "componentId": "instance_approval",
9046
- "args": {
9047
- "value": {
9048
- new_next_step: "${event.data.value}",
9049
- }
9050
- },
9051
- "actionType": "setValue"
9052
- },
9053
- {
9054
- "args": {
9055
- next_step: "${event.data.value}",
9056
- },
9057
- "actionType": "broadcast",
9058
- eventName: "approve_next_step_change"
9059
- },
9060
- ]
9061
- }
9062
- }
9056
+ // "onEvent": {
9057
+ // "change": {
9058
+ // "weight": 0,
9059
+ // "actions": [
9060
+ // {
9061
+ // "componentId": "instance_approval",
9062
+ // "args": {
9063
+ // "value": {
9064
+ // new_next_step: "${event.data.value}",
9065
+ // }
9066
+ // },
9067
+ // "actionType": "setValue"
9068
+ // },
9069
+ // // {
9070
+ // // "args": {
9071
+ // // next_step: "${event.data.value}",
9072
+ // // },
9073
+ // // "actionType": "broadcast",
9074
+ // // eventName: "approve_next_step_change"
9075
+ // // },
9076
+ // ]
9077
+ // }
9078
+ // }
9063
9079
  },
9064
9080
  ],
9065
9081
  id: "u:4d3a884b437c",
@@ -9097,56 +9113,44 @@ const getNextStepUsersInput = async (instance) => {
9097
9113
  body: [
9098
9114
  // TODO 处理下一步处理人默认值
9099
9115
  Object.assign({},
9100
- // await lookupToAmisPicker(
9101
- // {
9102
- // name: "next_users",
9103
- // label: false,
9104
- // reference_to: "space_users",
9105
- // reference_to_field: 'user',
9106
- // multiple: false,
9107
- // },
9108
- // false,
9109
- // {}
9110
- // ),
9111
9116
  {
9112
9117
  "type": "steedos-select-user"
9113
9118
  },
9114
-
9115
9119
  {
9116
9120
  name: "next_users",
9117
- // value: "",
9118
9121
  hiddenOn: "this.new_next_step.deal_type != 'pickupAtRuntime'",
9119
9122
  required: true
9120
9123
  }),
9121
9124
  {
9122
- type: "list-select",
9125
+ type: "steedos-select-user",
9123
9126
  label: "",
9124
9127
  name: "next_users",
9125
- // options: await getNextStepOptions(instance),
9126
9128
  id: "u:next_users",
9127
9129
  required: true,
9128
- multiple: "this.new_next_step.deal_type === 'counterSign'",
9129
- "source": {
9130
- "url": "${context.rootUrl}/api/workflow/v2/nextStepUsers",
9131
- "method": "post",
9132
- "sendOn": "!!this.new_next_step && this.new_next_step.step_type != 'end'",
9133
- "headers": {
9134
- "Authorization": "Bearer ${context.tenantId},${context.authToken}"
9135
- },
9136
- "messages": {
9130
+ hiddenOn: "this.new_next_step.deal_type === 'pickupAtRuntime'",
9131
+ amis: {
9132
+ multiple: "this.new_next_step.deal_type === 'counterSign'",
9133
+ "source": {
9134
+ "url": "${context.rootUrl}/api/workflow/v2/nextStepUsers",
9135
+ "method": "post",
9136
+ "sendOn": "!!this.new_next_step && this.new_next_step.step_type != 'end'",
9137
+ "headers": {
9138
+ "Authorization": "Bearer ${context.tenantId},${context.authToken}"
9139
+ },
9140
+ "messages": {
9141
+ },
9142
+ "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;",
9143
+ "adaptor": "\npayload.data = {value: payload.nextStepUsers.length === 1 ? payload.nextStepUsers[0].id : null, options: payload.nextStepUsers};\nreturn payload;",
9144
+ "data": {
9145
+ "&": "$$",
9146
+ "$scopeId": "$scopeId",
9147
+ "context": "${context}",
9148
+ "next_step": "${new_next_step}",
9149
+ }
9137
9150
  },
9138
- "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;",
9139
- "adaptor": "\npayload.data = payload.nextStepUsers;\nreturn payload;",
9140
- "data": {
9141
- "&": "$$",
9142
- "$scopeId": "$scopeId",
9143
- "context": "${context}",
9144
- "next_step": "${new_next_step}",
9145
- }
9146
- },
9147
- "labelField": "name",
9148
- "valueField": "id",
9149
- hiddenOn: "this.new_next_step.deal_type === 'pickupAtRuntime'"
9151
+ "labelField": "name",
9152
+ "valueField": "id",
9153
+ }
9150
9154
  }
9151
9155
  ],
9152
9156
  id: "u:81a4913c61cc",
@@ -9348,6 +9352,10 @@ const getApprovalDrawerSchema = async (instance) => {
9348
9352
  clearPersistDataAfterSubmit: true,
9349
9353
  persistData: `workflow_approve_form_${instance.approve._id}`,
9350
9354
  body: [
9355
+ {
9356
+ type: 'hidden',
9357
+ name: 'new_next_step'
9358
+ },
9351
9359
  await getJudgeInput(instance),
9352
9360
  {
9353
9361
  type: "textarea",
@@ -9378,7 +9386,7 @@ const getApprovalDrawerSchema = async (instance) => {
9378
9386
  // {
9379
9387
  // "actionType": "reload",
9380
9388
  // "componentId": "u:nex_users",
9381
- // "args": {t
9389
+ // "args": {
9382
9390
  // }
9383
9391
  // }
9384
9392
  // ]
@@ -9689,7 +9697,7 @@ const getInstanceApprovalHistory = async ()=>{
9689
9697
  * @Author: baozhoutao@steedos.com
9690
9698
  * @Date: 2022-09-07 16:20:45
9691
9699
  * @LastEditors: baozhoutao@steedos.com
9692
- * @LastEditTime: 2023-03-22 14:43:18
9700
+ * @LastEditTime: 2023-03-23 16:49:44
9693
9701
  * @Description:
9694
9702
  */
9695
9703
 
@@ -10253,7 +10261,6 @@ const getFormTableView = async (instance) => {
10253
10261
  trs: await getFormTrs(instance),
10254
10262
  id: "u:047f3669468b",
10255
10263
  };
10256
- console.log(`getFormTableView formSchema=====>`, formSchema);
10257
10264
  return formSchema;
10258
10265
  };
10259
10266