明树Git Lab

Commit 91b35f0b authored by zhanghan's avatar zhanghan

删除log

parent c5950ad7
Pipeline #106921 passed with stage
in 19 seconds
...@@ -389,7 +389,6 @@ onMounted(() => { ...@@ -389,7 +389,6 @@ onMounted(() => {
} }
} catch (e) { } catch (e) {
options.value = {}; options.value = {};
console.warn("解析resourceData失败:", e);
} }
if (rcCgqyglId.value) { if (rcCgqyglId.value) {
......
This diff is collapsed.
...@@ -113,11 +113,11 @@ ...@@ -113,11 +113,11 @@
border border
:cell-style="tableCellStyle" :cell-style="tableCellStyle"
:row-style="{ height: '48px' }" :row-style="{ height: '48px' }"
:header-row-style="{ height: '48px' }" :header-row-style="{ height: '48px', background: '#f5f7fa' }"
> >
<el-table-column <el-table-column
v-for="time in validDynamicTimeList" v-for="time in validDynamicTimeList"
:key="time" :key="`time-col-${time}`"
:label="time" :label="time"
width="160" width="160"
align="center" align="center"
...@@ -131,6 +131,7 @@ ...@@ -131,6 +131,7 @@
@change="() => handleChange(row)" @change="() => handleChange(row)"
:disabled="isPreview" :disabled="isPreview"
style="width: 100%" style="width: 100%"
:value="isNaN(Number(row[time])) ? 0 : Number(row[time])"
/> />
</template> </template>
</el-table-column> </el-table-column>
...@@ -140,13 +141,20 @@ ...@@ -140,13 +141,20 @@
</template> </template>
<script setup> <script setup>
// 修复1:删除错误的deepClone导入,Vue无此API import {
import { defineProps, computed, defineEmits, watch, onMounted, ref } from "vue"; defineProps,
computed,
defineEmits,
watch,
onMounted,
ref,
nextTick,
} from "vue";
// 1. 定义props和emit(保持不变) // 1. 定义props和emit(保持不变)
const props = defineProps({ const props = defineProps({
modelValue: { type: Array, default: () => [] }, modelValue: { type: Array, default: () => [] },
dynamicTimeList: { type: Array, default: () => [] }, dynamicTimeList: { type: Array, default: () => [] }, // 父组件必须传
isPreview: { type: Boolean, default: false }, isPreview: { type: Boolean, default: false },
}); });
...@@ -158,8 +166,14 @@ const emit = defineEmits([ ...@@ -158,8 +166,14 @@ const emit = defineEmits([
// 2. 核心:组件内部响应式数据,隔离props循环 // 2. 核心:组件内部响应式数据,隔离props循环
const tableData = ref([]); const tableData = ref([]);
// 3. 处理时间列表 - 去重+非空+去除隐形空白字符(保持原有逻辑 // 3. 处理时间列表 - 去重+非空+去除隐形空白字符+**兜底默认值**(关键修复
const validDynamicTimeList = computed(() => { const validDynamicTimeList = computed(() => {
if (
!Array.isArray(props.dynamicTimeList) ||
props.dynamicTimeList.length === 0
) {
return ["2025及以前", "2026", "2026-小记"]; // 兜底,保证列能渲染
}
return [...new Set(props.dynamicTimeList)] return [...new Set(props.dynamicTimeList)]
.map((time) => { .map((time) => {
return typeof time === "string" ? time.trim() : ""; return typeof time === "string" ? time.trim() : "";
...@@ -188,9 +202,10 @@ const initRowTimeField = (row) => { ...@@ -188,9 +202,10 @@ const initRowTimeField = (row) => {
// 工具方法:计算行合计【仅读取年份字段,不碰其他字段】 // 工具方法:计算行合计【仅读取年份字段,不碰其他字段】
const calcRowTotal = (row) => { const calcRowTotal = (row) => {
if (!row || typeof row !== "object") return 0; if (!row || typeof row !== "object") return 0;
return validDynamicTimeList.value.reduce((sum, time) => { const total = validDynamicTimeList.value.reduce((sum, time) => {
return sum + (Number(row[time]) || 0); return sum + (Number(row[time]) || 0);
}, 0); }, 0);
return total;
}; };
// 工具方法:深拷贝+数据处理【强制保留所有原有字段,仅新增/更新total、处理年份】 // 工具方法:深拷贝+数据处理【强制保留所有原有字段,仅新增/更新total、处理年份】
...@@ -205,14 +220,15 @@ const handleTableData = (sourceData) => { ...@@ -205,14 +220,15 @@ const handleTableData = (sourceData) => {
return newData; return newData;
}; };
// 监听props.modelValue变化,仅同步到内部tableData,不emit【打印日志调试字段是否丢失 // 监听props.modelValue变化,仅同步到内部tableData,不emit【修复:nextTick确保时间列表先处理
watch( watch(
() => props.modelValue, () => props.modelValue,
(newVal) => { async (newVal) => {
console.log("父组件传递的原始modelValue:", newVal); // 调试:看父组件传的是否有id/名称字段
if (newVal.length > 0) { if (newVal.length > 0) {
console.log("父组件传的第一行字段:", Object.keys(newVal[0])); // 关键调试:看是否丢失字段 console.log(Object.keys(newVal[0]), "值:", newVal[0]);
} }
// 关键修复:等待validDynamicTimeList计算完成后再处理数据
await nextTick();
const newData = handleTableData(newVal); const newData = handleTableData(newVal);
tableData.value = newData; // 只更新内部数据,不emit tableData.value = newData; // 只更新内部数据,不emit
}, },
...@@ -237,7 +253,6 @@ const emitDataChange = (newData) => { ...@@ -237,7 +253,6 @@ const emitDataChange = (newData) => {
const emitData = JSON.parse(JSON.stringify(newData)); // 深拷贝保留所有字段 const emitData = JSON.parse(JSON.stringify(newData)); // 深拷贝保留所有字段
emit("update:modelValue", emitData); emit("update:modelValue", emitData);
emit("handleAnnualPlanChange", emitData); emit("handleAnnualPlanChange", emitData);
console.log("子组件emit的完整数据:", emitData); // 调试:看emit的是否有所有字段
}; };
// 7. 获取对应行的合计值 - 从内部tableData取值 // 7. 获取对应行的合计值 - 从内部tableData取值
...@@ -260,19 +275,13 @@ const tableCellStyle = ({ row }) => ...@@ -260,19 +275,13 @@ const tableCellStyle = ({ row }) =>
// 调试日志(打印内部数据字段,确认是否保留) // 调试日志(打印内部数据字段,确认是否保留)
onMounted(() => { onMounted(() => {
console.log("处理后的有效时间字段:", validDynamicTimeList.value);
console.log("子组件内部tableData:", tableData.value);
if (tableData.value.length > 0) { if (tableData.value.length > 0) {
console.log(
"子组件tableData第一行所有字段:",
Object.keys(tableData.value[0]),
);
} }
}); });
</script> </script>
<style scoped lang="scss"> <style scoped lang="scss">
// 所有样式保持不变 // 所有样式保持不变,仅优化input样式,确保能看见
.annual-plan-wrap { .annual-plan-wrap {
display: flex; display: flex;
align-items: flex-start; align-items: flex-start;
...@@ -313,10 +322,12 @@ onMounted(() => { ...@@ -313,10 +322,12 @@ onMounted(() => {
font-weight: 500; font-weight: 500;
background-color: #f5f7fa; background-color: #f5f7fa;
} }
// 样式优化:移除不必要的隐藏,确保元素可见
:deep(.el-table) { :deep(.el-table) {
--el-table-border-color: #ebeef5; --el-table-border-color: #ebeef5;
--el-table-row-height: 48px !important; --el-table-row-height: 48px !important;
border-left: 0; // 移除border-left:0,避免表格左边无框看似没渲染
border-left: 1px solid #ebeef5 !important;
} }
:deep(.el-table__header tr), :deep(.el-table__header tr),
:deep(.el-table__body tr) { :deep(.el-table__body tr) {
...@@ -328,6 +339,7 @@ onMounted(() => { ...@@ -328,6 +339,7 @@ onMounted(() => {
vertical-align: middle; vertical-align: middle;
box-sizing: border-box; box-sizing: border-box;
} }
// 确保输入框完全显示
:deep(.el-input-number) { :deep(.el-input-number) {
width: 100%; width: 100%;
display: flex; display: flex;
...@@ -337,9 +349,13 @@ onMounted(() => { ...@@ -337,9 +349,13 @@ onMounted(() => {
:deep(.el-input-number__input) { :deep(.el-input-number__input) {
text-align: right; text-align: right;
padding-right: 25px; padding-right: 25px;
width: 90%; width: 100% !important; // 改为100%,确保填满单元格
} }
.flex { .flex {
display: flex; display: flex;
} }
// 右侧表格容器加最小宽度,避免挤压
.right-table {
min-width: calc(160px * 12); // 按12列计算最小宽度
}
</style> </style>
...@@ -134,7 +134,6 @@ onMounted(() => { ...@@ -134,7 +134,6 @@ onMounted(() => {
options.value = JSON.parse(sessionStorage.getItem("resourceData")) || {}; options.value = JSON.parse(sessionStorage.getItem("resourceData")) || {};
} catch (e) { } catch (e) {
options.value = {}; options.value = {};
console.warn("解析resourceData失败:", e);
} }
// 编辑/预览模式,加载详情数据 // 编辑/预览模式,加载详情数据
if (rcCgqyglId.value) { if (rcCgqyglId.value) {
......
...@@ -154,7 +154,6 @@ onMounted(() => { ...@@ -154,7 +154,6 @@ onMounted(() => {
options.value = JSON.parse(sessionStorage.getItem("resourceData")) || {}; options.value = JSON.parse(sessionStorage.getItem("resourceData")) || {};
} catch (e) { } catch (e) {
options.value = {}; options.value = {};
console.warn("解析resourceData失败:", e);
} }
// 编辑/预览模式,加载详情数据 // 编辑/预览模式,加载详情数据
if (rcCgqyglId.value) { if (rcCgqyglId.value) {
......
...@@ -170,7 +170,6 @@ const saveClick = () => { ...@@ -170,7 +170,6 @@ const saveClick = () => {
loading.value = true; loading.value = true;
// 投委会管理专属新增/编辑接口 // 投委会管理专属新增/编辑接口
console.log(rcTwhglId.value, "rcTwhglId.value");
const url = rcTwhglId.value const url = rcTwhglId.value
? "/api/project/updateTwhgl" ? "/api/project/updateTwhgl"
......
...@@ -277,7 +277,6 @@ ...@@ -277,7 +277,6 @@
dsjngjjw: res.dsjngjjw ? res.dsjngjjw.toString() : undefined, dsjngjjw: res.dsjngjjw ? res.dsjngjjw.toString() : undefined,
xmlx: res.xmlx ? res.xmlx.toString() : undefined, xmlx: res.xmlx ? res.xmlx.toString() : undefined,
}); });
console.log(formData);
szjList.value = jnwList.filter(item => item.key == res.jnw)[0]?.children || []; szjList.value = jnwList.filter(item => item.key == res.jnw)[0]?.children || [];
dsgjList.value = szjList.value.filter(item => item.key == res.sjnzjjw)[0]?.children || []; dsgjList.value = szjList.value.filter(item => item.key == res.sjnzjjw)[0]?.children || [];
Object.assign(fxczqkData.value, res.zdfxczs); Object.assign(fxczqkData.value, res.zdfxczs);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment