Files
admin-govern/src/views/govern/device/control/testItemRecords.vue

212 lines
7.8 KiB
Vue
Raw Normal View History

2024-11-27 16:01:08 +08:00
<template>
2024-12-11 11:33:44 +08:00
<!-- 测试项日志 -->
2024-11-27 16:01:08 +08:00
<div :style="{ height: height }">
<vxe-table height="auto" auto-resize :data="dataList" v-bind="defaultAttribute" :key="key">
<vxe-column v-for="item in column" :field="item.field" :title="item.title" :formatter="formatter"
2024-12-11 11:33:44 +08:00
:min-width="item.width" :sortable="item.sortable"></vxe-column>
2025-01-09 11:40:17 +08:00
<vxe-column title="操作" fixed="right" width="120" v-if="showButtom">
2024-11-27 16:01:08 +08:00
<template v-slot:default="scoped">
2025-01-09 11:40:17 +08:00
<el-button link type="primary" @click="revise(scoped.row)">修改</el-button>
2024-11-27 16:01:08 +08:00
<el-button link type="danger" @click="remove(scoped.row)">删除</el-button>
</template>
</vxe-column>
</vxe-table>
2025-01-09 11:40:17 +08:00
<el-dialog draggable v-model="dialogVisible" title="修改" width="400" :before-close="handleClose">
<el-form :model="form" ref="ruleFormRef" label-width="auto" class="form-one" :rules="rules">
<el-form-item label="数据起始时间" prop="proStartTime">
<el-date-picker v-model="form.proStartTime" type="datetime" format="YYYY-MM-DD HH:mm:ss"
value-format="YYYY-MM-DD HH:mm:ss" placeholder="请选择数据起始时间" />
</el-form-item>
<el-form-item label="数据结束时间" prop="proEndTime">
<el-date-picker v-model="form.proEndTime" type="datetime" format="YYYY-MM-DD HH:mm:ss"
value-format="YYYY-MM-DD HH:mm:ss" placeholder="请选择数据结束时间" />
</el-form-item>
</el-form>
<template #footer>
<el-button @click="handleClose">取消</el-button>
<el-button type="primary" @click="handleConfirm">
确定
</el-button>
</template>
</el-dialog>
2024-11-27 16:01:08 +08:00
</div>
</template>
<script setup lang='ts'>
import { mainHeight } from '@/utils/layout'
import { ref, reactive } from 'vue'
2025-01-09 11:40:17 +08:00
import { betweenDay } from '@/utils/formatTime'
2024-11-27 16:01:08 +08:00
import { defaultAttribute } from '@/components/table/defaultAttribute'
import { ElMessageBox, ElMessage } from 'element-plus'
import { activateUser, deluser, passwordConfirm } from '@/api/user-boot/user'
import { useDictData } from '@/stores/dictData'
2025-01-09 11:40:17 +08:00
import { updateRecordData } from '@/api/cs-device-boot/EquipmentDelivery'
import { useAdminInfo } from '@/stores/adminInfo'
2024-11-27 16:01:08 +08:00
const dictData = useDictData()
const voltageLevelList: any = dictData.getBasicData('Dev_Voltage_Stand')
import { deleteItem } from '@/api/cs-device-boot/csGroup'
const volConTypeList = dictData.getBasicData('Dev_Connect')
const emit = defineEmits(['onSubmit'])
2024-12-11 11:33:44 +08:00
const height = mainHeight(295).height
2024-11-27 16:01:08 +08:00
const dataList = ref([])
const key: any = ref(0)
2025-01-09 11:40:17 +08:00
const ruleFormRef = ref()
const adminInfo = useAdminInfo()
const showButtom = ref(adminInfo.roleCode.includes('operation_manager') || adminInfo.roleCode.includes('root'))
const dialogVisible = ref(false)
2024-11-27 16:01:08 +08:00
const column: any = ref([
2024-12-11 11:33:44 +08:00
{ field: 'startTime', title: '数据起始时间', width: '140px', sortable: true },
{ field: 'endTime', title: '数据结束时间', width: '140px', sortable: true },
2024-12-23 11:30:28 +08:00
{ field: 'lastTime', title: '持续时间', width: '140px', sortable: true },
2024-12-11 11:33:44 +08:00
{ field: 'itemName', title: '数据来源', width: '100px' },
2024-12-17 11:05:04 +08:00
{ field: 'statisticalInterval', title: '时间间隔(分钟)', width: '120px', },
{ field: 'voltageLevel', title: '电压等级', width: '100px', sortable: true },
{ field: 'volConType', title: ' 电压接线方式', width: '120px', sortable: true },
{
2024-12-17 20:57:07 +08:00
field: 'pt', title: 'PT', width: '100px',
2024-12-17 11:05:04 +08:00
},
2024-12-17 20:57:07 +08:00
{ field: 'ct', title: 'CT', width: '100px', },
2024-12-11 11:33:44 +08:00
{ field: 'capacitySi', title: '用户协议容量(MVA)', width: '140px', },
2024-12-17 11:05:04 +08:00
{ field: 'capacitySt', title: '供电设备容量(MVA)', width: '140px', },
2024-12-11 11:33:44 +08:00
{ field: 'capacitySscb', title: '基准短路容量(MVA)', width: '140px', },
{ field: 'capacitySscmin', title: '最小短路容量(MVA)', width: '140px', },
2024-12-17 11:05:04 +08:00
2024-12-23 11:30:28 +08:00
// { field: 'location', title: ' 测试位置', width: '100px', },
2024-12-11 11:33:44 +08:00
2024-12-17 11:05:04 +08:00
2024-11-27 16:01:08 +08:00
])
2025-01-09 11:40:17 +08:00
const form = reactive({
proStartTime: '',
proEndTime: '',
id: ''
})
const rules = {
proStartTime: [{ required: true, message: '请输入数据起始时间', trigger: 'blur' }],
proEndTime: [{ required: true, message: '请输入数据结束时间', trigger: 'blur' }],
}
2024-11-27 16:01:08 +08:00
const setData = (data: any) => {
dataList.value = JSON.parse(JSON.stringify(data))
key.value += 1
}
const formatter = (row: any) => {
if (row.column.field == 'voltageLevel') {
return row.cellValue == null ? '/' : voltageLevelList.filter((item: any) => item.id == row.cellValue)[0]?.name
} else if (row.column.field == 'volConType') {
return row.cellValue == null ? '/' : volConTypeList.filter((item: any) => item.id == row.cellValue)[0]?.name
} else {
return row.cellValue == null ? '/' : row.cellValue
}
2025-01-09 11:40:17 +08:00
}
// 取消
const handleClose = () => {
dialogVisible.value = false
}
// 确定
const handleConfirm = () => {
ruleFormRef.value.validate((valid: any) => {
if (valid) {
let data = betweenDay(new Date(form.proStartTime), new Date(form.proEndTime))
if (data < 0) {
ElMessage.warning('数据结束时间不能小于数据起始时间')
} else {
updateRecordData(form).then((res) => {
ElMessage.success(res.message)
dialogVisible.value = false
emit('onSubmit')
})
}
}
})
// dialogVisible.value = false
2024-11-27 16:01:08 +08:00
}
// 删除
const remove = (row: any) => {
ElMessageBox.prompt('二次校验密码确认', '', {
confirmButtonText: '确认',
cancelButtonText: '取消',
customClass: 'customInput',
2024-12-17 20:57:07 +08:00
inputType: 'text',
beforeClose: (action, instance, done) => {
if (action === 'confirm') {
if (instance.inputValue == null) {
return ElMessage.warning('请输入密码')
} else if (instance.inputValue?.length > 32) {
return ElMessage.warning('密码长度不能超过32位,当前密码长度为' + instance.inputValue.length)
} else {
done();
}
} else {
done();
}
}
2024-11-27 16:01:08 +08:00
}).then(({ value }) => {
2024-12-17 20:57:07 +08:00
2024-11-27 16:01:08 +08:00
passwordConfirm(value).then(res => {
console.log('密码正确');
deleteItem({ id: row.id }).then(() => {
ElMessage.success('删除成功')
emit('onSubmit')
})
})
})
2025-01-09 11:40:17 +08:00
}
// 修改
const revise = (row: any) => {
ElMessageBox.prompt('二次校验密码确认', '', {
confirmButtonText: '确认',
cancelButtonText: '取消',
customClass: 'customInput',
inputType: 'text',
beforeClose: (action, instance, done) => {
if (action === 'confirm') {
if (instance.inputValue == null) {
return ElMessage.warning('请输入密码')
} else if (instance.inputValue?.length > 32) {
return ElMessage.warning('密码长度不能超过32位,当前密码长度为' + instance.inputValue.length)
} else {
done();
}
} else {
done();
}
}
}).then(({ value }) => {
passwordConfirm(value).then(res => {
dialogVisible.value = true
form.proStartTime = row.startTime
form.proEndTime = row.endTime
form.id = row.id
})
})
2024-11-27 16:01:08 +08:00
}
defineExpose({ setData })
</script>
<style lang="scss">
.customInput {
.el-input__inner {
-webkit-text-security: disc !important;
}
}
</style>