@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.cjs.js CHANGED
@@ -928,7 +928,7 @@ function getRecordPermissionsQuery(object, recordId, options){
928
928
  function getApi$2 (isMobile){
929
929
  if(isMobile);else {
930
930
  // return __meteor_runtime_config__.ROOT_URL_PATH_PREFIX + "/graphql"
931
- return `\${context.rootUrl}/graphql`
931
+ return `\${context.rootUrl}/graphql?reload=\${additionalFilters}`
932
932
  }
933
933
  }
934
934
 
@@ -1075,6 +1075,7 @@ async function getSource$1(field, ctx) {
1075
1075
  }
1076
1076
  data.$value = `$${valueField}`;
1077
1077
  // data["&"] = "$$";
1078
+
1078
1079
  const requestAdaptor = `
1079
1080
  var filters = [['parent', '=', null]];
1080
1081
  api.data.query = api.data.query.replace(/{__filters}/g, JSON.stringify(filters));
@@ -1187,7 +1188,7 @@ async function getDeferApi$1(field, ctx) {
1187
1188
  `;
1188
1189
  return {
1189
1190
  "method": "post",
1190
- "url": getApi$2() + "?ref=${ref}&dep=${value}",
1191
+ "url": getApi$2() + "&ref=${ref}&dep=${value}",
1191
1192
  "requestAdaptor": requestAdaptor,
1192
1193
  "adaptor": adaptor,
1193
1194
  "data": data,
@@ -1296,6 +1297,11 @@ async function getSelectUserSchema(field, readonly, ctx) {
1296
1297
  if (typeof amisSchema.searchable !== "boolean") {
1297
1298
  amisSchema.searchable = true;
1298
1299
  }
1300
+
1301
+ if(ctx.value){
1302
+ amisSchema.value = ctx.value;
1303
+ }
1304
+
1299
1305
  const onEvent = field.onEvent;
1300
1306
  if (onEvent) {
1301
1307
  amisSchema.onEvent = onEvent;
@@ -3695,7 +3701,7 @@ async function getDeferApi(field, ctx) {
3695
3701
  `;
3696
3702
  return {
3697
3703
  "method": "post",
3698
- "url": getApi$2() + "?dep=${value}",
3704
+ "url": getApi$2() + "&dep=${value}",
3699
3705
  "requestAdaptor": requestAdaptor,
3700
3706
  "adaptor": adaptor,
3701
3707
  "data": data,
@@ -4204,6 +4210,7 @@ async function lookupToAmisSelect(field, readonly, ctx){
4204
4210
  type: getAmisStaticFieldType('select', readonly),
4205
4211
  joinValues: false,
4206
4212
  extractValue: true,
4213
+ clearable: true,
4207
4214
  // labelField: labelField,
4208
4215
  // valueField: valueField,
4209
4216
  source: apiInfo,
@@ -4265,21 +4272,20 @@ async function lookupToAmis(field, readonly, ctx){
4265
4272
  // return await lookupToAmisGroup(field, readonly, ctx);
4266
4273
  }
4267
4274
 
4268
- if(ctx.ids || ctx.idsTrackOn){
4269
- return await lookupToAmisIdsPicker(field, readonly, ctx);
4270
- }
4271
-
4272
4275
  let referenceTo = await getReferenceTo(field);
4273
4276
  if(!referenceTo){
4274
4277
  return await lookupToAmisSelect(field, readonly, ctx);
4275
4278
  }
4276
4279
 
4277
- const refObject = await getUISchema(referenceTo.objectName);
4278
-
4279
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
+ }
4280
4284
  return await lookupToAmisSelectUser(field, readonly, ctx);
4281
4285
  }
4282
4286
 
4287
+ const refObject = await getUISchema(referenceTo.objectName);
4288
+
4283
4289
  // 此处不参考 steedos 的 enable_enhanced_lookup 规则. 如果默认是开启弹出选择,用户选择过程操作太繁琐, 所以默认是关闭弹出选择.
4284
4290
  // 由于amis picker 目前不支持联动, 配置了depend_on时, 使用使用select ,以支持联动
4285
4291
  // TODO: 确认 amis picker 支持联动时, 清理field.depend_on判断
@@ -4314,7 +4320,7 @@ async function getIdsPickerSchema(field, readonly, ctx){
4314
4320
  }
4315
4321
  const refObjectConfig = await getUISchema(referenceTo.objectName);
4316
4322
 
4317
- const { ids, idsTrackOn } = ctx;
4323
+ const { idsDependOn } = ctx;
4318
4324
 
4319
4325
  const fields = {
4320
4326
  [referenceTo.labelField.name]: referenceTo.labelField,
@@ -4328,14 +4334,9 @@ async function getIdsPickerSchema(field, readonly, ctx){
4328
4334
  source.data.$term = "$term";
4329
4335
  source.data.$self = "$$";
4330
4336
 
4331
- if(ids && ids.length){
4332
- source.sendOn = true;
4333
- }
4334
- else {
4335
- source.sendOn = false;
4336
- }
4337
- if(idsTrackOn){
4338
- 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}`;
4339
4340
  }
4340
4341
 
4341
4342
  source.requestAdaptor = `
@@ -4352,10 +4353,10 @@ async function getIdsPickerSchema(field, readonly, ctx){
4352
4353
  }
4353
4354
  }
4354
4355
 
4355
- var ids = ${JSON.stringify(ids)};
4356
- var idsTrackOn = "${idsTrackOn}";
4357
- if(idsTrackOn){
4358
- ids = api.data.$self[idsTrackOn];
4356
+ var ids;
4357
+ var idsDependOn = "${idsDependOn}";
4358
+ if(idsDependOn){
4359
+ ids = api.data.$self[idsDependOn];
4359
4360
  }
4360
4361
  if(ids && ids.length){
4361
4362
  filters.push(["${referenceTo.valueField.name}", "=", ids]);
@@ -4398,6 +4399,14 @@ async function getIdsPickerSchema(field, readonly, ctx){
4398
4399
  data.extractValue = true;
4399
4400
  }
4400
4401
 
4402
+ if(ctx.value){
4403
+ data.value = ctx.value;
4404
+ }
4405
+
4406
+ if(ctx.selectFirst != undefined){
4407
+ data.selectFirst = ctx.selectFirst;
4408
+ }
4409
+
4401
4410
  if(readonly){
4402
4411
  data.tpl = await getLookupTpl(field, ctx);
4403
4412
  }
@@ -5372,15 +5381,17 @@ async function getEditFormInitApi(object, recordId, fields){
5372
5381
  const dataKeys = _.keys(data);
5373
5382
  const uiSchema = api.body.uiSchema;
5374
5383
  const fieldKeys = uiSchema && _.keys(uiSchema.fields);
5375
- _.each(dataKeys, function(key){
5376
- if(fieldKeys.indexOf(key)<0){
5377
- delete data[key];
5378
- }
5379
- })
5380
5384
 
5381
5385
  if(data){
5382
5386
  ${getScriptForAddUrlPrefixForImgFields(fields)}
5383
5387
  ${getScriptForRewriteValueForFileFields(fields)}
5388
+
5389
+ _.each(dataKeys, function(key){
5390
+ if(fieldKeys.indexOf(key)<0){
5391
+ delete data[key];
5392
+ }
5393
+ })
5394
+
5384
5395
  //初始化接口返回的字段移除字段值为null的字段
5385
5396
  for (key in data){
5386
5397
  if(data[key] === null){
@@ -6461,6 +6472,10 @@ async function getTableApi(mainObject, fields, options){
6461
6472
 
6462
6473
  if(!_.isEmpty(systemFilters)){
6463
6474
  filters = systemFilters;
6475
+ };
6476
+
6477
+ if(api.data.$self.additionalFilters){
6478
+ userFilters.push(api.data.$self.additionalFilters)
6464
6479
  }
6465
6480
 
6466
6481
  if(!_.isEmpty(userFilters)){
@@ -6877,7 +6892,7 @@ async function getObjectCalendar(objectSchema, calendarOptions, options) {
6877
6892
  initialView = "dayGridMonth";
6878
6893
  break;
6879
6894
  case "agenda":
6880
- initialView = "timeGridDay";
6895
+ initialView = "listWeek";
6881
6896
  break;
6882
6897
  }
6883
6898
  }
@@ -7099,6 +7114,30 @@ async function getObjectCalendar(objectSchema, calendarOptions, options) {
7099
7114
  }
7100
7115
  ]
7101
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
+ },
7102
7141
  }
7103
7142
  };
7104
7143
  return amisSchema;
@@ -8929,7 +8968,6 @@ const getJudgeInput = async (instance) => {
8929
8968
  "args": {
8930
8969
  "value": {
8931
8970
  new_judge: "${event.data.value}",
8932
- new_next_step: undefined,
8933
8971
  next_step: undefined,
8934
8972
  }
8935
8973
  },
@@ -8981,6 +9019,11 @@ const getNextStepInput = async (instance) => {
8981
9019
  id: "u:next_step",
8982
9020
  multiple: false,
8983
9021
  required: true,
9022
+ // selectFirst: true,
9023
+ autoFill: {
9024
+ "new_next_step": "${step}",
9025
+ "next_users": null
9026
+ },
8984
9027
  "source": {
8985
9028
  "url": "${context.rootUrl}/api/workflow/v2/nextStep?judge=${new_judge}",
8986
9029
  "headers": {
@@ -8992,10 +9035,12 @@ const getNextStepInput = async (instance) => {
8992
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;",
8993
9036
  "adaptor": `
8994
9037
  payload.data = {
9038
+ value: payload.nextSteps.length === 1 ? payload.nextSteps[0]._id : null,
8995
9039
  options: _.map(payload.nextSteps, (item)=>{
8996
9040
  return {
8997
9041
  label: item.name,
8998
- value: item
9042
+ value: item._id,
9043
+ step: item
8999
9044
  }
9000
9045
  })
9001
9046
  };
@@ -9008,44 +9053,29 @@ const getNextStepInput = async (instance) => {
9008
9053
  "judge": "${new_judge}",
9009
9054
  }
9010
9055
  },
9011
- // "labelField": "name",
9012
- // "valueField": "_id",
9013
- "onEvent": {
9014
- // "change": {
9015
- // "weight": 0,
9016
- // "actions": [
9017
- // {
9018
- // "componentId": "u:next_users",
9019
- // "args": {
9020
- // },
9021
- // "actionType": "reload"
9022
- // }
9023
- // ]
9024
- // },
9025
- "change": {
9026
- "weight": 0,
9027
- "actions": [
9028
- {
9029
- "componentId": "instance_approval",
9030
- "args": {
9031
- "value": {
9032
- new_next_step: "${event.data.value}",
9033
- }
9034
- },
9035
- "actionType": "setValue"
9036
- },
9037
- {
9038
- // "componentId": "u:next_step",
9039
- "args": {
9040
- next_step: "${event.data.value}",
9041
- },
9042
- "actionType": "broadcast",
9043
- eventName: "approve_next_step_change"
9044
- },
9045
- ]
9046
- }
9047
-
9048
- }
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
+ // }
9049
9079
  },
9050
9080
  ],
9051
9081
  id: "u:4d3a884b437c",
@@ -9083,56 +9113,44 @@ const getNextStepUsersInput = async (instance) => {
9083
9113
  body: [
9084
9114
  // TODO 处理下一步处理人默认值
9085
9115
  Object.assign({},
9086
- // await lookupToAmisPicker(
9087
- // {
9088
- // name: "next_users",
9089
- // label: false,
9090
- // reference_to: "space_users",
9091
- // reference_to_field: 'user',
9092
- // multiple: false,
9093
- // },
9094
- // false,
9095
- // {}
9096
- // ),
9097
9116
  {
9098
9117
  "type": "steedos-select-user"
9099
9118
  },
9100
-
9101
9119
  {
9102
9120
  name: "next_users",
9103
- // value: "",
9104
9121
  hiddenOn: "this.new_next_step.deal_type != 'pickupAtRuntime'",
9105
9122
  required: true
9106
9123
  }),
9107
9124
  {
9108
- type: "list-select",
9125
+ type: "steedos-select-user",
9109
9126
  label: "",
9110
9127
  name: "next_users",
9111
- // options: await getNextStepOptions(instance),
9112
9128
  id: "u:next_users",
9113
9129
  required: true,
9114
- multiple: "this.new_next_step.deal_type === 'counterSign'",
9115
- "source": {
9116
- "url": "${context.rootUrl}/api/workflow/v2/nextStepUsers",
9117
- "method": "post",
9118
- "sendOn": "!!this.new_next_step && this.new_next_step.step_type != 'end'",
9119
- "headers": {
9120
- "Authorization": "Bearer ${context.tenantId},${context.authToken}"
9121
- },
9122
- "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
+ }
9123
9150
  },
9124
- "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;",
9125
- "adaptor": "\npayload.data = payload.nextStepUsers;\nreturn payload;",
9126
- "data": {
9127
- "&": "$$",
9128
- "$scopeId": "$scopeId",
9129
- "context": "${context}",
9130
- "next_step": "${new_next_step}",
9131
- }
9132
- },
9133
- "labelField": "name",
9134
- "valueField": "id",
9135
- hiddenOn: "this.new_next_step.deal_type === 'pickupAtRuntime'"
9151
+ "labelField": "name",
9152
+ "valueField": "id",
9153
+ }
9136
9154
  }
9137
9155
  ],
9138
9156
  id: "u:81a4913c61cc",
@@ -9319,6 +9337,9 @@ const getApprovalDrawerSchema = async (instance) => {
9319
9337
  size: "sm",
9320
9338
  title: `${instance.step.name}`,
9321
9339
  className: "approval-drawer absolute",
9340
+ headerClassName: 'p-2',
9341
+ bodyClassName: 'p-2',
9342
+ footerClassName: 'p-2 pt-0',
9322
9343
  drawerContainer: ()=>{
9323
9344
  return window.$(".antd-Page-content",window.$(".steedos-instance-wrapper"))[0];
9324
9345
  },
@@ -9331,6 +9352,10 @@ const getApprovalDrawerSchema = async (instance) => {
9331
9352
  clearPersistDataAfterSubmit: true,
9332
9353
  persistData: `workflow_approve_form_${instance.approve._id}`,
9333
9354
  body: [
9355
+ {
9356
+ type: 'hidden',
9357
+ name: 'new_next_step'
9358
+ },
9334
9359
  await getJudgeInput(instance),
9335
9360
  {
9336
9361
  type: "textarea",
@@ -9361,7 +9386,7 @@ const getApprovalDrawerSchema = async (instance) => {
9361
9386
  // {
9362
9387
  // "actionType": "reload",
9363
9388
  // "componentId": "u:nex_users",
9364
- // "args": {t
9389
+ // "args": {
9365
9390
  // }
9366
9391
  // }
9367
9392
  // ]
@@ -9672,7 +9697,7 @@ const getInstanceApprovalHistory = async ()=>{
9672
9697
  * @Author: baozhoutao@steedos.com
9673
9698
  * @Date: 2022-09-07 16:20:45
9674
9699
  * @LastEditors: baozhoutao@steedos.com
9675
- * @LastEditTime: 2023-03-18 17:29:01
9700
+ * @LastEditTime: 2023-03-23 16:49:44
9676
9701
  * @Description:
9677
9702
  */
9678
9703
 
@@ -10236,7 +10261,6 @@ const getFormTableView = async (instance) => {
10236
10261
  trs: await getFormTrs(instance),
10237
10262
  id: "u:047f3669468b",
10238
10263
  };
10239
- console.log(`getFormTableView formSchema=====>`, formSchema);
10240
10264
  return formSchema;
10241
10265
  };
10242
10266
 
@@ -10385,6 +10409,7 @@ const getFlowFormSchema = async (instance, box) => {
10385
10409
  type: "page",
10386
10410
  name: "instancePage",
10387
10411
  className: "steedos-amis-instance-view",
10412
+ bodyClassName: "overflow-y-auto h-full",
10388
10413
  "title": {
10389
10414
  "type": "steedos-record-detail-header",
10390
10415
  "label": "标题面板",