@steedos-widgets/amis-lib 6.10.34-beta.5 → 6.10.34-beta.7

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
@@ -1241,8 +1241,8 @@ async function getPage({type, pageId = '', appId, objectName = '', recordId = ''
1241
1241
  /*
1242
1242
  * @Author: baozhoutao@steedos.com
1243
1243
  * @Date: 2022-10-28 14:15:09
1244
- * @LastEditors: baozhoutao@steedos.com
1245
- * @LastEditTime: 2025-02-13 09:31:02
1244
+ * @LastEditors: 殷亮辉 yinlianghui@hotoa.com
1245
+ * @LastEditTime: 2025-12-12 16:47:28
1246
1246
  * @Description:
1247
1247
  */
1248
1248
 
@@ -1390,7 +1390,7 @@ const getAmisFileReadonlySchema = async (steedosField,ctx = {})=>{
1390
1390
  // <a href='<%= item.url %>' target='_self' class='block'><%= item.name %></a>
1391
1391
  // <% });} %>`
1392
1392
  "type": "control",
1393
- "name": "",//control若存在name,内部each组件的source则会获取不到内容
1393
+ // "name": "",//control若存在name,内部each组件的source则会获取不到内容 //加上这个空nmae字段会造成列表页面报错 TypeError: Unexpected token } in 1:3,移除后原issue #6977 经测试并没有问题
1394
1394
  "body": {
1395
1395
  type: 'each',
1396
1396
  placeholder: "",
@@ -7354,30 +7354,30 @@ function getObjectListHeaderFirstLine(objectSchema, listViewName, ctx) {
7354
7354
  let amisButtonsSchema = getObjectListViewButtonsSchemas(objectSchema, {formFactor: ctx.formFactor});
7355
7355
  const reg = new RegExp('_', 'g');
7356
7356
  const standardIcon = icon && icon.replace(reg, '-');
7357
- const standardNewButton = _.find(amisButtonsSchema, { name: "standard_new" });
7357
+ _.find(amisButtonsSchema, { name: "standard_new" });
7358
7358
  const buttonSchema = [{
7359
7359
  "type": "flex",
7360
7360
  "items": amisButtonsSchema,
7361
- "visibleOn": "${display == 'split'?false:true}"
7361
+ // "visibleOn": "${display == 'split'?false:true}"
7362
7362
  }];
7363
- if(ctx.formFactor !== 'SMALL'){
7364
- const restButtons = Array.isArray(amisButtonsSchema) ? amisButtonsSchema.filter(obj => obj.name !== "standard_new"):[];
7365
- buttonSchema.push({
7366
- "type": "flex",
7367
- "items":[
7368
- standardNewButton,
7369
- (restButtons.length > 0) && {
7370
- "type": "dropdown-button",
7371
- "buttons": restButtons,
7372
- "className": " ml-1",
7373
- "menuClassName": "p-none split-dropdown-buttons",
7374
- "align": "right",
7375
- "size": "sm"
7376
- }
7377
- ],
7378
- "visibleOn": "${display == 'split'?true:false}"
7379
- });
7380
- }
7363
+ // if(ctx.formFactor !== 'SMALL'){
7364
+ // const restButtons = Array.isArray(amisButtonsSchema) ? amisButtonsSchema.filter(obj => obj.name !== "standard_new"):[]
7365
+ // buttonSchema.push({
7366
+ // "type": "flex",
7367
+ // "items":[
7368
+ // standardNewButton,
7369
+ // (restButtons.length > 0) && {
7370
+ // "type": "dropdown-button",
7371
+ // "buttons": restButtons,
7372
+ // "className": " ml-1",
7373
+ // "menuClassName": "p-none split-dropdown-buttons",
7374
+ // "align": "right",
7375
+ // "size": "sm"
7376
+ // }
7377
+ // ],
7378
+ // "visibleOn": "${display == 'split'?true:false}"
7379
+ // })
7380
+ // }
7381
7381
  const listviewNewButton = getNewListviewButtonSchema();
7382
7382
  listviewNewButton.visibleOn = "global.user.is_space_admin";
7383
7383
  return {
@@ -8780,11 +8780,12 @@ function adaptor(){
8780
8780
  const getSettingListviewToolbarButtonSchema = ()=>{
8781
8781
  return {
8782
8782
  "type": "dropdown-button",
8783
+ "hideCaret": true,
8783
8784
  "trigger": "click",
8784
8785
  "icon": "fa fa-cog",
8785
8786
  //TODO: dropdown-button只支持在按钮上方配置提示,对于上方按钮的点击会有影响,为保持统一,暂时去除,等待amis优化,https://github.com/baidu/amis/issues/7330
8786
8787
  // "tooltip": i18next.t('frontend_button_listview_control_tooltip'),
8787
- "btnClassName": "antd-Button--iconOnly bg-white !p-2 rounded text-gray-500",
8788
+ "btnClassName": "antd-Button--iconOnly bg-white !p-2 rounded !text-gray-500",
8788
8789
  "align": "right",
8789
8790
  "visibleOn": "${!isLookup && !!isObjectListview}",
8790
8791
  "buttons": [
@@ -8827,9 +8828,10 @@ const getDisplayAsButton = function(objectName, defaultEnableSplit){
8827
8828
  return {
8828
8829
  "type": "dropdown-button",
8829
8830
  "icon": "fa fa-table-columns",
8831
+ "hideCaret": true,
8830
8832
  //TODO: dropdown-button只支持在按钮上方配置提示,对于上方按钮的点击会有影响,暂时去除,等待amis优化,https://github.com/baidu/amis/issues/7330
8831
8833
  // "tooltip": `${i18next.t('frontend_display_as')} ${displayAsLabel}`,
8832
- "btnClassName": "antd-Button--iconOnly bg-white !p-2 rounded text-gray-500",
8834
+ "btnClassName": "antd-Button--iconOnly bg-white !p-2 rounded !text-gray-500",
8833
8835
  "align": "right",
8834
8836
  "visibleOn": "${window:innerWidth > 768 && !!!isLookup && !!isObjectListview}",
8835
8837
  "buttons": [
@@ -9055,7 +9057,7 @@ function getObjectHeaderToolbar(mainObject, fields, formFactor, {
9055
9057
  //TODO: dropdown-button只支持在按钮上方配置提示,对于上方按钮的点击会有影响,为保持统一,暂时去除,等待amis优化,https://github.com/baidu/amis/issues/7330
9056
9058
  // "tooltip": i18next.t('frontend_button_reload_tooltip'),
9057
9059
  "tooltipPlacement": "top",
9058
- "className": `bg-white p-2 rounded text-gray-500 list-view-btn-reload ${formFactor === 'SMALL' ? 'hidden' : ''}`,
9060
+ "className": `bg-white p-2 rounded !text-gray-500 list-view-btn-reload ${formFactor === 'SMALL' ? 'hidden' : ''}`,
9059
9061
  "label": "",
9060
9062
  "icon": "fa fa-sync",
9061
9063
  // "visibleOn": "${!showFieldsFilter}",
@@ -9112,7 +9114,7 @@ function getObjectHeaderToolbar(mainObject, fields, formFactor, {
9112
9114
  "visibleOn": "${isFieldsFilterEmpty == false && isLookup != true}"
9113
9115
  },
9114
9116
  "align": "right",
9115
- "className": "bg-white p-2 rounded text-gray-500",
9117
+ "className": "bg-white p-2 rounded !text-gray-500",
9116
9118
  "onEvent": {
9117
9119
  "click": {
9118
9120
  "actions": [
@@ -17164,8 +17166,7 @@ const getNextStepInput = async (instance, nextStepChangeEvents) => {
17164
17166
  required: true,
17165
17167
  // selectFirst: true,
17166
17168
  autoFill: {
17167
- "new_next_step": "${step}",
17168
- "next_users": null
17169
+ "new_next_step": "${step}"
17169
17170
  },
17170
17171
  "source": {
17171
17172
  "url": "/api/workflow/v2/nextStep?judge=${new_judge}",
@@ -19189,6 +19190,24 @@ const getScrollToBottomAutoOpenApproveDrawerScript = () => {
19189
19190
  `;
19190
19191
  };
19191
19192
 
19193
+ const checkInstanceFlowVersion = async (instance) => {
19194
+ const flow = await amisLib.fetchAPI(`/api/v1/flows/${instance.flow._id}?fields=["name","current._id"]`, {
19195
+ method: "get"
19196
+ });
19197
+ if (flow.data.current._id !== instance.flowVersion._id) {
19198
+ console.log("checkInstanceFlowVersion: flow version changed");
19199
+ return false;
19200
+ }
19201
+ const form = await amisLib.fetchAPI(`/api/v1/forms/${instance.form._id}?fields=["name","current._id"]`, {
19202
+ method: "get"
19203
+ });
19204
+ if (form.data.current._id !== instance.formVersion._id) {
19205
+ console.log("checkInstanceFlowVersion: form version changed");
19206
+ return false;
19207
+ }
19208
+ return true;
19209
+ };
19210
+
19192
19211
  const getFlowFormSchema = async (instance, box) => {
19193
19212
  const formStyle = instance.formVersion.style || "table";
19194
19213
  let formContentSchema;
@@ -19216,7 +19235,28 @@ const getFlowFormSchema = async (instance, box) => {
19216
19235
  nextStepChangeEvents = onEvent?.nextStepChange?.actions || [];
19217
19236
  nextStepUserChangeEvents = onEvent?.nextStepUserChange?.actions || [];
19218
19237
  }
19219
- // if (box == 'inbox' || box == 'draft') {
19238
+ if (box == 'draft' && instance.state === 'draft') {
19239
+ // 草稿调用流程版本接口确认是否有新版本,有则调用一次暂存接口,它会提示升级并自动刷新浏览器
19240
+ let isFlowVersionChecked = await checkInstanceFlowVersion(instance);
19241
+ if (!isFlowVersionChecked) {
19242
+ initedEvents.push({
19243
+ "actionType": "ajax",
19244
+ "api": {
19245
+ "url": "/api/workflow/v2/instance/save",
19246
+ "method": "post",
19247
+ "sendOn": "",
19248
+ "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;",
19249
+ "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')};",
19250
+ "headers": {
19251
+ "Authorization": "Bearer ${context.tenantId},${context.authToken}"
19252
+ },
19253
+ "data": {
19254
+ "&": "$$"
19255
+ }
19256
+ }
19257
+ });
19258
+ }
19259
+ }
19220
19260
  if ((box == 'inbox' || box == 'draft') && !!!window.disableAutoOpenApproveDrawer) {
19221
19261
  // 滚动条滚动到底部弹出底部签批drawer窗口
19222
19262
  initedEvents.push({