|
@@ -55,6 +55,8 @@
|
|
|
<el-select
|
|
<el-select
|
|
|
v-model="form.scopeKey"
|
|
v-model="form.scopeKey"
|
|
|
size="small"
|
|
size="small"
|
|
|
|
|
+ popper-class="report-scope-dropdown"
|
|
|
|
|
+ :popper-append-to-body="true"
|
|
|
:disabled="busy"
|
|
:disabled="busy"
|
|
|
@change="refreshMeta"
|
|
@change="refreshMeta"
|
|
|
>
|
|
>
|
|
@@ -166,6 +168,8 @@ export default {
|
|
|
farmId: { type: String, default: "" },
|
|
farmId: { type: String, default: "" },
|
|
|
modelId: { type: String, default: "" },
|
|
modelId: { type: String, default: "" },
|
|
|
unitId: { type: String, default: "" },
|
|
unitId: { type: String, default: "" },
|
|
|
|
|
+ units: { type: Array, default: () => [] },
|
|
|
|
|
+ models: { type: Array, default: () => [] },
|
|
|
},
|
|
},
|
|
|
data() {
|
|
data() {
|
|
|
return {
|
|
return {
|
|
@@ -222,18 +226,32 @@ export default {
|
|
|
});
|
|
});
|
|
|
},
|
|
},
|
|
|
scopeOptions() {
|
|
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() {
|
|
canExport() {
|
|
|
return !!(this.meta && this.meta.ok !== false);
|
|
return !!(this.meta && this.meta.ok !== false);
|
|
|
},
|
|
},
|
|
|
noteText() {
|
|
noteText() {
|
|
|
if (!this.meta) return "报告元信息加载中…";
|
|
if (!this.meta) return "报告元信息加载中…";
|
|
|
- return this.meta.note || "";
|
|
|
|
|
|
|
+ return this.meta.note || this.scopeNote(this.meta);
|
|
|
},
|
|
},
|
|
|
},
|
|
},
|
|
|
watch: {
|
|
watch: {
|
|
@@ -314,13 +332,54 @@ export default {
|
|
|
scope,
|
|
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() {
|
|
async refreshMeta() {
|
|
|
const query = this.buildQuery();
|
|
const query = this.buildQuery();
|
|
|
try {
|
|
try {
|
|
|
const { source, meta } = await loadReportMeta(query);
|
|
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.metaSource = source;
|
|
|
- this.meta = meta;
|
|
|
|
|
- this.noteWarn = !!(meta && meta.partial);
|
|
|
|
|
|
|
+ this.meta = next;
|
|
|
|
|
+ this.noteWarn = !!(next && next.partial);
|
|
|
} catch (err) {
|
|
} catch (err) {
|
|
|
this.meta = buildLocalReportMeta(query);
|
|
this.meta = buildLocalReportMeta(query);
|
|
|
this.metaSource = "mock";
|
|
this.metaSource = "mock";
|