风机列表:批量任务

多报表:初始化执行
节点:显示修改
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> </div>
<div class="headerRight"> <div class="headerRight">
<el-button type="primary" @click="airBlowerOperate('setTurbineFastStart')">{{ t('airBlower.start') }}</el-button> <el-popconfirm title="确认启动么?" @confirm="airBlowerOperate('setTurbineFastStart')">
<el-button style="color: #0064aa" @click="airBlowerOperate('setTurbineStop')">{{ t('airBlower.stop') }}</el-button> <template #reference>
<el-button style="color: #0064aa" @click="airBlowerOperate('setTurbineResetStatusCode')">{{ t('airBlower.reset') }}</el-button> <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> <el-button style="color: #0064aa">{{ t('airBlower.verify') }}</el-button>
</template>
</el-popconfirm>
</div> </div>
</el-header> </el-header>
<el-main class="mainPart"> <el-main class="mainPart">
@ -120,6 +136,29 @@
</el-main> </el-main>
</el-container> </el-container>
</div> </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> </template>
<script setup lang="ts"> <script setup lang="ts">
@ -127,9 +166,13 @@ import { SelectTypeObjType, SelectTypeKeyUnionType, TableDataObjType, TableColum
import { onUnmounted, reactive, ref, watch, nextTick } from 'vue' import { onUnmounted, reactive, ref, watch, nextTick } from 'vue'
import { useI18n } from 'vue-i18n' import { useI18n } from 'vue-i18n'
import { getAirBlowerListReq, getBelongLineListReq, runAirBlowerReq } from '/@/api/backend/airBlower/request' 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 { useRouter, useRoute } from 'vue-router'
import { getRealTimeState } from './utils' import { getRealTimeState } from './utils'
import { sendCommandReq } from '/@/api/backend/control/request'
import { fa } from 'element-plus/es/locales.mjs'
const router = useRouter() const router = useRouter()
const { t } = useI18n() const { t } = useI18n()
@ -240,27 +283,38 @@ const airBlowerOperate = (type: 'setTurbineFastStart' | 'setTurbineStop' | 'setT
setTurbineStop: '风机停机指令', setTurbineStop: '风机停机指令',
setTurbineResetStatusCode: '风机复位故障代码指令', setTurbineResetStatusCode: '风机复位故障代码指令',
} }
if (!selectList.value.length) {
ElMessage.warning('请先选择风机')
return
}
const data = selectList.value.map((item) => { const data = selectList.value.map((item) => {
return { return {
sendData: {
deviceId: item, deviceId: item,
serviceName: sendTypeEnum[type], serviceName: sendTypeEnum[type],
serviceCode: type, serviceCode: type,
optDesc: sendTypeEnum[type] +',设定值为:'+ 1, optDesc: sendTypeEnum[type] + ',设定值为:' + 1,
opValue: 1 as const, opValue: 1 as const,
measType: 147 as const, },
deviceName: tableData.value.find((listItem) => listItem.irn === item)!.name,
loading: 0 as const,
} }
}) })
console.log(data) mutiTaskList.value = data
mutiTaskTitle.value = sendTypeEnum[type]
runAirBlowerReq(data).then((res) => { multiTaskVisible.value = true
console.log(res); mutiTaskList.value.forEach((item) => {
if(res.success){ item.loading = 1
ElMessage.success('指令发送成功') sendCommandReq(item.sendData)
.then((res) => {
console.log(res)
if (res.success) {
item.loading = 2
} }
// ElMessage.success('') })
}).catch(()=>{ .catch(() => {
ElMessage.error('操作失败') 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(() => { onUnmounted(() => {
autoUpdateInterval.value && clearInterval(autoUpdateInterval.value) autoUpdateInterval.value && clearInterval(autoUpdateInterval.value)
autoUpdateInterval.value = null 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> </style>

View File

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

View File

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