Explorar o código

feat(web): 报告类型管理支持编辑采集指标

Xiaogang Liao hai 3 días
pai
achega
f3607c18e0
Modificáronse 1 ficheiros con 50 adicións e 1 borrados
  1. 50 1
      cfc-web/src/views/admin/ReportTypeManagement.vue

+ 50 - 1
cfc-web/src/views/admin/ReportTypeManagement.vue

@@ -41,6 +41,11 @@
             <span class="sort-header" @click.stop="onSortClick('minConfidence', $event)">阈值{{ sortIcon('minConfidence') }}</span>
           </template>
         </el-table-column>
+        <el-table-column label="采集指标" width="90">
+          <template slot-scope="{ row }">
+            <el-tag size="mini" type="info">{{ indicatorCount(row.expectedIndicators) }} 项</el-tag>
+          </template>
+        </el-table-column>
         <el-table-column label="状态" width="80">
           <template slot-scope="{ row }">
             <el-tag :type="row.isActive ? 'success' : 'info'" size="small">
@@ -104,6 +109,27 @@
         <el-form-item label="识别阈值">
           <el-input-number v-model="form.minConfidence" :min="1" :max="100" />
         </el-form-item>
+        <el-form-item label="采集指标">
+          <el-tag
+            v-for="(tag, idx) in indicators"
+            :key="idx"
+            closable
+            size="small"
+            style="margin: 0 6px 6px 0;"
+            @close="removeIndicator(idx)"
+          >{{ tag }}</el-tag>
+          <el-input
+            v-if="indicatorInputVisible"
+            ref="indicatorInput"
+            v-model="indicatorInput"
+            size="mini"
+            style="width: 160px;"
+            @keyup.enter.native="confirmIndicator"
+            @blur="confirmIndicator"
+          />
+          <el-button v-else size="mini" @click="showIndicatorInput">+ 添加指标</el-button>
+          <div class="el-form-item-msg">该类型报告应采集的指标项名称;留空表示不校验</div>
+        </el-form-item>
       </el-form>
       <div slot="footer">
         <el-button @click="dialogVisible = false">取消</el-button>
@@ -176,6 +202,7 @@ export default {
       sortableColumns: { id: 'ID', typeId: '类型标识', displayName: '显示名称', family: '家族', parserPath: '解析器路径', minConfidence: '阈值', source: '来源' },
       dialogVisible: false, isEdit: false,
       form: { typeId: '', displayName: '', family: '', description: '', parserPath: '', minConfidence: 10 },
+      indicators: [], indicatorInput: '', indicatorInputVisible: false,
       fpDialogVisible: false, currentType: null,
       fingerprints: [], fpFormVisible: false,
       fpForm: { pattern: '', weight: 10, isExclusion: false, sortOrder: 0 },
@@ -206,20 +233,42 @@ export default {
       } catch (e) { this.$message.error('加载失败') }
       this.loading = false
     },
+    safeParseIndicators(raw) {
+      if (!raw) return []
+      try {
+        const arr = JSON.parse(raw)
+        return Array.isArray(arr) ? arr.filter(x => typeof x === 'string') : []
+      } catch (e) { return [] }
+    },
+    indicatorCount(raw) { return this.safeParseIndicators(raw).length },
+    showIndicatorInput() {
+      this.indicatorInputVisible = true
+      this.$nextTick(() => this.$refs.indicatorInput && this.$refs.indicatorInput.focus())
+    },
+    confirmIndicator() {
+      const v = (this.indicatorInput || '').trim()
+      if (v && !this.indicators.includes(v)) this.indicators.push(v)
+      this.indicatorInput = ''
+      this.indicatorInputVisible = false
+    },
+    removeIndicator(idx) { this.indicators.splice(idx, 1) },
     handleCreate() {
       this.isEdit = false
       this.form = { typeId: '', displayName: '', family: '', description: '', parserPath: '', minConfidence: 10 }
+      this.indicators = []
       this.dialogVisible = true
     },
     handleEdit(row) {
       this.isEdit = true
       this.form = { ...row }
+      this.indicators = this.safeParseIndicators(row.expectedIndicators)
       this.dialogVisible = true
     },
     async handleSubmit() {
       this.submitting = true
       try {
-        await saveReportType(this.form)
+        const payload = { ...this.form, expectedIndicators: JSON.stringify(this.indicators) }
+        await saveReportType(payload)
         this.$message.success('保存成功')
         this.dialogVisible = false
         this.fetchTypes()