@lcap/nasl-concepts 3.10.1-rc.1 → 3.10.2-alpha.3

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.
Files changed (121) hide show
  1. package/README.md +3 -3
  2. package/out/common/BaseNode.d.ts +8 -16
  3. package/out/common/BaseNode.d.ts.map +1 -1
  4. package/out/common/BaseNode.js +22 -69
  5. package/out/common/BaseNode.js.map +1 -1
  6. package/out/concepts/App__.d.ts +18 -8
  7. package/out/concepts/App__.d.ts.map +1 -1
  8. package/out/concepts/App__.js +78 -1
  9. package/out/concepts/App__.js.map +1 -1
  10. package/out/concepts/Argument__.d.ts +1 -1
  11. package/out/concepts/Argument__.d.ts.map +1 -1
  12. package/out/concepts/Argument__.js +3 -3
  13. package/out/concepts/Argument__.js.map +1 -1
  14. package/out/concepts/BindAttribute__.js +25 -25
  15. package/out/concepts/BusinessComponent__.js +30 -30
  16. package/out/concepts/CallAuthInterface__.d.ts.map +1 -1
  17. package/out/concepts/CallAuthInterface__.js +7 -4
  18. package/out/concepts/CallAuthInterface__.js.map +1 -1
  19. package/out/concepts/CallConnector__.d.ts +11 -3
  20. package/out/concepts/CallConnector__.d.ts.map +1 -1
  21. package/out/concepts/CallConnector__.js +156 -16
  22. package/out/concepts/CallConnector__.js.map +1 -1
  23. package/out/concepts/CallInterface__.d.ts.map +1 -1
  24. package/out/concepts/CallInterface__.js +2 -3
  25. package/out/concepts/CallInterface__.js.map +1 -1
  26. package/out/concepts/CallLogic__.d.ts +6 -1
  27. package/out/concepts/CallLogic__.d.ts.map +1 -1
  28. package/out/concepts/CallLogic__.js +49 -41
  29. package/out/concepts/CallLogic__.js.map +1 -1
  30. package/out/concepts/CallQueryComponent__.js +2 -2
  31. package/out/concepts/ConnectorLogic__.d.ts +10 -1
  32. package/out/concepts/ConnectorLogic__.d.ts.map +1 -1
  33. package/out/concepts/ConnectorLogic__.js +72 -0
  34. package/out/concepts/ConnectorLogic__.js.map +1 -1
  35. package/out/concepts/Connector__.d.ts +1 -1
  36. package/out/concepts/Connector__.d.ts.map +1 -1
  37. package/out/concepts/Connector__.js +7 -1
  38. package/out/concepts/Connector__.js.map +1 -1
  39. package/out/concepts/ForEachStatement__.js +1 -1
  40. package/out/concepts/ForEachStatement__.js.map +1 -1
  41. package/out/concepts/FrontendType__.d.ts +5 -0
  42. package/out/concepts/FrontendType__.d.ts.map +1 -1
  43. package/out/concepts/FrontendType__.js +18 -0
  44. package/out/concepts/FrontendType__.js.map +1 -1
  45. package/out/concepts/Identifier__.d.ts.map +1 -1
  46. package/out/concepts/Identifier__.js +3 -0
  47. package/out/concepts/Identifier__.js.map +1 -1
  48. package/out/concepts/Interface__.d.ts +4 -0
  49. package/out/concepts/Interface__.d.ts.map +1 -1
  50. package/out/concepts/Interface__.js +8 -0
  51. package/out/concepts/Interface__.js.map +1 -1
  52. package/out/concepts/Logic__.d.ts +13 -1
  53. package/out/concepts/Logic__.d.ts.map +1 -1
  54. package/out/concepts/Logic__.js +43 -2
  55. package/out/concepts/Logic__.js.map +1 -1
  56. package/out/concepts/NewComposite__.d.ts +1 -1
  57. package/out/concepts/NewComposite__.js +1 -1
  58. package/out/concepts/NewComposite__.js.map +1 -1
  59. package/out/concepts/New__.d.ts +1 -0
  60. package/out/concepts/New__.d.ts.map +1 -1
  61. package/out/concepts/New__.js +7 -0
  62. package/out/concepts/New__.js.map +1 -1
  63. package/out/concepts/ProcessV2__.js +1 -1
  64. package/out/concepts/Structure__.d.ts +0 -6
  65. package/out/concepts/Structure__.d.ts.map +1 -1
  66. package/out/concepts/Structure__.js +0 -46
  67. package/out/concepts/Structure__.js.map +1 -1
  68. package/out/concepts/TypeAnnotation__.d.ts +1 -0
  69. package/out/concepts/TypeAnnotation__.d.ts.map +1 -1
  70. package/out/concepts/TypeAnnotation__.js +8 -0
  71. package/out/concepts/TypeAnnotation__.js.map +1 -1
  72. package/out/concepts/ViewElement__.d.ts +5 -0
  73. package/out/concepts/ViewElement__.d.ts.map +1 -1
  74. package/out/concepts/ViewElement__.js +73 -35
  75. package/out/concepts/ViewElement__.js.map +1 -1
  76. package/out/concepts/View__.d.ts +2 -1
  77. package/out/concepts/View__.d.ts.map +1 -1
  78. package/out/concepts/View__.js +297 -259
  79. package/out/concepts/View__.js.map +1 -1
  80. package/out/concepts/WhileStatement__.d.ts.map +1 -1
  81. package/out/concepts/WhileStatement__.js +8 -2
  82. package/out/concepts/WhileStatement__.js.map +1 -1
  83. package/out/concepts/basics/stdlib/nasl.interface.d.ts.map +1 -1
  84. package/out/concepts/basics/stdlib/nasl.interface.js +8 -1
  85. package/out/concepts/basics/stdlib/nasl.interface.js.map +1 -1
  86. package/out/service/annotation.d.ts +2 -0
  87. package/out/service/annotation.d.ts.map +1 -1
  88. package/out/service/annotation.js +11 -7
  89. package/out/service/annotation.js.map +1 -1
  90. package/out/service/callLogicHeader.d.ts +3 -0
  91. package/out/service/callLogicHeader.d.ts.map +1 -0
  92. package/out/service/callLogicHeader.js +13 -0
  93. package/out/service/callLogicHeader.js.map +1 -0
  94. package/out/service/formatTsUtils.d.ts +3 -2
  95. package/out/service/formatTsUtils.d.ts.map +1 -1
  96. package/out/service/formatTsUtils.js +20 -9
  97. package/out/service/formatTsUtils.js.map +1 -1
  98. package/out/service/getConnector.d.ts +1 -1
  99. package/out/service/getConnector.d.ts.map +1 -1
  100. package/out/service/getConnector.js +50 -11
  101. package/out/service/getConnector.js.map +1 -1
  102. package/out/service/getMemberIdentifier.d.ts +12 -0
  103. package/out/service/getMemberIdentifier.d.ts.map +1 -1
  104. package/out/service/getMemberIdentifier.js +39 -20
  105. package/out/service/getMemberIdentifier.js.map +1 -1
  106. package/out/service/index.d.ts +1 -0
  107. package/out/service/index.d.ts.map +1 -1
  108. package/out/service/index.js +1 -0
  109. package/out/service/index.js.map +1 -1
  110. package/out/utils/bak-translator.d.ts.map +1 -1
  111. package/out/utils/bak-translator.js +38 -47
  112. package/out/utils/bak-translator.js.map +1 -1
  113. package/out/utils/constant.d.ts +1 -0
  114. package/out/utils/constant.d.ts.map +1 -1
  115. package/out/utils/constant.js +3 -1
  116. package/out/utils/constant.js.map +1 -1
  117. package/out/utils/style.d.ts +7 -0
  118. package/out/utils/style.d.ts.map +1 -0
  119. package/out/utils/style.js +119 -0
  120. package/out/utils/style.js.map +1 -0
  121. package/package.json +6 -5
@@ -1042,271 +1042,277 @@ let View = class View extends Annotatable__1.default {
1042
1042
  };
1043
1043
  let code = '';
1044
1044
  let mixin = '';
1045
- const keyboardEventMixinCode = `const keyboardEventMixin = {
1046
- mounted() {
1047
- document.addEventListener('keydown', this.onKeyDown);
1048
- document.addEventListener('keyup', this.onKeyUp);
1049
- },
1050
- beforeDestroy() {
1051
- document.removeEventListener('keydown', this.onKeyDown);
1052
- document.removeEventListener('keyup', this.onKeyUp);
1053
- },
1054
- methods: {
1055
- async onKeyDown(e) {
1045
+ const keyboardEventMixinCode = `const keyboardEventMixin = {
1046
+ mounted() {
1047
+ document.addEventListener('keydown', this.onKeyDown);
1048
+ document.addEventListener('keyup', this.onKeyUp);
1049
+ },
1050
+ beforeDestroy() {
1051
+ document.removeEventListener('keydown', this.onKeyDown);
1052
+ document.removeEventListener('keyup', this.onKeyUp);
1053
+ },
1054
+ methods: {
1055
+ async onKeyDown(e) {
1056
1056
  ${this.bindEvents
1057
1057
  .filter((event) => ['keydown'].includes(event.name))
1058
1058
  .map((event) => `await this.${event.view.name}_${event.name}(e);`)
1059
- .join('\n')}
1060
- },
1061
- async onKeyUp(e) {
1059
+ .join('\n')}
1060
+ },
1061
+ async onKeyUp(e) {
1062
1062
  ${this.bindEvents
1063
1063
  .filter((event) => ['keyup'].includes(event.name))
1064
1064
  .map((event) => `await this.${event.view.name}_${event.name}(e);`)
1065
- .join('\n')}
1066
- }
1067
- }
1065
+ .join('\n')}
1066
+ }
1067
+ }
1068
1068
  };\n`;
1069
1069
  code += keyboardEventMixinCode;
1070
- const processDetailFrom = this.getViewProcessForm(), hasProcessDetailFrom = !!processDetailFrom, processV2 = this.getDestinationProcessV2();
1070
+ const processDetailFrom = this.getViewProcessForm(), hasProcessDetailFrom = !!processDetailFrom, processV2 = this.getDestinationProcessV2;
1071
1071
  if (hasProcessDetailFrom) {
1072
- const processDetailFromMixinCode = `const processDetailFromMixin = {
1073
- data() {
1074
- return {
1075
- processDetailFormData: {},
1076
- ${processV2.name} : {
1077
- data: {},
1078
- },
1079
- ${processDetailFrom.getBindAttribute('processPrefix')?.value} : {
1080
- data: {},
1081
- },
1082
- formTemplate: "", // 表单模版
1083
- formVM: null, // 表单实例
1084
- needReplaced: false, // 是否需要替换模版
1085
- }
1086
- },
1087
- methods: {
1088
- sliceStrByTag(tag, referIndex, startIndex = 0, endIndex = Infinity) {
1089
- const sliceEndIndex = this.formTemplate.indexOf(\`</\${tag}>\`, referIndex);
1090
- if (sliceEndIndex > -1 && sliceEndIndex < endIndex) {
1091
- const sliceStartIndex = this.formTemplate.lastIndexOf(\`<\${tag} \`,sliceEndIndex);
1092
- if (sliceStartIndex > -1 && sliceStartIndex > startIndex) {
1093
- return this.formTemplate.substring(sliceStartIndex, sliceEndIndex + (\`</\${tag}>\`).length);
1094
- }
1095
- }
1096
- return '';
1097
- },
1098
- modifyFieldTemplateByPermission(replaceTemplateList, propertyName, fieldStr, permission, tag, relationDataName) {
1099
- let startIndex = 0, endIndex = Infinity;
1100
- if (relationDataName) {
1101
- const tableIndexConfig = this.getRelationDataStartAndEndIndex(relationDataName)
1102
- startIndex = tableIndexConfig.tableStartIndex
1103
- endIndex = tableIndexConfig.tableEndIndex
1104
- }
1105
- let itemStr = '';
1106
- const replaceStr = \`<span text=\${fieldStr}></span>\`
1107
- const fieldStrIndex = this.formTemplate.indexOf(fieldStr, startIndex);
1108
- if (fieldStrIndex > -1 && fieldStrIndex < endIndex) {
1109
- itemStr = this.sliceStrByTag(tag, fieldStrIndex, startIndex, endIndex);
1110
- if (permission === 'hidden') {
1111
- this.formTemplate = this.formTemplate.replace(itemStr, '');
1112
- return;
1113
- } else if (['readOnly', 'preview'].includes(permission)) {
1114
- const newItemStr = itemStr.replace(fieldStr, \`\${fieldStr} preview \`);
1115
- this.formTemplate = this.formTemplate.replace(itemStr, newItemStr);
1116
- itemStr = newItemStr;
1117
- }
1118
- // 先使用替换模版填充,保证初始化可渲染
1119
- this.formTemplate = this.formTemplate.replace(itemStr, replaceStr);
1120
- replaceTemplateList.push({
1121
- propertyName,
1122
- origin: itemStr,
1123
- replace: replaceStr
1124
- });
1125
- }
1126
- return startIndex;
1127
- },
1128
- getRelationDataStartAndEndIndex(relationDataName) {
1129
- const tag = 'u-table-view';
1130
- let tableStartIndex = tableEndIndex = -1;
1131
- const reg = new RegExp(\`dataSource="[^"]*processDetailFormData[^"]*\\\\.\${relationDataName}"\`, 'g');
1132
- const match = this.formTemplate.match(reg);
1133
- if (match && match.length) {
1134
- const relationDataStr = match[0], relationDataStrIndex = this.formTemplate.indexOf(relationDataStr);
1135
- tableEndIndex = this.formTemplate.indexOf('</' + tag + '>',relationDataStrIndex);
1136
- if (tableEndIndex > -1) {
1137
- tableStartIndex = this.formTemplate.lastIndexOf('<' + tag + ' ',tableEndIndex);
1138
- }
1139
- }
1140
- return { tableStartIndex, tableEndIndex };
1141
- },
1142
- dynamicRender(vmRoot){
1143
- const Local = Vue.extend({
1144
- template: this.formTemplate,
1145
- data() {
1146
- return {
1147
- ...vmRoot.$data
1148
- }
1149
- },
1150
- methods: {
1151
- ...vmRoot.$options.methods
1152
- }
1153
- })
1154
- this.formVM = new Local().$mount()
1155
- this.needReplaced = !this.formVM?.$el?.firstChild // 判断当前模版是否渲染成功
1156
- },
1157
- renderForm ({fieldReplTemplates, vmRoot, isSubForm}) {
1158
- for (let i = 0; i <= fieldReplTemplates.length; i++) {
1159
- const { propertyName, origin, replace } = fieldReplTemplates[i] || {};
1160
- // step1: 如果上一次渲染失败,更换为替换模版
1161
- if (this.needReplaced && i > 0) {
1162
- const { origin: lastOrigin, replace: lastReplace } = fieldReplTemplates[i - 1];
1163
- this.formTemplate = this.formTemplate.replace(lastOrigin, lastReplace);
1164
- }
1165
- // step2: 如果子表单的首次渲染失败,则不在继续替换后续模版,直接取消掉该子表单的渲染
1166
- if (isSubForm && this.needReplaced && i === 1) break;
1167
- // step3: 尝试用原始模板渲染
1168
- if (propertyName) this.formTemplate = this.formTemplate.replace(replace, origin);
1169
- // step4: 动态渲染
1170
- if (propertyName || this.needReplaced || i === 0) this.dynamicRender(vmRoot)
1171
- }
1172
- this.needReplaced = false;
1173
- },
1174
- cutStrByTag(template, tag, filterReferStr) {
1175
- const filterReferStrIndex = template.indexOf(filterReferStr);
1176
- const endIndex = template.indexOf(\`</\${tag}>\`, filterReferStrIndex);
1177
- if (endIndex > -1) {
1178
- const startIndex = template.lastIndexOf(\`<\${tag} \`, endIndex);
1179
- if (startIndex > -1) {
1180
- const targetStr = template.substring(startIndex, endIndex + (\`</\${tag}>\`).length);
1181
- return template.replace(targetStr, '');
1182
- }
1183
- }
1184
- return template;
1185
- },
1186
- previewSubFormTemplate(stencilStr){
1187
- stencilStr = this.cutStrByTag(stencilStr, 'u-button', ':subFormBtnType="\`add\`"' )
1188
- stencilStr = this.cutStrByTag(stencilStr, 'u-table-view-column', ':subFormInitialColumn="\`action\`"' )
1189
- return stencilStr
1190
- }
1191
- },
1192
- async mounted() {
1193
- try {
1194
- const taskId = this.$route.query.taskId
1195
- if (!taskId) return
1196
- // 获取表单定义
1197
- let templateProcessDetailFrom = await this.$processV2.getProcessFormDefinition({
1198
- body: { taskId }
1199
- })
1200
- this.formTemplate = templateProcessDetailFrom?.data
1201
- // 获取表单数据
1202
- let formData = await this.$processV2.getTaskInstanceForm({ body: { taskId } })
1203
- formData = formData?.data
1204
- // 获取流程变量
1205
- let processVars = await this.$processV2.getProcVariable({ body: { taskId } })
1206
- processVars = processVars?.data
1207
- formData = { ...formData, ...processVars }
1208
- // 获取字段权限
1209
- // let fieldPermission = await this.$processV2.fieldPermissionDetail({ body: { taskId } }) // 旧接口
1210
- const fieldPermission = await this.$processV2.getFieldPermissionDetail({ body: { taskId } })
1211
-
1212
- const itemTag = ${this.frontend.type === 'pc' ? `'u-form-item'` : `'van-field'`};
1213
-
1214
- // 主表单的字段权限
1215
- const mainPerms = fieldPermission?.data?.[0]?.subFieldPermissions || []
1216
- // 主表字段渲染错误时的替换模版
1217
- const mainReplTemplates = []
1218
- mainPerms.forEach(({propertyName, permission}) => {
1219
- const fieldStrReg = new RegExp(\`"[^"]*processDetailFormData[^"]*\\\\.data[^"]*\\\\.\${propertyName}"\`, "g");
1220
- const fieldStr = this.formTemplate.match(fieldStrReg)?.[0];
1221
- if (!fieldStr) return;
1222
- this.modifyFieldTemplateByPermission(mainReplTemplates ,propertyName, fieldStr, permission,itemTag);
1223
- })
1224
-
1225
- // n个子表单的字段权限 (n>=0)
1226
- const subPerms = fieldPermission?.data?.slice(1) || []
1227
- // 子字段渲染错误时的替换模版
1228
- const subReplTemplates = []
1229
- if (subPerms.length && ${this.frontend.type === 'pc'}) {
1230
- const fieldTag = 'u-table-view-column', stencilTag = 'u-grid-layout-column';
1231
- // 遍历每个子表单
1232
- subPerms.forEach((relationData) => {
1233
- const { propertyName, subFieldPermissions, permission } = relationData;
1234
- // step1: 判断是否存在当前子表单
1235
- let { tableStartIndex, tableEndIndex } = this.getRelationDataStartAndEndIndex(propertyName)
1236
- if (tableStartIndex === -1 || tableEndIndex === -1) return;
1237
- let stencilStr = this.sliceStrByTag(stencilTag, tableStartIndex);
1238
- // step2: 根据子表单整体权限,控制子表单的部分节点 或 整个子表单 的隐藏
1239
- if(['readOnly', 'preview'].includes(permission)){
1240
- const newStencilStr = this.previewSubFormTemplate(stencilStr)
1241
- this.formTemplate = this.formTemplate.replace(stencilStr, newStencilStr)
1242
- stencilStr = newStencilStr
1243
- }else if(permission === 'hidden'){
1244
- this.formTemplate = this.formTemplate.replace(stencilStr, '')
1245
- return;
1246
- }
1247
- // step3: 初始化存放槽位
1248
- const curReplTemplates = []
1249
- subReplTemplates.push(curReplTemplates);
1250
- // step4: 遍历当前子表单的字段权限
1251
- subFieldPermissions.forEach(({ propertyName: fieldName, permission: fieldPermission }, index) => {
1252
- const fieldStr = \`"current.item.\${fieldName}"\`;
1253
- tableStartIndex = this.modifyFieldTemplateByPermission(curReplTemplates, fieldName, fieldStr, fieldPermission,fieldTag, propertyName);
1254
- // step5: 当前子表单首次渲染时,会去除掉所有列,来检查当前子表单内是否有其他因素导致渲染失败
1255
- if (index === subFieldPermissions.length - 1) {
1256
- stencilStr = this.sliceStrByTag(stencilTag, tableStartIndex);
1257
- const replaceStencilStr = \`<span text="processDetailFormData.\${propertyName}"></span>\`
1258
- this.formTemplate = this.formTemplate.replace(stencilStr, replaceStencilStr)
1259
- curReplTemplates.unshift({
1260
- propertyName,
1261
- origin: stencilStr,
1262
- replace: replaceStencilStr
1263
- })
1264
- }
1265
- })
1266
- })
1267
- }
1268
-
1269
- if (formData) this.processDetailFormData = formData
1270
- // 使processDetailFormData内每一个key具备双向绑定能力
1271
- Object.keys(this.processDetailFormData).forEach(key => {
1272
- this.$set(this.processDetailFormData, key, this.processDetailFormData[key])
1273
- })
1274
-
1275
- const container = document.getElementById('dynamicRenderContainer')
1276
- if (!container) return
1277
- const vmRoot = this
1278
- // 动态渲染主表单
1279
- this.renderForm({
1280
- fieldReplTemplates: mainReplTemplates,
1281
- vmRoot,
1282
- isSubForm: false
1283
- })
1284
- // 动态渲染子表单
1285
- subReplTemplates.forEach((fieldReplTemplates) => {
1286
- this.renderForm({
1287
- fieldReplTemplates,
1288
- vmRoot,
1289
- isSubForm: true
1290
- })
1291
- })
1292
-
1293
- var parentElement = container.parentNode
1294
- const regex = /ref-name="([^"]+)"/;
1295
- const match = this.formTemplate.match(regex);
1296
- parentElement.replaceChild(this.formVM?.$el, container)
1297
- window.__processDetailFromMixinFormVm__ = this.formVM?.$refs[match[1]]
1298
- const processVarsKeys = Object.keys(processVars);
1299
- const data = {};
1300
- for (const key in this.processDetailFormData) {
1301
- if (!processVarsKeys.includes(key)) {
1302
- data[key] = this.processDetailFormData[key];
1303
- }
1304
- }
1305
- window.__processDetailFromMixinFormData__ = data;
1306
- } catch (error) {
1307
- console.warn('processDetailFromMixin warn', error)
1308
- }
1309
- }
1072
+ const processDetailFromMixinCode = `const processDetailFromMixin = {
1073
+ data() {
1074
+ return {
1075
+ processDetailFormData: {},
1076
+ ${processV2.name} : {
1077
+ data: {},
1078
+ },
1079
+ ${processDetailFrom.getBindAttribute('processPrefix')?.value} : {
1080
+ data: {},
1081
+ },
1082
+ formTemplate: "", // 表单模版
1083
+ formVM: null, // 表单实例
1084
+ needReplaced: false, // 是否需要替换模版
1085
+ }
1086
+ },
1087
+ methods: {
1088
+ sliceStrByTag(tag, referIndex, startIndex = 0, endIndex = Infinity) {
1089
+ const sliceEndIndex = this.formTemplate.indexOf(\`</\${tag}>\`, referIndex);
1090
+ if (sliceEndIndex > -1 && sliceEndIndex < endIndex) {
1091
+ const sliceStartIndex = this.formTemplate.lastIndexOf(\`<\${tag} \`,sliceEndIndex);
1092
+ if (sliceStartIndex > -1 && sliceStartIndex > startIndex) {
1093
+ return this.formTemplate.substring(sliceStartIndex, sliceEndIndex + (\`</\${tag}>\`).length);
1094
+ }
1095
+ }
1096
+ return '';
1097
+ },
1098
+ modifyFieldTemplateByPermission(replaceTemplateList, propertyName, fieldStr, permission, tag, relationDataName) {
1099
+ let startIndex = 0, endIndex = Infinity;
1100
+ if (relationDataName) {
1101
+ const tableIndexConfig = this.getRelationDataStartAndEndIndex(relationDataName)
1102
+ startIndex = tableIndexConfig.tableStartIndex
1103
+ endIndex = tableIndexConfig.tableEndIndex
1104
+ }
1105
+ let itemStr = '';
1106
+ const replaceStr = \`<span text=\${fieldStr}></span>\`
1107
+ const fieldStrIndex = this.formTemplate.indexOf(fieldStr, startIndex);
1108
+ if (fieldStrIndex > -1 && fieldStrIndex < endIndex) {
1109
+ itemStr = this.sliceStrByTag(tag, fieldStrIndex, startIndex, endIndex);
1110
+ if (permission === 'hidden') {
1111
+ this.formTemplate = this.formTemplate.replace(itemStr, '');
1112
+ return startIndex;
1113
+ } else if (['readOnly', 'preview'].includes(permission)) {
1114
+ const newItemStr = itemStr.replace(fieldStr, \`\${fieldStr} preview \`);
1115
+ this.formTemplate = this.formTemplate.replace(itemStr, newItemStr);
1116
+ itemStr = newItemStr;
1117
+ }
1118
+ // 先使用替换模版填充,保证初始化可渲染
1119
+ this.formTemplate = this.formTemplate.replace(itemStr, replaceStr);
1120
+ replaceTemplateList.push({
1121
+ propertyName,
1122
+ origin: itemStr,
1123
+ replace: replaceStr
1124
+ });
1125
+ }
1126
+ return startIndex;
1127
+ },
1128
+ getRelationDataStartAndEndIndex(relationDataName) {
1129
+ const tag = 'u-table-view';
1130
+ let tableStartIndex = tableEndIndex = -1;
1131
+ const reg = new RegExp(\`dataSource="[^"]*processDetailFormData[^"]*\\\\.\${relationDataName}"\`, 'g');
1132
+ const match = this.formTemplate.match(reg);
1133
+ if (match && match.length) {
1134
+ const relationDataStr = match[0], relationDataStrIndex = this.formTemplate.indexOf(relationDataStr);
1135
+ tableEndIndex = this.formTemplate.indexOf('</' + tag + '>',relationDataStrIndex);
1136
+ if (tableEndIndex > -1) {
1137
+ tableStartIndex = this.formTemplate.lastIndexOf('<' + tag + ' ',tableEndIndex);
1138
+ // console.log('tableStr', this.formTemplate.slice(startIndex, endIndex + tag.length + 3));
1139
+ }
1140
+ }
1141
+ return { tableStartIndex, tableEndIndex };
1142
+ },
1143
+ dynamicRender(vmRoot){
1144
+ const Local = Vue.extend({
1145
+ template: this.formTemplate,
1146
+ data() {
1147
+ return {
1148
+ ...vmRoot.$data
1149
+ }
1150
+ },
1151
+ methods: Object.assign(
1152
+ {},
1153
+ ...Object.entries(vmRoot.$options.methods).map(([key, method]) => ({
1154
+ [key]: method.bind(vmRoot)
1155
+ }))
1156
+ )
1157
+ })
1158
+ this.formVM = new Local()
1159
+ this.formVM.$refs = vmRoot.$refs
1160
+ this.formVM.$mount()
1161
+ this.needReplaced = !this.formVM?.$el?.firstChild // 判断当前模版是否渲染成功
1162
+ },
1163
+ renderForm ({fieldReplTemplates, vmRoot, isSubForm}) {
1164
+ for (let i = 0; i <= fieldReplTemplates.length; i++) {
1165
+ const { propertyName, origin, replace } = fieldReplTemplates[i] || {};
1166
+ // step1: 如果上一次渲染失败,更换为替换模版
1167
+ if (this.needReplaced && i > 0) {
1168
+ const { origin: lastOrigin, replace: lastReplace } = fieldReplTemplates[i - 1];
1169
+ this.formTemplate = this.formTemplate.replace(lastOrigin, lastReplace);
1170
+ }
1171
+ // step2: 如果子表单的首次渲染失败,则不在继续替换后续模版,直接取消掉该子表单的渲染
1172
+ if (isSubForm && this.needReplaced && i === 1) break;
1173
+ // step3: 尝试用原始模板渲染
1174
+ if (propertyName) this.formTemplate = this.formTemplate.replace(replace, origin);
1175
+ // step4: 动态渲染
1176
+ if (propertyName || this.needReplaced || i === 0) this.dynamicRender(vmRoot)
1177
+ }
1178
+ this.needReplaced = false;
1179
+ },
1180
+ cutStrByTag(template, tag, filterReferStr) {
1181
+ const filterReferStrIndex = template.indexOf(filterReferStr);
1182
+ const endIndex = template.indexOf(\`</\${tag}>\`, filterReferStrIndex);
1183
+ if (endIndex > -1) {
1184
+ const startIndex = template.lastIndexOf(\`<\${tag} \`, endIndex);
1185
+ if (startIndex > -1) {
1186
+ const targetStr = template.substring(startIndex, endIndex + (\`</\${tag}>\`).length);
1187
+ return template.replace(targetStr, '');
1188
+ }
1189
+ }
1190
+ return template;
1191
+ },
1192
+ previewSubFormTemplate(stencilStr){
1193
+ stencilStr = this.cutStrByTag(stencilStr, 'u-button', ':subFormBtnType="\`add\`"' )
1194
+ stencilStr = this.cutStrByTag(stencilStr, 'u-table-view-column', ':subFormInitialColumn="\`action\`"' )
1195
+ return stencilStr
1196
+ }
1197
+ },
1198
+ async mounted() {
1199
+ try {
1200
+ const taskId = this.$route.query.taskId
1201
+ if (!taskId) return
1202
+ // 获取表单定义
1203
+ let templateProcessDetailFrom = await this.$processV2.getProcessFormDefinition({
1204
+ body: { taskId }
1205
+ })
1206
+ this.formTemplate = templateProcessDetailFrom?.data
1207
+ // 获取表单数据
1208
+ let formData = await this.$processV2.getTaskInstanceForm({ body: { taskId } })
1209
+ formData = formData?.data
1210
+ // 获取流程变量
1211
+ let processVars = await this.$processV2.getProcVariable({ body: { taskId } })
1212
+ processVars = processVars?.data
1213
+ formData = { ...formData, ...processVars }
1214
+ // 获取字段权限
1215
+ // let fieldPermission = await this.$processV2.fieldPermissionDetail({ body: { taskId } }) // 旧接口
1216
+ const fieldPermission = await this.$processV2.getFieldPermissionDetail({ body: { taskId } })
1217
+
1218
+ const itemTag = ${this.frontend.type === 'pc' ? `'u-form-item'` : `'van-field'`};
1219
+
1220
+ // 主表单的字段权限
1221
+ const mainPerms = fieldPermission?.data?.[0]?.subFieldPermissions || []
1222
+ // 主表字段渲染错误时的替换模版
1223
+ const mainReplTemplates = []
1224
+ mainPerms.forEach(({propertyName, permission}) => {
1225
+ const fieldStrReg = new RegExp(\`"[^"]*processDetailFormData[^"]*\\\\.data[^"]*\\\\.\${propertyName}"\`, "g");
1226
+ const fieldStr = this.formTemplate.match(fieldStrReg)?.[0];
1227
+ if (!fieldStr) return;
1228
+ this.modifyFieldTemplateByPermission(mainReplTemplates ,propertyName, fieldStr, permission,itemTag);
1229
+ })
1230
+
1231
+ // n个子表单的字段权限 (n>=0)
1232
+ const subPerms = fieldPermission?.data?.slice(1) || []
1233
+ // 子字段渲染错误时的替换模版
1234
+ const subReplTemplates = []
1235
+ if (subPerms.length && ${this.frontend.type === 'pc'}) {
1236
+ const fieldTag = 'u-table-view-column', stencilTag = 'u-grid-layout-column';
1237
+ // 遍历每个子表单
1238
+ subPerms.forEach((relationData) => {
1239
+ const { propertyName, subFieldPermissions, permission } = relationData;
1240
+ // step1: 判断是否存在当前子表单
1241
+ let { tableStartIndex, tableEndIndex } = this.getRelationDataStartAndEndIndex(propertyName)
1242
+ if (tableStartIndex === -1 || tableEndIndex === -1) return;
1243
+ let stencilStr = this.sliceStrByTag(stencilTag, tableStartIndex);
1244
+ // step2: 根据子表单整体权限,控制子表单的部分节点 或 整个子表单 的隐藏
1245
+ if(['readOnly', 'preview'].includes(permission)){
1246
+ const newStencilStr = this.previewSubFormTemplate(stencilStr)
1247
+ this.formTemplate = this.formTemplate.replace(stencilStr, newStencilStr)
1248
+ stencilStr = newStencilStr
1249
+ }else if(permission === 'hidden'){
1250
+ this.formTemplate = this.formTemplate.replace(stencilStr, '')
1251
+ return;
1252
+ }
1253
+ // step3: 初始化存放槽位
1254
+ const curReplTemplates = []
1255
+ subReplTemplates.push(curReplTemplates);
1256
+ // step4: 遍历当前子表单的字段权限
1257
+ subFieldPermissions.forEach(({ propertyName: fieldName, permission: fieldPermission }, index) => {
1258
+ const fieldStr = \`"current.item.\${fieldName}"\`;
1259
+ tableStartIndex = this.modifyFieldTemplateByPermission(curReplTemplates, fieldName, fieldStr, fieldPermission,fieldTag, propertyName);
1260
+ // step5: 当前子表单首次渲染时,会去除掉所有列,来检查当前子表单内是否有其他因素导致渲染失败
1261
+ if (index === subFieldPermissions.length - 1) {
1262
+ stencilStr = this.sliceStrByTag(stencilTag, tableStartIndex);
1263
+ const replaceStencilStr = \`<span text="processDetailFormData.\${propertyName}"></span>\`
1264
+ this.formTemplate = this.formTemplate.replace(stencilStr, replaceStencilStr)
1265
+ curReplTemplates.unshift({
1266
+ propertyName,
1267
+ origin: stencilStr,
1268
+ replace: replaceStencilStr
1269
+ })
1270
+ }
1271
+ })
1272
+ })
1273
+ }
1274
+
1275
+ if (formData) this.processDetailFormData = formData
1276
+ // 使processDetailFormData内每一个key具备双向绑定能力
1277
+ Object.keys(this.processDetailFormData).forEach(key => {
1278
+ this.$set(this.processDetailFormData, key, this.processDetailFormData[key])
1279
+ })
1280
+
1281
+ const container = document.getElementById('dynamicRenderContainer')
1282
+ if (!container) return
1283
+ const vmRoot = this
1284
+ // 动态渲染主表单
1285
+ this.renderForm({
1286
+ fieldReplTemplates: mainReplTemplates,
1287
+ vmRoot,
1288
+ isSubForm: false
1289
+ })
1290
+ // 动态渲染子表单
1291
+ subReplTemplates.forEach((fieldReplTemplates) => {
1292
+ this.renderForm({
1293
+ fieldReplTemplates,
1294
+ vmRoot,
1295
+ isSubForm: true
1296
+ })
1297
+ })
1298
+
1299
+ var parentElement = container.parentNode
1300
+ const regex = /ref-name="([^"]+)"/;
1301
+ const match = this.formTemplate.match(regex);
1302
+ parentElement.replaceChild(this.formVM?.$el, container)
1303
+ window.__processDetailFromMixinFormVm__ = this.formVM?.$refs[match[1]]
1304
+ const processVarsKeys = Object.keys(processVars);
1305
+ const data = {};
1306
+ for (const key in this.processDetailFormData) {
1307
+ if (!processVarsKeys.includes(key)) {
1308
+ data[key] = this.processDetailFormData[key];
1309
+ }
1310
+ }
1311
+ window.__processDetailFromMixinFormData__ = data;
1312
+ } catch (error) {
1313
+ console.warn('processDetailFromMixin warn', error)
1314
+ }
1315
+ }
1310
1316
  }; \n`;
1311
1317
  code += processDetailFromMixinCode;
1312
1318
  }
@@ -1449,7 +1455,7 @@ let View = class View extends Annotatable__1.default {
1449
1455
  }
1450
1456
  }
1451
1457
  // 获取指向该页面的流程
1452
- getDestinationProcessV2() {
1458
+ get getDestinationProcessV2() {
1453
1459
  const processV2 = this.app?.processV2s || [];
1454
1460
  let res;
1455
1461
  const isM = this.frontend?.type === 'h5';
@@ -1569,6 +1575,11 @@ let View = class View extends Annotatable__1.default {
1569
1575
  code += yield* variable.toEmbeddedTS((0, nasl_translator_1.shiftState)(state, code, { inline: true }));
1570
1576
  return;
1571
1577
  }
1578
+ /**
1579
+ * HACK: 这里不对toEmbeddedTS传入state。变量提升完全不应该写入sourceMap。如果写入,则有可能覆盖节点在正文中的sourceMap项,导致重命名时findMinRange返回错误的值。
1580
+ * 一则逻辑重命名时误伤MemberExpression的例子:https://projectmanage.netease-official.lcap.163yun.com/dashboard/BugDetail?id=2940451268658688
1581
+ */
1582
+ const tempState = (0, nasl_translator_1.createCompilerState)(undefined, { isVariableHost: true });
1572
1583
  code += `${(0, nasl_translator_1.indent)((state?.tabSize || 0) + 1)}// @ts-ignore\n`;
1573
1584
  code += `${(0, nasl_translator_1.indent)((state?.tabSize || 0) + 1)}let `;
1574
1585
  code += yield* variable.toEmbeddedTS((0, nasl_translator_1.shiftState)(state, code, { inline: true }));
@@ -1583,7 +1594,7 @@ let View = class View extends Annotatable__1.default {
1583
1594
  const rightNode = rightIndex.length === 1
1584
1595
  ? assignment.rights[rightIndex[0]]?.expression
1585
1596
  : assignment.rights[rightIndex[0]]?.members[rightIndex[1]];
1586
- const rightCode = yield* rightNode?.toEmbeddedTS((0, nasl_translator_1.shiftState)(state, code, { inline: true })) ??
1597
+ const rightCode = yield* rightNode?.toEmbeddedTS((0, nasl_translator_1.shiftState)(tempState, code, { inline: true })) ??
1587
1598
  (0, utils_1.returnOrigin)('');
1588
1599
  code += yield* self.getRightCode(rightCode, assignment, rightNode);
1589
1600
  }
@@ -1601,7 +1612,7 @@ let View = class View extends Annotatable__1.default {
1601
1612
  }
1602
1613
  rightCode +=
1603
1614
  assignment.right && assignment.right.toEmbeddedTS
1604
- ? yield* assignment.right.toEmbeddedTS((0, nasl_translator_1.shiftState)(state, code, { inline: true }))
1615
+ ? yield* assignment.right.toEmbeddedTS((0, nasl_translator_1.shiftState)(tempState, code, { inline: true }))
1605
1616
  : '__RIGHT__';
1606
1617
  code += yield* self.getRightCode(rightCode, assignment, assignment.right);
1607
1618
  }
@@ -2346,6 +2357,33 @@ let View = class View extends Annotatable__1.default {
2346
2357
  });
2347
2358
  return callbackLogics;
2348
2359
  }
2360
+ async delProcessViewDestination() {
2361
+ if (this?.concept !== 'View')
2362
+ return;
2363
+ const app = this.getAncestor('App');
2364
+ const naslServer = app.naslServer;
2365
+ const refsList = await naslServer._isHaveRef(this);
2366
+ refsList.forEach((record) => {
2367
+ const fileNode = naslServer.file2NodeMap.get(record.file);
2368
+ if (!fileNode)
2369
+ return;
2370
+ const minRange = naslServer._findMinRange(record, fileNode);
2371
+ let node = minRange.node;
2372
+ if (node?.concept === 'Destination' && node?.getAncestor?.('ProcessElementV2')) {
2373
+ node.parentNode.update({
2374
+ destination: {
2375
+ concept: 'Destination',
2376
+ name: '',
2377
+ label: '跳转页面',
2378
+ arguments: [],
2379
+ anchor: {
2380
+ concept: 'Anchor',
2381
+ },
2382
+ },
2383
+ });
2384
+ }
2385
+ });
2386
+ }
2349
2387
  getViewProcessForm() {
2350
2388
  let res;
2351
2389
  const excludedKeySet = new Set([