@steedos-widgets/amis-lib 6.10.3 → 6.10.5

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
@@ -1,5 +1,5 @@
1
1
  import * as _$1 from 'lodash';
2
- import ___default, { isEmpty, isArray, each, find, endsWith, cloneDeep, forEach, includes, trimEnd, has, isBoolean, omitBy, isNil, toArray, mergeWith, get, map, isString, union, slice, defaultsDeep as defaultsDeep$1, isObject as isObject$1, clone, filter, startsWith } from 'lodash';
2
+ import ___default, { isEmpty, isArray, each, find, endsWith, cloneDeep, forEach, includes, trimEnd, has, isBoolean, omitBy, isNil, toArray, mergeWith, get, map, isString, union, slice, defaultsDeep as defaultsDeep$1, isObject as isObject$1, clone, filter, last, groupBy, sortBy, indexOf, startsWith } from 'lodash';
3
3
  import i18next from 'i18next';
4
4
  export { default as i18next } from 'i18next';
5
5
  import { initReactI18next } from 'react-i18next';
@@ -2826,6 +2826,7 @@ var widget_ed = {
2826
2826
  "steedos-field_type_file": "Attachment",
2827
2827
  "steedos-field_type_formula": "Formula",
2828
2828
  "steedos-field_type_summary": "Rollup Summary",
2829
+ "steedos-field_type_approval_comments": "Approval Comments",
2829
2830
  "steedos-field_label": "Display Name",
2830
2831
  "steedos-field_api_name": "API Name",
2831
2832
  "steedos-field_api_name_remark": "The API name can only contain lowercase letters and numbers, must start with a letter, cannot end with an underscore or contain two consecutive underscores.",
@@ -2951,6 +2952,7 @@ var sfield_file = "附件";
2951
2952
  var sfield_formula = "公式";
2952
2953
  var sfield_summary = "累计汇总";
2953
2954
  var sfield_table = "表格";
2955
+ var sfield_approval_comments = "审批意见";
2954
2956
  var sfield_settings_panel_title = "设置";
2955
2957
  var sfield_control_advanced = "高级";
2956
2958
  var sfield_control_general = "通用";
@@ -3123,6 +3125,7 @@ var widget_zh = {
3123
3125
  sfield_formula: sfield_formula,
3124
3126
  sfield_summary: sfield_summary,
3125
3127
  sfield_table: sfield_table,
3128
+ sfield_approval_comments: sfield_approval_comments,
3126
3129
  sfield_settings_panel_title: sfield_settings_panel_title,
3127
3130
  sfield_control_advanced: sfield_control_advanced,
3128
3131
  sfield_control_general: sfield_control_general,
@@ -3610,6 +3613,7 @@ var widget_zh = {
3610
3613
  "steedos-field_type_file": "附件",
3611
3614
  "steedos-field_type_formula": "公式",
3612
3615
  "steedos-field_type_summary": "累计汇总",
3616
+ "steedos-field_type_approval_comments": "审批意见",
3613
3617
  "steedos-field_label": "显示名称",
3614
3618
  "steedos-field_api_name": "API 名称",
3615
3619
  "steedos-field_api_name_remark": "API 名称只能包含小写字母、数字,必须以字母开头,不能以下划线字符结尾或包含两个连续的下划线字符",
@@ -15263,6 +15267,45 @@ const getHtmlFieldSchema = (field, readonly, ctx)=>{
15263
15267
  }
15264
15268
  };
15265
15269
 
15270
+ /*
15271
+ * @Author: 殷亮辉 yinlianghui@hotoa.com
15272
+ * @Date: 2025-11-04 12:00:23
15273
+ * @LastEditors: 殷亮辉 yinlianghui@hotoa.com
15274
+ * @LastEditTime: 2025-11-11 22:01:39
15275
+ */
15276
+
15277
+ function approvalCommentsToAmis(field, readonly, ctx) {
15278
+
15279
+ let approvalComments = `
15280
+ '<div class="instance-sign-item' + (item.is_finished ? ' mt-1' : ' text-gray-500 border-l-2 px-1 border-blue-500 ' + (item.isMyApprove ? 'my-approve' : '') + ' not-finished') + '">' +
15281
+ '<p class="m-0 p-0">' + (item.isMyApprove ? (instance_my_approve_description || item.description || '') : (item.description || '')) + '</p>' +
15282
+ ((item.isMyApprove ? !!(instance_my_approve_description || item.description) : true) ? (item.showApproveSignImage ? item.userSignImage : ('&emsp;&emsp;' + item.handler_name + '&emsp;')) : '') +
15283
+ (item.finishDateFormated || '') +
15284
+ '</div>'`;
15285
+ let html = `
15286
+ \${JOIN(ARRAYMAP(record.approvalCommentsFields["${field.name}"].comments, item => ${approvalComments}), '') || '&emsp;&emsp;'}
15287
+ `;
15288
+ let approvalCommentsSchema = {
15289
+ "type": "wrapper",
15290
+ "className": "instance-sign",
15291
+ "body": [
15292
+ {
15293
+ "type": "tpl",
15294
+ "tpl": html,
15295
+ "className": "instance-sign-content block m-2.5"
15296
+ },
15297
+ // TODO:签批链接,点击弹出填写签批意见,readonly时不显示签批链接
15298
+ ],
15299
+ "size": "none"
15300
+ };
15301
+ let amisSchema = {
15302
+ "type": "control",
15303
+ "label": field.label,
15304
+ "body": [approvalCommentsSchema]
15305
+ };
15306
+ return amisSchema;
15307
+ }
15308
+
15266
15309
  const QUICK_SEARCHABLE_FIELD_TYPES = ["text", "textarea", "autonumber", "url", "email"];
15267
15310
  const OMIT_FIELDS = ['created', 'created_by', 'modified', 'modified_by'];
15268
15311
  // const Lookup = require('./lookup');
@@ -16058,6 +16101,9 @@ async function convertSFieldToAmisField(field, readonly, ctx) {
16058
16101
  }
16059
16102
  }
16060
16103
  break;
16104
+ case 'approval_comments':
16105
+ convertData = approvalCommentsToAmis(field);
16106
+ break;
16061
16107
  }
16062
16108
  if(!_$1.isEmpty(convertData)){
16063
16109
  const className = convertData.className;
@@ -18695,6 +18741,237 @@ var getDefaultRenderData = function () {
18695
18741
  };
18696
18742
  };
18697
18743
 
18744
+ /*
18745
+ * @Author: baozhoutao@steedos.com
18746
+ * @Date: 2022-10-08 16:26:26
18747
+ * @LastEditors: 殷亮辉 yinlianghui@hotoa.com
18748
+ * @LastEditTime: 2025-11-11 21:23:23
18749
+ * @Description:
18750
+ */
18751
+
18752
+ const getTraceApprovesGroupBySteps = (instance, flow) => {
18753
+ if (!instance || !flow) {
18754
+ return {};
18755
+ }
18756
+
18757
+ const steps = flow.steps;
18758
+ const tracesResult = {};
18759
+
18760
+ (instance.traces || []).forEach(trace => {
18761
+ const step = find(steps, s => s._id === trace.step);
18762
+ const approves = [];
18763
+
18764
+ (trace.approves || []).forEach(approve => {
18765
+ let judge_name = '';
18766
+ if (trace.is_finished === true) {
18767
+ if (approve.judge === 'approved') {
18768
+ judge_name = i18next$1.t("Instance State approved");
18769
+ } else if (approve.judge === 'rejected') {
18770
+ judge_name = i18next$1.t("Instance State rejected");
18771
+ } else if (approve.judge === 'terminated') {
18772
+ judge_name = i18next$1.t("Instance State terminated");
18773
+ } else if (approve.judge === 'reassigned') {
18774
+ judge_name = i18next$1.t("Instance State reassigned");
18775
+ } else if (approve.judge === 'relocated') {
18776
+ judge_name = i18next$1.t("Instance State relocated");
18777
+ } else if (!approve.judge) {
18778
+ judge_name = "";
18779
+ } else {
18780
+ judge_name = "";
18781
+ }
18782
+ } else {
18783
+ judge_name = i18next$1.t("Instance State pending");
18784
+ }
18785
+
18786
+ approves.push({
18787
+ _id: approve._id,
18788
+ handler: approve.user,
18789
+ handler_name: approve.handler_name,
18790
+ handler_organization_name: approve.handler_organization_name,
18791
+ handler_organization_fullname: approve.handler_organization_fullname,
18792
+ finish_date: approve.finish_date,
18793
+ judge: approve.judge,
18794
+ judge_name: judge_name,
18795
+ description: approve.description,
18796
+ is_finished: approve.is_finished,
18797
+ type: approve.type,
18798
+ opinion_fields_code: approve.opinion_fields_code,
18799
+ sign_field_code: approve.sign_field_code,
18800
+ is_read: approve.is_read,
18801
+ sign_show: approve.sign_show
18802
+ });
18803
+ });
18804
+
18805
+ if (step) {
18806
+ if (tracesResult.hasOwnProperty(step.name)) {
18807
+ tracesResult[step.name] = tracesResult[step.name].concat(approves);
18808
+ } else {
18809
+ tracesResult[step.name] = approves;
18810
+ }
18811
+ }
18812
+ });
18813
+
18814
+ return tracesResult;
18815
+ };
18816
+
18817
+ const getTraceApprovesByStep = (instance, flow, stepName, only_cc_opinion) => {
18818
+ if (!instance) return [];
18819
+
18820
+ const is_completed = instance?.state === "completed";
18821
+ let completed_date = 0;
18822
+ if (is_completed) {
18823
+ let lastTrace = last(instance.traces);
18824
+ completed_date = lastTrace && lastTrace.finish_date ? (new Date(lastTrace.finish_date)).getTime() : 0;
18825
+ }
18826
+ if (is_completed && instance.finish_date) {
18827
+ completed_date = (new Date(instance.finish_date)).getTime();
18828
+ }
18829
+
18830
+ const tracesObj = getTraceApprovesGroupBySteps(instance, flow);
18831
+
18832
+ let approves = clone(tracesObj[stepName] || []);
18833
+
18834
+ const approve_sort = approvesParam => {
18835
+ return sortBy(approvesParam, approve => {
18836
+ let date = approve.finish_date ? new Date(approve.finish_date) : new Date();
18837
+ return -date.getTime();
18838
+ }) || [];
18839
+ };
18840
+
18841
+ approves = filter(approves, a => a.type !== "forward" && a.type !== "distribute" && a.type !== "terminated");
18842
+
18843
+ if (only_cc_opinion) {
18844
+ approves = filter(approves, a => a.type === "cc");
18845
+ }
18846
+
18847
+ let approves_sorted = approve_sort(approves);
18848
+
18849
+ const approvesGroup = groupBy(approves, "handler");
18850
+
18851
+ function hasNext(approve, group) {
18852
+ const handlerApproves = group[approve.handler];
18853
+ return indexOf(handlerApproves, approve) + 1 < handlerApproves.length;
18854
+ }
18855
+
18856
+ approves_sorted.forEach(approve => {
18857
+ // showBlank为false时,签字字段上配置的默认意见不会生效
18858
+ const showBlank = true;//Meteor.settings.public.workflow?.showBlankApproveDescription;
18859
+ if (
18860
+ approve.sign_show !== false
18861
+ && (approve.description
18862
+ || (!approve.description && !hasNext(approve, approvesGroup) && !approve.is_finished)
18863
+ || showBlank
18864
+ )
18865
+ && approve.judge !== 'terminated'
18866
+ ) {
18867
+ approve._display = true;
18868
+ }
18869
+ });
18870
+
18871
+ approves_sorted = filter(approves_sorted, a => {
18872
+ if (is_completed) {
18873
+ return a._display === true && a.is_finished && a.finish_date && (new Date(a.finish_date)).getTime() <= completed_date;
18874
+ } else {
18875
+ return a._display === true;
18876
+ }
18877
+ });
18878
+
18879
+ return approves_sorted;
18880
+ };
18881
+
18882
+ const isOpinionOfField = (approve, field) => {
18883
+ if (approve.type === "cc" && field.name) {
18884
+ return field.name === approve.sign_field_code;
18885
+ } else {
18886
+ return true;
18887
+ }
18888
+ };
18889
+
18890
+ const isMyApprove = ({ approve, only_cc_opinion, box, currentApprove, field }) => {
18891
+ if (box !== 'inbox') {
18892
+ return false;
18893
+ }
18894
+
18895
+ if (!approve?._id) {
18896
+ approve = currentApprove;
18897
+ }
18898
+
18899
+ if (
18900
+ approve._id === currentApprove?._id &&
18901
+ currentApprove?.type === 'cc' &&
18902
+ field.name
18903
+ ) {
18904
+ return ___default.indexOf(currentApprove?.opinion_fields_code, field.name) > -1;
18905
+ }
18906
+
18907
+ if (!(currentApprove?.type === 'cc') && only_cc_opinion) {
18908
+ return false;
18909
+ }
18910
+
18911
+ if (currentApprove && approve._id === currentApprove._id) {
18912
+ return true;
18913
+ }
18914
+
18915
+ return false;
18916
+ };
18917
+
18918
+ const showApprove = (approve, field) => {
18919
+ if (!approve.sign_field_code || approve.sign_field_code === field.name) {
18920
+ if (approve?.is_read) {
18921
+ if (approve.is_finished) {
18922
+ return ["approved", "rejected", "submitted", "readed"].includes(approve.judge);
18923
+ }
18924
+ }
18925
+ }
18926
+ return false;
18927
+ };
18928
+
18929
+ const isReaded = (judge) => {
18930
+ return ["approved", "rejected", "submitted", "readed"].includes(judge);
18931
+ };
18932
+
18933
+ const showApproveDefaultDescription = (approve) => {
18934
+ if (approve.is_finished && isReaded(approve.judge)) {
18935
+ return true;
18936
+ }
18937
+ return false;
18938
+ };
18939
+
18940
+ const showApproveSignImage = (judge) => {
18941
+ return !['returned', 'terminated', 'retrieved'].includes(judge);
18942
+ };
18943
+
18944
+ const getUserApprove = ({ instance, userId }) => {
18945
+ const currentTrace = find(instance.traces, (trace) => {
18946
+ return trace.is_finished != true;
18947
+ });
18948
+ let currentApprove = null;
18949
+ if (currentTrace) {
18950
+ currentApprove = find(currentTrace.approves, (approve) => {
18951
+ return approve.is_finished != true && approve.handler == userId;
18952
+ });
18953
+ }
18954
+
18955
+ //传阅的approve返回最新一条
18956
+ if (!currentApprove || currentApprove.type == "cc") {
18957
+ // 当前是传阅
18958
+ ___default.each(instance.traces, function (t) {
18959
+ ___default.each(t.approves, function (a) {
18960
+ if (a.type == "cc" && a.handler == userId && a.is_finished == false) {
18961
+ currentApprove = a;
18962
+ }
18963
+ });
18964
+ });
18965
+ }
18966
+
18967
+ if (!currentApprove) return;
18968
+
18969
+ if (currentApprove._id) {
18970
+ currentApprove.id = currentApprove._id;
18971
+ }
18972
+ return currentApprove;
18973
+ };
18974
+
18698
18975
  //TODO Meteor.settings.public?.workflow?.hideCounterSignJudgeOptions
18699
18976
 
18700
18977
  const HIDE_COUNTER_SIGN_JUDGE_OPTIONS = false;
@@ -19263,6 +19540,8 @@ const getSubmitActions = async (instance, submitEvents) => {
19263
19540
  };
19264
19541
 
19265
19542
  const getApprovalDrawerSchema = async (instance, submitEvents) => {
19543
+ const userId = getSteedosAuth$1().userId;
19544
+ const userApprove = getUserApprove({ instance, userId });
19266
19545
  return {
19267
19546
  type: "drawer",
19268
19547
  overlay: false,
@@ -19300,7 +19579,23 @@ const getApprovalDrawerSchema = async (instance, submitEvents) => {
19300
19579
  minRows: 3,
19301
19580
  maxRows: 20,
19302
19581
  placeholder: i18next$1.t('frontend_workflow_suggestion_placeholder'),//"请填写意见",
19303
- requiredOn: "${judge === 'rejected'}"
19582
+ requiredOn: "${judge === 'rejected'}",
19583
+ value: userApprove?.description,
19584
+ "onEvent": {
19585
+ "change": {
19586
+ "actions": [
19587
+ {
19588
+ "componentId": "u:instancePage",
19589
+ "actionType": "setValue",
19590
+ "args": {
19591
+ "value": {
19592
+ "instance_my_approve_description": "${value}"
19593
+ }
19594
+ }
19595
+ }
19596
+ ]
19597
+ }
19598
+ }
19304
19599
  },
19305
19600
  await getNextStepInput(instance),
19306
19601
  await getNextStepUsersInput(instance),
@@ -19326,23 +19621,23 @@ const getApprovalDrawerSchema = async (instance, submitEvents) => {
19326
19621
  // }
19327
19622
  // ]
19328
19623
  // },
19329
- validateError: {
19330
- weight: 0,
19331
- actions: [
19332
- {
19333
- "componentId": "",
19334
- "args": {
19335
- "msgType": "info",
19336
- "position": "top-right",
19337
- "closeButton": true,
19338
- "showIcon": true,
19339
- "title": i18next$1.t('frontend_workflow_submit_validate_error_title'),//"提交失败",
19340
- "msg": i18next$1.t('frontend_workflow_submit_validate_error_msg'),//"请填写必填字段"
19341
- },
19342
- "actionType": "toast"
19343
- }
19344
- ],
19345
- }
19624
+ // validateError: {
19625
+ // weight: 0,
19626
+ // actions: [
19627
+ // {
19628
+ // "componentId": "",
19629
+ // "args": {
19630
+ // "msgType": "info",
19631
+ // "position": "top-right",
19632
+ // "closeButton": true,
19633
+ // "showIcon": true,
19634
+ // "title": i18next.t('frontend_workflow_submit_validate_error_title'),//"提交失败",
19635
+ // "msg": i18next.t('frontend_workflow_submit_validate_error_msg'),//"请填写必填字段"
19636
+ // },
19637
+ // "actionType": "toast"
19638
+ // }
19639
+ // ],
19640
+ // }
19346
19641
  },
19347
19642
 
19348
19643
  },
@@ -19577,7 +19872,7 @@ const getRelatedInstances = async (instance)=>{
19577
19872
  * @Author: baozhoutao@steedos.com
19578
19873
  * @Date: 2022-09-24 16:48:28
19579
19874
  * @LastEditors: 殷亮辉 yinlianghui@hotoa.com
19580
- * @LastEditTime: 2025-08-28 01:38:39
19875
+ * @LastEditTime: 2025-11-03 11:16:43
19581
19876
  * @Description:
19582
19877
  */
19583
19878
 
@@ -19601,19 +19896,19 @@ const getInstanceApprovalHistory = async ()=>{
19601
19896
  "name": "user_name",
19602
19897
  "label": "user_name",
19603
19898
  "type": "tpl",
19604
- "tpl": "<div><div>${opinion}</div>${user_name}</div>"
19899
+ "tpl": "<div><div>${opinion}</div>${user_name|raw}</div>"
19605
19900
  },
19606
19901
  {
19607
19902
  "name": "finish_date",
19608
19903
  "label": "finish_date",
19609
- "classNameExpr": "<%= data.finish_date == i18next.t('frontend_workflow_approval_history_read') ? 'text-[blue]' : (data.finish_date == i18next.t('frontend_workflow_approval_history_unprocessed') ? 'text-[red]' : '') %>"
19904
+ "classNameExpr": `<%= data.finish_date == '${i18next$1.t('frontend_workflow_approval_history_read')}' ? 'text-[blue]' : (data.finish_date == '${i18next$1.t('frontend_workflow_approval_history_unprocessed')}' ? 'text-[red]' : '') %>`
19610
19905
  // "type": "datetime",
19611
19906
  // "format": "YYYY-MM-DD HH:mm"
19612
19907
  },
19613
19908
  {
19614
19909
  "name": "judge",
19615
19910
  "label": "judge",
19616
- "classNameExpr": "<%= data.judge == i18next.t('frontend_workflow_approval_judge_approved') ? 'text-green-600' : (data.judge == i18next.t('frontend_workflow_approval_judge_rejected') ? 'text-[red]' : '') %>"
19911
+ "classNameExpr": `<%= data.judge == '${i18next$1.t('frontend_workflow_approval_judge_approved')}' ? 'text-green-600' : (data.judge == '${i18next$1.t('frontend_workflow_approval_judge_rejected')}' ? 'text-[red]' : '') %>`
19617
19912
  }
19618
19913
  ]
19619
19914
  }
@@ -19623,7 +19918,7 @@ const getInstanceApprovalHistory = async ()=>{
19623
19918
  * @Author: baozhoutao@steedos.com
19624
19919
  * @Date: 2022-09-07 16:20:45
19625
19920
  * @LastEditors: 殷亮辉 yinlianghui@hotoa.com
19626
- * @LastEditTime: 2025-09-08 14:35:29
19921
+ * @LastEditTime: 2025-10-30 13:40:31
19627
19922
  * @Description:
19628
19923
  */
19629
19924
 
@@ -19641,7 +19936,7 @@ const getSelectOptions = (field) => {
19641
19936
  return options;
19642
19937
  };
19643
19938
 
19644
- const isOpinionField$1 = (field)=>{
19939
+ const isOpinionField = (field)=>{
19645
19940
  const field_formula = field.formula;
19646
19941
  return (field_formula?.indexOf("{traces.") > -1 || field_formula?.indexOf("{signature.traces.") > -1 || field_formula?.indexOf("{yijianlan:") > -1 || field_formula?.indexOf("{\"yijianlan\":") > -1 || field_formula?.indexOf("{'yijianlan':") > -1)
19647
19942
  };
@@ -19655,7 +19950,7 @@ const getFieldEditTpl = async (field, label)=>{
19655
19950
  disabled: field.permission !== "editable",
19656
19951
  required: field.is_required
19657
19952
  };
19658
- if(isOpinionField$1(field)){
19953
+ if(isOpinionField(field)){
19659
19954
  tpl.type = 'input-group';
19660
19955
  tpl.body = [
19661
19956
  {
@@ -20453,11 +20748,54 @@ const getApproveButton = async (instance, submitEvents)=>{
20453
20748
  },
20454
20749
  id: "steedos-approve-button",
20455
20750
  level: "primary",
20456
- className:
20457
- "approve-button w-14 h-14 rounded-full fixed bottom-4 right-4 shadow-lg text-white text-base text-center font-semibold bg-blue-500 p-0",
20751
+ className: {
20752
+ "approve-button w-14 h-14 rounded-full fixed bottom-4 right-4 shadow-lg text-white text-base text-center font-semibold bg-blue-500 p-0": true,
20753
+ "hidden": instance.box === 'draft'
20754
+ }
20458
20755
  }
20459
20756
  };
20460
20757
 
20758
+ const getScrollToBottomAutoOpenApproveDrawerScript = () => {
20759
+ return `
20760
+ (function () {
20761
+ setTimeout(function () {
20762
+ var bodyEl = document.querySelector('.steedos-amis-instance-view-body');
20763
+ if (!bodyEl) return;
20764
+ var btn = document.querySelector('.approve-button');
20765
+ if (!btn) return;
20766
+
20767
+ var lastAtBottom = false; // 上一个scroll事件是否到底
20768
+
20769
+ function isAtBottom() {
20770
+ var scrollTop = bodyEl.scrollTop,
20771
+ scrollHeight = bodyEl.scrollHeight,
20772
+ clientHeight = bodyEl.clientHeight;
20773
+ return (scrollHeight <= clientHeight) || (scrollTop + clientHeight >= scrollHeight - 2);
20774
+ }
20775
+
20776
+ // wheel: 只要现在到底、且是向下滚,即可弹出
20777
+ bodyEl.addEventListener('wheel', function (e) {
20778
+ var atBottom = isAtBottom();
20779
+ if (atBottom && e.deltaY > 0) {
20780
+ // [wheel] 拖动条在底部且向下滚,弹drawer
20781
+ btn.click();
20782
+ }
20783
+ });
20784
+
20785
+ // scroll: 拖动时仅“从非底部->底部”瞬间弹
20786
+ bodyEl.addEventListener('scroll', function () {
20787
+ var atBottom = isAtBottom();
20788
+ if (!lastAtBottom && atBottom) {
20789
+ // [scroll] 拖动条到底,弹drawer
20790
+ btn.click();
20791
+ }
20792
+ lastAtBottom = atBottom;
20793
+ });
20794
+ }, 1000);
20795
+ })();
20796
+ `;
20797
+ };
20798
+
20461
20799
  const getFlowFormSchema = async (instance, box) => {
20462
20800
  const formStyle = instance.form.current.style || "table";
20463
20801
  let formContentSchema;
@@ -20480,6 +20818,14 @@ const getFlowFormSchema = async (instance, box) => {
20480
20818
  changeEvents = onEvent?.change.actions || [];
20481
20819
  submitEvents = onEvent?.submit.actions || [];
20482
20820
  }
20821
+ if (box == 'inbox' || box == 'draft') {
20822
+ // 滚动条滚动到底部弹出底部签批drawer窗口
20823
+ initedEvents.push({
20824
+ "actionType": "custom",
20825
+ "script": getScrollToBottomAutoOpenApproveDrawerScript(),
20826
+ "args": {}
20827
+ });
20828
+ }
20483
20829
 
20484
20830
  console.log('getFlowFormSchema formContentSchema', formContentSchema);
20485
20831
  return {
@@ -20561,23 +20907,23 @@ const getFlowFormSchema = async (instance, box) => {
20561
20907
  ],
20562
20908
  id: "instance_form",
20563
20909
  onEvent: {
20564
- validateError: {
20565
- weight: 0,
20566
- actions: [
20567
- {
20568
- "componentId": "",
20569
- "args": {
20570
- "msgType": "info",
20571
- "position": "top-right",
20572
- "closeButton": true,
20573
- "showIcon": true,
20574
- "title": i18next$1.t('frontend_workflow_submit_validate_error_title'),//"提交失败",
20575
- "msg": i18next$1.t('frontend_workflow_submit_validate_error_msg'),//"请填写必填字段"
20576
- },
20577
- "actionType": "toast"
20578
- }
20579
- ],
20580
- },
20910
+ // validateError: {
20911
+ // weight: 0,
20912
+ // actions: [
20913
+ // {
20914
+ // "componentId": "",
20915
+ // "args": {
20916
+ // "msgType": "info",
20917
+ // "position": "top-right",
20918
+ // "closeButton": true,
20919
+ // "showIcon": true,
20920
+ // "title": i18next.t('frontend_workflow_submit_validate_error_title'),//"提交失败",
20921
+ // "msg": i18next.t('frontend_workflow_submit_validate_error_msg'),//"请填写必填字段"
20922
+ // },
20923
+ // "actionType": "toast"
20924
+ // }
20925
+ // ],
20926
+ // },
20581
20927
  change: {
20582
20928
  weight: 0,
20583
20929
  actions: [
@@ -20666,83 +21012,6 @@ const getFlowFormSchema = async (instance, box) => {
20666
21012
  };
20667
21013
  };
20668
21014
 
20669
- /*
20670
- * @Author: baozhoutao@steedos.com
20671
- * @Date: 2022-10-08 16:26:26
20672
- * @LastEditors: baozhoutao@steedos.com
20673
- * @LastEditTime: 2022-10-08 16:28:42
20674
- * @Description:
20675
- */
20676
-
20677
- const isOpinionField = (field_formula)=>{
20678
- return (field_formula?.indexOf("{traces.") > -1 || field_formula?.indexOf("{signature.traces.") > -1 || field_formula?.indexOf("{yijianlan:") > -1 || field_formula?.indexOf("{\"yijianlan\":") > -1 || field_formula?.indexOf("{'yijianlan':") > -1)
20679
- };
20680
-
20681
- const getOpinionFieldStepsName = (field, top_keywords) => {
20682
- const field_formula = field.formula;
20683
- var foo1, opinionFields;
20684
- opinionFields = new Array();
20685
- if (isOpinionField(field_formula)) {
20686
- if (field_formula) {
20687
- foo1 = field_formula.split(";");
20688
- foo1.forEach(function(foo) {
20689
- var json_formula, s1, sf, _ref, _ref1;
20690
- json_formula = {};
20691
- try {
20692
- json_formula = eval("(" + foo + ")");
20693
- } catch (_error) {
20694
- json_formula = {};
20695
- }
20696
- if (json_formula != null ? json_formula.yijianlan : void 0) {
20697
- sf = {};
20698
- sf.stepName = json_formula.yijianlan.step;
20699
- sf.image_sign = json_formula.yijianlan.image_sign || false;
20700
- sf.only_cc_opinion = json_formula.yijianlan.only_cc || false;
20701
- sf.default_description = json_formula.yijianlan["default"];
20702
- sf.only_handler = json_formula.yijianlan.only_handler;
20703
- sf.top_keywords = json_formula.yijianlan.top_keywords || top_keywords;
20704
- return opinionFields.push(sf);
20705
- } else if ((field_formula != null ? field_formula.indexOf("{traces.") : void 0) > -1 || (field_formula != null ? field_formula.indexOf("{signature.traces.") : void 0) > -1) {
20706
- sf = {
20707
- only_cc_opinion: false,
20708
- image_sign: false,
20709
- top_keywords: top_keywords
20710
- };
20711
- if (foo.indexOf("{signature.") > -1) {
20712
- sf.image_sign = true;
20713
- foo = foo.replace("{signature.", "");
20714
- }
20715
- s1 = foo.replace("{", "").replace("}", "");
20716
- if (s1.split(".").length > 1) {
20717
- sf.stepName = s1.split(".")[1];
20718
- if (opinionFields.filterProperty("stepName", sf.stepName).length > 0) {
20719
- if ((_ref = opinionFields.findPropertyByPK("stepName", sf.stepName)) != null) {
20720
- _ref.only_cc_opinion = true;
20721
- }
20722
- } else {
20723
- if (s1.split(".").length > 2) {
20724
- if (((_ref1 = s1.split(".")[2]) != null ? _ref1.toLocaleLowerCase() : void 0) === 'cc') {
20725
- sf.only_cc_opinion = true;
20726
- }
20727
- }
20728
- }
20729
- }
20730
- return opinionFields.push(sf);
20731
- }
20732
- });
20733
- }
20734
- }
20735
- return opinionFields;
20736
- };
20737
-
20738
- /*
20739
- * @Author: baozhoutao@steedos.com
20740
- * @Date: 2022-09-09 17:47:37
20741
- * @LastEditors: 殷亮辉 yinlianghui@hotoa.com
20742
- * @LastEditTime: 2025-09-01 23:33:14
20743
- * @Description:
20744
- */
20745
-
20746
21015
  const getMoment = ()=>{
20747
21016
  if(window.amisRequire){
20748
21017
  return window.amisRequire("moment");
@@ -20757,37 +21026,6 @@ const getTrace = ({ instance, traceId }) => {
20757
21026
  });
20758
21027
  };
20759
21028
 
20760
- const getUserApprove = ({ instance, userId }) => {
20761
- const currentTrace = find(instance.traces, (trace) => {
20762
- return trace.is_finished != true;
20763
- });
20764
- let currentApprove = null;
20765
- if (currentTrace) {
20766
- currentApprove = find(currentTrace.approves, (approve) => {
20767
- return approve.is_finished != true && approve.handler == userId;
20768
- });
20769
- }
20770
-
20771
- //传阅的approve返回最新一条
20772
- if (!currentApprove || currentApprove.type == "cc") {
20773
- // 当前是传阅
20774
- ___default.each(instance.traces, function (t) {
20775
- ___default.each(t.approves, function (a) {
20776
- if (a.type == "cc" && a.handler == userId && a.is_finished == false) {
20777
- currentApprove = a;
20778
- }
20779
- });
20780
- });
20781
- }
20782
-
20783
- if (!currentApprove) return;
20784
-
20785
- if (currentApprove._id) {
20786
- currentApprove.id = currentApprove._id;
20787
- }
20788
- return currentApprove;
20789
- };
20790
-
20791
21029
  const getApproveValues = ({ instance, trace, step, approve, box }) => {
20792
21030
  let instanceValues = null;
20793
21031
  if (!approve || approve.type === "cc") {
@@ -20884,10 +21122,26 @@ const getLastCCStep = ({ traces }, userId) => {
20884
21122
  return step_id;
20885
21123
  };
20886
21124
 
20887
- const isCurrentStepOpinionField = (field, currentStep)=>{
20888
- return ___default.includes(___default.map(getOpinionFieldStepsName(field), 'stepName'), currentStep?.name);
21125
+ const isNeedToShowSignImage = (is_finished, judge, traceShowSignImage) => {
21126
+ if (traceShowSignImage === false) {
21127
+ return false;
21128
+ }
21129
+ if (!is_finished) {
21130
+ return false;
21131
+ }
21132
+ if (['returned', 'terminated', 'retrieved'].includes(judge)) {
21133
+ return false;
21134
+ }
21135
+ return true;
20889
21136
  };
20890
21137
 
21138
+ const getSpaceUserSign = async (space, handler) => {
21139
+ const result = await fetchAPI$1(`/api/v1/space_user_signs?filters=[["space","=","${space}"],["user","=","${handler}"]]&fields=["sign"]`);
21140
+ if (result?.data?.items && result.data.items.length > 0) {
21141
+ return result.data.items[0].sign;
21142
+ }
21143
+ return null;
21144
+ };
20891
21145
 
20892
21146
  const getInstanceInfo = async (props) => {
20893
21147
  const { instanceId, box } = props;
@@ -20940,7 +21194,7 @@ const getInstanceInfo = async (props) => {
20940
21194
  }),
20941
21195
  });
20942
21196
 
20943
-
21197
+ const moment = getMoment();
20944
21198
  let userApprove = null;
20945
21199
  let trace = null;
20946
21200
  let step = null;
@@ -20975,7 +21229,77 @@ const getInstanceInfo = async (props) => {
20975
21229
  method: "get",
20976
21230
  });
20977
21231
 
20978
- const moment = getMoment();
21232
+ const signImageCache = new Map();
21233
+ const approvalCommentsFields = {};
21234
+ ___default.each(formVersion.fields, (field) => {
21235
+ if (field.config?.type === "approval_comments") {
21236
+ approvalCommentsFields[field.code] = ___default.clone(field.config);
21237
+ }
21238
+ if (field.type === 'section') {
21239
+ ___default.each(field.fields, (subField) => {
21240
+ if (subField.config?.type === "approval_comments") {
21241
+ approvalCommentsFields[subField.code] = ___default.clone(subField.config);
21242
+ }
21243
+ });
21244
+ }
21245
+ });
21246
+ const myApproveFields = [];
21247
+ for (const field of ___default.values(approvalCommentsFields)) {
21248
+ const fieldSteps = ___default.clone(field.steps);
21249
+ if (fieldSteps && fieldSteps.length > 0) {
21250
+ let fieldComments = [];
21251
+ for (const fieldStep of fieldSteps) {
21252
+ const only_cc_opinion = fieldStep.show_cc && !fieldStep.show_handler;
21253
+ const stepApproves = getTraceApprovesByStep(instance, flowVersion, fieldStep.name, only_cc_opinion);
21254
+ for (const approve of stepApproves) {
21255
+ let userName = approve.user_name;
21256
+ approve.isOpinionOfField = isOpinionOfField(approve, field);
21257
+ if (approve.isOpinionOfField) {
21258
+ approve.isMyApprove = isMyApprove({ approve, only_cc_opinion, box, currentApprove: userApprove, field });
21259
+ if (approve.isMyApprove) {
21260
+ myApproveFields.push(field);
21261
+ }
21262
+ approve.showApprove = showApprove(approve, field);
21263
+ if (approve.showApprove && !approve.description && fieldStep.default && showApproveDefaultDescription(approve)) {
21264
+ approve.description = fieldStep.default;
21265
+ }
21266
+ if (approve.description){
21267
+ approve.description = approve.description.replace(/\n/g, "<br/>");
21268
+ }
21269
+ if (moment && approve.finish_date){
21270
+ approve.finishDateFormated = moment(approve.finish_date).format("YYYY-MM-DD");
21271
+ }
21272
+ let showSignImage = fieldStep.show_image_sign && showApproveSignImage(approve.judge);
21273
+ if (showSignImage){
21274
+ let userSign, userSignImage;
21275
+ if (signImageCache.has(approve.handler)) {
21276
+ userSign = signImageCache.get(approve.handler);
21277
+ } else {
21278
+ userSign = await getSpaceUserSign(instance.space, approve.handler);
21279
+ signImageCache.set(approve.handler, userSign);
21280
+ }
21281
+ if (userSign){
21282
+ userSignImage = `<img class="image-sign" alt="${userName}" src="/api/v6/files/download/cfs.avatars.filerecord/${userSign}" />`;
21283
+ }
21284
+ approve.showApproveSignImage = !!userSign;
21285
+ approve.userSignImage = userSignImage;
21286
+ }
21287
+ }
21288
+ } fieldComments = ___default.union(fieldComments, stepApproves);
21289
+ } field.comments = fieldComments.filter((comment) => {
21290
+ return comment.isOpinionOfField && (comment.isMyApprove || (comment.showApprove && !!comment.description));
21291
+ });
21292
+ }
21293
+ }
21294
+ if (step?.permissions) {
21295
+ // 字段字段
21296
+ ___default.each(approvalCommentsFields, (field) => {
21297
+ delete step.permissions[field.name];
21298
+ if (___default.find(myApproveFields, { name: field.name })) {
21299
+ step.permissions[field.name] = 'editable';
21300
+ }
21301
+ });
21302
+ }
20979
21303
  return {
20980
21304
  box: box,
20981
21305
  _id: instanceId,
@@ -20994,12 +21318,14 @@ const getInstanceInfo = async (props) => {
20994
21318
  name: instance.name || instance.form.name,
20995
21319
  fields: ___default.map(formVersion.fields, (field) => {
20996
21320
  const newField = Object.assign({}, field, {
20997
- permission: userApprove?.type != 'cc' && (step?.permissions[field.code] || ( isCurrentStepOpinionField(field, step) ? 'editable' : '')),
21321
+ // permission: userApprove?.type != 'cc' && (step?.permissions[field.code] || ( isCurrentStepOpinionField(field, step) ? 'editable' : '')),
21322
+ permission: userApprove?.type != 'cc' && step?.permissions[field.code],
20998
21323
  }) ;
20999
21324
  if(field.type === 'section'){
21000
21325
  newField.fields = ___default.map(field.fields, (sfield) => {
21001
21326
  return Object.assign({}, sfield, {
21002
- permission: userApprove?.type != 'cc' && (step?.permissions[sfield.code] || ( isCurrentStepOpinionField(sfield, step) ? 'editable' : '')),
21327
+ // permission: userApprove?.type != 'cc' && (step?.permissions[sfield.code] || ( isCurrentStepOpinionField(sfield, step) ? 'editable' : '')),
21328
+ permission: userApprove?.type != 'cc' && step?.permissions[sfield.code],
21003
21329
  type: sfield._type || sfield.type
21004
21330
  });
21005
21331
  });
@@ -21019,14 +21345,28 @@ const getInstanceInfo = async (props) => {
21019
21345
  forward_from_instance: instance.forward_from_instance,
21020
21346
  cc_users: instance.cc_users,
21021
21347
  traces: instance.traces,
21022
- historyApproves: ___default.map(instance.traces, (trace) => {
21348
+ historyApproves: await Promise.all(___default.map(instance.traces, async (trace) => {
21023
21349
  return Object.assign(
21024
21350
  {
21025
- children: ___default.map(trace.approves, (approve) => {
21351
+ children: await Promise.all(___default.map(trace.approves, async (approve) => {
21026
21352
  let finishDate = approve.finish_date;
21027
21353
  let judge = approve.judge;
21028
21354
  let userName = approve.user_name;
21029
21355
  let opinion = approve.description;
21356
+ const traceShowSignImage = true;
21357
+ let showSignImage = isNeedToShowSignImage(approve.is_finished, approve.judge, traceShowSignImage);
21358
+ let userSign;
21359
+ if (showSignImage) {
21360
+ if (signImageCache.has(approve.handler)) {
21361
+ userSign = signImageCache.get(approve.handler);
21362
+ } else {
21363
+ userSign = await getSpaceUserSign(instance.space, approve.handler);
21364
+ signImageCache.set(approve.handler, userSign);
21365
+ }
21366
+ if (userSign){
21367
+ userName = `<img class="image-sign" alt="${userName}" src="/api/v6/files/download/cfs.avatars.filerecord/${userSign}" />`;
21368
+ }
21369
+ }
21030
21370
  if(approve.type === 'cc'){
21031
21371
  userName = `${userName} (传阅)`;
21032
21372
  opinion = approve.cc_description;
@@ -21080,11 +21420,12 @@ const getInstanceInfo = async (props) => {
21080
21420
  judge: judge,
21081
21421
  opinion: opinion,
21082
21422
  };
21083
- }),
21423
+ })),
21084
21424
  },
21085
21425
  { name: trace.name, judge: "" }
21086
21426
  );
21087
- }),
21427
+ })),
21428
+ approvalCommentsFields
21088
21429
  };
21089
21430
  };
21090
21431