Files
admin-govern/src/views/govern/manage/programVersion/index.vue

218 lines
8.6 KiB
Vue
Raw Normal View History

2026-03-19 11:29:26 +08:00
<template>
<div class="default-main">
2026-04-24 09:13:48 +08:00
<TableHeader ref="tableHeaderRef" showExport>
2026-03-19 11:29:26 +08:00
<template #select>
<el-form-item label="关键字筛选">
2026-04-24 09:13:48 +08:00
<el-input v-model="tableStore.table.params.searchValue" clearable placeholder="请输入设备名称"
style="width:200px" />
2026-03-19 11:29:26 +08:00
</el-form-item>
<el-form-item label="通讯状态">
2026-04-24 09:13:48 +08:00
<el-select v-model.trim="tableStore.table.params.connectStatus" filterable placeholder="请选择通讯状态"
clearable>
<el-option label="中断" :value="0"></el-option>
<el-option label="正常" :value="1"></el-option>
2026-03-19 11:29:26 +08:00
</el-select>
</el-form-item>
2026-04-02 09:08:57 +08:00
<el-form-item label="设备型号">
2026-04-24 09:13:48 +08:00
<el-select v-model.trim="tableStore.table.params.devModel" filterable placeholder="请选择设备型号"
clearable>
<el-option v-for="item in DevTypeOptions" :key="item.id" :label="item.name"
:value="item.id"></el-option>
2026-03-19 11:29:26 +08:00
</el-select>
</el-form-item>
2026-04-24 09:13:48 +08:00
<el-form-item label="icd模型">
<el-select v-model.trim="tableStore.table.params.icd" filterable placeholder="请选择设备系列" clearable>
<el-option v-for="item in icdList" :key="item.id" :label="item.name"
:value="item.id"></el-option>
2026-03-19 11:29:26 +08:00
</el-select>
</el-form-item>
2026-04-02 09:08:57 +08:00
<el-form-item label="升级设备筛选">
2026-04-24 09:13:48 +08:00
<el-select v-model.trim="tableStore.table.params.upgrade" filterable placeholder="请选择升级设备筛选"
clearable>
<el-option label="可升级" :value="1"></el-option>
<el-option label="不可升级" :value="0"></el-option>
2026-03-19 11:29:26 +08:00
</el-select>
</el-form-item>
</template>
<template #operation>
2026-04-24 09:13:48 +08:00
<el-button :icon="Document" type="primary" class="ml10" @click="maintenance">版本维护</el-button>
<!-- <el-button :icon="Share" type="primary" class="ml10" @click="upgradeVersion">批量升级</el-button> -->
2026-03-19 11:29:26 +08:00
</template>
</TableHeader>
2026-04-24 09:13:48 +08:00
<Table :checkbox-config="checkboxConfig" ref="tableRef" />
<upgrade ref="upgradeRef" />
<deviceLog ref="deviceLogRef" />
2026-03-19 11:29:26 +08:00
</div>
</template>
<script setup lang="ts">
import { ref, onMounted, provide } from 'vue'
import TableStore from '@/utils/tableStore'
import Table from '@/components/table/index.vue'
import TableHeader from '@/components/table/header/index.vue'
import { ElMessage } from 'element-plus'
import { queryByCode, queryByid } from '@/api/system-boot/dictTree'
import { useDictData } from '@/stores/dictData'
2026-04-24 09:13:48 +08:00
import { Share, Document } from '@element-plus/icons-vue'
2026-03-19 11:29:26 +08:00
import { useRouter } from 'vue-router'
2026-04-24 09:13:48 +08:00
import upgrade from './comp/upgrade.vue'
import deviceLog from './comp/deviceLog.vue'
2026-03-19 11:29:26 +08:00
defineOptions({
name: 'govern/manage/programVersion'
})
2026-04-24 09:13:48 +08:00
const upgradeRef = ref()
const deviceLogRef = ref()
2026-03-19 11:29:26 +08:00
const dictData = useDictData()
const DevTypeOptions = ref()
2026-04-24 09:13:48 +08:00
const icdList = ref()
2026-03-19 11:29:26 +08:00
const tableHeaderRef = ref()
const { push, options, currentRoute } = useRouter()
const tableStore = new TableStore({
2026-04-24 09:13:48 +08:00
url: '/cs-device-boot/EquipmentDelivery/version/page',
2026-03-19 11:29:26 +08:00
method: 'POST',
column: [
2026-04-24 09:13:48 +08:00
// { type: 'checkbox', width: '60', },
2026-03-19 11:29:26 +08:00
{
field: 'index',
title: '序号',
width: '80',
formatter: (row: any) => {
return (tableStore.table.params.pageNum - 1) * tableStore.table.params.pageSize + row.rowIndex + 1
}
},
2026-04-24 09:13:48 +08:00
{ title: '设备名称', field: 'name', minWidth: '150' },
{ title: '版本号', field: 'version', minWidth: '100', formatter: (row: any) => { return row.cellValue || '/' } },
{ title: '协议版本', field: 'protocolVersion', minWidth: '100', formatter: (row: any) => { return row.cellValue || '/' } },
{ title: '版本日期', field: 'versionDate', minWidth: '150', formatter: (row: any) => { return row.cellValue || '/' } },
{ title: '设备型号', field: 'devModelName', minWidth: '120', formatter: (row: any) => { return row.cellValue || '/' } },
{ title: 'icd模型', field: 'icd', minWidth: '120', formatter: (row: any) => { return icdList.value.filter(item => item.id == row.cellValue)[0]?.name || '/' } },
{ title: '所属工程', field: 'associatedEngineering', minWidth: '120', formatter: (row: any) => { return row.cellValue || '/' } },
{ title: '所属项目', field: 'associatedProject', minWidth: '120', formatter: (row: any) => { return row.cellValue || '/' } },
2026-03-19 11:29:26 +08:00
{
title: '状态',
2026-04-24 09:13:48 +08:00
field: 'runStatus',
2026-03-19 11:29:26 +08:00
render: 'tag',
minWidth: '80',
custom: {
2026-04-24 09:13:48 +08:00
1: 'danger',
2: 'success'
2026-03-19 11:29:26 +08:00
},
replaceValue: {
2026-04-24 09:13:48 +08:00
1: '离线',
2: '在线'
2026-03-19 11:29:26 +08:00
}
},
2026-04-24 09:13:48 +08:00
{ title: '更新时间', field: 'updateTime', minWidth: '150', formatter: (row: any) => { return row.cellValue || '/' } ,sortable: true},
{ title: '修改人员', field: 'updateByName', minWidth: '100', formatter: (row: any) => { return row.cellValue || '/' } },
2026-03-19 11:29:26 +08:00
{
title: '操作',
fixed: 'right',
align: 'center',
2026-04-24 09:13:48 +08:00
width: '130',
2026-03-19 11:29:26 +08:00
render: 'buttons',
buttons: [
{
name: 'productSetting',
title: '升级',
type: 'primary',
icon: 'el-icon-EditPen',
2026-04-24 09:13:48 +08:00
disabled: (row: any) => {
return row.upgrade == 0
},
render: 'basicButton',
click: (row: any) => {
upgradeRef.value.open({
id: [row.id],
devModel: row.devModel,
version:row.version
})
}
2026-03-19 11:29:26 +08:00
},
{
name: 'productSetting',
2026-04-24 09:13:48 +08:00
title: '日志',
2026-03-19 11:29:26 +08:00
type: 'primary',
icon: 'el-icon-EditPen',
2026-04-24 09:13:48 +08:00
render: 'basicButton',
click: (row: any) => {
deviceLogRef.value.open(row)
}
2026-03-19 11:29:26 +08:00
}
]
}
],
2026-04-24 09:13:48 +08:00
loadCallback: () => { }
2026-03-19 11:29:26 +08:00
})
2026-04-24 09:13:48 +08:00
const checkboxConfig = reactive({
checkMethod: ({ row }) => {
return row.upgrade == 1
}
})
const getQuery = async () => {
queryByCode('Device_Type').then(res => {
const id = res.data.id
queryByid(id).then(res => {
res.data.map((item: any, index: any) => {
if (item.pid == id) {
res.data.splice(index, 1)
}
})
2026-03-19 11:29:26 +08:00
2026-04-24 09:13:48 +08:00
DevTypeOptions.value = res.data
})
2026-03-19 11:29:26 +08:00
})
2026-04-24 09:13:48 +08:00
queryByCode('Icd_Model').then(res => {
const id = res.data.id
queryByid(id).then(res => {
icdList.value = res.data
})
})
}
// 禁止点击
// 升级版本
const upgradeVersion = () => {
if (!tableStore.table.selection.length) {
ElMessage.warning('请选择需要升级的设备!')
return
}
// 获取第一个设备的 devModel
const firstDevModel = tableStore.table.selection[0].devModel
// 检查是否所有设备的 devModel 都相同
const allSame = tableStore.table.selection.every(device => device.devModel === firstDevModel)
if (!allSame) {
return ElMessage.warning('请选择相同设备型号的设备进行批量升级!')
}
upgradeRef.value.open(
{
id: tableStore.table.selection.map(item => item.id),
devModel: firstDevModel
}
)
}
2026-03-19 11:29:26 +08:00
// 版本维护
const maintenance = () => {
push({
2026-04-03 14:47:36 +08:00
// path: '/versionMaintenance'
2026-04-24 09:13:48 +08:00
path: '/version'
2026-03-19 11:29:26 +08:00
})
}
2026-04-24 09:13:48 +08:00
tableStore.table.params.searchValue = ''
tableStore.table.params.connectStatus = ''
tableStore.table.params.devModel = ''
tableStore.table.params.icd = ''
tableStore.table.params.upgrade = ''
2026-03-19 11:29:26 +08:00
provide('tableStore', tableStore)
onMounted(() => {
2026-04-24 09:13:48 +08:00
getQuery()
2026-03-19 11:29:26 +08:00
tableHeaderRef.value.onComSearch()
})
</script>