Files
admin-govern/src/views/govern/manage/basic/version.vue

212 lines
7.5 KiB
Vue
Raw Normal View History

2026-01-04 14:55:31 +08:00
<template>
<div class="default-main">
<TableHeader ref="tableHeaderRef">
<template #select>
<el-form-item label="装置型号:">
<el-select v-model.trim="tableStore.table.params.devType" placeholder="请选择装置型号" clearable>
2026-01-05 11:31:50 +08:00
<el-option
v-for="item in DevTypeOptions"
:key="item.id"
:label="item.name"
:value="item.id"
></el-option>
2026-01-04 14:55:31 +08:00
</el-select>
</el-form-item>
</template>
<template #operation>
<el-button :icon="Plus" type="primary" @click="addMenu" class="ml10">新增版本</el-button>
</template>
</TableHeader>
<Table ref="tableRef" />
2026-01-05 11:31:50 +08:00
<PopupVersion ref="popupVersionRef" v-if="showPopup" @closePopup="closePopup"></PopupVersion>
2026-01-04 14:55:31 +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 { delCsDictData } from '@/api/system-boot/csDictData'
import { ElMessage } from 'element-plus'
import { queryByCode, queryByid } from '@/api/system-boot/dictTree'
import { useDictData } from '@/stores/dictData'
import PopupVersion from '@/views/govern/manage/basic/popupVersion.vue'
import { Plus } from '@element-plus/icons-vue'
import { auditEdData } from '@/api/cs-device-boot/edData'
2026-01-12 11:06:54 +08:00
import { getFileUrl, downLoadFile } from '@/api/cs-system-boot/manage'
2026-01-04 14:55:31 +08:00
defineOptions({
name: 'govern/manage/basic/version'
})
const popupVersionRef = ref()
const dictData = useDictData()
const showPopup = ref(false)
const DevTypeOptions = ref()
const tableHeaderRef = ref()
const tableStore = new TableStore({
url: '/cs-device-boot/edData/queryEdDataPage',
method: 'POST',
column: [
2026-01-14 13:30:23 +08:00
{
field: 'index',
title: '序号',
width: '80',
formatter: (row: any) => {
return (tableStore.table.params.pageNum - 1) * tableStore.table.params.pageSize + row.rowIndex + 1
}
},
{ title: '装置型号', field: 'devTypeName' ,minWidth: '100'},
{ title: '版本号', field: 'versionNo' ,minWidth: '100'},
{ title: '版本协议', field: 'versionAgreement' ,minWidth: '100'},
{ title: '版本日期', field: 'versionDate' ,minWidth: '100'},
{ title: '归档日期', field: 'updateTime',minWidth: '150' },
{ title: '描述', field: 'description',minWidth: '200' },
2026-01-04 14:55:31 +08:00
{
2026-01-05 11:31:50 +08:00
title: '状态',
field: 'status',
render: 'tag',
2026-01-14 13:30:23 +08:00
minWidth: '80',
2026-01-04 14:55:31 +08:00
custom: {
0: 'error',
2026-01-05 11:31:50 +08:00
1: 'success'
2026-01-04 14:55:31 +08:00
},
replaceValue: {
0: '禁用',
2026-01-05 11:31:50 +08:00
1: '启用'
2026-01-04 14:55:31 +08:00
}
},
{
2026-01-14 13:30:23 +08:00
title: '操作', fixed: 'right',
2026-01-04 14:55:31 +08:00
align: 'center',
width: '180',
render: 'buttons',
buttons: [
2026-01-12 11:06:54 +08:00
{
name: 'productSetting',
title: '下载文件',
type: 'primary',
icon: 'el-icon-EditPen',
render: 'basicButton',
click: row => {
downloadTheReport(row.filePath)
}
},
2026-01-04 14:55:31 +08:00
{
name: 'edit',
title: '编辑',
type: 'primary',
icon: 'el-icon-EditPen',
render: 'basicButton',
click: row => {
2026-01-05 11:31:50 +08:00
showPopup.value = true
setTimeout(() => {
popupVersionRef.value.open('编辑版本', row)
}, 100)
2026-01-04 14:55:31 +08:00
}
},
{
name: 'edit',
title: '启用',
type: 'primary',
icon: 'el-icon-Open',
render: 'basicButton',
disabled: row => {
return row.status == 1
},
click: row => {
auditEdData({
id: row.id,
status: 1
}).then((res: any) => {
ElMessage.success('启用成功')
tableStore.index()
})
}
},
{
name: 'del',
title: '禁用',
type: 'danger',
icon: 'el-icon-SwitchButton',
render: 'confirmButton',
popconfirm: {
confirmButtonText: '确认',
cancelButtonText: '取消',
confirmButtonType: 'danger',
title: '确定禁用吗?'
},
disabled: row => {
return row.status == 0
},
click: row => {
auditEdData({
id: row.id,
status: 0
}).then((res: any) => {
ElMessage.success('禁用成功')
tableStore.index()
})
}
}
]
}
],
loadCallback: () => {
tableStore.table.data.forEach((item: any) => {
item.statusName = item.status == 1 ? '禁用' : '启用'
for (let key in item) {
if (typeof item[key] !== 'number') {
item[key] = item[key] || '/'
}
}
})
}
})
queryByCode('Device_Type').then(res => {
2026-01-05 11:31:50 +08:00
const id = res.data.id
queryByid(id).then(res1 => {
res1.data.map((item: any, index: any) => {
if (item.pid == id) {
res1.data.splice(index, 1)
}
2026-01-04 14:55:31 +08:00
})
2026-01-05 11:31:50 +08:00
DevTypeOptions.value = res1.data
2026-01-04 14:55:31 +08:00
})
2026-01-05 11:31:50 +08:00
})
2026-01-12 11:06:54 +08:00
// 下载报告
const downloadTheReport = (name: string) => {
getFileUrl(name).then((res: any) => {
downLoadFile(res.data).then(res => {
let blob = new Blob([res], {
type: 'application/octet-stream'
})
const url = window.URL.createObjectURL(blob)
const link = document.createElement('a') // 创建a标签
link.href = url
link.download = name.split('/').pop() || '升级文件' // 设置下载的文件名
document.body.appendChild(link)
link.click() //执行下载
document.body.removeChild(link)
ElMessage.success('下载成功')
})
})
}
2026-01-04 14:55:31 +08:00
tableStore.table.params.devType = ''
provide('tableStore', tableStore)
onMounted(() => {
tableHeaderRef.value.onComSearch()
})
const addMenu = () => {
showPopup.value = true
2026-01-05 11:31:50 +08:00
setTimeout(() => {
popupVersionRef.value.open('新增版本')
}, 100)
}
const closePopup = () => {
showPopup.value = false
2026-01-04 14:55:31 +08:00
}
</script>