@steedos-widgets/amis-lib 6.10.26 → 6.10.28

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
@@ -3793,13 +3793,20 @@ function getCalendarRecordPermissionsApi(mainObject, recordId) {
3793
3793
 
3794
3794
  function getCalendarRecordSaveApi(object, calendarOptions) {
3795
3795
  const formData = {};
3796
+ const groups = calendarOptions.groups;
3797
+ const groupFieldName = groups?.[0];
3796
3798
  const idFieldName = object.idFieldName || "_id";
3797
3799
  formData[idFieldName] = "${event.data.event.id}";
3798
3800
  const nameFieldKey = object.NAME_FIELD_KEY || "name";
3799
3801
  formData[nameFieldKey] = "${event.data.event.title}";
3800
3802
  formData[calendarOptions.startDateExpr] = "${event.data.event.start}";
3801
3803
  formData[calendarOptions.endDateExpr] = "${event.data.event.end}";
3802
- formData[calendarOptions.allDayExpr] = "${event.data.event.allDay}";
3804
+ if (calendarOptions.allDayExpr){
3805
+ formData[calendarOptions.allDayExpr] = "${event.data.event.allDay}";
3806
+ }
3807
+ if (groupFieldName){
3808
+ formData[groupFieldName] = "${event.data.event._def.resourceIds[0]}";
3809
+ }
3803
3810
  // formData[calendarOptions.textExpr] = "${event.data.event.title}";
3804
3811
  const apiData = {
3805
3812
  objectName: object.name,
@@ -3846,20 +3853,32 @@ function getCalendarResourcesApi(objectSchema, calendarOptions) {
3846
3853
  const groupFieldName = groups[0];
3847
3854
  const groupField = objectSchema.fields[groupFieldName];
3848
3855
  let groupObjectName = groupField?.reference_to;
3856
+ let groupReferenceToField = groupField?.reference_to_field || "_id";
3849
3857
  if (!groupObjectName){
3850
3858
  return {};
3851
3859
  }
3852
- const fetchFields = [objectSchema.NAME_FIELD_KEY || 'name'];
3860
+ let groupFilters = filters || [];
3861
+ let spaceUsersAdditionalFilters = ["user_accepted", "=", true];
3862
+ if (groupObjectName === "users") {
3863
+ groupObjectName = "space_users";
3864
+ groupReferenceToField = "user";
3865
+ }
3866
+ if (groupObjectName === "space_users") {
3867
+ groupFilters = groupFilters.length > 0 ? [groupFilters, spaceUsersAdditionalFilters] : spaceUsersAdditionalFilters;
3868
+ }
3869
+ const groupObjectConfig = getUISchemaSync(groupObjectName);
3870
+ const groupNameField = groupObjectConfig.NAME_FIELD_KEY || 'name';
3871
+ const fetchFields = [groupNameField, groupReferenceToField];
3853
3872
  if (color) {
3854
3873
  fetchFields.push(color);
3855
3874
  }
3856
3875
  return {
3857
- url: `/api/v1/${groupObjectName}?fields=${JSON.stringify(fetchFields)}&filters=${JSON.stringify(filters || [])}`,
3876
+ url: `/api/v1/${groupObjectName}?fields=${JSON.stringify(fetchFields)}&filters=${JSON.stringify(groupFilters || [])}&top=1000`,
3858
3877
  adaptor: function (payload, response, api, context) {
3859
3878
  const items = payload?.data?.items || [];
3860
3879
  const resources = items.map(item => ({
3861
- id: item._id,
3862
- title: item.name,
3880
+ id: item[groupReferenceToField],
3881
+ title: item[groupNameField],
3863
3882
  eventColor: item.color
3864
3883
  }));
3865
3884
  context.successCallback(resources);
@@ -10402,7 +10421,7 @@ async function getObjectRelatedListsMiniSchema(objectApiName){
10402
10421
  * @Author: baozhoutao@steedos.com
10403
10422
  * @Date: 2022-07-05 15:55:39
10404
10423
  * @LastEditors: 殷亮辉 yinlianghui@hotoa.com
10405
- * @LastEditTime: 2025-12-02 15:56:17
10424
+ * @LastEditTime: 2025-12-04 14:03:00
10406
10425
  * @Description:
10407
10426
  */
10408
10427
 
@@ -10686,6 +10705,13 @@ async function getViewSchema(objectName, recordId, ctx) {
10686
10705
  };
10687
10706
  }
10688
10707
 
10708
+ function isListViewSupported(listView) {
10709
+ if(listView.type === "calendar" || listView.type === "timeline"){
10710
+ return listView.type === "timeline" ? (!!window.BuilderFullCalendarScheduler) : (!!window.BuilderFullCalendar || !!window.BuilderFullCalendarScheduler);
10711
+ }
10712
+ return true;
10713
+ }
10714
+
10689
10715
  // 获取列表视图
10690
10716
  async function getListSchema(
10691
10717
  appName,
@@ -10712,6 +10738,16 @@ async function getListSchema(
10712
10738
  if (!listView) {
10713
10739
  return { uiSchema };
10714
10740
  }
10741
+ if (!isListViewSupported(listView)) {
10742
+ return {
10743
+ uiSchema,
10744
+ amisSchema: {
10745
+ "type": "alert",
10746
+ "body": `当前版本不支持此视图类型`,
10747
+ "level": "warning"
10748
+ }
10749
+ };
10750
+ }
10715
10751
 
10716
10752
  // 直接返回自定义的列表视图schema
10717
10753
  if(listView.enable_amis_schema && listView.amis_schema){
@@ -17589,21 +17625,21 @@ const getApprovalDrawerSchema = async (instance, events) => {
17589
17625
  placeholder: i18next__default.t('frontend_workflow_suggestion_placeholder'),//"请填写意见",
17590
17626
  requiredOn: "${judge === 'rejected'}",
17591
17627
  value: userApprove?.description,
17592
- // "onEvent": {
17593
- // "blur": {
17594
- // "actions": [
17595
- // {
17596
- // "componentId": "u:instancePage",
17597
- // "actionType": "setValue",
17598
- // "args": {
17599
- // "value": {
17600
- // "instance_my_approve_description": "${value}"
17601
- // }
17602
- // }
17603
- // }
17604
- // ]
17605
- // }
17606
- // }
17628
+ "onEvent": {
17629
+ "blur": {
17630
+ "actions": [
17631
+ {
17632
+ "componentId": "u:instancePage",
17633
+ "actionType": "setValue",
17634
+ "args": {
17635
+ "value": {
17636
+ "instance_my_approve_description": "${value}"
17637
+ }
17638
+ }
17639
+ }
17640
+ ]
17641
+ }
17642
+ }
17607
17643
  },
17608
17644
  await getNextStepInput(instance, nextStepChangeEvents),
17609
17645
  await getNextStepUsersInput(instance, nextStepUserChangeEvents),
@@ -17928,7 +17964,7 @@ const getInstanceApprovalHistory = async ()=>{
17928
17964
  * @Author: baozhoutao@steedos.com
17929
17965
  * @Date: 2022-09-07 16:20:45
17930
17966
  * @LastEditors: 殷亮辉 yinlianghui@hotoa.com
17931
- * @LastEditTime: 2025-11-20 20:13:03
17967
+ * @LastEditTime: 2025-12-04 13:47:10
17932
17968
  * @Description:
17933
17969
  */
17934
17970
 
@@ -17979,7 +18015,9 @@ const getFieldEditTpl = async (field, label)=>{
17979
18015
  visibleOn: field.visibleOn,
17980
18016
  requiredOn: field.requiredOn
17981
18017
  };
17982
-
18018
+ if(field.default_value){
18019
+ tpl.value = field.default_value;
18020
+ }
17983
18021
  if(isOpinionField(field)){
17984
18022
  tpl.type = 'input-group';
17985
18023
  tpl.body = [
@@ -18379,7 +18417,7 @@ const getFieldEditTpl = async (field, label)=>{
18379
18417
  break;
18380
18418
  }
18381
18419
  }
18382
- // console.log('getFieldEditTpl ', label, tpl)
18420
+ console.log('getFieldEditTpl ', label, tpl, field);
18383
18421
  return tpl;
18384
18422
  };
18385
18423
 
@@ -18721,6 +18759,22 @@ const getApplicantTableView = async (instance) => {
18721
18759
  "onEvent": {
18722
18760
  "change": {
18723
18761
  "actions": [
18762
+ {
18763
+ "actionType": "ajax",
18764
+ "api": {
18765
+ "url": "/api/workflow/v2/instance/save",
18766
+ "method": "post",
18767
+ "sendOn": "",
18768
+ "requestAdaptor": "var _SteedosUI$getRef$get, _approveValues$next_s;\nconst formValues = context._scoped.getComponentById(\"instance_form\").getValues(); const _formValues = JSON.parse(JSON.stringify(formValues)); if(_formValues){delete _formValues.__applicant} \nconst approveValues = (_SteedosUI$getRef$get = context._scoped.getComponentById(\"instance_approval\")) === null || _SteedosUI$getRef$get === void 0 ? void 0 : _SteedosUI$getRef$get.getValues();\nlet nextUsers = approveValues === null || approveValues === void 0 ? void 0 : approveValues.next_users;\nif (_.isString(nextUsers)) {\n nextUsers = [approveValues.next_users];\n}\nconst instance = context.record;\nconst body = {\n instance: {\n _id: instance._id,\n applicant: context.__applicant,\n submitter: formValues.submitter,\n traces: [{\n _id: instance.trace._id,\n step: instance.step._id,\n approves: [{\n _id: instance.approve._id,\n next_steps: [{\n step: approveValues === null || approveValues === void 0 || (_approveValues$next_s = approveValues.next_step) === null || _approveValues$next_s === void 0 ? void 0 : _approveValues$next_s._id,\n users: nextUsers\n }],\n description: approveValues === null || approveValues === void 0 ? void 0 : approveValues.suggestion,\n values: _formValues\n }]\n }]\n }\n};\napi.data = body;\nreturn api;",
18769
+ "adaptor": "if (payload.instance == \"upgraded\") { window.setTimeout(function(){ window.location.reload(); }, 2000); return {...payload, status: 1, msg: t('instance_action_instance_save_msg_upgraded')}; } \n return payload.instance === true ? {...payload, status: 0, msg: ''} : {...payload, status: 1, msg: t('instance_action_instance_save_msg_failed')};",
18770
+ "headers": {
18771
+ "Authorization": "Bearer ${context.tenantId},${context.authToken}"
18772
+ },
18773
+ "data": {
18774
+ "&": "$$"
18775
+ }
18776
+ }
18777
+ },
18724
18778
  {
18725
18779
  "actionType": "ajax",
18726
18780
  "api": {
@@ -18753,7 +18807,7 @@ const getApplicantTableView = async (instance) => {
18753
18807
  id: "u:2016b04355f4",
18754
18808
  };
18755
18809
  }
18756
-
18810
+ // console.log('applicantInput', applicantInput);
18757
18811
  if(applicantInput){
18758
18812
  if(applicantInput.className){
18759
18813
  applicantInput.className = `${applicantInput.className} inline-left`;
@@ -18932,8 +18986,7 @@ const getFlowFormSchema = async (instance, box) => {
18932
18986
  nextStepUserChangeEvents = onEvent?.nextStepUserChange?.actions || [];
18933
18987
  }
18934
18988
  // if (box == 'inbox' || box == 'draft') {
18935
- // TODO: 临时去掉 AutoOpenApproveDrawer 功能因为测试到性能问题
18936
- if ((box == 'inbox' || box == 'draft') && window.enableAutoOpenApproveDrawer) {
18989
+ if ((box == 'inbox' || box == 'draft') && !!!window.disableAutoOpenApproveDrawer) {
18937
18990
  // 滚动条滚动到底部弹出底部签批drawer窗口
18938
18991
  initedEvents.push({
18939
18992
  "actionType": "custom",
@@ -21838,6 +21891,17 @@ var widget_zh = {
21838
21891
  * @LastEditTime: 2025-08-26 10:17:05
21839
21892
  */
21840
21893
 
21894
+ const resources = {
21895
+ "en": {
21896
+ translation: en_us$1,
21897
+ 'widgets-meta': widget_en
21898
+ },
21899
+ "zh-CN": {
21900
+ translation: zh_cn$1,
21901
+ 'widgets-meta': widget_zh
21902
+ }
21903
+ };
21904
+
21841
21905
  const getUserLanguage$1 = () => {
21842
21906
  var lan = Builder.settings.context?.user?.language || Builder.settings.locale || window.navigator.language;
21843
21907
  if(lan === 'en' || lan.startsWith('en-')){
@@ -21845,15 +21909,33 @@ const getUserLanguage$1 = () => {
21845
21909
  }
21846
21910
  return lan;
21847
21911
  };
21912
+
21913
+ var locale$1 = "zh-CN";
21848
21914
  if (typeof window != 'undefined') {
21849
21915
  window.steedosI18next = i18next;
21850
- getUserLanguage$1();
21916
+ // locale = getUserLanguage();
21851
21917
  }
21852
21918
 
21853
- i18next.addResources('en', 'translation', en_us$1);
21854
- i18next.addResources('en', 'widgets-meta', widget_en);
21855
- i18next.addResources('zh-CN', 'translation', zh_cn$1);
21856
- i18next.addResources('zh-CN', 'widgets-meta', widget_zh);
21919
+ if (!i18next.isInitialized) {
21920
+ i18next
21921
+ // .use(LanguageDetector)
21922
+ .init({
21923
+ // lng: locale,
21924
+ fallbackLng: 'zh-CN',
21925
+ resources,
21926
+ }, ()=>{
21927
+ console.log("i18next initialized:", locale$1);
21928
+ // i18next.addResources('en', 'translation', en_us);
21929
+ // i18next.addResources('en', 'widgets-meta', widget_en);
21930
+ // i18next.addResources('zh-CN', 'translation', zh_cn);
21931
+ // i18next.addResources('zh-CN', 'widgets-meta', widget_zh);
21932
+ });
21933
+ } else {
21934
+ i18next.addResources('en', 'translation', en_us$1);
21935
+ i18next.addResources('en', 'widgets-meta', widget_en);
21936
+ i18next.addResources('zh-CN', 'translation', zh_cn$1);
21937
+ i18next.addResources('zh-CN', 'widgets-meta', widget_zh);
21938
+ }
21857
21939
 
21858
21940
  var asc$1 = "Asc";
21859
21941
  var cancel$1 = "Cancel";