map/ui/dasadmin/src/views/backend/equipment/airBlower/index.vue

660 lines
24 KiB
Vue
Raw Normal View History

2024-10-17 14:01:38 +08:00
<template>
<div class="airBlower">
<el-container class="containerPart">
<el-header class="headerPart">
<div class="headerLeft">
<div class="selectPart">
<span>{{ t('airBlower.status') }}</span>
<el-select
2024-10-24 19:13:18 +08:00
v-model="airBlowerSelect.iturbineoperationmode"
@change="selectAirBlower('iturbineoperationmode')"
2024-10-17 14:01:38 +08:00
:placeholder="'请选择' + t('airBlower.status')"
class="airBlowerSelect"
>
2024-10-24 19:13:18 +08:00
<el-option
v-for="v in airBlowerSelectOptions.iturbineoperationmode"
:key="v.value"
:label="v.label"
:value="v.value"
></el-option>
2024-10-17 14:01:38 +08:00
</el-select>
</div>
<div class="selectPart">
<span>{{ t('airBlower.feeder') }}</span>
<el-select
2024-10-24 19:13:18 +08:00
v-model="airBlowerSelect.belongLine"
@change="selectAirBlower('belongLine')"
2024-10-17 14:01:38 +08:00
:placeholder="'请选择' + t('airBlower.feeder')"
class="airBlowerSelect"
>
2024-10-24 19:13:18 +08:00
<el-option v-for="v in airBlowerSelectOptions.belongLine" :key="v.value" :label="v.value" :value="v.value"></el-option>
</el-select>
2024-10-17 14:01:38 +08:00
</div>
<div class="selectPart">
2024-10-24 19:13:18 +08:00
<span>自动更新</span>
<el-switch
v-model="autoUpdate"
class="ml-2"
style="--el-switch-on-color: #13ce66; --el-switch-off-color: #ff4949"
></el-switch>
2024-10-17 14:01:38 +08:00
</div>
</div>
<div class="headerRight">
<el-popconfirm title="确认启动么?" @confirm="airBlowerOperate('setTurbineFastStart')">
<template #reference>
<el-button type="primary">{{ t('airBlower.start') }}</el-button>
</template>
</el-popconfirm>
<el-popconfirm title="确认停机么?" @confirm="airBlowerOperate('setTurbineStop')">
<template #reference>
<el-button style="color: #0064aa">{{ t('airBlower.stop') }}</el-button>
</template>
</el-popconfirm>
<el-popconfirm title="确认复位么?" @confirm="airBlowerOperate('setTurbineResetStatusCode')">
<template #reference>
<el-button style="color: #0064aa">{{ t('airBlower.reset') }}</el-button>
</template>
</el-popconfirm>
<el-popconfirm title="确认风机对时么?">
<template #reference>
<el-button style="color: #0064aa">{{ t('airBlower.verify') }}</el-button>
</template>
</el-popconfirm>
2024-10-17 14:01:38 +08:00
</div>
</el-header>
<el-main class="mainPart">
<el-table
ref="tableRef"
:column="tableColumn"
:data="tableData"
:header-row-style="tableHaderStyle"
@selectionChange="selectTable"
class="tableClass"
>
2024-10-24 19:13:18 +08:00
<el-table-column type="selection" width="55"></el-table-column>
2024-10-17 14:01:38 +08:00
<template v-for="item in tableColumn" :key="item.prop">
<el-table-column
v-if="!item.custom"
:prop="item.prop"
2024-10-24 19:13:18 +08:00
:label="item.label"
2024-10-17 14:01:38 +08:00
:align="item.align"
:width="item.width"
:type="item.type"
/>
2024-10-24 19:13:18 +08:00
<el-table-column v-else :label="item.label" :align="item.align" :width="item.width">
2024-10-17 14:01:38 +08:00
<template v-if="item.custom === 'default'" #default="scope">
2024-10-24 19:13:18 +08:00
<div v-if="item.prop === 'iturbineoperationmode'">
2024-11-01 17:45:34 +08:00
<el-tag v-if="scope.row.locked === 1" color="rgba(254,55,49,0.20)" style="color: #fe3731">已锁定</el-tag>
2024-10-24 19:13:18 +08:00
<el-tag v-if="scope.row.iturbineoperationmode === 20" color="rgba(0,100,170,0.20)" style="color: #0064aa"
>并网</el-tag
>
<el-tag v-if="scope.row.iturbineoperationmode === 10" color="rgba(0,160,150,0.20)" style="color: #00a096"
>维护</el-tag
>
<el-tag v-if="scope.row.iturbineoperationmode === 8" color="rgba(255,126,0,0.20)" style="color: #ff7e00"
>限功率运行</el-tag
>
<el-tag v-if="scope.row.iturbineoperationmode === 0" color="rgba(153,153,153,0.20)" style="color: #666666"
>离线</el-tag
>
<el-tag v-if="scope.row.iturbineoperationmode === 16" color="rgba(6,180,41,0.20)" style="color: #06b429"
>启动</el-tag
>
<el-tag v-if="scope.row.iturbineoperationmode === 6" color="rgba(254,55,49,0.20)" style="color: #fe3731"
>正常停机</el-tag
>
<el-tag v-if="scope.row.iturbineoperationmode === 1" color="rgba(254,55,49,0.20)" style="color: #fe3731"
>外部因素导致停机</el-tag
>
<el-tag v-if="scope.row.iturbineoperationmode === 2" color="rgba(254,55,49,0.20)" style="color: #fe3731"
>停机</el-tag
2024-10-24 19:13:18 +08:00
>
<el-tag v-if="scope.row.iturbineoperationmode === 11" color="rgba(255,182,0,0.20)" style="color: #ffb600"
>待机</el-tag
>
<el-tag v-if="scope.row.iturbineoperationmode === 1110" color="rgba(153,153,153,0.20)" style="color: #666666"
>解缆状态</el-tag
>
<el-tag v-if="scope.row.iturbineoperationmode === 1111" color="rgba(254,55,49,0.20)" style="color: #fe3731"
>电网故障停机</el-tag
2024-10-24 19:13:18 +08:00
>
2024-10-17 14:01:38 +08:00
</div>
</template>
<template v-if="item.custom === 'header'" #header="scope">
<div>{{ scope.column.label.split(' ')[0] }}</div>
<div>{{ scope.column.label.split(' ')[1] }}</div>
</template>
<template v-if="item.custom === 'header'" #default="scope">
<div>{{ scope.row[item.prop] }}</div>
</template>
2024-10-24 19:13:18 +08:00
<template v-if="item.prop === 'name'" #default="scope">
<div class="tableColumnClick" @click="openWindTurbine(scope.row)">{{ scope.row[item.prop] }}</div>
2024-10-24 19:13:18 +08:00
</template>
2024-10-17 14:01:38 +08:00
</el-table-column>
</template>
</el-table>
</el-main>
</el-container>
</div>
<el-dialog v-model="multiTaskVisible" :title="mutiTaskTitle" width="400" :close-on-click-modal="false">
<el-row v-for="item in mutiTaskList" :key="item.sendData.deviceId">
<el-col :span="18">
<div class="mutiTaskName">
{{ item.deviceName }}
</div>
</el-col>
<el-col :span="6">
<div class="mutiTaskStatus">
<el-icon style="color: #f56c6c" size="30" v-if="item.loading === 3">
<CircleClose />
</el-icon>
<el-icon style="color: #06b429" size="30" v-if="item.loading === 2">
<CircleCheck />
</el-icon>
<el-icon style="color: #4fa5ff" size="30" class="mutiTaskLoading" v-if="item.loading === 1">
<Loading />
</el-icon>
<div v-if="item.loading === 0">等待发送</div>
</div>
</el-col>
</el-row>
</el-dialog>
2024-10-17 14:01:38 +08:00
</template>
<script setup lang="ts">
2024-10-24 19:13:18 +08:00
import { SelectTypeObjType, SelectTypeKeyUnionType, TableDataObjType, TableColumnType } from './type'
import { onUnmounted, reactive, ref, watch, nextTick } from 'vue'
2024-10-17 14:01:38 +08:00
import { useI18n } from 'vue-i18n'
import { getAirBlowerListReq, getBelongLineListReq } from '/@/api/backend/airBlower/request'
import { CircleCheck, CircleClose, Loading } from '@element-plus/icons-vue'
import { ElMessage, TableInstance, ElPopconfirm } from 'element-plus'
import { useRouter, useRoute } from 'vue-router'
import { getRealTimeState } from './utils'
import { sendCommandReq } from '/@/api/backend/control/request'
import { adminBaseRoutePath } from '/@/router/static/adminBase'
const router = useRouter()
2024-10-17 14:01:38 +08:00
const { t } = useI18n()
2024-10-24 19:13:18 +08:00
const airBlowerSelect = reactive<SelectTypeObjType>({
iturbineoperationmode: 987654321,
belongLine: '全部',
2024-10-17 14:01:38 +08:00
})
2024-10-24 19:13:18 +08:00
const airBlowerSelectOptions = reactive<{ [K in SelectTypeKeyUnionType]: { label: string; value: string | number }[] }>({
iturbineoperationmode: [
{
label: '全部',
value: 987654321,
},
{
label: '并网',
value: 20,
},
{
label: '待机',
value: 11,
},
{
label: '启动',
value: 16,
},
{
label: '维护',
value: 10,
},
{
label: '离线',
value: 0,
},
{
label: '限功率运行',
value: 8,
},
{
label: '正常停机',
value: 6,
},
{
label: '外部因素导致停机',
2024-10-24 19:13:18 +08:00
value: 1,
},
{
label: '停机',
value: 2,
},
2024-10-24 19:13:18 +08:00
{
label: '解缆状态',
value: 1110,
},
{
label: '电网故障停机',
value: 1111,
},
{
label: '安全链停机',
value: 1112,
},
2024-10-24 19:13:18 +08:00
],
belongLine: [],
2024-10-17 14:01:38 +08:00
})
2024-10-24 19:13:18 +08:00
const selectAirBlower = (type: SelectTypeKeyUnionType) => {
if (airBlowerSelect.belongLine === '全部' && airBlowerSelect.iturbineoperationmode === 987654321) {
tableData.value = originTableData.value
return
} else if (airBlowerSelect.belongLine !== '全部' && airBlowerSelect.iturbineoperationmode !== 987654321) {
if (type === 'iturbineoperationmode' && airBlowerSelect.iturbineoperationmode === 2) {
const type1 = originTableData.value.filter((item) => item.iturbineoperationmode === 1)
const type6 = originTableData.value.filter((item) => item.iturbineoperationmode === 6)
const type2 = originTableData.value.filter((item) => item.iturbineoperationmode === 2)
const typeAll = [...type1, ...type6, ...type2]
tableData.value = typeAll.filter((item) => item.belongLine === airBlowerSelect.belongLine)
return
}
const resData = originTableData.value.filter((item) => item.iturbineoperationmode === airBlowerSelect.iturbineoperationmode)
tableData.value = resData.filter((item) => item.belongLine === airBlowerSelect.belongLine)
return
} else {
if (type === 'belongLine' && airBlowerSelect.belongLine === '全部') {
tableData.value = originTableData.value.filter((item) => item.iturbineoperationmode === airBlowerSelect.iturbineoperationmode)
return
} else if (type === 'iturbineoperationmode' && airBlowerSelect.iturbineoperationmode === 987654321) {
tableData.value = originTableData.value.filter((item) => item.belongLine === airBlowerSelect.belongLine)
return
}
if (type === 'iturbineoperationmode' && airBlowerSelect.iturbineoperationmode === 2) {
const type1 = originTableData.value.filter((item) => item.iturbineoperationmode === 1)
const type6 = originTableData.value.filter((item) => item.iturbineoperationmode === 6)
const type2 = originTableData.value.filter((item) => item.iturbineoperationmode === 2)
tableData.value = [...type1, ...type6, ...type2]
return
}
tableData.value = originTableData.value.filter((item) => item[type] === airBlowerSelect[type])
return
2024-10-17 14:01:38 +08:00
}
}
2024-11-07 09:32:34 +08:00
const airBlowerOperate = async (type: 'setTurbineFastStart' | 'setTurbineStop' | 'setTurbineResetStatusCode') => {
2024-11-01 17:45:34 +08:00
const sendTypeEnum = {
setTurbineFastStart: '风机快速启动指令',
setTurbineStop: '风机停机指令',
setTurbineResetStatusCode: '风机复位故障代码指令',
}
if (!selectList.value.length) {
ElMessage.warning('请先选择风机')
return
}
2024-10-24 19:13:18 +08:00
const data = selectList.value.map((item) => {
return {
sendData: {
deviceId: item,
serviceName: sendTypeEnum[type],
serviceCode: type,
optDesc: sendTypeEnum[type] + ',设定值为:' + 1,
opValue: 1 as const,
},
deviceName: tableData.value.find((listItem) => listItem.irn === item)!.name,
loading: 0 as const,
2024-10-24 19:13:18 +08:00
}
})
mutiTaskList.value = data
mutiTaskTitle.value = sendTypeEnum[type]
multiTaskVisible.value = true
2024-11-07 09:32:34 +08:00
for (let i = 0; i < mutiTaskList.value.length; i++) {
mutiTaskList.value[i].loading = 1
2024-11-07 10:26:39 +08:00
runTask(mutiTaskList.value[i].sendData, i)
2024-11-07 09:32:34 +08:00
}
}
2024-11-07 11:18:03 +08:00
const runTask = async (data: any, index: number) => {
try {
let resp = await sendCommandReq(data)
if (resp.success) {
mutiTaskList.value[index].loading = 2
}
} catch (error) {
mutiTaskList.value[index].loading = 3
}
2024-11-07 10:26:39 +08:00
2024-11-07 11:18:03 +08:00
// .then((res: any) => {
// console.log(res)
// if (res.success) {
// console.log(data, 'success')
// mutiTaskList.value[index].loading = 2
// } else {
// mutiTaskList.value[index].loading = 3
// }
// })
// .catch(() => {
// mutiTaskList.value[index].loading = 3
// })
2024-10-17 14:01:38 +08:00
}
const tableHaderStyle = {
color: '#333',
}
2024-10-24 19:13:18 +08:00
const tableColumn: TableColumnType[] = [
2024-10-17 14:01:38 +08:00
{
2024-10-24 19:13:18 +08:00
label: '风机列表',
prop: 'name',
2024-10-17 14:01:38 +08:00
align: 'center',
2024-10-24 19:13:18 +08:00
custom: 'default',
2024-10-17 14:01:38 +08:00
},
{
2024-10-24 19:13:18 +08:00
label: '风机型号',
prop: 'model',
2024-10-17 14:01:38 +08:00
align: 'center',
},
{
2024-10-24 19:13:18 +08:00
label: '风机状态',
prop: 'iturbineoperationmode',
2024-10-17 14:01:38 +08:00
align: 'center',
custom: 'default',
},
{
2024-10-24 19:13:18 +08:00
label: '线路',
prop: 'belongLine',
2024-10-17 14:01:38 +08:00
align: 'center',
},
{
2024-10-24 19:13:18 +08:00
label: '风速 (m/s)',
prop: 'iwindspeed',
2024-10-17 14:01:38 +08:00
align: 'center',
custom: 'header',
},
{
2024-10-24 19:13:18 +08:00
label: '有功功率 (MW)',
prop: 'igenpower',
2024-10-17 14:01:38 +08:00
align: 'center',
custom: 'header',
},
{
2024-10-24 19:13:18 +08:00
label: '日发电量 (kWh)',
prop: 'ikwhthisday',
2024-10-17 14:01:38 +08:00
align: 'center',
custom: 'header',
},
{
2024-10-24 19:13:18 +08:00
label: '总发电量 (万kWh)',
prop: 'ikwhoverall',
2024-10-17 14:01:38 +08:00
align: 'center',
custom: 'header',
},
{
2024-10-24 19:13:18 +08:00
label: '机舱角度',
prop: 'ivanedirection',
2024-10-17 14:01:38 +08:00
align: 'center',
},
{
2024-10-24 19:13:18 +08:00
label: '叶轮转速 (rmp)',
prop: 'irotorspeed',
2024-10-17 14:01:38 +08:00
align: 'center',
custom: 'header',
},
{
2024-10-24 19:13:18 +08:00
label: '发电机转速 (rmp)',
prop: 'igenspeed',
2024-10-17 14:01:38 +08:00
align: 'center',
custom: 'header',
},
{
2024-10-24 19:13:18 +08:00
label: '机舱温度 (℃)',
prop: 'itempnacelle_1sec',
2024-10-17 14:01:38 +08:00
align: 'center',
custom: 'header',
},
{
2024-10-24 19:13:18 +08:00
label: '主油路压力 (kpa)',
prop: 'ihydrpress',
2024-10-17 14:01:38 +08:00
align: 'center',
custom: 'header',
},
{
2024-10-24 19:13:18 +08:00
label: '变桨角度',
prop: 'ipitchangle',
2024-10-17 14:01:38 +08:00
align: 'center',
},
]
const tableRef = ref<TableInstance>()
2024-10-24 19:13:18 +08:00
const tableData = ref<TableDataObjType[]>([])
const originTableData = ref<TableDataObjType[]>([])
const getTableData = () => {
getAirBlowerListReq()
.then((res) => {
const data = res.data.map((item: any) => {
const state = getRealTimeState(item.attributeMap)
const ipitchangle = Math.min(item.attributeMap.ipitchangle1, item.attributeMap.ipitchangle2, item.attributeMap.ipitchangle3)
const resVal: any = {}
Object.keys(item.attributeMap).forEach((attrKey) => {
resVal[attrKey] =
item.attributeMap[attrKey] === 0
? 0
: item.attributeMap[attrKey]
? item.attributeMap.iwindspeed % 1 === 0
? item.attributeMap.iwindspeed
: Math.floor(item.attributeMap[attrKey] * 1000) / 1000
: '-'
})
2024-10-24 19:13:18 +08:00
return {
irn: item.irn,
name: item.name ?? '-',
model: item.model || '-',
iotModelId: item.modelId,
belongLine: item.belongLine || '-',
iwindspeed: '-',
igenpower: '-',
ikwhthisday: '-',
ikwhoverall: '-',
ivanedirection: '-',
irotorspeed: '-',
igenspeed: '-',
itempnacelle_1sec: '-',
ihydrpress: '-',
...resVal,
ipitchangle: ipitchangle === 0 ? 0 : ipitchangle ? Math.floor(ipitchangle * 1000) / 1000 : '-',
2024-10-24 19:13:18 +08:00
iturbineoperationmode: state,
}
})
2024-10-17 14:01:38 +08:00
2024-10-24 19:13:18 +08:00
originTableData.value = data
if (airBlowerSelect.belongLine === '全部' && airBlowerSelect.iturbineoperationmode === 987654321) {
tableData.value = data
} else {
const irn = tableData.value.map((item) => item.irn)
const result: TableDataObjType[] = []
data.forEach((item: TableDataObjType) => {
if (irn.includes(item.irn)) {
result.push(item)
}
})
tableData.value = result
}
if (selectList.value.length) {
const selected = tableData.value.filter((item) => selectList.value.includes(item.irn))
selected.forEach((item) => {
nextTick(() => {
tableRef.value?.toggleRowSelection(item, true)
})
})
}
2024-10-24 19:13:18 +08:00
})
.catch((err: any) => {
})
}
const getBlongLineList = () => {
getBelongLineListReq()
.then((res) => {
const data = res.data.map((item: any) => {
return {
value: item,
}
})
airBlowerSelectOptions.belongLine = [{ value: '全部', label: '全部' }, ...data]
})
.catch((err) => {
console.log(err)
})
}
2024-10-17 14:01:38 +08:00
const selectList = ref<string[]>([])
2024-10-24 19:13:18 +08:00
const selectTable = (selected: TableDataObjType[]) => {
selectList.value = selected.map((item) => item.irn)
2024-10-24 19:13:18 +08:00
}
const autoUpdate = ref(false)
const autoUpdateInterval = ref<any>(null)
watch(autoUpdate, (newVal: boolean) => {
if (newVal) {
if (autoUpdateInterval.value) return
ElMessage.success('开启自动刷新')
2024-10-24 19:13:18 +08:00
autoUpdateInterval.value = setInterval(() => {
getTableData()
}, 2000)
} else {
ElMessage.warning('关闭自动刷新')
2024-10-24 19:13:18 +08:00
clearInterval(autoUpdateInterval.value)
autoUpdateInterval.value = null
}
2024-10-17 14:01:38 +08:00
})
const openWindTurbine = (row: TableDataObjType) => {
if (!router.hasRoute('windTurbine')) {
router.addRoute('admin', {
path: adminBaseRoutePath + '/windTurbine',
name: 'windTurbine',
component: () => import('/@/views/backend/WindBlower/index.vue'),
meta: {
title: 'WindBlower',
2024-10-25 17:34:28 +08:00
menuDesc: '单风机详情',
addtab: true,
},
})
}
router.push({
name: 'windTurbine',
query: {
irn: row.irn,
iotModelId: row.iotModelId,
name: row.name,
},
})
}
const multiTaskVisible = ref(false)
const mutiTaskTitle = ref('')
const mutiTaskList = ref<
{
loading: 0 | 1 | 2 | 3
deviceName: string
sendData: {
deviceId: string
serviceName: string
serviceCode: string
optDesc: string
opValue: 1
}
}[]
>([])
onUnmounted(() => {
autoUpdateInterval.value && clearInterval(autoUpdateInterval.value)
autoUpdateInterval.value = null
})
2024-10-24 19:13:18 +08:00
getTableData()
getBlongLineList()
2024-10-17 14:01:38 +08:00
</script>
<style scoped lang="scss">
.airBlower {
width: 100%;
2024-10-17 14:01:38 +08:00
height: 100%;
.containerPart {
width: 100%;
2024-10-17 14:01:38 +08:00
height: 100%;
.headerPart {
padding: 20px;
width: 100%;
height: 60px;
2024-10-17 14:01:38 +08:00
display: flex;
justify-content: space-between;
align-items: center;
.headerLeft {
display: flex;
.selectPart {
display: flex;
justify-content: space-between;
align-items: center;
height: 40px;
margin-right: 20px;
span {
margin-right: 10px;
}
.airBlowerSelect {
width: 200px;
:deep(.el-select__wrapper) {
height: 40px;
}
}
}
}
.headerRight {
width: 436px;
display: flex;
justify-content: space-between;
.el-button {
width: 100px;
height: 40px;
}
}
}
.mainPart {
width: 100%;
height: calc(100% - 60px);
.tableClass{
width: 100%;
height: 100%;
}
2024-10-24 19:13:18 +08:00
.tableColumnClick {
text-decoration: underline;
color: #00a4ff;
cursor: pointer;
2024-10-17 14:01:38 +08:00
}
}
}
}
.mutiTaskName {
width: 100%;
height: 40px;
line-height: 40px;
font-size: 16px;
}
.mutiTaskStatus {
display: flex;
align-items: center;
justify-content: right;
width: 100%;
height: 40px;
}
.mutiTaskLoading {
animation: rotate 1s linear infinite;
}
@keyframes rotate {
0% {
transform: rotate(0deg);
}
100% {
transform: rotate(360deg);
}
}
2024-10-17 14:01:38 +08:00
</style>