@steedos-widgets/amis-lib 6.3.0-beta.12 → 6.3.0-beta.14

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
@@ -599,7 +599,7 @@ function getNameTpl(field, ctx){
599
599
  }
600
600
  let nameLabel = field.name;
601
601
  //若字段类型是lookup,则按照相关表tpl的label规则显示;若是其它类型,则显示_display或字段本身的值
602
- if (field.type == "lookup") {
602
+ if (field.type == "lookup" || field.type == "master_detail") {
603
603
  if(!field.reference_to && (field.optionsFunction || field._optionsFunction || field.options)){
604
604
  if(!field.isTableField){
605
605
  nameLabel = `\${${field.name}__label}`;
@@ -1851,7 +1851,12 @@ async function getQuickEditSchema(object, columnField, options){
1851
1851
  break;
1852
1852
  case "percent":
1853
1853
  TempDisplayField = `
1854
- _display["${field.name}"] = event.data.value.toFixed(${field.scale}) + '%';
1854
+ if(event.data.value){
1855
+ _display["${field.name}"] = event.data.value.toFixed(${field.scale}) + '%';
1856
+ } else {
1857
+ _display["${field.name}"] = event.data.value;
1858
+ }
1859
+
1855
1860
  `;
1856
1861
  quickEditSchema.body[0].onEvent["change"] = quickEditOnEvent(TempDisplayField);
1857
1862
  break;
@@ -2203,6 +2208,7 @@ async function getColumnItemOnClick(field, options){
2203
2208
  ...recordPage.schema.data,
2204
2209
  "_inDrawer": true, // 用于判断是否在抽屉中
2205
2210
  "recordLoaded": false, // 重置数据加载状态
2211
+ "recordId": `\${${options.idFieldName}}`//审批微页面依赖了作用域中的recordId
2206
2212
  }
2207
2213
  }) : {
2208
2214
  "type": "steedos-record-detail",
@@ -3345,7 +3351,7 @@ function getReadonlyFormAdaptor(object, fields, options){
3345
3351
  var fieldNames = ___namespace.map(fields, function(n){return n.name});
3346
3352
  var nameField = object.fields[object.NAME_FIELD_KEY];
3347
3353
  let nameLabel = nameField && nameField.name;
3348
- if (nameField && nameField.type == "lookup") {
3354
+ if (nameField && (nameField.type == "lookup" || nameField.type == "master_detail")) {
3349
3355
  if(!nameField.reference_to && (nameField.optionsFunction || nameField._optionsFunction || nameField.options)){
3350
3356
  if(!nameField.isTableField){
3351
3357
  nameLabel = `record.${nameField.name}__label`;
@@ -4737,16 +4743,6 @@ const getSchema$5 = async (uiSchema, ctx) => {
4737
4743
  data: formSchema
4738
4744
  };
4739
4745
  `;
4740
- const onDialogCancelScript = `
4741
- // 这里加setTimeout是因为amis的Bug,它会先触发cancel事件执行此脚本关闭父窗口然后再关闭子窗口
4742
- // 正确的顺序应该是先关闭子窗口再关闭父窗口,顺序错了会造成第二次点击新建按钮的时候异常
4743
- setTimeout(function(){
4744
- doAction({
4745
- "actionType": "cancel",
4746
- "componentId": "object_actions_drawer_${uiSchema.name}"
4747
- });
4748
- }, 200);
4749
- `;
4750
4746
  const getSelectedRowsScript = `
4751
4747
  const isLookup = event.data.isLookup;
4752
4748
  if(isLookup){
@@ -4836,17 +4832,6 @@ const getSchema$5 = async (uiSchema, ctx) => {
4836
4832
  "closeOnEsc": false,
4837
4833
  "closeOnOutside": false,
4838
4834
  "size": "lg",
4839
- "onEvent": {
4840
- "cancel": {
4841
- "actions": [
4842
- {
4843
- "actionType": "custom",
4844
- "script": onDialogCancelScript,
4845
- "expression": "${window:innerWidth < 768}",
4846
- }
4847
- ]
4848
- }
4849
- },
4850
4835
  "actions": [
4851
4836
  {
4852
4837
  type: 'button',
@@ -4864,8 +4849,7 @@ const getSchema$5 = async (uiSchema, ctx) => {
4864
4849
  type: 'button',
4865
4850
  actionType: 'confirm',
4866
4851
  label: i18next__default["default"].t('frontend_form_save'),
4867
- primary: true,
4868
- close: `object_actions_drawer_${uiSchema.name}`
4852
+ primary: true
4869
4853
  },
4870
4854
  ]
4871
4855
  }
@@ -4917,16 +4901,6 @@ const getSchema$4 = async (uiSchema, ctx) => {
4917
4901
  : page.schema;
4918
4902
  }
4919
4903
 
4920
- const onDialogCancelScript = `
4921
- // 这里加setTimeout是因为amis的Bug,它会先触发cancel事件执行此脚本关闭父窗口然后再关闭子窗口
4922
- // 正确的顺序应该是先关闭子窗口再关闭父窗口,顺序错了会造成第二次点击编辑按钮的时候异常
4923
- setTimeout(function(){
4924
- doAction({
4925
- "actionType": "cancel",
4926
- "componentId": "object_actions_drawer_${uiSchema.name}"
4927
- });
4928
- }, 200);
4929
- `;
4930
4904
 
4931
4905
  return {
4932
4906
  type: "service",
@@ -4956,17 +4930,6 @@ const getSchema$4 = async (uiSchema, ctx) => {
4956
4930
  "_master.relatedKey": "${relatedKey}"
4957
4931
  },
4958
4932
  size: "lg",
4959
- "onEvent": {
4960
- "cancel": {
4961
- "actions": [
4962
- {
4963
- "actionType": "custom",
4964
- "script": onDialogCancelScript,
4965
- "expression": "${window:innerWidth < 768}",
4966
- }
4967
- ]
4968
- }
4969
- },
4970
4933
  "actions": [
4971
4934
  {
4972
4935
  type: 'button',
@@ -4977,8 +4940,7 @@ const getSchema$4 = async (uiSchema, ctx) => {
4977
4940
  type: 'button',
4978
4941
  actionType: 'confirm',
4979
4942
  label: i18next__default["default"].t('frontend_form_save'),
4980
- primary: true,
4981
- close: `object_actions_drawer_${uiSchema.name}`
4943
+ primary: true
4982
4944
  },
4983
4945
  ]
4984
4946
  },
@@ -5062,8 +5024,7 @@ const getSchema$3 = (uiSchema)=>{
5062
5024
  }
5063
5025
  ]
5064
5026
  }
5065
- },
5066
- "close": `object_actions_drawer_${uiSchema.name}`
5027
+ }
5067
5028
  }
5068
5029
  ],
5069
5030
  "regions": [
@@ -5761,6 +5722,105 @@ const getObjectDetailHeaderButtons = (objectSchema, recordId)=>{
5761
5722
  };
5762
5723
  };
5763
5724
 
5725
+ const getDropdown = (dropdownButtons)=>{
5726
+ const dropdown = {
5727
+ "type": "dropdown-button",
5728
+ "icon": "fa fa-angle-down",
5729
+ "size": "sm",
5730
+ "hideCaret": true,
5731
+ "className": "mr-0 steedos-mobile-header-drop-down",
5732
+ "closeOnClick": true,
5733
+ "menuClassName": "buttons-drawer fixed inset-0 bg-none border-0 shadow-none",
5734
+ "align": "right",
5735
+ "body": [
5736
+ {
5737
+ "type": "action",
5738
+ "style": {
5739
+ "position": "fixed",
5740
+ "top": 0,
5741
+ "right": 0,
5742
+ "bottom": 0,
5743
+ "left": 0,
5744
+ "z-index": 1,
5745
+ "background": "var(--Drawer-overlay-bg)",
5746
+ "height": "unset",
5747
+ "width": "unset",
5748
+ "padding": "0",
5749
+ "margin": "0",
5750
+ "border-radius": "0"
5751
+ }
5752
+ },
5753
+ {
5754
+ "type": "wrapper",
5755
+ "style": {
5756
+ "position": "fixed",
5757
+ "bottom": 0,
5758
+ "z-index": 2,
5759
+ "width": "100vw",
5760
+ "left": "0",
5761
+ "padding": "0",
5762
+ "background": "white",
5763
+ "box-shadow": "0 -10px 10px -10px rgba(0, 0, 0, 0.2)"
5764
+ },
5765
+ "body": [
5766
+ {
5767
+ "type": "flex",
5768
+ "justify": "space-between",
5769
+ "items": [
5770
+ {
5771
+ "type": "tpl",
5772
+ "tpl": "操作",
5773
+ "style": {
5774
+ "padding": "4px 12px",
5775
+ "align-items": "center",
5776
+ "display": "flex"
5777
+ }
5778
+ },
5779
+ {
5780
+ "type": "action",
5781
+ "label": "",
5782
+ "icon": "fa fa-times",
5783
+ "level": "link",
5784
+ "style": {
5785
+ "color": "black"
5786
+ },
5787
+ }
5788
+ ],
5789
+ "style": {
5790
+ "padding-top": "0.5rem",
5791
+ "padding-bottom": "0.5rem",
5792
+ "border-bottom": "var(--Drawer-content-borderWidth) solid var(--Drawer-header-borderColor)"
5793
+ }
5794
+ },
5795
+ {
5796
+ "type": "wrapper",
5797
+ "body": [
5798
+ {
5799
+ "type": "button-group",
5800
+ "id": "u:fd837823be5b",
5801
+ "vertical": true,
5802
+ "tiled": true,
5803
+ "buttons": dropdownButtons,
5804
+ "className": "w-full overflow-auto",
5805
+ "btnClassName": "w-full",
5806
+ "size": "lg"
5807
+ }
5808
+ ],
5809
+ "style": {
5810
+ "padding": "0",
5811
+ "overflow": "auto",
5812
+ "max-height": "70vh"
5813
+ }
5814
+ }
5815
+
5816
+ ]
5817
+ }
5818
+ ]
5819
+ };
5820
+
5821
+ return dropdown;
5822
+ };
5823
+
5764
5824
  const getObjectDetailButtonsSchemas = (objectSchema, recordId, ctx)=>{
5765
5825
  const { buttons, moreButtons, moreButtonsVisibleOn } = getObjectDetailHeaderButtons(objectSchema, recordId);
5766
5826
  if(ctx.formFactor === 'SMALL'){
@@ -5784,46 +5844,7 @@ const getObjectDetailButtonsSchemas = (objectSchema, recordId, ctx)=>{
5784
5844
  }
5785
5845
  });
5786
5846
 
5787
- return [
5788
- {
5789
- "type": "button",
5790
- "icon": "fa fa-angle-down",
5791
- "visibleOn": phoneMoreButtonsVisibleOn,
5792
- "onEvent": {
5793
- "click": {
5794
- "actions": [
5795
- {
5796
- "actionType": "drawer",
5797
- "drawer": {
5798
- "type": "drawer",
5799
- "title": i18next__default["default"].t('frontend_operation'),
5800
- "id": "object_actions_drawer_" + objectSchema.name,
5801
- "body": [
5802
- {
5803
- "type": "button-group",
5804
- "id": "u:fd837823be5b",
5805
- "vertical": true,
5806
- "tiled": true,
5807
- "buttons": dropdownButtons,
5808
- "btnLevel": "enhance",
5809
- "className": "w-full",
5810
- "btnClassName": "w-full",
5811
- "size": "lg"
5812
- }
5813
- ],
5814
- "position": "bottom",
5815
- "closeOnOutside": true,
5816
- "resizable": false,
5817
- "className": "buttons-drawer",
5818
- "bodyClassName": "m-none p-none",
5819
- "actions": []
5820
- }
5821
- }
5822
- ]
5823
- }
5824
- }
5825
- }
5826
- ]
5847
+ return [getDropdown(dropdownButtons)];
5827
5848
  }else {
5828
5849
  if(moreButtons.length > 0){
5829
5850
  const dropdownButtonsSchema = {
@@ -5844,54 +5865,16 @@ const getObjectDetailButtonsSchemas = (objectSchema, recordId, ctx)=>{
5844
5865
  const getObjectListViewButtonsSchemas = (objectSchema, ctx)=>{
5845
5866
  const buttons = getListViewButtons(objectSchema, ctx);
5846
5867
  if(ctx.formFactor === 'SMALL'){
5847
- return {
5848
- "type": "button",
5849
- "icon": "fa fa-angle-down",
5850
- "className": "mr-0",
5851
- "onEvent": {
5852
- "click": {
5853
- "actions": [
5854
- {
5855
- "actionType": "drawer",
5856
- "drawer": {
5857
- "type": "drawer",
5858
- "title": i18next__default["default"].t('frontend_operation'),
5859
- "id": "object_actions_drawer_" + objectSchema.name,
5860
- "body": [
5861
- {
5862
- "type": "button-group",
5863
- "id": "u:fd837823be5b",
5864
- "vertical": true,
5865
- "tiled": true,
5866
- "buttons": [
5867
- ...___namespace.map(buttons, (button)=>{
5868
- return {
5869
- type: 'steedos-object-button',
5870
- name: button.name,
5871
- objectName: button.objectName,
5872
- visibleOn: getButtonVisibleOn(button),
5873
- className: `button_${button.name} w-full`
5874
- }
5875
- })
5876
- ],
5877
- "btnLevel": "enhance",
5878
- "className": "w-full",
5879
- "btnClassName": "w-full",
5880
- "size": "lg"
5881
- }
5882
- ],
5883
- "position": "bottom",
5884
- "closeOnOutside": true,
5885
- "resizable": false,
5886
- "className": "buttons-drawer",
5887
- "bodyClassName": "m-none p-none",
5888
- "actions": []
5889
- }
5890
- }
5891
- ]
5892
- }
5868
+ const dropdownButtons = ___namespace.map(buttons, (button)=>{
5869
+ return {
5870
+ type: 'steedos-object-button',
5871
+ name: button.name,
5872
+ objectName: button.objectName,
5873
+ visibleOn: getButtonVisibleOn(button),
5874
+ className: `button_${button.name} w-full`
5893
5875
  }
5894
- }
5876
+ });
5877
+ return getDropdown(dropdownButtons);
5895
5878
  }else {
5896
5879
  return ___namespace.map(buttons, (button) => {
5897
5880
  return {
@@ -5908,55 +5891,19 @@ const getObjectListViewButtonsSchemas = (objectSchema, ctx)=>{
5908
5891
  const getObjectRecordDetailRelatedListButtonsSchemas = (objectSchema, ctx)=>{
5909
5892
  const buttons = getObjectRelatedListButtons(objectSchema, ctx);
5910
5893
  if(ctx.formFactor === 'SMALL'){
5911
- return {
5912
- "type": "button",
5913
- "icon": "fa fa-angle-down",
5914
- "onEvent": {
5915
- "click": {
5916
- "actions": [
5917
- {
5918
- "actionType": "drawer",
5919
- "drawer": {
5920
- "type": "drawer",
5921
- "title": i18next__default["default"].t('frontend_operation'),
5922
- "id": "object_actions_drawer_" + objectSchema.name,
5923
- "body": [
5924
- {
5925
- "type": "button-group",
5926
- "vertical": true,
5927
- "tiled": true,
5928
- "buttons": [
5929
- ...___namespace.map(buttons, (button)=>{
5930
- return {
5931
- type: 'steedos-object-button',
5932
- name: button.name,
5933
- objectName: button.objectName,
5934
- visibleOn: getButtonVisibleOn(button),
5935
- className: `button_${button.name} w-full`
5936
- }
5937
- })
5938
- ],
5939
- "btnLevel": "enhance",
5940
- "className": "w-full",
5941
- "btnClassName": "w-full",
5942
- "size": "lg"
5943
- }
5944
- ],
5945
- "position": "bottom",
5946
- "closeOnOutside": true,
5947
- "resizable": false,
5948
- "className": "buttons-drawer",
5949
- "bodyClassName": "m-none p-none",
5950
- "actions": []
5951
- }
5952
- }
5953
- ]
5954
- }
5894
+ const dropdownButtons = ___namespace.map(buttons, (button)=>{
5895
+ return {
5896
+ type: 'steedos-object-button',
5897
+ name: button.name,
5898
+ objectName: button.objectName,
5899
+ visibleOn: getButtonVisibleOn(button),
5900
+ className: `button_${button.name} w-full`
5955
5901
  }
5956
- }
5902
+ });
5903
+ return [getDropdown(dropdownButtons)];
5957
5904
  }else {
5958
5905
  return ___namespace.map(buttons, (button) => {
5959
- return {
5906
+ return {
5960
5907
  type: 'steedos-object-button',
5961
5908
  name: button.name,
5962
5909
  objectName: button.objectName,
@@ -10381,7 +10328,7 @@ async function getRecordDetailSchema(objectName, appId, props = {}){
10381
10328
  };
10382
10329
  const content = {
10383
10330
  "type": "tabs",
10384
- "className": "steedos-record-tabs bg-white p-4 m-2 border rounded",
10331
+ "className": "steedos-record-tabs bg-white p-4 sm:m-2 sm:border sm:rounded",
10385
10332
  "contentClassName": "bg-none",
10386
10333
  "tabs": [
10387
10334
  detailed
@@ -13664,17 +13611,17 @@ async function getFormBody(permissionFields, formFields, ctx){
13664
13611
  /*
13665
13612
  * @Author: 殷亮辉 yinlianghui@hotoa.com
13666
13613
  * @Date: 2024-01-18 15:12:41
13667
- * @LastEditors: 殷亮辉 yinlianghui@hotoa.com
13668
- * @LastEditTime: 2024-01-18 15:12:49
13614
+ * @LastEditors: baozhoutao@steedos.com
13615
+ * @LastEditTime: 2024-05-20 13:46:41
13669
13616
  */
13670
13617
  /**
13671
13618
  * 生成符合标准uuid格式的36位满足唯一性的随机串
13672
13619
  * @returns uuid
13673
13620
  */
13674
13621
  function uuidv4() {
13675
- return "10000000-1000-4000-8000-100000000000".replace(/[018]/g, c =>
13676
- (c ^ window.crypto.getRandomValues(new Uint8Array(1))[0] & 15 >> c / 4).toString(16)
13677
- );
13622
+ return "10000000-1000-4000-8000-100000000000".replace(/[018]/g, function (c) {
13623
+ return (c ^ window.crypto.getRandomValues(new Uint8Array(1))[0] & 15 >> c / 4).toString(16);
13624
+ });
13678
13625
  }
13679
13626
 
13680
13627
  /*
@@ -18034,4 +17981,5 @@ exports.setSteedosAuth = setSteedosAuth;
18034
17981
  exports.setUISchemaFunction = setUISchemaFunction;
18035
17982
  exports.setVariable = setVariable;
18036
17983
  exports.standardButtonsTodo = standardButtonsTodo;
17984
+ exports.uuidv4 = uuidv4;
18037
17985
  //# sourceMappingURL=index.cjs.js.map