@steedos-widgets/amis-lib 6.10.18 → 6.10.20

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
@@ -16930,7 +16930,9 @@ function getInputTableCell(field, showAsInlineEditMode) {
16930
16930
  // })
16931
16931
  // },
16932
16932
  label: field.label,
16933
- name: field.name
16933
+ name: field.name,
16934
+ visibleOn: field.visibleOn,
16935
+ requiredOn: field.requiredOn
16934
16936
  }
16935
16937
  }
16936
16938
  else {
@@ -16954,7 +16956,9 @@ function getInputTableCell(field, showAsInlineEditMode) {
16954
16956
  "static": true,
16955
16957
  "readonly": true,
16956
16958
  label: field.label,
16957
- name: field.name
16959
+ name: field.name,
16960
+ visibleOn: field.visibleOn,
16961
+ requiredOn: field.requiredOn
16958
16962
  }
16959
16963
  }
16960
16964
  }
@@ -17793,7 +17797,8 @@ async function getButtonActions(props, mode) {
17793
17797
  // "__tableItems": `\${${props.name}|json|toJson}`
17794
17798
  // 在节点嵌套情况下,当前节点正好是带children属性的节点的话,这里弹出的dialog映射到的会是children数组,这是amis目前的规则,
17795
17799
  // 所以这里加判断有children时,用__super.__super让映射到正确的作用域层,如果不加,则__tableItems取到的会是children数组,而不是整个子表组件的值
17796
- "__tableItems": `\${((children ? __super.__super.${props.name} : __super.${props.name}) || [])|json|toJson}`
17800
+ "__tableItems": `\${((children ? __super.__super.${props.name} : __super.${props.name}) || [])|json|toJson}`,
17801
+ ...(props.actionData || {})
17797
17802
  },
17798
17803
  "actions": dialogButtons,
17799
17804
  "onEvent": {
@@ -17919,7 +17924,8 @@ async function getButtonActions(props, mode) {
17919
17924
  // "__tableItems": `\${((__super.parent ? __super.__super.${props.name} : __super.${props.name}) || [])|json|toJson}`
17920
17925
  // 在节点嵌套情况下,当前节点正好是带children属性的节点的话,这里弹出的dialog映射到的会是children数组,这是amis目前的规则,
17921
17926
  // 所以这里加判断有children时,用__super.__super让映射到正确的作用域层,如果不加,则__tableItems取到的会是children数组,而不是整个子表组件的值
17922
- "__tableItems": `\${((children ? __super.__super.${props.name} : __super.${props.name}) || [])|json|toJson}`
17927
+ "__tableItems": `\${((children ? __super.__super.${props.name} : __super.${props.name}) || [])|json|toJson}`,
17928
+ ...(props.actionData || {})
17923
17929
  },
17924
17930
  }
17925
17931
  }
@@ -19195,7 +19201,7 @@ const getJudgeInput = async (instance) => {
19195
19201
  };
19196
19202
 
19197
19203
  //TODO 只有一个下一步时,默认选中,并且禁止修改.
19198
- const getNextStepInput = async (instance) => {
19204
+ const getNextStepInput = async (instance, nextStepChangeEvents) => {
19199
19205
  // console.log('getNextStepInput', instance);
19200
19206
  if(instance.approve?.type == 'cc'){
19201
19207
  return ;
@@ -19283,29 +19289,14 @@ const getNextStepInput = async (instance) => {
19283
19289
  "judge": "${new_judge}",
19284
19290
  }
19285
19291
  },
19286
- // "onEvent": {
19287
- // "change": {
19288
- // "weight": 0,
19289
- // "actions": [
19290
- // {
19291
- // "componentId": "instance_approval",
19292
- // "args": {
19293
- // "value": {
19294
- // new_next_step: "${event.data.value}",
19295
- // }
19296
- // },
19297
- // "actionType": "setValue"
19298
- // },
19299
- // // {
19300
- // // "args": {
19301
- // // next_step: "${event.data.value}",
19302
- // // },
19303
- // // "actionType": "broadcast",
19304
- // // eventName: "approve_next_step_change"
19305
- // // },
19306
- // ]
19307
- // }
19308
- // }
19292
+ "onEvent": {
19293
+ "change": {
19294
+ "weight": 0,
19295
+ "actions": [
19296
+ ...nextStepChangeEvents
19297
+ ]
19298
+ }
19299
+ }
19309
19300
  },
19310
19301
  ],
19311
19302
  id: "u:4d3a884b437c",
@@ -19318,7 +19309,7 @@ const getNextStepInput = async (instance) => {
19318
19309
  };
19319
19310
 
19320
19311
  //TODO 只有一个处理人时,默认选中,禁止修改. 部分情况不需要显示下一步处理人
19321
- const getNextStepUsersInput = async (instance) => {
19312
+ const getNextStepUsersInput = async (instance, nextStepUserChangeEvents) => {
19322
19313
  if(instance.approve?.type == 'cc'){
19323
19314
  return ;
19324
19315
  }
@@ -19346,7 +19337,15 @@ const getNextStepUsersInput = async (instance) => {
19346
19337
  label: "",
19347
19338
  name: "next_users",
19348
19339
  hiddenOn: "this.new_next_step.deal_type != 'pickupAtRuntime' || this.new_next_step.step_type == 'counterSign'",
19349
- required: true
19340
+ required: true,
19341
+ "onEvent": {
19342
+ "change": {
19343
+ "weight": 0,
19344
+ "actions": [
19345
+ ...nextStepUserChangeEvents
19346
+ ]
19347
+ }
19348
+ }
19350
19349
  },
19351
19350
  {
19352
19351
  type: "steedos-select-user",
@@ -19354,7 +19353,15 @@ const getNextStepUsersInput = async (instance) => {
19354
19353
  name: "next_users",
19355
19354
  hiddenOn: "this.new_next_step.deal_type != 'pickupAtRuntime' || this.new_next_step.step_type != 'counterSign'",
19356
19355
  required: true,
19357
- multiple: true
19356
+ multiple: true,
19357
+ "onEvent": {
19358
+ "change": {
19359
+ "weight": 0,
19360
+ "actions": [
19361
+ ...nextStepUserChangeEvents
19362
+ ]
19363
+ }
19364
+ }
19358
19365
  },
19359
19366
  {
19360
19367
  type: "list-select",
@@ -19399,6 +19406,14 @@ const getNextStepUsersInput = async (instance) => {
19399
19406
  value: '${new_next_step.approver_users}',
19400
19407
  "joinValues": false,
19401
19408
  "extractValue": true,
19409
+ "onEvent": {
19410
+ "change": {
19411
+ "weight": 0,
19412
+ "actions": [
19413
+ ...nextStepUserChangeEvents
19414
+ ]
19415
+ }
19416
+ }
19402
19417
  },
19403
19418
  {
19404
19419
  type: "list-select",
@@ -19443,6 +19458,14 @@ const getNextStepUsersInput = async (instance) => {
19443
19458
  value: '${new_next_step.approver_users}',
19444
19459
  "joinValues": false,
19445
19460
  "extractValue": true,
19461
+ "onEvent": {
19462
+ "change": {
19463
+ "weight": 0,
19464
+ "actions": [
19465
+ ...nextStepUserChangeEvents
19466
+ ]
19467
+ }
19468
+ }
19446
19469
  },
19447
19470
  // {
19448
19471
  // type: "steedos-select-user",
@@ -19512,7 +19535,7 @@ const getPostSubmitRequestAdaptor = async (instance) => {
19512
19535
  const body = {Instances: [{
19513
19536
  _id: "${instance._id}",
19514
19537
  flow: "${instance.flow._id}",
19515
- applicant: formValues.applicant,
19538
+ applicant: formValues.__applicant,
19516
19539
  submitter: formValues.submitter,
19517
19540
  traces: [{
19518
19541
  _id: "${instance.trace._id}",
@@ -19697,10 +19720,11 @@ const getSubmitActions = async (instance, submitEvents) => {
19697
19720
  ];
19698
19721
  };
19699
19722
 
19700
- const getApprovalDrawerSchema = async (instance, submitEvents) => {
19723
+ const getApprovalDrawerSchema = async (instance, events) => {
19724
+ const { submitEvents , nextStepInitedEvents, nextStepChangeEvents, nextStepUserChangeEvents } = events;
19701
19725
  const userId = amisLib.getSteedosAuth().userId;
19702
19726
  const userApprove = getUserApprove({ instance, userId });
19703
- return {
19727
+ const schema = {
19704
19728
  type: "drawer",
19705
19729
  overlay: false,
19706
19730
  resizable: false,
@@ -19718,6 +19742,10 @@ const getApprovalDrawerSchema = async (instance, submitEvents) => {
19718
19742
  body: [
19719
19743
  {
19720
19744
  type: "form",
19745
+ initApi: {
19746
+ method: 'POST',
19747
+ url: '/api/v6/amis/health_check'
19748
+ },
19721
19749
  debug: false,
19722
19750
  id: "instance_approval",
19723
19751
  resetAfterSubmit: true,
@@ -19755,8 +19783,8 @@ const getApprovalDrawerSchema = async (instance, submitEvents) => {
19755
19783
  // }
19756
19784
  // }
19757
19785
  },
19758
- await getNextStepInput(instance),
19759
- await getNextStepUsersInput(instance),
19786
+ await getNextStepInput(instance, nextStepChangeEvents),
19787
+ await getNextStepUsersInput(instance, nextStepUserChangeEvents),
19760
19788
  ],
19761
19789
  onEvent: {
19762
19790
  "approve_judge_change": {
@@ -19769,6 +19797,11 @@ const getApprovalDrawerSchema = async (instance, submitEvents) => {
19769
19797
  }
19770
19798
  ]
19771
19799
  },
19800
+ "inited": {
19801
+ "actions": [
19802
+ ...nextStepInitedEvents
19803
+ ]
19804
+ }
19772
19805
  // "approve_next_step_change": {
19773
19806
  // "actions": [
19774
19807
  // {
@@ -19832,6 +19865,8 @@ const getApprovalDrawerSchema = async (instance, submitEvents) => {
19832
19865
  },
19833
19866
  ]
19834
19867
  };
19868
+ console.log(`getApprovalDrawerSchema: `, schema);
19869
+ return schema;
19835
19870
  };
19836
19871
 
19837
19872
  /*
@@ -20116,15 +20151,22 @@ const getArgumentsList = (func)=>{
20116
20151
  };
20117
20152
 
20118
20153
  const getFieldEditTpl = async (field, label)=>{
20119
- console.log('field',field);
20154
+ // console.log('field',field)
20120
20155
  const tpl = {
20121
20156
  label: label === true ? field.name : false,
20122
20157
  name: field.code,
20123
20158
  mode: "horizontal",
20124
20159
  className: "m-none p-none form-control",
20125
20160
  disabled: field.permission !== "editable",
20126
- required: field.is_required
20161
+ required: field.is_required,
20162
+ visibleOn: field.visibleOn,
20163
+ requiredOn: field.requiredOn
20127
20164
  };
20165
+
20166
+ if(field.formula){
20167
+ tpl.value = `$${field.formula}`;
20168
+ }
20169
+
20128
20170
  if(isOpinionField(field)){
20129
20171
  tpl.type = 'input-group';
20130
20172
  tpl.body = [
@@ -20426,7 +20468,6 @@ const getFieldEditTpl = async (field, label)=>{
20426
20468
  const filters = \`${_.replace(field.filters, /_.pluck/g, '_.map')}\`;
20427
20469
  const url = \`${field.url}\`;
20428
20470
  if(filters){
20429
- console.log('filters', filters);
20430
20471
  const joinKey = url.indexOf('?') > 0 ? '&' : '?';
20431
20472
  if(filters.startsWith('function(') || filters.startsWith('function (')){
20432
20473
  const argsName = ${JSON.stringify(argsName)};
@@ -20448,7 +20489,7 @@ const getFieldEditTpl = async (field, label)=>{
20448
20489
  trackExpression: _.join(_.map(argsName, (item)=>{return `\${${item}|json}`}), '-')
20449
20490
  };
20450
20491
  tpl.isAmis=true;
20451
- console.log(`odata`, tpl);
20492
+ // console.log(`odata`, tpl)
20452
20493
  break;
20453
20494
  case "html":
20454
20495
  if (tpl.disabled) {
@@ -20478,6 +20519,11 @@ const getFieldEditTpl = async (field, label)=>{
20478
20519
  tpl.editable = tpl.addable;
20479
20520
  tpl.copyable = tpl.addable;
20480
20521
  tpl.removable = tpl.addable;
20522
+ if(tpl.addable){
20523
+ tpl.actionData = {
20524
+ "&" : "$$"
20525
+ };
20526
+ }
20481
20527
  // tpl.fieldPrefix = field.name + "_";
20482
20528
  tpl.autoGeneratePrimaryKeyValue = true;
20483
20529
  tpl.fields = [];
@@ -20488,7 +20534,16 @@ const getFieldEditTpl = async (field, label)=>{
20488
20534
  if (sField.type != "hidden") {
20489
20535
  sField.permission = field.permission;
20490
20536
  const column = await getTdInputTpl(sField, true);
20537
+ // console.log('table column', column, sField);
20491
20538
  if(column.type === 'steedos-field'){
20539
+ if(sField.visibleOn){
20540
+ column.config.visibleOn = sField.visibleOn;
20541
+ }
20542
+
20543
+ if(sField.requiredOn){
20544
+ column.config.requiredOn = sField.requiredOn;
20545
+ }
20546
+
20492
20547
  tpl.fields.push(column.config);
20493
20548
  }else {
20494
20549
  tpl.fields.push(column);
@@ -20516,6 +20571,9 @@ const getFieldReadonlyTpl = async (field, label)=>{
20516
20571
  mode: "horizontal",
20517
20572
  className: "m-none p-none form-control",
20518
20573
  };
20574
+ if(field.formula){
20575
+ tpl.value = `$${field.formula}`;
20576
+ }
20519
20577
  if(_$1.includes(['text'], field.type)){
20520
20578
  tpl.type = `static-${field.type}`;
20521
20579
  }else if(field.type === 'select'){
@@ -20636,6 +20694,8 @@ const getTdField = async (field, fieldsCount) => {
20636
20694
  };
20637
20695
 
20638
20696
  const getTdTitle = (field) => {
20697
+ const requiredOn = field.config?.amis.requiredOn;
20698
+ // console.log('getTdTitle', field.is_required , requiredOn, field);
20639
20699
  return {
20640
20700
  className: `td-title td-title-${field.type}`,
20641
20701
  align: field.type != "section" ? "center" : "left",
@@ -20645,7 +20705,8 @@ const getTdTitle = (field) => {
20645
20705
  body: [
20646
20706
  {
20647
20707
  type: "tpl",
20648
- tpl: `<div class='${field.type == "section" ? "font-bold" : ""}'>${field.name || field.code} ${field.is_required ? '<span class="antd-Form-star">*</span>' : ''}</div>`,
20708
+ tpl: `<div class='${field.type == "section" ? "font-bold" : ""}'>${field.name || field.code} <span class="antd-Form-star">*</span></div>`,
20709
+ className: field.is_required ? 'steedos-field-required' : (requiredOn ? {'steedos-field-required' : `${requiredOn}`} : '')
20649
20710
  },
20650
20711
  ],
20651
20712
  // "id": "u:9b001b7ff92d",
@@ -20672,6 +20733,7 @@ const getTds = async (tdFields) => {
20672
20733
  };
20673
20734
 
20674
20735
  const getFormTrs = async (instance) => {
20736
+ // console.log('getFormTrs instance====>', instance);
20675
20737
  const trsSchema = [];
20676
20738
  const trs = [];
20677
20739
  let tdFields = [];
@@ -20826,9 +20888,9 @@ const getFormWizardView = async (instance) => {
20826
20888
  const getApplicantTableView = async (instance) => {
20827
20889
  let applicantInput = null;
20828
20890
  if(instance.state === 'draft'){
20829
- applicantInput = Object.assign({name: "applicant", value: instance.applicant || amisLib.getSteedosAuth().userId, disabled: instance.box !== 'draft'}, await amisLib.lookupToAmis(
20891
+ applicantInput = Object.assign({name: "__applicant", value: instance.applicant || amisLib.getSteedosAuth().userId, disabled: instance.box !== 'draft'}, await amisLib.lookupToAmis(
20830
20892
  {
20831
- name: "applicant",
20893
+ name: "__applicant",
20832
20894
  label: false,
20833
20895
  reference_to: "space_users",
20834
20896
  reference_to_field: 'user',
@@ -20836,7 +20898,31 @@ const getApplicantTableView = async (instance) => {
20836
20898
  },
20837
20899
  false,
20838
20900
  {}
20839
- ));
20901
+ ), {
20902
+ "onEvent": {
20903
+ "change": {
20904
+ "actions": [
20905
+ {
20906
+ "actionType": "ajax",
20907
+ "api": {
20908
+ "url": "/api/formula/user/${__applicant}",
20909
+ "method": "get",
20910
+ "messages": {
20911
+ "success": "",
20912
+ "failed": ""
20913
+ },
20914
+ "silent": true,
20915
+ "adaptor": "return {applicantInfo: payload}"
20916
+ }
20917
+ },
20918
+ {
20919
+ "actionType": "custom",
20920
+ "script": "doAction({'componentId': 'u:instancePage', 'actionType': 'setValue', 'args': { 'value': { 'applicant': event.data.applicantInfo } }}) "
20921
+ }
20922
+ ]
20923
+ }
20924
+ }
20925
+ });
20840
20926
  }else {
20841
20927
  applicantInput = {
20842
20928
  label: false,
@@ -20925,7 +21011,7 @@ const getApplicantTableView = async (instance) => {
20925
21011
  };
20926
21012
  };
20927
21013
 
20928
- const getApproveButton = async (instance, submitEvents)=>{
21014
+ const getApproveButton = async (instance, events)=>{
20929
21015
  if(!instance.approve || ( instance.box != 'inbox' && instance.box != 'draft')){
20930
21016
  return null;
20931
21017
  }
@@ -20939,7 +21025,7 @@ const getApproveButton = async (instance, submitEvents)=>{
20939
21025
  componentId: "",
20940
21026
  args: {},
20941
21027
  actionType: "drawer",
20942
- drawer: await getApprovalDrawerSchema(instance, submitEvents),
21028
+ drawer: await getApprovalDrawerSchema(instance, events),
20943
21029
  },
20944
21030
  ],
20945
21031
  },
@@ -21013,12 +21099,18 @@ const getFlowFormSchema = async (instance, box) => {
21013
21099
  let initedEvents = [];
21014
21100
  let changeEvents = [];
21015
21101
  let submitEvents = [];
21102
+ let nextStepInitedEvents = [];
21103
+ let nextStepChangeEvents = [];
21104
+ let nextStepUserChangeEvents = [];
21016
21105
 
21017
21106
  if(amisSchemaStr){
21018
21107
  const onEvent = JSON.parse(instance.formVersion.amis_schema).onEvent;
21019
- initedEvents = onEvent?.inited.actions || [];
21020
- changeEvents = onEvent?.change.actions || [];
21021
- submitEvents = onEvent?.submit.actions || [];
21108
+ initedEvents = onEvent?.inited?.actions || [];
21109
+ changeEvents = onEvent?.change?.actions || [];
21110
+ submitEvents = onEvent?.submit?.actions || [];
21111
+ nextStepInitedEvents = onEvent?.nextStepInited?.actions || [];
21112
+ nextStepChangeEvents = onEvent?.nextStepChange?.actions || [];
21113
+ nextStepUserChangeEvents = onEvent?.nextStepUserChange.actions || [];
21022
21114
  }
21023
21115
  // if (box == 'inbox' || box == 'draft') {
21024
21116
  // TODO: 临时去掉 AutoOpenApproveDrawer 功能因为测试到性能问题
@@ -21030,7 +21122,7 @@ const getFlowFormSchema = async (instance, box) => {
21030
21122
  "args": {}
21031
21123
  });
21032
21124
  }
21033
-
21125
+ // console.log('formContentSchema....', formContentSchema)
21034
21126
  return {
21035
21127
  type: "page",
21036
21128
  name: "instancePage",
@@ -21106,7 +21198,6 @@ const getFlowFormSchema = async (instance, box) => {
21106
21198
  },
21107
21199
  formContentSchema,
21108
21200
  await getApplicantTableView(instance),
21109
-
21110
21201
  ],
21111
21202
  id: "instance_form",
21112
21203
  onEvent: {
@@ -21133,8 +21224,7 @@ const getFlowFormSchema = async (instance, box) => {
21133
21224
  {
21134
21225
  "actionType": "reload",
21135
21226
  "componentId": "u:next_step",
21136
- "args": {
21137
- }
21227
+ "args": {}
21138
21228
  },
21139
21229
  ...changeEvents
21140
21230
  ]
@@ -21142,7 +21232,7 @@ const getFlowFormSchema = async (instance, box) => {
21142
21232
  }
21143
21233
  },
21144
21234
  await getInstanceApprovalHistory(),
21145
- await getApproveButton(instance, submitEvents)
21235
+ await getApproveButton(instance, { submitEvents , nextStepInitedEvents, nextStepChangeEvents, nextStepUserChangeEvents})
21146
21236
  ],
21147
21237
  id: "u:instancePage",
21148
21238
  messages: {},
@@ -21657,6 +21747,15 @@ const getInstanceInfo = async (props) => {
21657
21747
  };
21658
21748
  };
21659
21749
 
21750
+
21751
+
21752
+ const getApplicant = async (userId) => {
21753
+ const result = await amisLib.fetchAPI(`/api/formula/user/${userId}`, {
21754
+ method: "get"
21755
+ });
21756
+ return result;
21757
+ };
21758
+
21660
21759
  var asc$1 = "Asc";
21661
21760
  var cancel$1 = "Cancel";
21662
21761
  var clear$1 = "Clear";
@@ -22466,6 +22565,7 @@ exports.filtersToConditions = filtersToConditions;
22466
22565
  exports.getAmisInputTableSchema = getAmisInputTableSchema;
22467
22566
  exports.getAmisLocaleResource = getAmisLocaleResource;
22468
22567
  exports.getApp = getApp;
22568
+ exports.getApplicant = getApplicant;
22469
22569
  exports.getApps = getApps;
22470
22570
  exports.getAuthToken = getAuthToken;
22471
22571
  exports.getAuthorization = getAuthorization;