WholeProcessPlatform/frontend-sjgl/src/views/conventionalHydropower/BasicData/index.vue
2026-07-21 18:38:17 +08:00

1064 lines
21 KiB
Vue

<template>
<div class="w-full h-full flex flex-col pt-[20px] pl-[20px] body_one">
<!-- 搜索组件 -->
<BasicDataSearch
:topHynmList="topHynmList"
:hycdList="hycdList"
:topHynmLoading="topHynmLoading"
:hycdLoading="hycdLoading"
:dvtpList="dvtpList"
@export-btn="exportBtn"
@custom-filter-btn="customFilterBtn"
@search-finish="onSearchFinish"
@reset="onReset"
ref="searchRef"
/>
<!-- 表格组件 -->
<BasicTable
ref="tableRef"
:enableEllipsis="true"
:scrollX="tableScrollX"
:scrollY="tableScrollY"
:columns="columns"
:searchParams="{
sort: sort
}"
:list-url="getPowerTableList"
>
<template #action="{ record }">
<a-button
type="link"
class="text-[#2f6b98]"
size="small"
@click="handleDetail(record)"
>查看详情</a-button
>
<a-button
type="link"
class="text-[#2f6b98]"
size="small"
@click="handleEdit(record)"
>编辑</a-button
>
<a-button type="link" danger size="small" @click="handleDelete(record)"
>删除</a-button
>
</template>
</BasicTable>
<!-- 自定义数据列 Modal -->
<CustomColumnModal
v-model:visible="customColumnVisible"
@confirm="handleColumnConfirm"
/>
<!-- 编辑电站 Modal -->
<EditPowerModal
v-model:open="editVisible"
:dvtp-list="dvtpList"
:record="editRecord"
:top-hynm-list="topHynmList"
:hycd-list="hycdList"
@success="handleEditSuccess"
/>
<!-- 删除确认 Modal -->
<DeleteConfirmModal ref="deleteModalRef" @success="handleEditSuccess" />
</div>
</template>
<script setup lang="ts">
import { ref, computed, onMounted, nextTick } from 'vue';
import dayjs from 'dayjs';
import BasicDataSearch from './BasicDataSearch.vue';
import BasicTable from '@/components/BasicTable/index.vue';
import CustomColumnModal from './CustomColumnModal.vue';
import EditPowerModal from './EditPowerModal.vue';
import DeleteConfirmModal from './DeleteConfirmModal.vue';
import {
getCompanyList,
getPowerTableList,
updatePowerInfo,
deletePowerInfo
} from '@/api/DataQueryMenuModule';
import { getEngInfoById } from '@/api/select';
import { calcTableScrollY } from '@/utils/index';
import { useModelStore } from '@/store/modules/model';
import { BasicColumns } from '@/components/MapModal/column.config';
const modelStore = useModelStore();
const sort = ref<any>([
{
field: 'baseStepSort',
dir: 'asc'
},
{
field: 'rvcdStepSort',
dir: 'asc'
},
{
field: 'rstcdStepSort',
dir: 'asc'
},
{
field: 'ttpwr',
dir: 'asc'
}
]);
const tableRef = ref();
const searchRef = ref();
const tableScrollY = ref<string | number>(0);
const currentSearchParams = ref<any>({});
const exportLoading = ref(false);
const customColumnVisible = ref(false);
// 编辑相关
const editVisible = ref(false);
const editRecord = ref<any>(null);
const deleteModalRef = ref();
// 集团和公司数据
const topHynmList = ref<any>([]);
const hycdList = ref<any>([]);
const topHynmLoading = ref(false);
const hycdLoading = ref(false);
const isEdit = ref(true);
const dvtpList = ref<any[]>([
{ label: '堤坝式', value: '0' },
{ label: '引水式', value: '1' },
{ label: '混合式', value: '2' }
]);
const columns = ref<any[]>([
{
key: 'stnm',
title: '电站名称',
dataIndex: 'stnm',
visible: true,
width: 150,
fixed: 'left',
sort: true,
ellipsis: true
},
{
key: 'addvcdName',
title: '所在地址',
dataIndex: 'addvcdName',
visible: true,
width: 150,
sort: true,
ellipsis: true
},
{
key: 'stlc',
title: '详细地址',
dataIndex: 'stlc',
visible: true,
width: 200,
sort: true,
ellipsis: true
},
{
key: 'baseName',
title: '基地',
dataIndex: 'baseName',
visible: true,
width: 120,
ellipsis: true
},
{
key: 'reachcdName',
title: '所在河流',
dataIndex: 'reachcdName',
visible: true,
width: 300,
ellipsis: true
},
{
key: 'jcdt',
title: '建设时间',
dataIndex: 'jcdt',
visible: true,
width: 120,
sort: true,
ellipsis: true,
customRender: ({ text }) => {
if (!text || text === '-') return '-';
const date = dayjs(text);
return date.isValid() ? date.format('YYYY-MM-DD') : '-';
}
},
{
key: 'piodt',
title: '第一台机组投产时间',
dataIndex: 'piodt',
visible: true,
width: 160,
sort: true,
ellipsis: true,
customRender: ({ text }) => {
if (!text || text === '-') return '-';
const date = dayjs(text);
return date.isValid() ? date.format('YYYY-MM-DD') : '-';
}
},
{
key: 'aiodt',
title: '全部机组投产时间',
dataIndex: 'aiodt',
visible: true,
width: 150,
sort: true,
ellipsis: true,
customRender: ({ text }) => {
if (!text || text === '-') return '-';
const date = dayjs(text);
return date.isValid() ? date.format('YYYY-MM-DD') : '-';
}
},
{
key: 'bldsttCcodeName',
title: '建设状态',
dataIndex: 'bldsttCcodeName',
visible: false,
width: 100,
sort: true,
ellipsis: true
},
{
key: 'hynm',
title: '所属公司',
dataIndex: 'hynm',
visible: true,
width: 150,
sort: true,
ellipsis: true
},
{
key: 'topHynm',
title: '所属集团',
dataIndex: 'topHynm',
visible: true,
width: 150,
sort: true,
ellipsis: true
},
{
key: 'nrupar',
title: '坝址以上流域面积(km²)',
dataIndex: 'nrupar',
visible: true,
width: 180,
sort: true
},
{
key: 'dstcrvr',
title: '距河源距离(km)',
dataIndex: 'dstcrvr',
visible: true,
width: 150,
sort: true
},
{
key: 'avyrp',
title: '多年平均降雨量(mm)',
dataIndex: 'avyrp',
visible: true,
width: 170,
sort: true
},
{
key: 'avw',
title: '多年平均年径流量(亿m³)',
dataIndex: 'avw',
visible: true,
width: 190,
sort: true
},
{
key: 'avq',
title: '多年平均流量(m³/s)',
dataIndex: 'avq',
visible: true,
width: 160,
sort: true
},
{
key: 'avq01',
title: '1月多年平均流量(m³/s)',
dataIndex: 'avq01',
visible: true,
width: 180,
sort: true
},
{
key: 'avq02',
title: '2月多年平均流量(m³/s)',
dataIndex: 'avq02',
visible: true,
width: 180,
sort: true
},
{
key: 'avq03',
title: '3月多年平均流量(m³/s)',
dataIndex: 'avq03',
visible: true,
width: 180,
sort: true
},
{
key: 'avq04',
title: '4月多年平均流量(m³/s)',
dataIndex: 'avq04',
visible: true,
width: 180,
sort: true
},
{
key: 'avq05',
title: '5月多年平均流量(m³/s)',
dataIndex: 'avq05',
visible: true,
width: 180,
sort: true
},
{
key: 'avq06',
title: '6月多年平均流量(m³/s)',
dataIndex: 'avq06',
visible: true,
width: 180,
sort: true
},
{
key: 'avq07',
title: '7月多年平均流量(m³/s)',
dataIndex: 'avq07',
visible: true,
width: 180,
sort: true
},
{
key: 'avq08',
title: '8月多年平均流量(m³/s)',
dataIndex: 'avq08',
visible: true,
width: 180,
sort: true
},
{
key: 'avq09',
title: '9月多年平均流量(m³/s)',
dataIndex: 'avq09',
visible: true,
width: 180,
sort: true
},
{
key: 'avq10',
title: '10月多年平均流量(m³/s)',
dataIndex: 'avq10',
visible: true,
width: 190,
sort: true
},
{
key: 'avq11',
title: '11月多年平均流量(m³/s)',
dataIndex: 'avq11',
visible: true,
width: 190,
sort: true
},
{
key: 'avq12',
title: '12月多年平均流量(m³/s)',
dataIndex: 'avq12',
visible: true,
width: 190,
sort: true
},
{
key: 'obmxq',
title: '实测最大流量(m³/s)',
dataIndex: 'obmxq',
visible: true,
width: 170,
sort: true
},
{
key: 'obmnq',
title: '实测最小流量(m³/s)',
dataIndex: 'obmnq',
visible: true,
width: 170,
sort: true
},
{
key: 'hmxq',
title: '调查历史最大流量(m³/s)',
dataIndex: 'hmxq',
visible: true,
width: 190,
sort: true
},
{
key: 'dsnfqfrq',
title: '设计入库洪水流量(m³/s)',
dataIndex: 'dsnfqfrq',
visible: true,
width: 190,
sort: true
},
{
key: 'dsrcin',
title: '设计洪水重现期(年)',
dataIndex: 'dsrcin',
visible: true,
width: 160,
sort: true
},
{
key: 'ckfqfqr',
title: '校核入库洪水流量(m³/s)',
dataIndex: 'ckfqfqr',
visible: true,
width: 190,
sort: true
},
{
key: 'chrcin',
title: '校核洪水重现期(年)',
dataIndex: 'chrcin',
visible: true,
width: 160,
sort: true
},
{
key: 'obmxw3',
title: '实测最大洪量(三天)(亿m³)',
dataIndex: 'obmxw3',
visible: true,
width: 220,
sort: true
},
{
key: 'dsw3',
title: '设计洪量(三天)(亿m³)',
dataIndex: 'dsw3',
visible: true,
width: 190,
sort: true
},
{
key: 'ckw3',
title: '校核洪量(三天)(亿m³)',
dataIndex: 'ckw3',
visible: true,
width: 190,
sort: true
},
{
key: 'avsd',
title: '多年平均输沙量(万t)',
dataIndex: 'avsd',
visible: true,
width: 180
},
{
key: 'avs',
title: '多年平均含沙量(kg/m³)',
dataIndex: 'avs',
visible: true,
width: 180,
sort: true
},
{
key: 'obmxs',
title: '实测最大含沙量(kg/m³)',
dataIndex: 'obmxs',
visible: true,
width: 180,
sort: true
},
{
key: 'ckflz',
title: '校核洪水位(m)',
dataIndex: 'ckflz',
visible: true,
width: 140,
sort: true
},
{
key: 'dsflz',
title: '设计洪水位(m)',
dataIndex: 'dsflz',
visible: true,
width: 140,
sort: true
},
{
key: 'normz',
title: '正常蓄水位(m)',
dataIndex: 'normz',
visible: true,
width: 140,
sort: true
},
{
key: 'uzfc',
title: '防洪高水位(m)',
dataIndex: 'uzfc',
visible: true,
width: 140,
sort: true
},
{
key: 'fsltdz',
title: '防洪限制水位(m)',
dataIndex: 'fsltdz',
visible: true,
width: 150,
sort: true
},
{
key: 'ydownz',
title: '年消落水位(m)',
dataIndex: 'ydownz',
visible: true,
width: 140,
sort: true
},
{
key: 'ddz',
title: '死水位(m)',
dataIndex: 'ddz',
visible: true,
width: 120,
sort: true
},
{
key: 'nrzar',
title: '正常蓄水位水库面积(km²)',
dataIndex: 'nrzar',
visible: true,
width: 200,
sort: true
},
{
key: 'bcklen',
title: '回水长度(km)',
dataIndex: 'bcklen',
visible: true,
width: 130,
sort: true
},
{
key: 'ttcp',
title: '总库容(亿m³)',
dataIndex: 'ttcp',
visible: true,
width: 130,
sort: true
},
{
key: 'nmzcp',
title: '正常蓄水位以下库容(亿m³)',
dataIndex: 'nmzcp',
visible: true,
width: 200,
sort: true
},
{
key: 'fldcpStr',
title: '防洪库容(亿m³)',
dataIndex: 'fldcpStr',
visible: true,
width: 140,
sort: true
},
{
key: 'actcp',
title: '调节库容(亿m³)',
dataIndex: 'actcp',
visible: true,
width: 140,
sort: true
},
{
key: 'ddcp',
title: '死库容(亿m³)',
dataIndex: 'ddcp',
visible: true,
width: 130,
sort: true
},
{
key: 'cpsc',
title: '库容系数(%)',
dataIndex: 'cpsc',
visible: true,
width: 120,
sort: true
},
{
key: 'rgcpName',
title: '调节性能',
dataIndex: 'rgcpName',
visible: true,
width: 120,
sort: true,
ellipsis: true
},
{
key: 'dsflzmxq',
title: '设计洪水位时最大下泄流量(m³/s)',
dataIndex: 'dsflzmxq',
visible: true,
width: 250,
sort: true
},
{
key: 'dsflzxyz',
title: '设计洪水位时最大下泄流量相应下游水位(m)',
dataIndex: 'dsflzxyz',
visible: true,
width: 320,
sort: true
},
{
key: 'ckflzmxq',
title: '校核洪水位时最大下泄流量(m³/s)',
dataIndex: 'ckflzmxq',
visible: true,
width: 250,
sort: true
},
{
key: 'ckflzxyz',
title: '校核洪水位时最大下泄流量相应下游水位(m)',
dataIndex: 'ckflzxyz',
visible: true,
width: 320,
sort: true
},
{
key: 'ksqadjq',
title: '枯水期调节流量(m³/s)',
dataIndex: 'ksqadjq',
visible: true,
width: 170,
sort: true
},
{
key: 'ksqxyz',
title: '枯水期调节流量相应下游水位(m)',
dataIndex: 'ksqxyz',
visible: true,
width: 250,
sort: true
},
{
key: 'gemaxrq',
title: '发电最大引用流量(m³/s)',
dataIndex: 'gemaxrq',
visible: true,
width: 190,
sort: true
},
{
key: 'mxgeqxyz',
title: '发电最大引用流量相应下游水位(m)',
dataIndex: 'mxgeqxyz',
visible: true,
width: 260,
sort: true
},
{
key: 'ttpwr',
title: '装机容量',
dataIndex: 'ttpwr',
visible: true,
width: 120,
sort: true,
ellipsis: true
},
{
key: 'gncnt',
title: '装机台数(台)',
dataIndex: 'gncnt',
visible: true,
width: 130,
sort: true,
ellipsis: true
},
{
key: 'gntp',
title: '容量构成(台*MW)',
dataIndex: 'gntp',
visible: true,
width: 150,
sort: true,
ellipsis: true
},
{
key: 'grntpwr',
title: '保证出力(MW)',
dataIndex: 'grntpwr',
visible: true,
width: 130,
sort: true,
ellipsis: true
},
{
key: 'yrge',
title: '多年平均年发电量(亿kW·h)',
dataIndex: 'yrge',
visible: true,
width: 200,
sort: true
},
{
key: 'ushr',
title: '年利用小时数(h)',
dataIndex: 'ushr',
visible: true,
width: 150,
sort: true
},
{
key: 'k',
title: '机组综合出力系数',
dataIndex: 'k',
visible: true,
width: 150,
sort: true,
ellipsis: true
},
{
key: 'dmtp',
title: '坝型',
dataIndex: 'dmtp',
visible: true,
width: 100,
sort: true,
ellipsis: true
},
{
key: 'dmcrel',
title: '坝顶高程(m)',
dataIndex: 'dmcrel',
visible: true,
width: 130,
sort: true
},
{
key: 'mxdmhg',
title: '最大坝高(m)',
dataIndex: 'mxdmhg',
visible: true,
width: 120,
sort: true
},
{
key: 'dmlen',
title: '坝顶长度(m)',
dataIndex: 'dmlen',
visible: true,
width: 130,
sort: true
},
{
key: 'sgyge',
title: '单独年发电量(亿kW·h)',
dataIndex: 'sgyge',
visible: true,
width: 180,
sort: true
},
{
key: 'unyge',
title: '联合年发电量(亿kW·h)',
dataIndex: 'unyge',
visible: true,
width: 180,
sort: true
},
{
key: 'gap',
title: '利用落差(m)',
dataIndex: 'gap',
visible: true,
width: 120,
sort: true
},
{
key: 'dvtpName',
title: '开发方式',
dataIndex: 'dvtpName',
visible: true,
width: 120,
sort: true
},
{
key: 'dtinName',
title: '接入状态',
dataIndex: 'dtinName',
visible: true,
width: 120,
sort: true,
ellipsis: true
},
{
key: 'action',
title: '操作',
dataIndex: 'action',
fixed: 'right',
width: isEdit.value ? 180 : 100
}
]);
const tableScrollX = computed(() =>
Math.max(
columns.value.reduce(
(sum: number, col: any) => sum + (col.width || 180),
0
),
600
)
);
const onSearchFinish = (values: any) => {
currentSearchParams.value = values;
initTable(values);
};
const onReset = (values: any) => {
currentSearchParams.value = values;
initTable(values);
};
// 导出
const exportBtn = () => {
if (exportLoading.value) return;
exportLoading.value = true;
searchRef.value.btnLoading = true;
tableRef.value
.exportTable({
fileName: `基础数据_${dayjs().format('YYYY-MM-DD HH-mm-ss')}`
})
.finally(() => {
exportLoading.value = false;
searchRef.value.btnLoading = false;
});
};
// 自定义筛选列
const customFilterBtn = () => {
customColumnVisible.value = true;
};
// 确认自定义列选择
const handleColumnConfirm = (selectedFiledKeys: string[]) => {
console.log('选中的 filed keys:', selectedFiledKeys);
// filed 到 dataIndex 的映射
const filedToDataIndexMap: Record<string, string> = {
ennm: 'stnm'
};
// 根据选中的 filed 更新列的 visible 状态
columns.value.forEach((col: any) => {
if (col.key === 'action') return; // 操作列不受控制
// 查找是否有对应的 filed 映射,没有则使用 dataIndex 本身
const filed = filedToDataIndexMap[col.dataIndex] || col.dataIndex;
col.visible = selectedFiledKeys.includes(filed);
});
};
const buildSearchParams = (values: any) => {
console.log(values);
return {
logic: 'and',
filters: [
values.rvcd && values.rvcd !== 'all'
? {
field: 'rvcd',
operator: 'contains',
dataType: 'string',
value: values.rvcd
}
: null,
values.rstcd
? {
field: 'stcd',
operator: 'eq',
dataType: 'string',
value: values.rstcd
}
: null,
values.baseId
? {
field: 'baseId',
operator: 'eq',
dataType: 'string',
value: values.baseId
}
: null,
values.hbrvcd
? {
field: 'hbrvcd',
operator: 'eq',
dataType: 'string',
value: values.hbrvcd
}
: null,
values.bldsttCcode != undefined && values.bldsttCcode != ''
? {
field: 'bldsttCcode',
operator: 'eq',
dataType: 'string',
value: values.bldsttCcode
}
: null,
values.hycd
? {
field: 'hycd',
operator: 'eq',
dataType: 'string',
value: values.hycd
}
: null,
values.topHynm
? {
field: 'topHynm',
operator: 'eq',
dataType: 'string',
value: values.topHynm
}
: null,
values.ttpwr && values.ttpwr.min
? {
field: 'ttpwr',
operator: 'gte',
dataType: 'string',
value: values.ttpwr.min * 10
}
: null,
values.ttpwr && values.ttpwr.max
? {
field: 'ttpwr',
operator: 'lte',
dataType: 'string',
value: values.ttpwr.max * 10
}
: null,
values.jcdt && values.jcdt.min
? {
field: 'jcdt',
operator: 'gte',
dataType: 'date',
value: values.jcdt.min
}
: null,
values.jcdt && values.jcdt.max
? {
field: 'jcdt',
operator: 'lte',
dataType: 'date',
value: values.jcdt.max
}
: null,
values.dtin && values.dtin !== 'all'
? {
field: 'dtin',
operator: 'eq',
dataType: 'string',
value: values.dtin
}
: null,
values.dvtp && values.dvtp.length > 0
? {
logic: 'or',
filters: [
...values.dvtp.map((item: any) => ({
field: 'dvtp',
operator: 'eq',
dataType: 'string',
value: item
}))
]
}
: null
].filter(Boolean)
};
};
const initTable = (values: any) => {
const params = buildSearchParams(values);
tableRef.value.getList(params);
};
const init = () => {
topHynmLoading.value = true;
hycdLoading.value = true;
// 获取集团列表 (lx=1)
getCompanyList({ lx: 1 }).then(res => {
topHynmList.value = res?.data || [];
topHynmLoading.value = false;
});
// 获取公司列表 (lx=2)
getCompanyList({ lx: 2 }).then(res => {
hycdList.value = res?.data || [];
hycdLoading.value = false;
});
};
// 查看详情
const handleDetail = (record: any) => {
modelStore.modalVisible = true;
modelStore.params.sttp = record.sttp || record.sttpCode;
modelStore.params.stcd = record.stcd;
modelStore.title = record.stnm;
};
// 编辑
const handleEdit = (record: any) => {
getEngInfoById({ stcd: record.stcd }).then(res => {
console.log(res);
editRecord.value = { ...res.data };
});
editVisible.value = true;
};
// 编辑成功回调
const handleEditSuccess = () => {
initTable(currentSearchParams.value);
};
// 删除
const handleDelete = (record: any) => {
deleteModalRef.value?.open(record, () => {
initTable(currentSearchParams.value);
});
};
onMounted(() => {
init();
nextTick(() => {
tableScrollY.value = calcTableScrollY();
});
});
</script>
<style scoped lang="scss">
.body_one{
position: relative;
z-index: 900;
pointer-events: all;
}
</style>