Browse Source

rankingApp: 下载报告范围用真实机型 + scope 下拉样式

- ReportExportDialog 接收 units/models,scope 选项按真实机型生成(不再用 mock)
- 报告范围下拉改用 popper 挂 body 并加独立样式
liujiejie 31 phút trước cách đây
mục cha
commit
57cf80c5df

+ 2 - 0
src/views/rankingApp/FarmDiagView.vue

@@ -118,6 +118,8 @@
       :project-name="currentProject ? currentProject.name : ''"
       :farm-id="farmId"
       :model-id="filterModelId"
+      :units="units"
+      :models="models"
     />
 
     <div class="cards-3">

+ 67 - 8
src/views/rankingApp/components/ReportExportDialog.vue

@@ -55,6 +55,8 @@
             <el-select
               v-model="form.scopeKey"
               size="small"
+              popper-class="report-scope-dropdown"
+              :popper-append-to-body="true"
               :disabled="busy"
               @change="refreshMeta"
             >
@@ -166,6 +168,8 @@ export default {
     farmId: { type: String, default: "" },
     modelId: { type: String, default: "" },
     unitId: { type: String, default: "" },
+    units: { type: Array, default: () => [] },
+    models: { type: Array, default: () => [] },
   },
   data() {
     return {
@@ -222,18 +226,32 @@ export default {
       });
     },
     scopeOptions() {
-      const pid =
-        this.projectId ||
-        (PROJECTS[0] && PROJECTS[0].id) ||
-        "";
-      return getScopeOptions(pid);
+      const ids = [];
+      (this.units || []).forEach((unit) => {
+        if (!unit || !unit.modelId) return;
+        if (this.projectId && unit.projectId && unit.projectId !== this.projectId) return;
+        if (ids.indexOf(unit.modelId) < 0) ids.push(unit.modelId);
+      });
+      const named = ids.map((id) => {
+        const found = (this.models || []).find((model) => model && model.id === id);
+        return {
+          value: "model:" + id,
+          label: (found && (found.name || found.id)) || id,
+        };
+      });
+      named.sort((a, b) => String(a.label).localeCompare(String(b.label), "zh"));
+      if (!named.length) {
+        const pid = this.projectId || (PROJECTS[0] && PROJECTS[0].id) || "";
+        return getScopeOptions(pid);
+      }
+      return [{ value: "project", label: "全部机型" }, ...named];
     },
     canExport() {
       return !!(this.meta && this.meta.ok !== false);
     },
     noteText() {
       if (!this.meta) return "报告元信息加载中…";
-      return this.meta.note || "";
+      return this.meta.note || this.scopeNote(this.meta);
     },
   },
   watch: {
@@ -314,13 +332,54 @@ export default {
         scope,
       });
     },
+    scopeNote(meta) {
+      const year = Number((meta && meta.year) || this.form.year) || 2026;
+      const number = Number((meta && meta.number) || this.form.number) || 8;
+      const month = String(number).padStart(2, "0");
+      const endDay = new Date(year, number, 0).getDate();
+      const start = `${year}-${month}-01`;
+      const end = `${year}-${month}-${String(endDay).padStart(2, "0")}`;
+      const rows = meta && meta.rows != null ? Number(meta.rows) : 0;
+      const valid = meta && meta.valid != null ? Number(meta.valid) : 0;
+      const partial = !rows || valid < rows;
+      const coverage = partial
+        ? "当前源数据未覆盖全部机组的完整周期,按实有记录生成,不外推缺失时段。"
+        : "统计周期已结束;内部缺测仍按覆盖率披露。";
+      return `名义周期 ${start} 至 ${end};实际记录 无 至 无。${coverage}`;
+    },
+    metaFromPageUnits(query) {
+      let list = (this.units || []).filter((unit) => {
+        if (query.projectId && unit.projectId && unit.projectId !== query.projectId) return false;
+        if (query.scope === "model" && query.modelId && unit.modelId !== query.modelId) return false;
+        return true;
+      });
+      const rows = list.length;
+      const valid = list.filter((unit) => unit.st && Object.keys(unit.st).length).length;
+      const issueUnits = list.filter((unit) => Number(unit.count) > 0).length;
+      const partial = valid < rows;
+      return {
+        ok: valid > 0,
+        partial,
+        title: `${query.projectName || "风电项目"}${query.year}年${query.number}月功能诊断月报`,
+        valid,
+        rows,
+        issueUnits,
+        year: query.year,
+        number: query.number,
+        note: "",
+      };
+    },
     async refreshMeta() {
       const query = this.buildQuery();
       try {
         const { source, meta } = await loadReportMeta(query);
+        const pageMeta = this.metaFromPageUnits(query);
+        const stub = !meta || (!meta.note && !Number(meta.valid) && !Number(meta.rows));
+        const next = stub && pageMeta.rows ? { ...meta, ...pageMeta } : { ...(meta || {}) };
+        if (!next.note) next.note = this.scopeNote(next);
         this.metaSource = source;
-        this.meta = meta;
-        this.noteWarn = !!(meta && meta.partial);
+        this.meta = next;
+        this.noteWarn = !!(next && next.partial);
       } catch (err) {
         this.meta = buildLocalReportMeta(query);
         this.metaSource = "mock";

+ 3 - 2
src/views/rankingApp/styles/ranking-app.scss

@@ -2162,8 +2162,9 @@
   background-color: #1a2330 !important;
 }
 
-/* ===== 日期选择器下拉面板层级:需高于导出月报弹窗(.report-mask z-index 2400) ===== */
-.el-picker-panel.el-popper {
+/* ===== 日期、机型下拉面板层级:需高于导出月报弹窗(.report-mask z-index 2400) ===== */
+.el-picker-panel.el-popper,
+.report-scope-dropdown.el-select-dropdown {
   z-index: 3000 !important;
 }