2024-09-04 20:59:57 +08:00
|
|
|
<template>
|
2024-09-06 15:10:30 +08:00
|
|
|
<div class="default-main">
|
|
|
|
|
<!-- 模版 -->
|
|
|
|
|
<TableHeader ref="TableHeaderRef" datePicker>
|
|
|
|
|
<template #operation>
|
|
|
|
|
<el-button icon="el-icon-Plus" type="primary" @click="addUser">新增</el-button>
|
|
|
|
|
</template>
|
|
|
|
|
</TableHeader>
|
|
|
|
|
<Table ref="tableRef"></Table>
|
|
|
|
|
<!-- 弹框 -->
|
2024-09-13 18:31:35 +08:00
|
|
|
<PopupEdit ref="popupEditRef" @onSubmit="tableStore.index()" />
|
2024-09-06 15:10:30 +08:00
|
|
|
</div>
|
|
|
|
|
</template>
|
|
|
|
|
<script setup lang="ts">
|
|
|
|
|
import { onMounted, ref, provide } from 'vue'
|
2024-09-04 20:59:57 +08:00
|
|
|
|
2024-09-06 15:10:30 +08:00
|
|
|
import TableStore from '@/utils/tableStore'
|
|
|
|
|
import TableHeader from '@/components/table/header/index.vue'
|
2024-09-13 18:31:35 +08:00
|
|
|
import { libtemplateDel } from '@/api/supervision-boot/database/index'
|
|
|
|
|
import { ElMessage } from 'element-plus'
|
2024-09-06 15:10:30 +08:00
|
|
|
import Table from '@/components/table/index.vue'
|
2024-09-18 15:52:50 +08:00
|
|
|
import { getFileNameAndFilePath, downloadFile } from '@/api/system-boot/file'
|
2024-09-06 15:10:30 +08:00
|
|
|
import PopupEdit from './components/form.vue'
|
|
|
|
|
defineOptions({
|
2024-09-14 10:56:49 +08:00
|
|
|
name: 'database/stencil'
|
2024-09-06 15:10:30 +08:00
|
|
|
})
|
|
|
|
|
|
|
|
|
|
const popupEditRef = ref()
|
2024-09-04 20:59:57 +08:00
|
|
|
|
2024-09-06 15:10:30 +08:00
|
|
|
const TableHeaderRef = ref()
|
|
|
|
|
|
|
|
|
|
const tableStore = new TableStore({
|
2024-09-13 18:31:35 +08:00
|
|
|
url: '/supervision-boot/libtemplate/pageQuery',
|
2024-09-06 15:10:30 +08:00
|
|
|
method: 'POST',
|
|
|
|
|
column: [
|
|
|
|
|
{ title: '模版名称', field: 'name' },
|
|
|
|
|
{
|
|
|
|
|
title: '创建时间',
|
2024-09-13 18:31:35 +08:00
|
|
|
field: 'createTime'
|
2024-09-06 15:10:30 +08:00
|
|
|
},
|
2024-09-13 18:31:35 +08:00
|
|
|
{
|
|
|
|
|
title: '操作',
|
|
|
|
|
width: '280',
|
|
|
|
|
render: 'buttons',
|
|
|
|
|
buttons: [
|
|
|
|
|
{
|
|
|
|
|
name: 'edit',
|
|
|
|
|
title: '预览 ',
|
|
|
|
|
type: 'primary',
|
|
|
|
|
icon: 'el-icon-Plus',
|
|
|
|
|
render: 'basicButton',
|
2024-09-14 10:56:49 +08:00
|
|
|
click: row => {
|
2024-09-18 15:52:50 +08:00
|
|
|
window.open(window.location.origin + '/#/previewFile?' + row.url)
|
2024-09-14 10:56:49 +08:00
|
|
|
}
|
2024-09-13 18:31:35 +08:00
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
name: 'edit',
|
|
|
|
|
title: '下载 ',
|
|
|
|
|
type: 'primary',
|
|
|
|
|
icon: 'el-icon-Plus',
|
|
|
|
|
render: 'basicButton',
|
2024-09-14 10:56:49 +08:00
|
|
|
click: row => {
|
|
|
|
|
downloadTheReport(row.url)
|
|
|
|
|
}
|
2024-09-13 18:31:35 +08:00
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
name: 'edit',
|
|
|
|
|
title: '修改 ',
|
|
|
|
|
type: 'primary',
|
|
|
|
|
icon: 'el-icon-Plus',
|
|
|
|
|
render: 'basicButton',
|
|
|
|
|
click: row => {
|
|
|
|
|
popupEditRef.value.open('修改模版', row)
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
title: '删除',
|
|
|
|
|
type: 'danger',
|
|
|
|
|
icon: 'el-icon-Delete',
|
|
|
|
|
render: 'confirmButton',
|
|
|
|
|
popconfirm: {
|
|
|
|
|
confirmButtonText: '确认',
|
|
|
|
|
cancelButtonText: '取消',
|
|
|
|
|
confirmButtonType: 'danger',
|
|
|
|
|
title: '确定删除吗?'
|
|
|
|
|
},
|
|
|
|
|
click: row => {
|
|
|
|
|
libtemplateDel({ id: row.id }).then(() => {
|
|
|
|
|
ElMessage.success('删除成功')
|
|
|
|
|
tableStore.index()
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
]
|
|
|
|
|
}
|
2024-09-06 15:10:30 +08:00
|
|
|
],
|
2024-09-13 18:31:35 +08:00
|
|
|
loadCallback: () => {}
|
2024-09-06 15:10:30 +08:00
|
|
|
})
|
|
|
|
|
|
|
|
|
|
// 弹框
|
|
|
|
|
const addUser = () => {
|
2024-09-13 18:31:35 +08:00
|
|
|
popupEditRef.value.open('新增模版')
|
2024-09-06 15:10:30 +08:00
|
|
|
}
|
2024-09-18 15:52:50 +08:00
|
|
|
|
2024-09-14 10:56:49 +08:00
|
|
|
// 下载报告
|
|
|
|
|
const downloadTheReport = (url: string) => {
|
2024-09-18 15:52:50 +08:00
|
|
|
let urls = url
|
|
|
|
|
let name = url.match(/\/([^/]+)\.(\w+)$/)[1]
|
|
|
|
|
downloadFile({ filePath: url }).then((res: any) => {
|
|
|
|
|
let blob = new Blob([res], {
|
|
|
|
|
type: urls.includes('.pdf')
|
|
|
|
|
? 'application/pdf'
|
|
|
|
|
: urls.includes('.docx')
|
|
|
|
|
? 'application/vnd.openxmlformats-officedocument.wordprocessingml.document'
|
|
|
|
|
: ''
|
|
|
|
|
})
|
|
|
|
|
const url = window.URL.createObjectURL(blob)
|
|
|
|
|
const link = document.createElement('a')
|
|
|
|
|
link.href = url
|
|
|
|
|
link.download = name
|
|
|
|
|
document.body.appendChild(link)
|
|
|
|
|
link.click()
|
|
|
|
|
link.remove()
|
|
|
|
|
})
|
2024-09-14 10:56:49 +08:00
|
|
|
}
|
2024-09-06 15:10:30 +08:00
|
|
|
|
|
|
|
|
provide('tableStore', tableStore)
|
|
|
|
|
onMounted(() => {
|
|
|
|
|
tableStore.index()
|
|
|
|
|
})
|
|
|
|
|
</script>
|
|
|
|
|
<style lang="scss"></style>
|