Files
admin/src/pages/progress/index.vue

1206 lines
42 KiB
Vue
Raw Normal View History

2026-04-20 10:13:52 +08:00
<template>
<div class="progress-page">
<div class="canvas">
<header class="topbar"><div class="topbar-center"><div class="model-title">XXX特大桥主体模型.rvt</div></div></header>
<section class="model-stage">
2026-04-29 18:22:07 +08:00
<ModelPlaceholder ref="modelRef" @componentBindEncoding="onComponentBindEncoding" @codeBindComponent="codeBindComponent" />
2026-04-20 10:13:52 +08:00
</section>
<section class="module-topbar">
<div class="module-topbar-panel">
<div class="field field-time">
<select class="select" v-model="timeStatMode"><option value="cutoff">日期截止统计</option></select>
<input class="date-input" type="date" v-model="cutoffDateDraft" />
<button class="btn btn-sm btn-accent" type="button" @click="applyCutoffDate">查询</button>
<div class="kpi kpi-progress">整体完成百分比<span class="kpi-number">{{ formatPercentValue(overallPercent, 2) }}</span></div>
</div>
<div class="field field-percent">
<span class="field-label">进度百分比</span>
<label class="chip chip-status"><input type="checkbox" :checked="percentFilters.all" @change="togglePercentFilter('all', $event.target.checked)" /> 全部</label>
<label class="chip chip-status chip-gray"><input type="checkbox" :checked="percentFilters.p0" @change="togglePercentFilter('p0', $event.target.checked)" /> 0%</label>
<label class="chip chip-status chip-red"><input type="checkbox" :checked="percentFilters.p0_50" @change="togglePercentFilter('p0_50', $event.target.checked)" /> 0%-50%</label>
<label class="chip chip-status chip-blue"><input type="checkbox" :checked="percentFilters.p50_100" @change="togglePercentFilter('p50_100', $event.target.checked)" /> 50%-100%</label>
<label class="chip chip-status chip-green"><input type="checkbox" :checked="percentFilters.p100" @change="togglePercentFilter('p100', $event.target.checked)" /> 100%</label>
</div>
</div>
</section>
<aside class="sidepanel" :class="{ 'is-collapsed': sideCollapsed }">
<header class="sidepanel-header">
<div class="sidepanel-title">工程部位</div>
<button class="iconbtn" type="button" @click="sideCollapsed = !sideCollapsed">{{ sideCollapsed ? "" : "" }}</button>
</header>
<div class="sidepanel-body" v-show="!sideCollapsed">
2026-04-29 18:22:07 +08:00
<div class="tree">
<div class="tree-item" :class="{ 'is-active': row.leaf && row.id === selectedStructureId }" :style="{ paddingLeft: `${10 + row.level * 14}px` }" v-for="row in visibleTreeRows" :key="row.id" @click="onTreeRowClick(row)" @contextmenu.prevent="onTreeRightClick($event, row)">
<button class="tree-caret" type="button" :class="{ 'is-leaf': row.leaf }" :disabled="row.leaf" @click.stop="toggleTreeExpand(row)">{{ row.leaf ? "" : row.open ? "" : "" }}</button>
<span class="tree-bullet"></span>
<span class="tree-text">{{ row.name }}</span>
</div>
</div>
<div v-if="showContextMenu" class="context-menu" :style="{ left: contextMenuX + 'px', top: contextMenuY + 'px' }" @click.stop>
<div class="context-menu-item" @click="onAddComponent">绑定编码</div>
<div class="context-menu-item" @click="onViewComponent">查看编辑</div>
</div>
<div v-if="showAddModal" class="add-modal" :style="modalPosition" @pointerdown.stop="onModalPointerDown">
<header class="add-modal-header">
<div class="add-modal-title">绑定编码</div>
<button class="add-modal-close" type="button" @click="showAddModalClose"></button>
</header>
<div class="add-modal-body">
<div class="add-modal-split">
<div class="add-modal-left">
<div class="add-modal-section-title">部位列表</div>
<div class="add-modal-list">
<div class="add-modal-tag" v-for="(id, index) in partList" :key="index">
<span>{{ getStructureName(id.id) }}</span>
<button class="add-modal-tag-delete" type="button" @click="partList.splice(index, 1)"></button>
</div>
</div>
</div>
<div class="add-modal-right">
<div class="add-modal-section-title">构件列表</div>
<div class="add-modal-list">
<div class="add-modal-tag" v-for="(item, index) in componentList" :key="index">
<!-- <input class="add-form-input" v-model="item.code" placeholder="请输入构件编码" />-->
<span>{{ item.code }}</span>
<button class="add-modal-tag-delete" type="button" @click="componentList.splice(index, 1)"></button>
</div>
</div>
</div>
</div>
<div class="add-modal-footer">
<button class="add-modal-btn add-modal-btn-secondary" type="button" @click="showAddModalHandle">取消</button>
<button class="add-modal-btn add-modal-btn-primary" type="button" @click="onSaveComponent">保存</button>
</div>
</div>
</div>
<div v-if="showViewModal" class="add-modal" :style="viewModalPosition" @pointerdown.stop="onViewModalPointerDown">
<header class="add-modal-header">
<div class="add-modal-title">查看构件</div>
<button class="add-modal-close" type="button" @click="showViewModal = false"></button>
</header>
<div class="add-modal-body">
<div class="add-modal-split">
<div class="add-modal-left">
<div class="add-modal-section-title">部位列表</div>
<div class="add-modal-list">
<div class="add-modal-tag" v-for="(id, index) in viewPartList" :key="index">
<span>{{ getStructureName(id?.id || id) }}</span>
2026-04-29 18:22:07 +08:00
</div>
</div>
</div>
<div class="add-modal-right">
<div class="add-modal-section-title">构件列表</div>
<div class="add-modal-list">
<div class="add-modal-tag" v-for="(item, index) in viewComponentList" :key="index">
<span>{{ getViewComponentCode(item) }}</span>
2026-04-29 18:22:07 +08:00
<button class="add-modal-tag-delete" type="button" @click="viewComponentList.splice(index, 1)"></button>
</div>
</div>
</div>
</div>
<div class="add-modal-footer">
<button class="add-modal-btn add-modal-btn-secondary" type="button" @click="showViewModal = false">取消</button>
<button class="add-modal-btn add-modal-btn-primary" type="button" @click="onDeleteComponent">保存</button>
</div>
</div>
2026-04-20 10:13:52 +08:00
</div>
</div>
2026-04-29 18:22:07 +08:00
</aside>
2026-04-20 10:13:52 +08:00
<section class="bottompanel" :class="{ 'is-collapsed': bottomCollapsed }">
<header class="bottompanel-header"><div class="tabs"><button class="tab is-on" type="button">项目日进度明细</button></div></header>
<button class="iconbtn bottompanel-toggle" type="button" @click="bottomCollapsed = !bottomCollapsed">{{ bottomCollapsed ? "" : "" }}</button>
<div class="bottompanel-body" v-show="!bottomCollapsed">
<table class="table">
<thead>
<tr>
2026-04-24 17:04:50 +08:00
<!-- <th>序号</th><th>全名称</th><th>清单编号</th><th>清单名称</th><th>单位</th><th>合同数量</th><th>合同金额</th><th>填报日期</th><th>完成数量</th><th>完成金额</th><th>累计完成数量</th>-->
2026-04-29 18:22:07 +08:00
<th>序号</th><th>全名称</th><th>清单编号</th><th>清单名称</th><th>单位</th><th>合同数量</th><th>合同金额</th><th>合同金额不含税</th><th>累计完成数量</th><th>进度</th>
2026-04-20 10:13:52 +08:00
</tr>
</thead>
<tbody>
<tr v-for="r in progressRows" :key="r.no">
2026-04-29 18:22:07 +08:00
<td>{{ r.no }}</td><td>{{ r.fullName }}</td><td>{{ r.workCode }}</td><td>{{ r.name }}</td><td>{{ r.workUnit }}</td><td>{{ formatNumber(r.meteringNum,2) }}</td><td>{{ formatMoney(r.meteringAmt) }}</td><td>{{ formatMoney(r.meteringNotaxAmt) }}</td><td>{{ r.totalNum }}</td><td>{{ proportion(r.meteringNum,r.totalNum) }}</td>
2026-04-20 10:13:52 +08:00
</tr>
</tbody>
</table>
</div>
</section>
</div>
</div>
2026-04-29 18:22:07 +08:00
<div v-if="toastText" class="toast" :class="'toast-' + toastType">{{ toastText }}</div>
2026-04-20 10:13:52 +08:00
</template>
<script setup>
2026-04-29 18:22:07 +08:00
import {computed, onMounted, reactive, ref} from "vue";
2026-04-20 10:13:52 +08:00
import ModelPlaceholder from "../../components/model-placeholder/index.vue";
2026-04-29 18:22:07 +08:00
import {progressApi} from "../../service/api/progress.js";
2026-04-20 10:13:52 +08:00
2026-04-24 17:04:50 +08:00
const structures = ref([]);
2026-04-29 18:22:07 +08:00
const modelRef = ref(null);
2026-04-24 17:04:50 +08:00
const elementTree = ref([]);
const progressData = ref([]);
2026-04-20 10:13:52 +08:00
const sideCollapsed = ref(false);
const bottomCollapsed = ref(false);
2026-04-24 17:04:50 +08:00
const selectedStructureId = ref("");
const expanded = ref(new Set());
const loading = ref(false);
2026-04-20 10:13:52 +08:00
2026-04-29 18:22:07 +08:00
const showContextMenu = ref(false);
const contextMenuX = ref(0);
const contextMenuY = ref(0);
const contextMenuRow = ref(null);
const showAddModal = ref(false);
const componentList = ref([]);
const partList = ref([]);
const showViewModal = ref(false);
const viewPartList = ref([]);
const viewComponentList = ref([]);
const toastText = ref("");
const toastType = ref("success");
const normalLight = ref([]);
const taskId = ref("");
2026-04-29 18:22:07 +08:00
const modalPosition = ref({ left: "50%", top: "50%", transform: "translate(-50%, -50%)" });
let modalDragging = false;
let modalStartX = 0, modalStartY = 0;
let modalStartLeft = 0, modalStartTop = 0;
function onModalPointerDown(e) {
if (e.target.closest(".add-modal-close") || e.button !== 0) return;
modalDragging = true;
modalStartX = e.clientX;
modalStartY = e.clientY;
const pos = modalPosition.value;
if (pos.transform) {
modalStartLeft = 50;
modalStartTop = 50;
}
window.addEventListener("pointermove", onModalPointerMove);
window.addEventListener("pointerup", onModalPointerUp);
}
function onModalPointerMove(e) {
if (!modalDragging) return;
const dx = e.clientX - modalStartX;
const dy = e.clientY - modalStartY;
modalPosition.value = {
left: `calc(50% + ${dx}px)`,
top: `calc(50% + ${dy}px)`,
transform: "translate(-50%, -50%)"
};
}
function onModalPointerUp() {
modalDragging = false;
window.removeEventListener("pointermove", onModalPointerMove);
window.removeEventListener("pointerup", onModalPointerUp);
}
const viewModalPosition = ref({ left: "50%", top: "50%", transform: "translate(-50%, -50%)" });
let viewModalDragging = false;
let viewModalStartX = 0, viewModalStartY = 0;
function onViewModalPointerDown(e) {
if (e.target.closest(".add-modal-close") || e.button !== 0) return;
viewModalDragging = true;
viewModalStartX = e.clientX;
viewModalStartY = e.clientY;
window.addEventListener("pointermove", onViewModalPointerMove);
window.addEventListener("pointerup", onViewModalPointerUp);
}
function onViewModalPointerMove(e) {
if (!viewModalDragging) return;
const dx = e.clientX - viewModalStartX;
const dy = e.clientY - viewModalStartY;
viewModalPosition.value = {
left: `calc(50% + ${dx}px)`,
top: `calc(50% + ${dy}px)`,
transform: "translate(-50%, -50%)"
};
}
function onViewModalPointerUp() {
viewModalDragging = false;
window.removeEventListener("pointermove", onViewModalPointerMove);
window.removeEventListener("pointerup", onViewModalPointerUp);
}
2026-04-20 10:13:52 +08:00
const timeStatMode = ref("cutoff");
const baselineDate = ref(todayISODate());
2026-04-24 17:04:50 +08:00
const baselineOverallPercent = ref(0);
2026-04-20 10:13:52 +08:00
const cutoffDate = ref(todayISODate());
const cutoffDateDraft = ref(cutoffDate.value);
const percentFilters = reactive({ all: false, p0: false, p0_50: false, p50_100: false, p100: false });
const filteredProgressCodeData = ref([]);
const filteredProgressColorParams = ref([]);
const percentColorMap = {
p0: "#6E7D96",
p0_50: "#D9363E",
p50_100: "#156CFF",
p100: "#2F8F2F",
};
2026-04-20 10:13:52 +08:00
const visibleTreeRows = computed(() => {
const rows = [];
const walk = (node, level) => {
2026-04-24 17:04:50 +08:00
const leaf = node.isLeaf === true;
2026-04-20 10:13:52 +08:00
const open = expanded.value.has(node.id);
2026-04-29 18:22:07 +08:00
rows.push({ id: node.id, name: node.name, level, leaf, open, createDate: node.createDate, projectId: node.projectId });
2026-04-24 17:04:50 +08:00
if (!leaf && open && node.children) {
node.children.forEach((c) => walk(c, level + 1));
}
2026-04-20 10:13:52 +08:00
};
2026-04-24 17:04:50 +08:00
elementTree.value.forEach((n) => walk(n, 0));
2026-04-20 10:13:52 +08:00
return rows;
});
2026-04-24 17:04:50 +08:00
const selectedStructureName = computed(() => {
const findById = (nodes) => {
for (const n of nodes) {
if (n.id === selectedStructureId.value) return n.name;
if (n.children) {
const found = findById(n.children);
if (found) return found;
}
}
};
return findById(elementTree.value) || "";
});
const selectedStructureNode = computed(() => {
return findNode(elementTree.value, selectedStructureId.value);
});
2026-04-20 10:13:52 +08:00
const overallPercent = computed(() => {
2026-04-24 17:04:50 +08:00
if (!selectedStructureNode.value) return 0;
return 0;
2026-04-20 10:13:52 +08:00
});
const progressRows = computed(() => {
2026-04-29 18:22:07 +08:00
if (!selectedStructureId.value && progressData.value.length === 0) return [];
2026-04-24 17:04:50 +08:00
return progressData.value.map((item, index) => ({
no: index + 1,
fullName: item.fullName || "",
workCode: item.workCode || "",
name: item.name || "",
workUnit: item.workUnit || "-",
meteringAmt: item.meteringAmt || 0,
meteringNotaxAmt: item.meteringNotaxAmt || 0,
meteringNum: item.meteringNum || 0,
2026-04-29 18:22:07 +08:00
totalNum: item.totalNum || '',
2026-04-24 17:04:50 +08:00
doneQty: item.doneQty || 0,
doneAmt: item.doneAmt || 0,
cumDoneQty: item.cumDoneQty || 0,
}));
});
async function loadWbsTree(parentId) {
loading.value = true;
try {
const data = await progressApi.getTree(parentId);
if (!parentId) {
elementTree.value = data.map((item) => ({
...item,
children: item.isLeaf ? [] : [],
isLeaf: !!item.isLeaf,
}));
if (data.length > 0) {
const firstLeaf = findFirstLeaf(elementTree.value);
if (firstLeaf) selectedStructureId.value = firstLeaf.id;
}
} else {
updateChildren(elementTree.value, parentId, data);
}
} catch (e) {
console.error("加载WBS树失败:", e);
} finally {
loading.value = false;
}
}
function findFirstLeaf(nodes) {
for (const n of nodes) {
if (n.isLeaf) return n;
if (n.children && n.children.length > 0) {
const found = findFirstLeaf(n.children);
if (found) return found;
}
}
}
function updateChildren(nodes, parentId, children) {
for (const n of nodes) {
if (n.id === parentId) {
n.children = children.map((item) => ({
...item,
children: item.isLeaf ? [] : [],
isLeaf: !!item.isLeaf,
}));
return true;
}
if (n.children && updateChildren(n.children, parentId, children)) return true;
}
return false;
}
function findNode(nodes, id) {
for (const n of nodes) {
if (n.id === id) return n;
if (n.children) {
const found = findNode(n.children, id);
if (found) return found;
}
}
return null;
}
onMounted(async() => {
await loadWbsTree();
2026-04-29 18:22:07 +08:00
window.addEventListener("click", closeContextMenu);
const result = await progressApi.calculateProgress();
taskId.value = result.taskId
2026-04-20 10:13:52 +08:00
});
function todayISODate() {
return new Date().toISOString().slice(0, 10);
}
2026-04-29 18:22:07 +08:00
function getStructureName(id) {
const findName = (nodes) => {
for (const n of nodes) {
if (n.id === id) return n.name;
if (n.children) {
const found = findName(n.children);
if (found) return found;
}
}
};
return findName(elementTree.value) || id;
}
2026-04-20 10:13:52 +08:00
function daysBetweenISO(a, b) {
const da = new Date(`${a}T00:00:00`);
const db = new Date(`${b}T00:00:00`);
return Math.round((db.getTime() - da.getTime()) / 86400000);
}
function clamp(value, min, max) {
return Math.min(max, Math.max(min, value));
}
function formatPercentValue(value, digits = 2) {
return `${Number(value).toFixed(digits)}%`;
}
function formatMoney(value) {
if (value == null || Number.isNaN(value)) return "--";
const abs = Math.abs(value);
const sign = value < 0 ? "-" : "";
if (abs >= 1e8) return `${sign}${(abs / 1e8).toFixed(2)}亿`;
if (abs >= 1e4) return `${sign}${(abs / 1e4).toFixed(2)}`;
return `${sign}${abs.toFixed(2)}`;
}
function formatNumber(value, digits = 0) {
return Number(value).toLocaleString("zh-CN", { minimumFractionDigits: digits, maximumFractionDigits: digits });
}
function extractProgressItems(response) {
if (Array.isArray(response)) return response;
if (Array.isArray(response?.current?.data)) return response.current.data;
if (Array.isArray(response?.data?.data)) return response.data.data;
if (Array.isArray(response?.data)) return response.data;
return [];
}
function normalizeProgressRatio(value) {
const n = Number(value);
if (!Number.isFinite(n)) return 0;
if (n > 1) return clamp(n / 100, 0, 1);
return clamp(n, 0, 1);
}
function isProgressMatched(ratio, key) {
const EPS = 1e-8;
if (key === "p0") return Math.abs(ratio) <= EPS;
if (key === "p0_50") return ratio > EPS && ratio <= 0.5 + EPS;
if (key === "p50_100") return ratio > 0.5 + EPS && ratio < 1 - EPS;
if (key === "p100") return Math.abs(ratio - 1) <= EPS;
return false;
}
function buildModelCodeData(list) {
const groupedByUrl = new Map();
for (const item of list) {
const rawCodeData = String(item?.codeData || "").trim();
if (!rawCodeData) continue;
const params = getParams(rawCodeData);
const url = String(params.url || "").trim();
const rawId = String(params.id || "").trim();
if (!url || !rawId) continue;
const id = Number(rawId);
const idValue = Number.isFinite(id) ? id : rawId;
if (!groupedByUrl.has(url)) groupedByUrl.set(url, new Set());
groupedByUrl.get(url).add(idValue);
}
return Array.from(groupedByUrl.entries()).map(([url, idSet]) => ({
url,
ids: Array.from(idSet),
}));
}
async function refreshFilteredProgressCodeData() {
if (!taskId.value) {
filteredProgressCodeData.value = [];
filteredProgressColorParams.value = [];
modelRef.value?.cancelLightModels();
return;
}
try {
const response = await progressApi.getProgress(taskId.value);
const items = extractProgressItems(response);
const enabledKeys = ["p0", "p0_50", "p50_100", "p100"].filter((k) => percentFilters[k]);
const activeKeys = percentFilters.all ? ["p0", "p0_50", "p50_100", "p100"] : enabledKeys;
if (activeKeys.length === 0) {
filteredProgressCodeData.value = [];
filteredProgressColorParams.value = [];
modelRef.value?.cancelLightModels();
return;
}
const groupedParams = [];
const allMatchedCodeData = [];
activeKeys.forEach((key) => {
const matched = items.filter((item) => isProgressMatched(normalizeProgressRatio(item.progressData), key));
if (!matched.length) return;
allMatchedCodeData.push(...matched.map((item) => item.codeData).filter(Boolean));
const modelCodeData = buildModelCodeData(matched);
if (!modelCodeData.length) return;
groupedParams.push({
range: key,
codeData: modelCodeData,
color: percentColorMap[key],
});
});
filteredProgressCodeData.value = Array.from(new Set(allMatchedCodeData));
filteredProgressColorParams.value = groupedParams;
if (groupedParams.length > 0) {
modelRef.value?.otherLightModels({ codeData: groupedParams, color: "" });
} else {
modelRef.value?.cancelLightModels();
}
} catch (e) {
console.error("按百分比筛选构件失败:", e);
filteredProgressCodeData.value = [];
filteredProgressColorParams.value = [];
modelRef.value?.cancelLightModels();
}
}
2026-04-20 10:13:52 +08:00
function applyCutoffDate() {
cutoffDate.value = cutoffDateDraft.value || cutoffDate.value || todayISODate();
}
2026-04-29 18:22:07 +08:00
// 计算比例count / allCount并显示百分比
function proportion(count, allCount) {
if (count==="" || allCount==="")
return ""
// 防止除以 0 报错
if (!allCount || allCount === 0) return `0 / 0 (0%)`
// 计算百分比保留2位小数
let percent = ((count / allCount) * 100).toFixed(2)
// 返回格式5 / 10 (50.00%)
return `${count} / ${allCount} (${percent}%)`
}
2026-04-20 10:13:52 +08:00
async function applyAllExclusive(key, checked) {
const isUncheckAction = checked === false;
2026-04-20 10:13:52 +08:00
if (key === "all") {
percentFilters.all = checked;
if (checked) {
2026-04-29 18:22:07 +08:00
percentFilters.p0 = true;
percentFilters.p0_50 = true;
percentFilters.p50_100 = true;
percentFilters.p100 = true;
} else {
2026-04-20 10:13:52 +08:00
percentFilters.p0 = false;
percentFilters.p0_50 = false;
percentFilters.p50_100 = false;
percentFilters.p100 = false;
}
if (isUncheckAction) {
modelRef.value?.cancelLightModels();
}
await refreshFilteredProgressCodeData();
2026-04-20 10:13:52 +08:00
return;
}
2026-04-20 10:13:52 +08:00
percentFilters[key] = checked;
if (checked) {
percentFilters.all = false;
} else {
// 取消任一区间时,"全部"必须退出选中态
percentFilters.all = false;
modelRef.value?.cancelLightModels();
}
2026-04-29 18:22:07 +08:00
if (!percentFilters.p0 && !percentFilters.p0_50 && !percentFilters.p50_100 && !percentFilters.p100) percentFilters.all = false;
await refreshFilteredProgressCodeData();
2026-04-20 10:13:52 +08:00
}
function togglePercentFilter(key, checked) { applyAllExclusive(key, checked).catch((e) => console.error("切换百分比筛选失败:", e)); }
2026-04-20 10:13:52 +08:00
2026-04-24 17:04:50 +08:00
function toggleTreeExpand(row) {
if (row.leaf) return;
if (expanded.value.has(row.id)) {
expanded.value.delete(row.id);
} else {
expanded.value.add(row.id);
const node = findNode(elementTree.value, row.id);
if (node && (!node.children || node.children.length === 0)) {
loadWbsTree(row.id);
}
}
}
2026-04-29 18:22:07 +08:00
async function onTreeRowClick(row) {
if (showAddModal.value) {
addPartToBindingList(row);
}
2026-04-29 18:22:07 +08:00
modelRef.value?.cancelLightModels();
normalLight.value = [];
const data = await progressApi.getByPartId(row.id);
if (showViewModal.value) {
applyViewModalData(row, data);
}
2026-04-29 18:22:07 +08:00
if (data.length > 0) {
for (const item of data) {
const codeData = getParams(item.codeData);
const url = codeData.url;
const id = Number(codeData.id);
// 1. 去找数组里有没有相同的 url
let existItem = normalLight.value.find((i) => i.url === url);
if (existItem) {
// 2. 找到了 → 把id加进去
existItem.ids.push(id);
} else {
// 3. 没找到 → 新增
normalLight.value.push({ url, ids: [id] });
}
}
modelRef.value?.highlightModels(normalLight.value);
}
2026-04-24 17:04:50 +08:00
if (row.leaf) {
selectedStructureId.value = row.id;
2026-04-29 18:22:07 +08:00
await loadProgressData(row.id, row.createDate);
2026-04-24 17:04:50 +08:00
} else {
toggleTreeExpand(row);
2026-04-29 18:22:07 +08:00
progressData.value = []
progressData.value = await progressApi.findActAmtByPositionId(row.projectId, row.id, row.createDate);
2026-04-24 17:04:50 +08:00
}
}
2026-04-29 18:22:07 +08:00
//获取"{url=https://lyz-1259524260.cos.ap-guangzhou.myqcloud.com/iflow/models/417664a3-76c8-4d94-9344-1337246a5d4e, id=353503}" return obj =>{url,id}
function getParams(str) {
let obj = {};
str.replace(/{([\s\S]+)}/, '$1').split(', ').forEach(i => {
let [k, v] = i.split('=');
obj[k] = v;
});
return obj;
}
function onTreeRightClick(e, row) {
// if (!row.leaf) return;
contextMenuX.value = e.clientX;
contextMenuY.value = e.clientY;
contextMenuRow.value = row;
showContextMenu.value = true;
}
function addPartToBindingList(row) {
if (!row?.id) return;
const exists = partList.value.some((item) => item.id === row.id);
if (exists) return;
partList.value.push({ id: row.id, createDate: row.createDate });
}
2026-04-29 18:22:07 +08:00
function onAddComponent() {
// Start a new binding session from current right-click row.
partList.value = [];
addPartToBindingList(contextMenuRow.value);
componentList.value = [];
2026-04-29 18:22:07 +08:00
showAddModal.value = true;
showContextMenu.value = false;
}
async function onViewComponent() {
const partId = contextMenuRow.value?.id;
if (!partId) return;
showContextMenu.value = false;
try {
const data = await progressApi.getByPartId(partId);
applyViewModalData(contextMenuRow.value, data);
2026-04-29 18:22:07 +08:00
} catch (e) {
console.error("获取构件列表失败:", e);
showToast("获取失败", "error");
}
}
function applyViewModalData(row, data) {
const partId = row?.id;
if (!partId) return;
viewPartList.value = [{ id: partId, createDate: row?.createDate }];
const mapped = (data || [])
.map((item) => toBindingCodeItem(item))
.filter(Boolean);
const seen = new Set();
viewComponentList.value = mapped.filter((item) => {
if (seen.has(item.code)) return false;
seen.add(item.code);
return true;
});
showViewModal.value = true;
}
function resolveComponentCode(item) {
const directId = item?.codeId ?? item?.code ?? item?.id;
if (directId != null && String(directId).trim()) return String(directId).trim();
const rawCodeData = String(item?.codeData || "").trim();
if (rawCodeData) {
try {
const parsed = getParams(rawCodeData);
const parsedId = String(parsed?.id || "").trim();
if (parsedId) return parsedId;
} catch (e) {
// ignore malformed codeData records
}
}
return "";
}
function resolveComponentCodeDataPayload(item, code) {
const rawCodeData = String(item?.codeData || "").trim();
if (rawCodeData) {
try {
return getParams(rawCodeData);
} catch (e) {
// fallback below
}
}
const rawData = item?.data;
if (typeof rawData === "string" && rawData.trim()) {
try {
return getParams(rawData.trim());
} catch (e) {
return { value: rawData.trim(), id: code };
}
}
if (rawData && typeof rawData === "object") {
const nestedCodeData = String(rawData?.codeData || "").trim();
if (nestedCodeData) {
try {
return getParams(nestedCodeData);
} catch (e) {
// fallback below
}
}
const nestedUrl = String(rawData?.url || "").trim();
const nestedId = String(rawData?.id || code || "").trim();
if (nestedUrl && nestedId) return { url: nestedUrl, id: nestedId };
}
const url = String(item?.url || "").trim();
if (url && code) return { url, id: code };
return rawData && typeof rawData === "object" ? rawData : { id: code };
}
function toBindingCodeItem(item) {
const code = resolveComponentCode(item);
if (!code) return null;
const data = resolveComponentCodeDataPayload(item, code);
if (data && typeof data === "object" && !Array.isArray(data) && !data.id) {
data.id = code;
}
return { code, data };
}
function getViewComponentCode(item) {
const code = resolveComponentCode(item);
if (code) return code;
return "--";
}
2026-04-29 18:22:07 +08:00
async function onDeleteComponent() {
const partIds = viewPartList.value;
const codeIds = viewComponentList.value;
if (!partIds.length || !codeIds.length) return;
2026-04-29 18:22:07 +08:00
try {
const res = await progressApi.deleteBatch({ partIds, codeIds });
2026-04-29 18:22:07 +08:00
if (res?.code === 200) {
showToast("保存成功!", "success");
2026-04-29 18:22:07 +08:00
showViewModal.value = false;
} else {
showToast(res?.message || "保存失败!", "error");
2026-04-29 18:22:07 +08:00
}
} catch (e) {
console.error("保存失败:", e);
showToast("保存失败!", "error");
2026-04-29 18:22:07 +08:00
}
}
function closeContextMenu() {
showContextMenu.value = false;
}
function addComponentToBindingList(component) {
const code = String(component?.id || "").trim();
if (!code) return;
const exists = componentList.value.some((item) => String(item?.code || "") === code);
if (exists) return;
componentList.value.push({ code, data: component });
}
function addComponentToViewList(component) {
const mapped = toBindingCodeItem(component);
if (!mapped) return;
const exists = viewComponentList.value.some((item) => String(item?.code || "") === mapped.code);
if (exists) return;
viewComponentList.value.push(mapped);
}
2026-04-29 18:22:07 +08:00
function onComponentBindEncoding(data) {
if (showAddModal.value) {
showAddModal.value = false;
return;
}
componentList.value = [];
partList.value = [];
showAddModal.value = true;
for (let component of data.components) {
addComponentToBindingList(component);
2026-04-29 18:22:07 +08:00
}
}
async function codeBindComponent(data) {
const inBindMode = showAddModal.value;
const inViewMode = showViewModal.value;
2026-04-29 18:22:07 +08:00
if (!data?.components?.length) return;
2026-04-29 18:22:07 +08:00
progressData.value = []
const newData = [];
for (const comp of data.components) {
const res = await progressApi.getByCodeId(comp.id);
for (const item of res) {
if (item.pjDayData) {
if (Array.isArray(item.pjDayData)) {
newData.push(...item.pjDayData);
} else {
newData.push(item.pjDayData);
}
}
}
if (inBindMode) {
addComponentToBindingList(comp);
}
if (inViewMode) {
addComponentToViewList(comp);
}
2026-04-29 18:22:07 +08:00
}
progressData.value = [...progressData.value, ...newData];
}
async function onSaveComponent() {
const partIds = partList.value;
const codeIds = componentList.value;
// const codeIds = componentList.value.filter((c) => c.code).map((c) => c.code);
if (!partIds.length || !codeIds.length) return;
try {
const res = await progressApi.saveBatch({ partIds, codeIds });
if (res.code === 200) {
showToast("保存成功!", "success");
showAddModal.value = false;
} else {
showToast(res.message || "保存失败!", "error");
}
} catch (e) {
console.error("保存失败:", e);
showToast("保存失败!", "error");
}
}
function showToast(text, type = "success") {
toastText.value = text;
toastType.value = type;
setTimeout(() => { toastText.value = ""; }, 2000);
}
async function showAddModalHandle() {
partList.value = [];
componentList.value = [];
showAddModal.value = false;
}
async function showAddModalClose() {
partList.value = [];
componentList.value = [];
showAddModal.value = false;
}
2026-04-24 17:04:50 +08:00
async function loadProgressData(positionId,time) {
loading.value = true;
try {
const data = await progressApi.getPjProgress({
2026-04-29 18:22:07 +08:00
projectId: "5e4bde33ec084f1a8673eb59b190dce7",
2026-04-24 17:04:50 +08:00
positionIds: positionId,
period: time,
});
progressData.value = data;
} catch (e) {
console.error("加载进度明细失败:", e);
progressData.value = [];
} finally {
loading.value = false;
}
}
2026-04-20 10:13:52 +08:00
</script>
<style scoped>
.progress-page { min-height: 100vh; font-family: "Microsoft YaHei", "PingFang SC", "Hiragino Sans GB", "Noto Sans CJK SC", sans-serif; }
.canvas { position: relative; min-height: 100vh; overflow: hidden; border-radius: 24px; border: 1px solid rgba(98,191,206,.34); background: radial-gradient(circle at 50% 30%, #bcc9d6 0%, #b2c3d2 60%, #a8b8c9 100%); box-shadow: inset 0 0 0 8px rgba(214,230,241,.55); }
.topbar { position: absolute; inset: 0 0 auto; height: 120px; z-index: 30; }
.topbar-center { position: absolute; left: 50%; transform: translateX(-50%); top: 16px; }
.model-title { font-size: 20px; letter-spacing: 1px; font-weight: 700; color: rgba(255,128,52,.95); text-shadow: 0 2px 10px rgba(0,0,0,.25); }
.model-stage { position: absolute; inset: 0; }
.module-topbar { position: absolute; left: 50%; top: 20px; transform: translateX(-50%); width: min(800px, calc(100% - 180px)); z-index: 99; }
.module-topbar-panel { border-radius: 18px; border: 1px solid rgba(83,214,206,.26); background: radial-gradient(420px 120px at 18% 0%, rgba(83,214,206,.22), transparent 70%), linear-gradient(180deg, rgba(18,32,40,.94), rgba(15,25,32,.88)); box-shadow: 0 20px 56px rgba(0,0,0,.28), 0 0 0 1px rgba(83,214,206,.12) inset; padding: 10px 14px; display: grid; gap: 10px; }
.field { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.field-time { flex-wrap: nowrap; }
.field-percent { flex-wrap: nowrap; }
.select, .date-input { height: 34px; border-radius: 10px; border: 1px solid rgba(255,255,255,.14); background: rgba(0,0,0,.18); color: rgba(255,255,255,.9); padding: 0 10px; font-size: 13px; font-weight: 700; }
.date-input { width: 150px; }
.btn { appearance: none; border: 1px solid rgba(255,255,255,.1); background: rgba(255,255,255,.08); color: rgba(255,255,255,.88); border-radius: 12px; padding: 8px 10px; cursor: pointer; }
.btn-sm { padding: 6px 10px; border-radius: 999px; font-size: 12px; font-weight: 800; }
.btn-accent { border-color: rgba(83,214,206,.22); background: rgba(43,191,178,.22); }
.kpi { margin-left: auto; font-size: 13px; font-weight: 800; color: rgba(236,248,251,.86); white-space: nowrap; }
.kpi-number { font-weight: 900; color: rgba(83,214,206,.95); margin-left: 4px; }
.field-label { font-weight: 900; color: rgba(244,252,255,.92); font-size: 14px; white-space: nowrap; }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 7px 12px; border-radius: 999px; border: 1px solid rgba(255,255,255,.12); background: rgba(0,0,0,.2); color: rgba(255,255,255,.88); font-weight: 800; font-size: 13px; white-space: nowrap; }
.chip input { width: 13px; height: 13px; margin: 0; accent-color: rgba(64,224,208,.92); }
.chip-status::before { content: ""; width: 10px; height: 10px; border-radius: 3px; border: 1px solid rgba(255,255,255,.2); background: transparent; }
.chip-status.chip-gray::before { border-color: rgba(110,125,150,.45); background: rgba(110,125,150,.24); }
.chip-status.chip-red::before { border-color: rgba(217,54,62,.4); background: rgba(217,54,62,.22); }
.chip-status.chip-blue::before { border-color: rgba(21,108,255,.4); background: rgba(21,108,255,.22); }
.chip-status.chip-green::before { border-color: rgba(47,143,47,.4); background: rgba(47,143,47,.22); }
.sidepanel { position: absolute; left: 16px; top: 175px; width: 320px; bottom: 100px; border-radius: 18px; border: 1px solid rgba(83,214,206,.24); background: radial-gradient(260px 140px at 8% 0%, rgba(63,203,191,.16), transparent 62%) padding-box, linear-gradient(180deg, rgba(20,31,37,.92), rgba(15,23,29,.88)) padding-box; box-shadow: 0 22px 60px rgba(0,0,0,.34), 0 0 0 1px rgba(83,214,206,.12) inset; overflow: hidden; z-index: 25; }
.sidepanel.is-collapsed { width: 64px; }
.sidepanel-header { display: flex; align-items: center; justify-content: space-between; padding: 10px 10px 10px 12px; border-bottom: 1px solid rgba(83,214,206,.16); background: radial-gradient(360px 100px at 10% 0%, rgba(83,214,206,.24), transparent 68%), linear-gradient(180deg, rgba(28,134,122,.84), rgba(15,60,74,.62)); }
.sidepanel-title { font-size: 14px; font-weight: 900; color: rgba(207,247,242,.96); }
.iconbtn { width: 30px; height: 30px; border-radius: 10px; border: 1px solid rgba(255,255,255,.12); background: rgba(255,255,255,.42); color: rgba(11,27,58,.86); font-weight: 900; cursor: pointer; }
.sidepanel-body { height: calc(100% - 52px); overflow: auto; padding: 8px; }
.tree { display: grid; gap: 8px; }
.tree-item { display: grid; grid-template-columns: 20px 10px 1fr; align-items: center; gap: 8px; min-height: 40px; border-radius: 14px; border: 1px solid rgba(154,186,198,.22); background: linear-gradient(180deg, rgba(44,58,68,.58), rgba(37,49,58,.54)); cursor: pointer; }
.tree-item:hover { border-color: rgba(83,214,206,.32); background: linear-gradient(180deg, rgba(51,67,78,.66), rgba(43,57,67,.62)); }
.tree-item.is-active { border-color: rgba(132,188,255,.3); background: linear-gradient(180deg, rgba(112,146,198,.34), rgba(95,128,180,.28)); }
.tree-caret { border: 0; background: transparent; color: rgba(203,230,236,.88); cursor: pointer; font-size: 14px; }
.tree-caret.is-leaf { cursor: default; }
.tree-bullet { width: 10px; height: 10px; border-radius: 50%; background: rgba(83,214,206,.85); }
2026-04-29 18:22:07 +08:00
.tree-text {
font-size: 13px;
font-weight: 800;
color: rgba(222,238,244,.9);
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
max-width: 180px;
display: inline-block;
}
2026-04-20 10:13:52 +08:00
.bottompanel { position: absolute; left: 370px; right: 16px; bottom: 100px; height: 390px; border-radius: 18px; border: 1px solid rgba(83,214,206,.24); background: radial-gradient(420px 180px at 14% 0%, rgba(83,214,206,.2), transparent 66%) padding-box, radial-gradient(520px 220px at 82% 0%, rgba(40,156,228,.14), transparent 70%) padding-box, linear-gradient(180deg, rgba(18,33,40,.94), rgba(14,24,31,.9)) padding-box; box-shadow: 0 24px 70px rgba(0,0,0,.36), 0 0 0 1px rgba(83,214,206,.14) inset; overflow: hidden; z-index: 26; }
.bottompanel-header { padding: 12px 52px 12px 12px; border-bottom: 1px solid rgba(83,214,206,.28); background: radial-gradient(380px 120px at 18% 0%, rgba(83,214,206,.28), transparent 70%), linear-gradient(180deg, rgba(25,137,124,.86), rgba(16,66,82,.64)); }
.bottompanel-toggle { position: absolute; right: 12px; top: 12px; }
.tabs { display: flex; gap: 10px; }
.tab { border: 1px solid rgba(255,255,255,.12); background: rgba(255,255,255,.08); color: rgba(214,235,241,.9); border-radius: 999px; padding: 8px 16px; cursor: pointer; font-weight: 900; font-size: 12px; }
.tab.is-on { border-color: rgba(83,214,206,.32); background: rgba(83,214,206,.24); }
.bottompanel.is-collapsed { height: 70px; }
.bottompanel-body { padding: 0 12px 12px; overflow: auto; height: calc(100% - 66px); }
.table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 14px; }
.table th, .table td { text-align: left; padding: 12px 14px; border-bottom: 1px solid rgba(178,206,216,.16); }
.table th { color: rgba(219,240,246,.86); font-weight: 900; background: linear-gradient(90deg, rgba(12,38,52,.92), rgba(16,47,61,.86)); position: sticky; top: 0; z-index: 2; }
.table td { color: rgba(222,238,244,.86); background: linear-gradient(90deg, rgba(37,51,61,.42), rgba(31,45,54,.36)); }
.table tbody tr:hover td { background: linear-gradient(90deg, rgba(69,102,130,.36), rgba(56,86,113,.32)); }
@media (max-width: 1300px) {
.module-topbar { width: calc(100% - 32px); }
.field-time, .field-percent { flex-wrap: wrap; }
.kpi { margin-left: 0; }
.sidepanel { width: 280px; }
.bottompanel { left: 330px; }
}
2026-04-29 18:22:07 +08:00
.context-menu {
position: fixed;
z-index: 9999;
border-radius: 10px;
border: 1px solid rgba(83, 214, 206, 0.25);
background: linear-gradient(180deg, rgba(20, 31, 37, 0.95), rgba(15, 23, 29, 0.92));
box-shadow: 0 12px 32px rgba(0, 0, 0, 0.4);
overflow: hidden;
}
.context-menu-item {
padding: 10px 16px;
font-size: 13px;
font-weight: 700;
color: rgba(207, 247, 242, 0.9);
cursor: pointer;
}
.context-menu-item:hover {
background: rgba(83, 214, 206, 0.18);
}
.add-modal {
position: fixed;
width: min(520px, 86vw);
border-radius: 16px;
border: 1px solid rgba(83, 214, 206, 0.25);
background: linear-gradient(180deg, rgba(20, 31, 37, 0.95), rgba(15, 23, 29, 0.92));
box-shadow: 0 32px 80px rgba(0, 0, 0, 0.45);
z-index: 100;
}
.add-modal-header {
display: flex;
align-items: center;
justify-content: space-between;
padding: 16px 18px;
border-bottom: 1px solid rgba(83, 214, 206, 0.16);
background: radial-gradient(360px 100px at 10% 0%, rgba(83, 214, 206, 0.18), transparent 68%),
linear-gradient(180deg, rgba(28, 134, 122, 0.45), rgba(15, 60, 74, 0.32));
}
.add-modal-title {
font-size: 15px;
font-weight: 800;
color: rgba(207, 247, 242, 0.96);
}
.add-modal-close {
width: 28px;
height: 28px;
border-radius: 8px;
border: 1px solid rgba(255, 255, 255, 0.12);
background: rgba(255, 255, 255, 0.08);
color: rgba(203, 230, 236, 0.75);
font-size: 14px;
cursor: pointer;
display: grid;
place-items: center;
}
.add-modal-close:hover {
background: rgba(255, 255, 255, 0.14);
color: rgba(236, 246, 250, 0.95);
}
.add-modal-body {
padding: 18px;
min-height: 300px;
max-height: 400px;
overflow: auto;
}
.add-modal-split {
display: grid;
grid-template-columns: 1fr 1fr;
gap: 20px;
height: 100%;
}
.add-modal-left,
.add-modal-right {
display: flex;
flex-direction: column;
gap: 10px;
}
.add-modal-section-title {
font-size: 13px;
font-weight: 800;
color: rgba(207, 247, 242, 0.9);
}
.add-modal-list {
display: flex;
flex-direction: column;
gap: 8px;
overflow-y: auto;
flex: 1;
}
.add-modal-tag {
display: flex;
align-items: center;
justify-content: space-between;
padding: 8px 12px;
border-radius: 8px;
border: 1px solid rgba(83, 214, 206, 0.25);
background: rgba(0, 0, 0, 0.2);
color: rgba(207, 247, 242, 0.9);
font-size: 13px;
}
.add-modal-tag-delete {
width: 22px;
height: 22px;
border-radius: 6px;
border: 1px solid rgba(217, 54, 62, 0.4);
background: rgba(217, 54, 62, 0.1);
color: rgba(217, 54, 62, 0.8);
font-size: 12px;
cursor: pointer;
}
.add-form-list {
display: flex;
flex-direction: column;
gap: 10px;
}
.add-form-item {
display: flex;
align-items: center;
gap: 10px;
}
.add-form-input {
flex: 1;
height: 36px;
border-radius: 8px;
border: 1px solid rgba(83, 214, 206, 0.25);
background: rgba(0, 0, 0, 0.2);
color: rgba(255, 255, 255, 0.9);
padding: 0 12px;
font-size: 13px;
}
.add-form-input:focus {
outline: none;
border-color: rgba(83, 214, 206, 0.5);
}
.add-form-delete {
width: 32px;
height: 36px;
border-radius: 8px;
border: 1px solid rgba(217, 54, 62, 0.4);
background: rgba(217, 54, 62, 0.15);
color: rgba(217, 54, 62, 0.9);
font-size: 14px;
cursor: pointer;
}
.add-form-delete:hover {
background: rgba(217, 54, 62, 0.25);
}
.add-form-add-btn {
margin-top: 12px;
height: 36px;
border-radius: 8px;
border: 1px solid rgba(83, 214, 206, 0.3);
background: rgba(83, 214, 206, 0.15);
color: rgba(83, 214, 206, 0.95);
font-size: 13px;
font-weight: 700;
padding: 0 16px;
cursor: pointer;
}
.add-form-add-btn:hover {
background: rgba(83, 214, 206, 0.25);
}
.add-modal-footer {
display: flex;
justify-content: flex-end;
gap: 10px;
padding-top: 16px;
border-top: 1px solid rgba(83, 214, 206, 0.16);
margin-top: 16px;
}
.add-modal-btn {
padding: 8px 16px;
border-radius: 8px;
font-size: 13px;
font-weight: 700;
cursor: pointer;
border: 1px solid transparent;
}
.add-modal-btn-secondary {
background: rgba(255, 255, 255, 0.1);
color: rgba(255, 255, 255, 0.85);
border-color: rgba(255, 255, 255, 0.15);
}
.add-modal-btn-secondary:hover {
background: rgba(255, 255, 255, 0.15);
}
.add-modal-btn-primary {
background: rgba(83, 214, 206, 0.25);
color: rgba(83, 214, 206, 0.95);
border-color: rgba(83, 214, 206, 0.3);
}
.add-modal-btn-primary:hover {
background: rgba(83, 214, 206, 0.35);
}
.toast {
position: fixed;
left: 50%;
top: 16px;
transform: translateX(-50%);
z-index: 9999;
padding: 10px 20px;
border-radius: 10px;
font-size: 14px;
font-weight: 700;
box-shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
}
.toast-success {
background: rgba(83, 214, 206, 0.25);
border: 1px solid rgba(83, 214, 206, 0.4);
color: rgba(83, 214, 206, 0.95);
}
.toast-error {
background: rgba(217, 54, 62, 0.25);
border: 1px solid rgba(217, 54, 62, 0.4);
color: rgba(255, 255, 255, 0.95);
}
2026-04-20 10:13:52 +08:00
</style>