@nstc-business/imes 1.0.16 → 1.0.18

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.16",
3
+ "version": "1.0.18",
4
4
  "private": false,
5
5
  "main": "src/index.js",
6
6
  "scripts": {
@@ -5,6 +5,7 @@
5
5
  v-else
6
6
  border
7
7
  :data="rows"
8
+ :merge-cells="mergeCells"
8
9
  :row-config="{ keyField: '_rowKey' }"
9
10
  :scroll-y="{ enabled: false }"
10
11
  >
@@ -118,6 +119,7 @@
118
119
 
119
120
  <script>
120
121
  import { InputNumber } from './ui'
122
+ import { setMergeCells } from '../common'
121
123
  import {
122
124
  isQualIndicator,
123
125
  digitsCalc,
@@ -125,6 +127,16 @@ import {
125
127
  indicatorResultText
126
128
  } from './helpers'
127
129
 
130
+ /** 与表格列顺序一致,供 setMergeCells 计算列索引 */
131
+ const STAT_FLAT_COLUMNS = [
132
+ { prop: 'pName' },
133
+ { prop: 'statsName' },
134
+ { prop: 'name' },
135
+ { prop: 'indicatorResult' },
136
+ { prop: 'result' },
137
+ { prop: 'indicatorValText' }
138
+ ]
139
+
128
140
  export default {
129
141
  name: 'MeasureStatFlatTable',
130
142
  components: { InputNumber },
@@ -138,6 +150,16 @@ export default {
138
150
  computed: {
139
151
  ctx() {
140
152
  return this.measureCtx()
153
+ },
154
+ /** 同目录(pid)下的「指标项」列合并,对齐旧版 modelCalcTest */
155
+ mergeCells() {
156
+ return setMergeCells({
157
+ list: this.rows,
158
+ columns: STAT_FLAT_COLUMNS,
159
+ merges: ['pName'],
160
+ condition: ['pid'],
161
+ field: 'prop'
162
+ })
141
163
  }
142
164
  },
143
165
  methods: {
@@ -191,6 +191,12 @@
191
191
  <span v-if="section.remark" class="section-remark">
192
192
  备注:<span class="remark-html" v-html="section.remark"></span>
193
193
  </span>
194
+ <span
195
+ v-if="sectionWeightText(section)"
196
+ class="section-weight-pill"
197
+ >
198
+ {{ sectionWeightText(section) }}
199
+ </span>
194
200
  <span
195
201
  v-if="sectionScoreText(section)"
196
202
  class="section-score-pill"
@@ -644,11 +650,11 @@ export default {
644
650
  this.leafList = leafList
645
651
  this.qualList = qualList
646
652
  this.subModelList = subModelList
653
+ // 仅以模型级测算结果 / 日志为准;分组节点 result 默认 0 不能当作已测算
647
654
  this.parentCalced = !!(
648
655
  this.logId ||
649
656
  this.model.logId ||
650
- (this.model.result !== '' && this.model.result != null) ||
651
- (root.result !== '' && root.result != null)
657
+ (this.model.result !== '' && this.model.result != null)
652
658
  )
653
659
  this.qualSelectionDraft = {}
654
660
  this.resultText = this.model.resultText || root.resultText || ''
@@ -1309,11 +1315,74 @@ export default {
1309
1315
  return `总得分: ${totalText} = ${parts.join(' + ')}`
1310
1316
  },
1311
1317
 
1312
- /** 分区标题旁得分(评价模型测算后) */
1318
+ /**
1319
+ * 收集参与总权重计算的叶子:指标 / 子模型(文件夹只下钻,不参与)
1320
+ * 公式:满分值 * 占模型权重%
1321
+ */
1322
+ collectWeightContributors(nodes, bucket = []) {
1323
+ if (!Array.isArray(nodes)) return bucket
1324
+ nodes.forEach(n => {
1325
+ if (!n) return
1326
+ if (this.isSubModel(n) || isIndicator(n)) {
1327
+ if (
1328
+ (n.fullScore === 0 || n.fullScore) &&
1329
+ (n.weight === 0 || n.weight)
1330
+ ) {
1331
+ bucket.push(n)
1332
+ }
1333
+ return
1334
+ }
1335
+ if (n.children && n.children.length) {
1336
+ this.collectWeightContributors(n.children, bucket)
1337
+ }
1338
+ })
1339
+ return bucket
1340
+ },
1341
+
1342
+ /**
1343
+ * 大分组总权重文案:总权重: 75.00(不展示计算过程)
1344
+ */
1345
+ buildGroupWeightText(groupNode, children) {
1346
+ if (!groupNode) return ''
1347
+ const contributors = this.collectWeightContributors(
1348
+ children || groupNode.children || []
1349
+ )
1350
+ let total = null
1351
+ if (contributors.length) {
1352
+ total = contributors.reduce((sum, n) => {
1353
+ const full = Number(n.fullScore)
1354
+ const weight = Number(n.weight)
1355
+ return (
1356
+ sum +
1357
+ ((Number.isNaN(full) ? 0 : full) *
1358
+ (Number.isNaN(weight) ? 0 : weight)) /
1359
+ 100
1360
+ )
1361
+ }, 0)
1362
+ } else if (groupNode.fullScore === 0 || groupNode.fullScore) {
1363
+ total = groupNode.fullScore
1364
+ }
1365
+ if (total === null) return ''
1366
+ return `总权重: ${this.formatScoreNum(total)}`
1367
+ },
1368
+
1369
+ /** 分区标题旁总权重(评价模型且开启显示权重) */
1370
+ sectionWeightText(section) {
1371
+ if (!this.evalRootModel || !section) return ''
1372
+ if (this.model.showWeight !== 1) return ''
1373
+ if (!section.container || this.isSubModel(section.container)) return ''
1374
+ return this.buildGroupWeightText(section.container, section.nodes)
1375
+ },
1376
+
1377
+ /** 分区标题旁得分(评价模型:未测算显示 --) */
1313
1378
  sectionScoreText(section) {
1314
- if (!this.evalRootModel || !this.parentCalced || !section) return ''
1379
+ if (!this.evalRootModel || !section) return ''
1315
1380
  if (!section.container || this.isSubModel(section.container)) return ''
1316
- return this.buildGroupScoreText(section.container, section.nodes)
1381
+ if (!this.parentCalced) return '总得分: --'
1382
+ return (
1383
+ this.buildGroupScoreText(section.container, section.nodes) ||
1384
+ '总得分: --'
1385
+ )
1317
1386
  },
1318
1387
 
1319
1388
  /**
@@ -1514,6 +1583,7 @@ export default {
1514
1583
  padding-left: 8px;
1515
1584
  border-left: 3px solid #409eff;
1516
1585
  }
1586
+ .section-weight-pill,
1517
1587
  .section-score-pill {
1518
1588
  display: inline-block;
1519
1589
  margin-left: 4px;
@@ -287,9 +287,12 @@ export function collectStatFlatRows(modelWrap, statNode) {
287
287
  const rows = []
288
288
 
289
289
  const pushIndicators = (groupNode, pName) => {
290
+ const groupPid = groupNode.itemID || groupNode.tid || groupNode.pid
290
291
  statItemChildren(groupNode).forEach(ind => {
291
292
  if (ind.itemType == 21 || ind.itemType == 22 || ind.isLeaf == 1) {
292
293
  if (!ind.pName) ind.pName = pName
294
+ // 合并单元格按 pid 分组;缺省时回落到目录节点 id
295
+ if (ind.pid == null || ind.pid === '') ind.pid = groupPid
293
296
  rows.push(ind)
294
297
  }
295
298
  })