@nstc-business/imes 1.0.18 → 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.18",
3
+ "version": "1.0.20",
4
4
  "private": false,
5
5
  "main": "src/index.js",
6
6
  "scripts": {
@@ -351,9 +351,11 @@
351
351
  </vxe-column>
352
352
  </table-pro>
353
353
  </div>
354
+ <!-- 子模型:按模型树文件夹顺序(定量→定性→调整项)展开,不按类型分块 -->
355
+ <template v-for="(item, index) in typeObj.orderedSubModels">
354
356
  <!-- 评价模型 -->
355
357
  <div
356
- v-for="(item, index) in typeObj.assessModelArray"
358
+ v-if="item._subModelKind === 'assess'"
357
359
  :key="'assessModelArray' + index"
358
360
  class="m-t-m"
359
361
  >
@@ -580,7 +582,7 @@
580
582
  </div>
581
583
  <!-- 计算模型 -->
582
584
  <div
583
- v-for="(item, index) in typeObj.evalModelArray"
585
+ v-else-if="item._subModelKind === 'eval'"
584
586
  :key="'evalModelArray' + index"
585
587
  class="m-t-m"
586
588
  >
@@ -797,7 +799,7 @@
797
799
 
798
800
  <!-- 统计模型 (暂不考虑子模型的情况) -->
799
801
  <div
800
- v-for="(item, index) in typeObj.statisticsArray"
802
+ v-else-if="item._subModelKind === 'stat'"
801
803
  :key="'statisticsArray' + index"
802
804
  class="m-t-m"
803
805
  >
@@ -999,6 +1001,7 @@
999
1001
  </table-pro>
1000
1002
  </div>
1001
1003
  </div>
1004
+ </template>
1002
1005
  </div>
1003
1006
  </expandable-pane>
1004
1007
  </Page>
@@ -1083,7 +1086,9 @@ export default {
1083
1086
  // 计算模型数组
1084
1087
  evalModelArray: [],
1085
1088
  // 评价模型数组
1086
- assessModelArray: []
1089
+ assessModelArray: [],
1090
+ // 子模型按模型树文件夹顺序(定量→定性→调整项)展开
1091
+ orderedSubModels: []
1087
1092
  },
1088
1093
  tabelHeadersAssessModel: [
1089
1094
  {
@@ -1402,6 +1407,7 @@ export default {
1402
1407
  this.processingData(this.model, 'targetArray')
1403
1408
  await this.queryCalcResultDetail()
1404
1409
  this.processingData(this.modelData)
1410
+ this.alignSubModelsWithTargetOrder()
1405
1411
  this.comFn(this.modelData)
1406
1412
  }
1407
1413
  break
@@ -1414,7 +1420,9 @@ export default {
1414
1420
  modelTreeVO.itemID = modelTreeVO.modelID
1415
1421
  modelTreeVO.tableData = []
1416
1422
  modelTreeVO.children = []
1417
- this.typeObj.statisticsArray.push({...modelTreeVO})
1423
+ const statRow = {...modelTreeVO, _subModelKind: 'stat'}
1424
+ this.typeObj.statisticsArray.push(statRow)
1425
+ this.typeObj.orderedSubModels.push(statRow)
1418
1426
  this.comFn(this.modelData)
1419
1427
  let showFullScore = 0
1420
1428
  let showIndicatorValText = 0
@@ -1706,6 +1714,21 @@ export default {
1706
1714
  // 统计模型table : isLeaf=2 itemType = 13
1707
1715
  // 计算模型table : isLeaf=0 itemType = 11
1708
1716
  // 评价模型table: isLeaf=0 itemType = 12
1717
+ /** 子模型展开顺序与主表指标(定量→定性→调整项)保持一致 */
1718
+ alignSubModelsWithTargetOrder() {
1719
+ const orderIds = this.typeObj.targetArray
1720
+ .filter(i => [11, 12, 13].includes(Number(i.itemType)))
1721
+ .map(i => i.itemID)
1722
+ if (!orderIds.length || !this.typeObj.orderedSubModels.length) {
1723
+ return
1724
+ }
1725
+ this.typeObj.orderedSubModels.sort((a, b) => {
1726
+ const ia = orderIds.indexOf(a.itemID)
1727
+ const ib = orderIds.indexOf(b.itemID)
1728
+ return (ia < 0 ? Number.MAX_SAFE_INTEGER : ia) -
1729
+ (ib < 0 ? Number.MAX_SAFE_INTEGER : ib)
1730
+ })
1731
+ },
1709
1732
  processingData(modelData, type) {
1710
1733
  const modelTreeVO = JSON.parse(JSON.stringify(modelData.modelTreeVO))
1711
1734
  const digui = data => {
@@ -1750,7 +1773,9 @@ export default {
1750
1773
  } else {
1751
1774
  item.children = []
1752
1775
  item.tableData = []
1753
- this.typeObj.evalModelArray.push({...item})
1776
+ const row = {...item, _subModelKind: 'eval'}
1777
+ this.typeObj.evalModelArray.push(row)
1778
+ this.typeObj.orderedSubModels.push(row)
1754
1779
  }
1755
1780
  }
1756
1781
  break
@@ -1766,7 +1791,9 @@ export default {
1766
1791
  } else {
1767
1792
  item.children = []
1768
1793
  item.tableData = []
1769
- this.typeObj.assessModelArray.push({...item})
1794
+ const row = {...item, _subModelKind: 'assess'}
1795
+ this.typeObj.assessModelArray.push(row)
1796
+ this.typeObj.orderedSubModels.push(row)
1770
1797
  }
1771
1798
  }
1772
1799
 
@@ -1783,7 +1810,9 @@ export default {
1783
1810
  } else {
1784
1811
  item.children = []
1785
1812
  item.tableData = []
1786
- this.typeObj.statisticsArray.push({...item})
1813
+ const row = {...item, _subModelKind: 'stat'}
1814
+ this.typeObj.statisticsArray.push(row)
1815
+ this.typeObj.orderedSubModels.push(row)
1787
1816
  }
1788
1817
  // this.typeObj.targetArray[this.typeObj.targetArray.length - 1] = await this.itemDataFn(item, data)
1789
1818
  }
@@ -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',