@steedos-widgets/amis-lib 6.10.4 → 6.10.6

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 名称只能包含小写字母、数字,必须以字母开头,不能以下划线字符结尾或包含两个连续的下划线字符",
@@ -5792,10 +5796,14 @@ function getBatchDelete(objectName){
5792
5796
  if(payload.errors){
5793
5797
  payload.data.deleteErrorMessage = [];
5794
5798
  payload.errors.forEach(function(error){
5795
- let errorRecord = error.path.map(function (item) {
5796
- return item.split('delete__')[1].to_float() + 1;
5797
- }).toString();
5798
- payload.data.deleteErrorMessage.push("第" + errorRecord + "条记录删除出现异常,报错信息为(" + (window.t ? window.t(error.message) : error.message) + ")");
5799
+ try {
5800
+ let errorRecord = error.path.map(function (item) {
5801
+ return item.split('delete__')[1].to_float() + 1;
5802
+ }).toString();
5803
+ payload.data.deleteErrorMessage.push("第" + errorRecord + "条记录删除出现异常,报错信息为(" + (window.t ? window.t(error.message) : error.message) + ")");
5804
+ } catch (error) {
5805
+ console.llg(error)
5806
+ }
5799
5807
  })
5800
5808
  }
5801
5809
  return payload;
@@ -15263,6 +15271,45 @@ const getHtmlFieldSchema = (field, readonly, ctx)=>{
15263
15271
  }
15264
15272
  };
15265
15273
 
15274
+ /*
15275
+ * @Author: 殷亮辉 yinlianghui@hotoa.com
15276
+ * @Date: 2025-11-04 12:00:23
15277
+ * @LastEditors: 殷亮辉 yinlianghui@hotoa.com
15278
+ * @LastEditTime: 2025-11-11 22:01:39
15279
+ */
15280
+
15281
+ function approvalCommentsToAmis(field, readonly, ctx) {
15282
+
15283
+ let approvalComments = `
15284
+ '<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') + '">' +
15285
+ '<p class="m-0 p-0">' + (item.isMyApprove ? (instance_my_approve_description || item.description || '') : (item.description || '')) + '</p>' +
15286
+ ((item.isMyApprove ? !!(instance_my_approve_description || item.description) : true) ? (item.showApproveSignImage ? item.userSignImage : ('&emsp;&emsp;' + item.handler_name + '&emsp;')) : '') +
15287
+ (item.finishDateFormated || '') +
15288
+ '</div>'`;
15289
+ let html = `
15290
+ \${JOIN(ARRAYMAP(record.approvalCommentsFields["${field.name}"].comments, item => ${approvalComments}), '') || '&emsp;&emsp;'}
15291
+ `;
15292
+ let approvalCommentsSchema = {
15293
+ "type": "wrapper",
15294
+ "className": "instance-sign",
15295
+ "body": [
15296
+ {
15297
+ "type": "tpl",
15298
+ "tpl": html,
15299
+ "className": "instance-sign-content block m-2.5"
15300
+ },
15301
+ // TODO:签批链接,点击弹出填写签批意见,readonly时不显示签批链接
15302
+ ],
15303
+ "size": "none"
15304
+ };
15305
+ let amisSchema = {
15306
+ "type": "control",
15307
+ "label": field.label,
15308
+ "body": [approvalCommentsSchema]
15309
+ };
15310
+ return amisSchema;
15311
+ }
15312
+
15266
15313
  const QUICK_SEARCHABLE_FIELD_TYPES = ["text", "textarea", "autonumber", "url", "email"];
15267
15314
  const OMIT_FIELDS = ['created', 'created_by', 'modified', 'modified_by'];
15268
15315
  // const Lookup = require('./lookup');
@@ -16058,6 +16105,9 @@ async function convertSFieldToAmisField(field, readonly, ctx) {
16058
16105
  }
16059
16106
  }
16060
16107
  break;
16108
+ case 'approval_comments':
16109
+ convertData = approvalCommentsToAmis(field);
16110
+ break;
16061
16111
  }
16062
16112
  if(!_$1.isEmpty(convertData)){
16063
16113
  const className = convertData.className;
@@ -18695,6 +18745,237 @@ var getDefaultRenderData = function () {
18695
18745
  };
18696
18746
  };
18697
18747
 
18748
+ /*
18749
+ * @Author: baozhoutao@steedos.com
18750
+ * @Date: 2022-10-08 16:26:26
18751
+ * @LastEditors: 殷亮辉 yinlianghui@hotoa.com
18752
+ * @LastEditTime: 2025-11-11 21:23:23
18753
+ * @Description:
18754
+ */
18755
+
18756
+ const getTraceApprovesGroupBySteps = (instance, flow) => {
18757
+ if (!instance || !flow) {
18758
+ return {};
18759
+ }
18760
+
18761
+ const steps = flow.steps;
18762
+ const tracesResult = {};
18763
+
18764
+ (instance.traces || []).forEach(trace => {
18765
+ const step = find(steps, s => s._id === trace.step);
18766
+ const approves = [];
18767
+
18768
+ (trace.approves || []).forEach(approve => {
18769
+ let judge_name = '';
18770
+ if (trace.is_finished === true) {
18771
+ if (approve.judge === 'approved') {
18772
+ judge_name = i18next$1.t("Instance State approved");
18773
+ } else if (approve.judge === 'rejected') {
18774
+ judge_name = i18next$1.t("Instance State rejected");
18775
+ } else if (approve.judge === 'terminated') {
18776
+ judge_name = i18next$1.t("Instance State terminated");
18777
+ } else if (approve.judge === 'reassigned') {
18778
+ judge_name = i18next$1.t("Instance State reassigned");
18779
+ } else if (approve.judge === 'relocated') {
18780
+ judge_name = i18next$1.t("Instance State relocated");
18781
+ } else if (!approve.judge) {
18782
+ judge_name = "";
18783
+ } else {
18784
+ judge_name = "";
18785
+ }
18786
+ } else {
18787
+ judge_name = i18next$1.t("Instance State pending");
18788
+ }
18789
+
18790
+ approves.push({
18791
+ _id: approve._id,
18792
+ handler: approve.user,
18793
+ handler_name: approve.handler_name,
18794
+ handler_organization_name: approve.handler_organization_name,
18795
+ handler_organization_fullname: approve.handler_organization_fullname,
18796
+ finish_date: approve.finish_date,
18797
+ judge: approve.judge,
18798
+ judge_name: judge_name,
18799
+ description: approve.description,
18800
+ is_finished: approve.is_finished,
18801
+ type: approve.type,
18802
+ opinion_fields_code: approve.opinion_fields_code,
18803
+ sign_field_code: approve.sign_field_code,
18804
+ is_read: approve.is_read,
18805
+ sign_show: approve.sign_show
18806
+ });
18807
+ });
18808
+
18809
+ if (step) {
18810
+ if (tracesResult.hasOwnProperty(step.name)) {
18811
+ tracesResult[step.name] = tracesResult[step.name].concat(approves);
18812
+ } else {
18813
+ tracesResult[step.name] = approves;
18814
+ }
18815
+ }
18816
+ });
18817
+
18818
+ return tracesResult;
18819
+ };
18820
+
18821
+ const getTraceApprovesByStep = (instance, flow, stepName, only_cc_opinion) => {
18822
+ if (!instance) return [];
18823
+
18824
+ const is_completed = instance?.state === "completed";
18825
+ let completed_date = 0;
18826
+ if (is_completed) {
18827
+ let lastTrace = last(instance.traces);
18828
+ completed_date = lastTrace && lastTrace.finish_date ? (new Date(lastTrace.finish_date)).getTime() : 0;
18829
+ }
18830
+ if (is_completed && instance.finish_date) {
18831
+ completed_date = (new Date(instance.finish_date)).getTime();
18832
+ }
18833
+
18834
+ const tracesObj = getTraceApprovesGroupBySteps(instance, flow);
18835
+
18836
+ let approves = clone(tracesObj[stepName] || []);
18837
+
18838
+ const approve_sort = approvesParam => {
18839
+ return sortBy(approvesParam, approve => {
18840
+ let date = approve.finish_date ? new Date(approve.finish_date) : new Date();
18841
+ return -date.getTime();
18842
+ }) || [];
18843
+ };
18844
+
18845
+ approves = filter(approves, a => a.type !== "forward" && a.type !== "distribute" && a.type !== "terminated");
18846
+
18847
+ if (only_cc_opinion) {
18848
+ approves = filter(approves, a => a.type === "cc");
18849
+ }
18850
+
18851
+ let approves_sorted = approve_sort(approves);
18852
+
18853
+ const approvesGroup = groupBy(approves, "handler");
18854
+
18855
+ function hasNext(approve, group) {
18856
+ const handlerApproves = group[approve.handler];
18857
+ return indexOf(handlerApproves, approve) + 1 < handlerApproves.length;
18858
+ }
18859
+
18860
+ approves_sorted.forEach(approve => {
18861
+ // showBlank为false时,签字字段上配置的默认意见不会生效
18862
+ const showBlank = true;//Meteor.settings.public.workflow?.showBlankApproveDescription;
18863
+ if (
18864
+ approve.sign_show !== false
18865
+ && (approve.description
18866
+ || (!approve.description && !hasNext(approve, approvesGroup) && !approve.is_finished)
18867
+ || showBlank
18868
+ )
18869
+ && approve.judge !== 'terminated'
18870
+ ) {
18871
+ approve._display = true;
18872
+ }
18873
+ });
18874
+
18875
+ approves_sorted = filter(approves_sorted, a => {
18876
+ if (is_completed) {
18877
+ return a._display === true && a.is_finished && a.finish_date && (new Date(a.finish_date)).getTime() <= completed_date;
18878
+ } else {
18879
+ return a._display === true;
18880
+ }
18881
+ });
18882
+
18883
+ return approves_sorted;
18884
+ };
18885
+
18886
+ const isOpinionOfField = (approve, field) => {
18887
+ if (approve.type === "cc" && field.name) {
18888
+ return field.name === approve.sign_field_code;
18889
+ } else {
18890
+ return true;
18891
+ }
18892
+ };
18893
+
18894
+ const isMyApprove = ({ approve, only_cc_opinion, box, currentApprove, field }) => {
18895
+ if (box !== 'inbox') {
18896
+ return false;
18897
+ }
18898
+
18899
+ if (!approve?._id) {
18900
+ approve = currentApprove;
18901
+ }
18902
+
18903
+ if (
18904
+ approve._id === currentApprove?._id &&
18905
+ currentApprove?.type === 'cc' &&
18906
+ field.name
18907
+ ) {
18908
+ return ___default.indexOf(currentApprove?.opinion_fields_code, field.name) > -1;
18909
+ }
18910
+
18911
+ if (!(currentApprove?.type === 'cc') && only_cc_opinion) {
18912
+ return false;
18913
+ }
18914
+
18915
+ if (currentApprove && approve._id === currentApprove._id) {
18916
+ return true;
18917
+ }
18918
+
18919
+ return false;
18920
+ };
18921
+
18922
+ const showApprove = (approve, field) => {
18923
+ if (!approve.sign_field_code || approve.sign_field_code === field.name) {
18924
+ if (approve?.is_read) {
18925
+ if (approve.is_finished) {
18926
+ return ["approved", "rejected", "submitted", "readed"].includes(approve.judge);
18927
+ }
18928
+ }
18929
+ }
18930
+ return false;
18931
+ };
18932
+
18933
+ const isReaded = (judge) => {
18934
+ return ["approved", "rejected", "submitted", "readed"].includes(judge);
18935
+ };
18936
+
18937
+ const showApproveDefaultDescription = (approve) => {
18938
+ if (approve.is_finished && isReaded(approve.judge)) {
18939
+ return true;
18940
+ }
18941
+ return false;
18942
+ };
18943
+
18944
+ const showApproveSignImage = (judge) => {
18945
+ return !['returned', 'terminated', 'retrieved'].includes(judge);
18946
+ };
18947
+
18948
+ const getUserApprove = ({ instance, userId }) => {
18949
+ const currentTrace = find(instance.traces, (trace) => {
18950
+ return trace.is_finished != true;
18951
+ });
18952
+ let currentApprove = null;
18953
+ if (currentTrace) {
18954
+ currentApprove = find(currentTrace.approves, (approve) => {
18955
+ return approve.is_finished != true && approve.handler == userId;
18956
+ });
18957
+ }
18958
+
18959
+ //传阅的approve返回最新一条
18960
+ if (!currentApprove || currentApprove.type == "cc") {
18961
+ // 当前是传阅
18962
+ ___default.each(instance.traces, function (t) {
18963
+ ___default.each(t.approves, function (a) {
18964
+ if (a.type == "cc" && a.handler == userId && a.is_finished == false) {
18965
+ currentApprove = a;
18966
+ }
18967
+ });
18968
+ });
18969
+ }
18970
+
18971
+ if (!currentApprove) return;
18972
+
18973
+ if (currentApprove._id) {
18974
+ currentApprove.id = currentApprove._id;
18975
+ }
18976
+ return currentApprove;
18977
+ };
18978
+
18698
18979
  //TODO Meteor.settings.public?.workflow?.hideCounterSignJudgeOptions
18699
18980
 
18700
18981
  const HIDE_COUNTER_SIGN_JUDGE_OPTIONS = false;
@@ -19263,6 +19544,8 @@ const getSubmitActions = async (instance, submitEvents) => {
19263
19544
  };
19264
19545
 
19265
19546
  const getApprovalDrawerSchema = async (instance, submitEvents) => {
19547
+ const userId = getSteedosAuth$1().userId;
19548
+ const userApprove = getUserApprove({ instance, userId });
19266
19549
  return {
19267
19550
  type: "drawer",
19268
19551
  overlay: false,
@@ -19300,7 +19583,23 @@ const getApprovalDrawerSchema = async (instance, submitEvents) => {
19300
19583
  minRows: 3,
19301
19584
  maxRows: 20,
19302
19585
  placeholder: i18next$1.t('frontend_workflow_suggestion_placeholder'),//"请填写意见",
19303
- requiredOn: "${judge === 'rejected'}"
19586
+ requiredOn: "${judge === 'rejected'}",
19587
+ value: userApprove?.description,
19588
+ "onEvent": {
19589
+ "change": {
19590
+ "actions": [
19591
+ {
19592
+ "componentId": "u:instancePage",
19593
+ "actionType": "setValue",
19594
+ "args": {
19595
+ "value": {
19596
+ "instance_my_approve_description": "${value}"
19597
+ }
19598
+ }
19599
+ }
19600
+ ]
19601
+ }
19602
+ }
19304
19603
  },
19305
19604
  await getNextStepInput(instance),
19306
19605
  await getNextStepUsersInput(instance),
@@ -19641,7 +19940,7 @@ const getSelectOptions = (field) => {
19641
19940
  return options;
19642
19941
  };
19643
19942
 
19644
- const isOpinionField$1 = (field)=>{
19943
+ const isOpinionField = (field)=>{
19645
19944
  const field_formula = field.formula;
19646
19945
  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
19946
  };
@@ -19655,7 +19954,7 @@ const getFieldEditTpl = async (field, label)=>{
19655
19954
  disabled: field.permission !== "editable",
19656
19955
  required: field.is_required
19657
19956
  };
19658
- if(isOpinionField$1(field)){
19957
+ if(isOpinionField(field)){
19659
19958
  tpl.type = 'input-group';
19660
19959
  tpl.body = [
19661
19960
  {
@@ -20717,83 +21016,6 @@ const getFlowFormSchema = async (instance, box) => {
20717
21016
  };
20718
21017
  };
20719
21018
 
20720
- /*
20721
- * @Author: baozhoutao@steedos.com
20722
- * @Date: 2022-10-08 16:26:26
20723
- * @LastEditors: baozhoutao@steedos.com
20724
- * @LastEditTime: 2022-10-08 16:28:42
20725
- * @Description:
20726
- */
20727
-
20728
- const isOpinionField = (field_formula)=>{
20729
- 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)
20730
- };
20731
-
20732
- const getOpinionFieldStepsName = (field, top_keywords) => {
20733
- const field_formula = field.formula;
20734
- var foo1, opinionFields;
20735
- opinionFields = new Array();
20736
- if (isOpinionField(field_formula)) {
20737
- if (field_formula) {
20738
- foo1 = field_formula.split(";");
20739
- foo1.forEach(function(foo) {
20740
- var json_formula, s1, sf, _ref, _ref1;
20741
- json_formula = {};
20742
- try {
20743
- json_formula = eval("(" + foo + ")");
20744
- } catch (_error) {
20745
- json_formula = {};
20746
- }
20747
- if (json_formula != null ? json_formula.yijianlan : void 0) {
20748
- sf = {};
20749
- sf.stepName = json_formula.yijianlan.step;
20750
- sf.image_sign = json_formula.yijianlan.image_sign || false;
20751
- sf.only_cc_opinion = json_formula.yijianlan.only_cc || false;
20752
- sf.default_description = json_formula.yijianlan["default"];
20753
- sf.only_handler = json_formula.yijianlan.only_handler;
20754
- sf.top_keywords = json_formula.yijianlan.top_keywords || top_keywords;
20755
- return opinionFields.push(sf);
20756
- } else if ((field_formula != null ? field_formula.indexOf("{traces.") : void 0) > -1 || (field_formula != null ? field_formula.indexOf("{signature.traces.") : void 0) > -1) {
20757
- sf = {
20758
- only_cc_opinion: false,
20759
- image_sign: false,
20760
- top_keywords: top_keywords
20761
- };
20762
- if (foo.indexOf("{signature.") > -1) {
20763
- sf.image_sign = true;
20764
- foo = foo.replace("{signature.", "");
20765
- }
20766
- s1 = foo.replace("{", "").replace("}", "");
20767
- if (s1.split(".").length > 1) {
20768
- sf.stepName = s1.split(".")[1];
20769
- if (opinionFields.filterProperty("stepName", sf.stepName).length > 0) {
20770
- if ((_ref = opinionFields.findPropertyByPK("stepName", sf.stepName)) != null) {
20771
- _ref.only_cc_opinion = true;
20772
- }
20773
- } else {
20774
- if (s1.split(".").length > 2) {
20775
- if (((_ref1 = s1.split(".")[2]) != null ? _ref1.toLocaleLowerCase() : void 0) === 'cc') {
20776
- sf.only_cc_opinion = true;
20777
- }
20778
- }
20779
- }
20780
- }
20781
- return opinionFields.push(sf);
20782
- }
20783
- });
20784
- }
20785
- }
20786
- return opinionFields;
20787
- };
20788
-
20789
- /*
20790
- * @Author: baozhoutao@steedos.com
20791
- * @Date: 2022-09-09 17:47:37
20792
- * @LastEditors: 殷亮辉 yinlianghui@hotoa.com
20793
- * @LastEditTime: 2025-11-03 15:17:50
20794
- * @Description:
20795
- */
20796
-
20797
21019
  const getMoment = ()=>{
20798
21020
  if(window.amisRequire){
20799
21021
  return window.amisRequire("moment");
@@ -20808,37 +21030,6 @@ const getTrace = ({ instance, traceId }) => {
20808
21030
  });
20809
21031
  };
20810
21032
 
20811
- const getUserApprove = ({ instance, userId }) => {
20812
- const currentTrace = find(instance.traces, (trace) => {
20813
- return trace.is_finished != true;
20814
- });
20815
- let currentApprove = null;
20816
- if (currentTrace) {
20817
- currentApprove = find(currentTrace.approves, (approve) => {
20818
- return approve.is_finished != true && approve.handler == userId;
20819
- });
20820
- }
20821
-
20822
- //传阅的approve返回最新一条
20823
- if (!currentApprove || currentApprove.type == "cc") {
20824
- // 当前是传阅
20825
- ___default.each(instance.traces, function (t) {
20826
- ___default.each(t.approves, function (a) {
20827
- if (a.type == "cc" && a.handler == userId && a.is_finished == false) {
20828
- currentApprove = a;
20829
- }
20830
- });
20831
- });
20832
- }
20833
-
20834
- if (!currentApprove) return;
20835
-
20836
- if (currentApprove._id) {
20837
- currentApprove.id = currentApprove._id;
20838
- }
20839
- return currentApprove;
20840
- };
20841
-
20842
21033
  const getApproveValues = ({ instance, trace, step, approve, box }) => {
20843
21034
  let instanceValues = null;
20844
21035
  if (!approve || approve.type === "cc") {
@@ -20935,10 +21126,6 @@ const getLastCCStep = ({ traces }, userId) => {
20935
21126
  return step_id;
20936
21127
  };
20937
21128
 
20938
- const isCurrentStepOpinionField = (field, currentStep)=>{
20939
- return ___default.includes(___default.map(getOpinionFieldStepsName(field), 'stepName'), currentStep?.name);
20940
- };
20941
-
20942
21129
  const isNeedToShowSignImage = (is_finished, judge, traceShowSignImage) => {
20943
21130
  if (traceShowSignImage === false) {
20944
21131
  return false;
@@ -21011,7 +21198,7 @@ const getInstanceInfo = async (props) => {
21011
21198
  }),
21012
21199
  });
21013
21200
 
21014
-
21201
+ const moment = getMoment();
21015
21202
  let userApprove = null;
21016
21203
  let trace = null;
21017
21204
  let step = null;
@@ -21046,8 +21233,77 @@ const getInstanceInfo = async (props) => {
21046
21233
  method: "get",
21047
21234
  });
21048
21235
 
21049
- const moment = getMoment();
21050
21236
  const signImageCache = new Map();
21237
+ const approvalCommentsFields = {};
21238
+ ___default.each(formVersion.fields, (field) => {
21239
+ if (field.config?.type === "approval_comments") {
21240
+ approvalCommentsFields[field.code] = ___default.clone(field.config);
21241
+ }
21242
+ if (field.type === 'section') {
21243
+ ___default.each(field.fields, (subField) => {
21244
+ if (subField.config?.type === "approval_comments") {
21245
+ approvalCommentsFields[subField.code] = ___default.clone(subField.config);
21246
+ }
21247
+ });
21248
+ }
21249
+ });
21250
+ const myApproveFields = [];
21251
+ for (const field of ___default.values(approvalCommentsFields)) {
21252
+ const fieldSteps = ___default.clone(field.steps);
21253
+ if (fieldSteps && fieldSteps.length > 0) {
21254
+ let fieldComments = [];
21255
+ for (const fieldStep of fieldSteps) {
21256
+ const only_cc_opinion = fieldStep.show_cc && !fieldStep.show_handler;
21257
+ const stepApproves = getTraceApprovesByStep(instance, flowVersion, fieldStep.name, only_cc_opinion);
21258
+ for (const approve of stepApproves) {
21259
+ let userName = approve.handler_name;
21260
+ approve.isOpinionOfField = isOpinionOfField(approve, field);
21261
+ if (approve.isOpinionOfField) {
21262
+ approve.isMyApprove = isMyApprove({ approve, only_cc_opinion, box, currentApprove: userApprove, field });
21263
+ if (approve.isMyApprove) {
21264
+ myApproveFields.push(field);
21265
+ }
21266
+ approve.showApprove = showApprove(approve, field);
21267
+ if (approve.showApprove && !approve.description && fieldStep.default && showApproveDefaultDescription(approve)) {
21268
+ approve.description = fieldStep.default;
21269
+ }
21270
+ if (approve.description){
21271
+ approve.description = approve.description.replace(/\n/g, "<br/>");
21272
+ }
21273
+ if (moment && approve.finish_date){
21274
+ approve.finishDateFormated = moment(approve.finish_date).format("YYYY-MM-DD");
21275
+ }
21276
+ let showSignImage = fieldStep.show_image_sign && showApproveSignImage(approve.judge);
21277
+ if (showSignImage){
21278
+ let userSign, userSignImage;
21279
+ if (signImageCache.has(approve.handler)) {
21280
+ userSign = signImageCache.get(approve.handler);
21281
+ } else {
21282
+ userSign = await getSpaceUserSign(instance.space, approve.handler);
21283
+ signImageCache.set(approve.handler, userSign);
21284
+ }
21285
+ if (userSign){
21286
+ userSignImage = `<img class="image-sign" alt="${userName}" src="/api/v6/files/download/cfs.avatars.filerecord/${userSign}" />`;
21287
+ }
21288
+ approve.showApproveSignImage = !!userSign;
21289
+ approve.userSignImage = userSignImage;
21290
+ }
21291
+ }
21292
+ } fieldComments = ___default.union(fieldComments, stepApproves);
21293
+ } field.comments = fieldComments.filter((comment) => {
21294
+ return comment.isOpinionOfField && (comment.isMyApprove || (comment.showApprove && !!comment.description));
21295
+ });
21296
+ }
21297
+ }
21298
+ if (step?.permissions) {
21299
+ // 字段字段
21300
+ ___default.each(approvalCommentsFields, (field) => {
21301
+ delete step.permissions[field.name];
21302
+ if (___default.find(myApproveFields, { name: field.name })) {
21303
+ step.permissions[field.name] = 'editable';
21304
+ }
21305
+ });
21306
+ }
21051
21307
  return {
21052
21308
  box: box,
21053
21309
  _id: instanceId,
@@ -21066,12 +21322,14 @@ const getInstanceInfo = async (props) => {
21066
21322
  name: instance.name || instance.form.name,
21067
21323
  fields: ___default.map(formVersion.fields, (field) => {
21068
21324
  const newField = Object.assign({}, field, {
21069
- permission: userApprove?.type != 'cc' && (step?.permissions[field.code] || ( isCurrentStepOpinionField(field, step) ? 'editable' : '')),
21325
+ // permission: userApprove?.type != 'cc' && (step?.permissions[field.code] || ( isCurrentStepOpinionField(field, step) ? 'editable' : '')),
21326
+ permission: userApprove?.type != 'cc' && step?.permissions[field.code],
21070
21327
  }) ;
21071
21328
  if(field.type === 'section'){
21072
21329
  newField.fields = ___default.map(field.fields, (sfield) => {
21073
21330
  return Object.assign({}, sfield, {
21074
- permission: userApprove?.type != 'cc' && (step?.permissions[sfield.code] || ( isCurrentStepOpinionField(sfield, step) ? 'editable' : '')),
21331
+ // permission: userApprove?.type != 'cc' && (step?.permissions[sfield.code] || ( isCurrentStepOpinionField(sfield, step) ? 'editable' : '')),
21332
+ permission: userApprove?.type != 'cc' && step?.permissions[sfield.code],
21075
21333
  type: sfield._type || sfield.type
21076
21334
  });
21077
21335
  });
@@ -21171,6 +21429,7 @@ const getInstanceInfo = async (props) => {
21171
21429
  { name: trace.name, judge: "" }
21172
21430
  );
21173
21431
  })),
21432
+ approvalCommentsFields
21174
21433
  };
21175
21434
  };
21176
21435