风机列表:批量任务

多报表:初始化执行
节点:显示修改
This commit is contained in:
高云鹏 2024-11-05 17:33:49 +08:00
parent 12fe28a2a8
commit 5c49d9ff8e
4 changed files with 158 additions and 53 deletions

View File

@ -40,10 +40,26 @@
</div>
</div>
<div class="headerRight">
<el-button type="primary" @click="airBlowerOperate('setTurbineFastStart')">{{ t('airBlower.start') }}</el-button>
<el-button style="color: #0064aa" @click="airBlowerOperate('setTurbineStop')">{{ t('airBlower.stop') }}</el-button>
<el-button style="color: #0064aa" @click="airBlowerOperate('setTurbineResetStatusCode')">{{ t('airBlower.reset') }}</el-button>
<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>
</div>
</el-header>
<el-main class="mainPart">
@ -120,6 +136,29 @@
</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>
</template>
<script setup lang="ts">
@ -127,9 +166,13 @@ import { SelectTypeObjType, SelectTypeKeyUnionType, TableDataObjType, TableColum
import { onUnmounted, reactive, ref, watch, nextTick } from 'vue'
import { useI18n } from 'vue-i18n'
import { getAirBlowerListReq, getBelongLineListReq, runAirBlowerReq } from '/@/api/backend/airBlower/request'
import { ElMessage, TableInstance } from 'element-plus'
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 { fa } from 'element-plus/es/locales.mjs'
const router = useRouter()
const { t } = useI18n()
@ -240,27 +283,38 @@ const airBlowerOperate = (type: 'setTurbineFastStart' | 'setTurbineStop' | 'setT
setTurbineStop: '风机停机指令',
setTurbineResetStatusCode: '风机复位故障代码指令',
}
if (!selectList.value.length) {
ElMessage.warning('请先选择风机')
return
}
const data = selectList.value.map((item) => {
return {
sendData: {
deviceId: item,
serviceName: sendTypeEnum[type],
serviceCode: type,
optDesc: sendTypeEnum[type] +',设定值为:'+ 1,
optDesc: sendTypeEnum[type] + ',设定值为:' + 1,
opValue: 1 as const,
measType: 147 as const,
},
deviceName: tableData.value.find((listItem) => listItem.irn === item)!.name,
loading: 0 as const,
}
})
console.log(data)
runAirBlowerReq(data).then((res) => {
console.log(res);
if(res.success){
ElMessage.success('指令发送成功')
mutiTaskList.value = data
mutiTaskTitle.value = sendTypeEnum[type]
multiTaskVisible.value = true
mutiTaskList.value.forEach((item) => {
item.loading = 1
sendCommandReq(item.sendData)
.then((res) => {
console.log(res)
if (res.success) {
item.loading = 2
}
// ElMessage.success('')
}).catch(()=>{
ElMessage.error('操作失败')
})
.catch(() => {
item.loading = 3
})
})
}
@ -481,6 +535,22 @@ const openWindTurbine = (row: TableDataObjType) => {
})
}
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
@ -538,4 +608,29 @@ getBlongLineList()
}
}
}
.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);
}
}
</style>

View File

@ -74,8 +74,8 @@
<div class="correctionTreeItem">
<span>{{ correctionDevice.findIndex((item) => item === data) + 1 + '、' + data.name }}</span>
<div class="rightItem">
<el-input v-if="data.isEdit" v-model="data.iotAddr" @keyup.enter="okEdit(data)" @blur="okEdit(data)" ></el-input>
<el-tag v-else type="info" @click="editAttr(data)">{{ data.iotAddr??'请输入地址' }}</el-tag>
<el-input v-if="data.isEdit" v-model="data.iotAddr" @keyup.enter="okEdit(data)" @blur="okEdit(data)"></el-input>
<el-tag v-else type="info" @click="editAttr(data)">{{ data.iotAddr ?? '请输入地址' }}</el-tag>
<el-popconfirm @confirm="delCorrectionDevice(node)" title="确认删除么?">
<template #reference>
<el-icon><Delete /></el-icon>
@ -111,13 +111,13 @@ import {
uploadMappingListReq,
} from '/@/api/backend/node/request'
import { useRoute, useRouter } from 'vue-router'
import { onBeforeUnmount, onMounted, ref, reactive } from 'vue'
import { onBeforeUnmount, onMounted, ref, reactive, nextTick } from 'vue'
import '@univerjs/design/lib/index.css'
import '@univerjs/ui/lib/index.css'
import '@univerjs/docs-ui/lib/index.css'
import '@univerjs/sheets-ui/lib/index.css'
import '@univerjs/sheets-formula/lib/index.css'
import '@univerjs/sheets-formula-ui/lib/index.css'
import { Univer, UniverInstanceType, Tools, Workbook, LocaleType, IWorkbookData } from '@univerjs/core'
import { defaultTheme } from '@univerjs/design'
@ -132,6 +132,7 @@ import { UniverDocsUIPlugin } from '@univerjs/docs-ui'
import { UniverSheetsPlugin } from '@univerjs/sheets'
import { UniverSheetsFormulaPlugin } from '@univerjs/sheets-formula'
import { UniverSheetsFormulaUIPlugin } from '@univerjs/sheets-formula-ui'
import { UniverSheetsUIPlugin } from '@univerjs/sheets-ui'
import DesignZhCN from '@univerjs/design/locale/zh-CN'
@ -139,6 +140,7 @@ import UIZhCN from '@univerjs/ui/locale/zh-CN'
import DocsUIZhCN from '@univerjs/docs-ui/locale/zh-CN'
import SheetsZhCN from '@univerjs/sheets/locale/zh-CN'
import SheetsUIZhCN from '@univerjs/sheets-ui/locale/zh-CN'
import SheetsFormulaUIZhCN from '@univerjs/sheets-formula-ui/locale/zh-CN'
import { FUniver } from '@univerjs/facade'
import { excelDefaultConfig, createWookbookData, createUpLoadExcelData, createSheetData, setExcelNameToLinkId } from './utils'
@ -192,7 +194,7 @@ const initExcel = (data = {}) => {
theme: defaultTheme,
locale: LocaleType.ZH_CN,
locales: {
[LocaleType.ZH_CN]: Tools.deepMerge(SheetsZhCN, DocsUIZhCN, SheetsUIZhCN, UIZhCN, DesignZhCN),
[LocaleType.ZH_CN]: Tools.deepMerge(SheetsZhCN, DocsUIZhCN, SheetsUIZhCN,SheetsFormulaUIZhCN, UIZhCN, DesignZhCN),
},
})
univerRef.value = univer
@ -214,6 +216,7 @@ const initExcel = (data = {}) => {
univer.registerPlugin(UniverSheetsPlugin)
univer.registerPlugin(UniverSheetsUIPlugin)
univer.registerPlugin(UniverSheetsFormulaPlugin)
univer.registerPlugin(UniverSheetsFormulaUIPlugin)
// create workbook instance
workbook.value = univer.createUnit<IWorkbookData, Workbook>(UniverInstanceType.UNIVER_SHEET, data)
@ -239,6 +242,14 @@ const initExcel = (data = {}) => {
}
})
hasLoading.value = false
// const wb = univerAPI.getActiveWorkbook()
// const worksheet = wb.getActiveSheet()
// console.log(worksheet)
// worksheet.setFrozenRows(1)
// const freezeState = worksheet.getFreeze()
// console.log('', freezeState)
}
/**
@ -552,12 +563,11 @@ onBeforeUnmount(() => {
}
}
}
.treeMain{
.treeMain {
height: 600px;
.el-tree{
.el-tree {
height: 100%;
overflow-y: auto;
}
}
</style>

View File

@ -46,14 +46,14 @@ export const excelDefaultConfig: any = {
code: 'limit1Enable',
default: 0
},
{
label: '限值1下限',
code: 'limit1Low'
},
{
label: '限值1上限',
code: 'limit1High'
},
{
label: '限值1下限',
code: 'limit1Low'
},
{
label: '限值2',
code: 'limit2Enable',
@ -255,14 +255,14 @@ export const excelDefaultConfig: any = {
label: '限值1',
code: 'limit1Enable'
},
{
label: '限值1下限',
code: 'limit1Low'
},
{
label: '限值1上限',
code: 'limit1High'
},
{
label: '限值1下限',
code: 'limit1Low'
},
{
label: '限值2',
code: 'limit2Enable'
@ -451,14 +451,14 @@ export const excelDefaultConfig: any = {
label: '限值1',
code: 'limit1Enable'
},
{
label: '限值1下限',
code: 'limit1Low'
},
{
label: '限值1上限',
code: 'limit1High'
},
{
label: '限值1下限',
code: 'limit1Low'
},
{
label: '限值2',
code: 'limit2Enable'
@ -544,14 +544,14 @@ export const excelDefaultConfig: any = {
label: '限值1',
code: 'limit1Enable'
},
{
label: '限值1下限',
code: 'limit1Low'
},
{
label: '限值1上限',
code: 'limit1High'
},
{
label: '限值1下限',
code: 'limit1Low'
},
{
label: '限值2',
code: 'limit2Enable'
@ -669,12 +669,12 @@ const createHeaderData = (protocol: string | number) => {
2: {
v: '属性名称',
s: '1',
custom: 'name',
custom: 'measPointName',
},
3: {
v: '属性编码',
s: '1',
custom: 'code',
custom: 'measPointCode',
},
...dynamicData,
},
@ -772,7 +772,7 @@ export const createUpLoadExcelData = (workbookData: any) => {
const sheetkeyMap: any = {}
const sheetKeys = Object.keys(sheets[item].cellData)
sheetKeys.forEach((key) => {
const sheetData: any = {}
let sheetData: any = {}
const fieldKeys = Object.keys(sheets[item].cellData[key])
if (key === '0') {
fieldKeys.forEach((fieldKey) => {
@ -784,11 +784,10 @@ export const createUpLoadExcelData = (workbookData: any) => {
const sheetKeyMapKeys = Object.keys(sheetkeyMap)
for (let fieldKey of sheetKeyMapKeys) {
if (fieldKey === '0') {
sheetData.equipmentId = sheets[item].cellData[key][fieldKey].custom.equipmentId
sheetData = { ...sheets[item].cellData[key][fieldKey].custom.otherData }
sheetData.linkId = workbookData.name
sheetData[sheetkeyMap[fieldKey]] = sheets[item].cellData[key][fieldKey]?.v ?? ''
sheetData.type = sheets[item].cellData[key][fieldKey].custom.type
sheetData.id = sheets[item].cellData[key][fieldKey].custom.id
continue
}
if (fieldKey === '1') {
@ -822,14 +821,14 @@ export const createSheetData = (data: any, protocol: string | number) => {
const row = index + 1
result[row] = {}
Object.keys(obj).forEach((field) => {
const col = excelCellDataMap[field]
if (col) {
let custom: any
if (col === '0') {
custom = {}
custom.equipmentId = obj.equipmentId
custom.type = item
custom.id = obj.id
custom.otherData = obj
}
result[row][col] = { v: obj[field], s: '1', custom }
}

View File

@ -582,6 +582,7 @@ const timestampToTime = (timestamp: any) => {
let s = date.getSeconds() < 10 ? '0' + date.getSeconds() : date.getSeconds()
return Y + M + D + h + m + s
}
getReportTemplateList()
onMounted(() => {
queryWindBlower()
})