@nstc-business/imes 1.0.19 → 1.0.20

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nstc-business/imes",
3
- "version": "1.0.19",
3
+ "version": "1.0.20",
4
4
  "private": false,
5
5
  "main": "src/index.js",
6
6
  "scripts": {
@@ -123,7 +123,8 @@ export default {
123
123
  try {
124
124
  this.tableData = await buildStatModelTables(
125
125
  this.subModel,
126
- id => this.fetchScoreMap(id)
126
+ id => this.fetchScoreMap(id),
127
+ this.ctx.modelWrap
127
128
  )
128
129
  } finally {
129
130
  this.loading = false
@@ -1054,6 +1054,10 @@ export default {
1054
1054
  if (this.statRootModel) {
1055
1055
  const treeRoot = resData.modelTreeVO || {}
1056
1056
  preprocessStatIndicatorDeepList(treeRoot.children || [])
1057
+ if (resData.modelStatsSetupVOS) {
1058
+ treeRoot.modelStatsSetupVOS = resData.modelStatsSetupVOS
1059
+ this.$set(this.model, 'modelStatsSetupVOS', resData.modelStatsSetupVOS)
1060
+ }
1057
1061
  mergeStatModelNode(this.model.modelTreeVO || {}, treeRoot)
1058
1062
  this.bumpStatTableVersion(this.model.modelTreeVO)
1059
1063
  }
@@ -1131,6 +1135,9 @@ export default {
1131
1135
  if (isStatModel(subModel)) {
1132
1136
  const treeRoot = data.modelTreeVO || {}
1133
1137
  preprocessStatIndicatorDeepList(treeRoot.children || [])
1138
+ if (data.modelStatsSetupVOS) {
1139
+ treeRoot.modelStatsSetupVOS = data.modelStatsSetupVOS
1140
+ }
1134
1141
  mergeStatModelNode(subModel, treeRoot)
1135
1142
  this.bumpStatTableVersion(subModel)
1136
1143
  }
@@ -1,7 +1,12 @@
1
1
  /**
2
2
  * 统计模型行转列:以 isLeaf=2 为横向展开边界
3
3
  * 逻辑参考 EvaOfCreditConditionsRewrite.initColumnsRewrite
4
- * statCalResult 仅作辅助元数据(列配置/标题/合计),不作为是否行转列的判断条件
4
+ * statCalResult / modelStatsSetupVOS 作辅助元数据(列配置/标题/合计),
5
+ * 不作为是否行转列的判断条件。
6
+ *
7
+ * 注意:getModelTree 对统计模型通常不下发 statCalResult(挂在评价模型的
8
+ * 定量分析/定性分析节点上),标题需按 pid 反查分组目录,列配置优先用
9
+ * modelStatsSetupVOS,避免回退到第一个指标名 / 默认 calType=0 导致错列。
5
10
  */
6
11
 
7
12
  function hasFilledValue(val) {
@@ -105,14 +110,31 @@ export function hasStatPivotData(statNode) {
105
110
  return hasStatPivotNodes(statNode)
106
111
  }
107
112
 
113
+ /**
114
+ * calType:0=指标取数(展示「xxx指标值/指标得分」),非 0(如 9=统计项运算)只展示统计项名。
115
+ * 树节点通常只有 rankType,缺 calType 时用 rankType 推断,避免「平均」被当成指标取数导致列重复。
116
+ */
117
+ function resolveStatCalType(statLike) {
118
+ if (!statLike) return 0
119
+ if (statLike.calType !== '' && statLike.calType != null) return statLike.calType
120
+ if (statLike.rankType !== '' && statLike.rankType != null) return statLike.rankType
121
+ return 0
122
+ }
123
+
108
124
  function resolveStatMeta(statsResultList, statChild) {
109
125
  const fromList = (statsResultList || []).find(
110
126
  s => s.name == statChild.statsName
111
127
  )
112
- if (fromList) return fromList
128
+ if (fromList) {
129
+ return {
130
+ ...fromList,
131
+ name: fromList.name || statChild.statsName,
132
+ calType: resolveStatCalType(fromList)
133
+ }
134
+ }
113
135
  return {
114
136
  name: statChild.statsName,
115
- calType: statChild.calType ?? 0,
137
+ calType: resolveStatCalType(statChild),
116
138
  statShow: statChild.statShow ?? 1,
117
139
  statCalMethod: statChild.statCalMethod,
118
140
  statResult: statChild.statResult
@@ -120,25 +142,104 @@ function resolveStatMeta(statsResultList, statChild) {
120
142
  }
121
143
 
122
144
  function buildStatsResultListFromChildren(statChildren) {
123
- return statChildren.map(c => ({
145
+ return (statChildren || []).map(c => ({
124
146
  name: c.statsName,
125
- calType: c.calType ?? 0,
147
+ calType: resolveStatCalType(c),
126
148
  statShow: c.statShow ?? 1,
127
149
  statCalMethod: c.statCalMethod,
128
150
  statResult: c.statResult
129
151
  }))
130
152
  }
131
153
 
132
- function resolveTableBlockMeta(treeData, pid, indicatorItems) {
133
- const calBlock = (treeData.statCalResult || []).find(r => r.pid === pid)
134
- const first = indicatorItems[0]
135
- const firstStatChildren = statItemChildren(first)
154
+ function normalizeStatsResultList(list) {
155
+ if (!Array.isArray(list) || !list.length) return null
156
+ return list.map(s => ({
157
+ name: s.name || s.statsName,
158
+ calType: resolveStatCalType(s),
159
+ statShow: s.statShow ?? 1,
160
+ statCalMethod: s.statCalMethod,
161
+ statResult: s.statResult
162
+ }))
163
+ }
164
+
165
+ /** 在节点树中按 tid 查找节点(含根) */
166
+ function findNodeByTid(root, tid) {
167
+ if (!root || tid == null || tid === '') return null
168
+ if (root.tid === tid || root.TID === tid) return root
169
+ const stack = Array.isArray(root.children) ? [...root.children] : []
170
+ while (stack.length) {
171
+ const node = stack.shift()
172
+ if (!node) continue
173
+ if (node.tid === tid || node.TID === tid) return node
174
+ if (Array.isArray(node.children) && node.children.length) {
175
+ stack.push(...node.children)
176
+ }
177
+ }
178
+ return null
179
+ }
180
+
181
+ /** 收集整棵树上所有 statCalResult(挂在定量分析/定性分析等祖先节点上) */
182
+ function collectAllStatCalResults(root, bucket = []) {
183
+ if (!root) return bucket
184
+ if (Array.isArray(root.statCalResult) && root.statCalResult.length) {
185
+ bucket.push(...root.statCalResult)
186
+ }
187
+ ;(root.children || []).forEach(child => collectAllStatCalResults(child, bucket))
188
+ return bucket
189
+ }
190
+
191
+ function findStatCalBlock(treeData, pid, modelWrap) {
192
+ const local = (treeData && treeData.statCalResult) || []
193
+ let block = local.find(r => r.pid === pid)
194
+ if (block) return block
195
+ const modelRoot = modelWrap && modelWrap.modelTreeVO
196
+ if (!modelRoot) return null
197
+ return collectAllStatCalResults(modelRoot).find(r => r.pid === pid) || null
198
+ }
199
+
200
+ /**
201
+ * 分组标题优先用 statCalResult.statIndicatorName(分组目录名),
202
+ * 否则按 pid 反查树节点 name;禁止回退到第一个指标 name(缺陷现象)。
203
+ */
204
+ function resolveStatIndicatorName(calBlock, treeData, pid, indicatorItems, modelWrap) {
205
+ if (calBlock && calBlock.statIndicatorName) return calBlock.statIndicatorName
206
+ const fromTree =
207
+ findNodeByTid(treeData, pid) ||
208
+ findNodeByTid(modelWrap && modelWrap.modelTreeVO, pid)
209
+ if (fromTree && fromTree.name) return fromTree.name
210
+ const first = indicatorItems && indicatorItems[0]
211
+ if (first && first.folderName) return first.folderName
212
+ return ''
213
+ }
214
+
215
+ function resolveStatsResultList(calBlock, treeData, indicatorItems, modelWrap) {
216
+ const fromBlock = normalizeStatsResultList(calBlock && calBlock.statsResultList)
217
+ if (fromBlock) return fromBlock
218
+ const fromModel = normalizeStatsResultList(
219
+ (modelWrap && modelWrap.modelStatsSetupVOS) ||
220
+ (treeData && treeData.modelStatsSetupVOS)
221
+ )
222
+ if (fromModel) return fromModel
223
+ const first = indicatorItems && indicatorItems[0]
224
+ return buildStatsResultListFromChildren(statItemChildren(first))
225
+ }
226
+
227
+ function resolveTableBlockMeta(treeData, pid, indicatorItems, modelWrap) {
228
+ const calBlock = findStatCalBlock(treeData, pid, modelWrap)
136
229
  return {
137
- statIndicatorName:
138
- calBlock?.statIndicatorName || first?.folderName || first?.name || '',
139
- statsResultList:
140
- calBlock?.statsResultList ||
141
- buildStatsResultListFromChildren(firstStatChildren)
230
+ statIndicatorName: resolveStatIndicatorName(
231
+ calBlock,
232
+ treeData,
233
+ pid,
234
+ indicatorItems,
235
+ modelWrap
236
+ ),
237
+ statsResultList: resolveStatsResultList(
238
+ calBlock,
239
+ treeData,
240
+ indicatorItems,
241
+ modelWrap
242
+ )
142
243
  }
143
244
  }
144
245
 
@@ -155,8 +256,9 @@ function groupIsLeaf2ByPid(nodes) {
155
256
  /**
156
257
  * @param {Object} treeData 统计模型节点
157
258
  * @param {Function} fetchScoreMap async (itemID) => optionList
259
+ * @param {Object} [modelWrap] 整模 ModelVO(含 modelTreeVO / modelStatsSetupVOS)
158
260
  */
159
- export async function buildStatModelTables(treeData, fetchScoreMap) {
261
+ export async function buildStatModelTables(treeData, fetchScoreMap, modelWrap) {
160
262
  const isLeaf2Nodes = collectIsLeaf2Nodes(treeData.children || [])
161
263
  if (!isLeaf2Nodes.length) return []
162
264
 
@@ -168,7 +270,8 @@ export async function buildStatModelTables(treeData, fetchScoreMap) {
168
270
  const { statIndicatorName, statsResultList } = resolveTableBlockMeta(
169
271
  treeData,
170
272
  pid,
171
- indicatorItems
273
+ indicatorItems,
274
+ modelWrap
172
275
  )
173
276
 
174
277
  const columns = [
@@ -342,6 +445,9 @@ export function mergeStatModelNode(target, source) {
342
445
  if (source.statsResultList) {
343
446
  target.statsResultList = source.statsResultList
344
447
  }
448
+ if (source.modelStatsSetupVOS) {
449
+ target.modelStatsSetupVOS = source.modelStatsSetupVOS
450
+ }
345
451
  const fields = [
346
452
  'result',
347
453
  'resultText',