2024-11-21 15:30:42 +08:00
|
|
|
<!-- components/MonitorPointTable.vue -->
|
|
|
|
|
<template>
|
2025-10-10 13:23:40 +08:00
|
|
|
<div class="table-box">
|
2024-11-21 15:30:42 +08:00
|
|
|
<ProTable
|
2025-10-10 13:23:40 +08:00
|
|
|
ref="proTable"
|
|
|
|
|
:pagination="false"
|
|
|
|
|
:toolButton="false"
|
|
|
|
|
:columns="columns"
|
|
|
|
|
:data="tableData"
|
|
|
|
|
:style="{ height: tableHeight + 'px', overflow: 'hidden' }"
|
2024-11-21 15:30:42 +08:00
|
|
|
>
|
2025-10-10 13:23:40 +08:00
|
|
|
<!-- 表格 header 按钮 -->
|
|
|
|
|
<template #tableHeader="scope">
|
|
|
|
|
<el-button
|
|
|
|
|
type="primary"
|
|
|
|
|
:icon="CirclePlus"
|
|
|
|
|
@click="openDialog('add')"
|
|
|
|
|
:disabled="props.DevFormContent.importFlag == 1"
|
|
|
|
|
>
|
|
|
|
|
新增
|
|
|
|
|
</el-button>
|
|
|
|
|
<el-button
|
|
|
|
|
v-auth.device="'delete'"
|
|
|
|
|
type="danger"
|
|
|
|
|
:icon="Delete"
|
|
|
|
|
plain
|
|
|
|
|
:disabled="!scope.isSelected"
|
|
|
|
|
@click="batchDelete(scope.selectedListIds)"
|
|
|
|
|
>
|
|
|
|
|
删除
|
|
|
|
|
</el-button>
|
|
|
|
|
</template>
|
|
|
|
|
<!-- 表格操作 -->
|
|
|
|
|
<template #operation="scope">
|
|
|
|
|
<el-button
|
|
|
|
|
v-auth.device="'edit'"
|
|
|
|
|
type="primary"
|
|
|
|
|
link
|
|
|
|
|
:icon="EditPen"
|
|
|
|
|
:model-value="false"
|
|
|
|
|
:disabled="props.DevFormContent.importFlag == 1"
|
|
|
|
|
@click="openDialog('edit', scope.row)"
|
|
|
|
|
>
|
|
|
|
|
编辑
|
|
|
|
|
</el-button>
|
|
|
|
|
<el-button
|
|
|
|
|
v-auth.device="'delete'"
|
|
|
|
|
type="primary"
|
|
|
|
|
link
|
|
|
|
|
:icon="Delete"
|
|
|
|
|
@click="handleDelete(scope.row.id)"
|
|
|
|
|
>
|
|
|
|
|
删除
|
|
|
|
|
</el-button>
|
|
|
|
|
</template>
|
2024-11-21 15:30:42 +08:00
|
|
|
</ProTable>
|
2025-10-10 13:23:40 +08:00
|
|
|
</div>
|
|
|
|
|
<MonitorPopup @getParameter="getParameter" ref="monitorPopup" />
|
|
|
|
|
</template>
|
2024-11-26 15:41:20 +08:00
|
|
|
|
2025-10-10 13:23:40 +08:00
|
|
|
<script setup lang="ts">
|
|
|
|
|
import { reactive, ref, watch } from 'vue'
|
|
|
|
|
import ProTable from '@/components/ProTable/index.vue' // 假设 ProTable 是自定义组件
|
|
|
|
|
import { CirclePlus, Delete, EditPen } from '@element-plus/icons-vue'
|
|
|
|
|
import MonitorPopup from '@/views/machine/device/components/monitorPopup.vue'
|
|
|
|
|
import { type ColumnProps, ProTableInstance } from '@/components/ProTable/interface'
|
|
|
|
|
import { type Monitor } from '@/api/device/interface/monitor'
|
|
|
|
|
import { useDictStore } from '@/stores/modules/dict'
|
|
|
|
|
import { Device } from '@/api/device/interface/device'
|
|
|
|
|
import { ElMessage, ElMessageBox } from 'element-plus'
|
2024-11-21 15:30:42 +08:00
|
|
|
|
2025-10-10 13:23:40 +08:00
|
|
|
// 定义 props
|
|
|
|
|
const props = defineProps<{
|
|
|
|
|
DevFormContent: Device.ResPqDev
|
|
|
|
|
tableHeight?: number // 接收外部传入的高度
|
|
|
|
|
selectOptions: Record<string, Device.SelectOption[]>
|
|
|
|
|
}>()
|
2024-11-21 15:30:42 +08:00
|
|
|
|
2025-10-10 13:23:40 +08:00
|
|
|
// ProTable 实例
|
|
|
|
|
const proTable = ref<ProTableInstance>()
|
|
|
|
|
const dictStore = useDictStore()
|
|
|
|
|
const monitorPopup = ref()
|
|
|
|
|
const tableData = ref<any[]>([])
|
|
|
|
|
const title_Type = ref('add')
|
|
|
|
|
|
|
|
|
|
// 表格配置项
|
2024-11-21 15:30:42 +08:00
|
|
|
const columns = reactive<ColumnProps<Monitor.ResPqMon>[]>([
|
2025-10-10 13:23:40 +08:00
|
|
|
{ type: 'selection', fixed: 'left', width: 70 },
|
|
|
|
|
{ type: 'index', fixed: 'left', width: 70, label: '序号' },
|
|
|
|
|
{
|
|
|
|
|
prop: 'name',
|
|
|
|
|
label: '名称',
|
|
|
|
|
width: 200
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
prop: 'busbar',
|
|
|
|
|
label: '所属母线',
|
|
|
|
|
width: 200
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
prop: 'num',
|
|
|
|
|
label: '线路号',
|
|
|
|
|
width: 200
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
prop: 'pt',
|
|
|
|
|
label: 'PT变比',
|
|
|
|
|
width: 110
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
prop: 'ct',
|
|
|
|
|
label: 'CT变比',
|
|
|
|
|
width: 130
|
2025-09-17 14:08:58 +08:00
|
|
|
},
|
2025-10-10 13:23:40 +08:00
|
|
|
{
|
|
|
|
|
prop: 'connection',
|
|
|
|
|
label: '接线方式',
|
|
|
|
|
enum: dictStore.getDictData('Dev_Connect'),
|
|
|
|
|
fieldNames: { label: 'name', value: 'id' },
|
|
|
|
|
width: 130
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
prop: 'statInterval',
|
|
|
|
|
label: '统计间隔',
|
|
|
|
|
width: 130
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
prop: 'checkFlag',
|
|
|
|
|
label: '是否参与检测',
|
|
|
|
|
render: (scope: any) => {
|
|
|
|
|
return scope.row.checkFlag === 1 ? '是' : '否'
|
|
|
|
|
},
|
|
|
|
|
width: 130
|
|
|
|
|
},
|
|
|
|
|
{ prop: 'operation', label: '操作', fixed: 'right', width: 200 }
|
2024-11-21 15:30:42 +08:00
|
|
|
])
|
2025-07-09 20:12:40 +08:00
|
|
|
|
|
|
|
|
const emit = defineEmits(['get-parameter'])
|
|
|
|
|
|
|
|
|
|
const getParameter = (data: Monitor.ResPqMon) => {
|
2025-10-15 08:49:11 +08:00
|
|
|
|
2025-10-10 13:23:40 +08:00
|
|
|
if (title_Type.value === 'edit') {
|
|
|
|
|
// 编辑:替换已有的数据
|
|
|
|
|
const index = tableData.value.findIndex(item => item.id === data.id)
|
|
|
|
|
if (index > -1) {
|
|
|
|
|
tableData.value = [...tableData.value.slice(0, index), data, ...tableData.value.slice(index + 1)]
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
// 新增:追加数据
|
|
|
|
|
tableData.value = [...tableData.value, data]
|
2025-07-09 20:12:40 +08:00
|
|
|
}
|
2025-10-10 13:23:40 +08:00
|
|
|
emit('get-parameter', tableData.value)
|
2025-07-09 20:12:40 +08:00
|
|
|
}
|
|
|
|
|
|
2025-10-10 13:23:40 +08:00
|
|
|
// 打开 drawer(新增、编辑)
|
|
|
|
|
const openDialog = (titleType: string, row: Partial<Monitor.ResPqMon> = {}) => {
|
|
|
|
|
if (props.DevFormContent.devType == '' || props.DevFormContent.devType == undefined) {
|
|
|
|
|
ElMessageBox.confirm('请先选择被检设备类型', '提示', {
|
|
|
|
|
confirmButtonText: '确定',
|
|
|
|
|
cancelButtonText: '取消',
|
|
|
|
|
type: 'warning'
|
|
|
|
|
})
|
|
|
|
|
return
|
|
|
|
|
}
|
2025-10-11 14:12:15 +08:00
|
|
|
// 新增时检查线路号是否全部被占用
|
|
|
|
|
if (titleType === 'add') {
|
|
|
|
|
if(props.DevFormContent.devChns == tableData.value.length){
|
|
|
|
|
ElMessageBox.confirm(`线路号已全部被占用,无法新增监测点`, '提示', {
|
|
|
|
|
confirmButtonText: '确定',
|
|
|
|
|
cancelButtonText: '取消',
|
|
|
|
|
type: 'warning'
|
|
|
|
|
})
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
2025-10-10 13:23:40 +08:00
|
|
|
title_Type.value = titleType
|
|
|
|
|
monitorPopup.value?.open(titleType, row, props.DevFormContent, tableData.value, props.selectOptions)
|
|
|
|
|
}
|
2025-07-09 20:12:40 +08:00
|
|
|
|
2025-10-10 13:23:40 +08:00
|
|
|
// 批量删除监测点台账
|
|
|
|
|
const batchDelete = (ids: string[]) => {
|
|
|
|
|
ElMessageBox.confirm(`是否批量删除监测点?`, '温馨提示', {
|
|
|
|
|
confirmButtonText: '确定',
|
|
|
|
|
cancelButtonText: '取消',
|
2025-07-09 20:12:40 +08:00
|
|
|
draggable: true
|
2025-10-10 13:23:40 +08:00
|
|
|
}).then(async () => {
|
|
|
|
|
tableData.value = tableData.value.filter(item => !ids.includes(item.id))
|
2025-07-09 20:12:40 +08:00
|
|
|
proTable.value?.clearSelection()
|
2025-10-10 13:23:40 +08:00
|
|
|
emit('get-parameter', tableData.value)
|
|
|
|
|
ElMessage({
|
|
|
|
|
type: 'success',
|
|
|
|
|
message: `批量删除监测点成功!`
|
|
|
|
|
})
|
|
|
|
|
})
|
2025-07-09 20:12:40 +08:00
|
|
|
}
|
|
|
|
|
|
2025-10-10 13:23:40 +08:00
|
|
|
// 删除监测点台账
|
|
|
|
|
const handleDelete = (id: string) => {
|
|
|
|
|
ElMessageBox.confirm(`是否删除监测点?`, '温馨提示', {
|
|
|
|
|
confirmButtonText: '确定',
|
|
|
|
|
cancelButtonText: '取消',
|
|
|
|
|
draggable: true
|
|
|
|
|
}).then(async () => {
|
|
|
|
|
tableData.value = tableData.value.filter(item => item.id !== id)
|
|
|
|
|
proTable.value?.clearSelection()
|
|
|
|
|
emit('get-parameter', tableData.value)
|
|
|
|
|
ElMessage({
|
|
|
|
|
type: 'success',
|
|
|
|
|
message: `删除监测点成功!`
|
|
|
|
|
})
|
|
|
|
|
})
|
|
|
|
|
}
|
2025-07-09 20:12:40 +08:00
|
|
|
|
|
|
|
|
watch(
|
2025-10-10 13:23:40 +08:00
|
|
|
() => props.DevFormContent.monitorList,
|
|
|
|
|
newVal => {
|
|
|
|
|
tableData.value = newVal || []
|
|
|
|
|
},
|
|
|
|
|
{ immediate: true }
|
2025-07-09 20:12:40 +08:00
|
|
|
)
|
2025-10-10 13:23:40 +08:00
|
|
|
</script>
|