You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
246 lines
6.2 KiB
246 lines
6.2 KiB
<script lang="ts" setup>
|
|
// import { useSettingStore } from '@/stores/settingStore'
|
|
import { syncSendCmd } from 'apis/system'
|
|
import { ElLoading } from 'element-plus'
|
|
import { FtMessage } from 'libs/message'
|
|
import { computed, onMounted, ref } from 'vue'
|
|
|
|
import HistoryDetail from '../setting/HistoryDetail.vue'
|
|
// const settingStore = useSettingStore()
|
|
// const systemStore = useSystemStore()
|
|
const tableData = ref<string[]>([])
|
|
const selectedRecords = ref<Setting.History[]>([])
|
|
const visible = ref(false)
|
|
const detailData = ref()
|
|
onMounted(() => {
|
|
getRecord()
|
|
})
|
|
|
|
const getRecord = () => {
|
|
const params = {
|
|
className: 'DisinfectionLogsService',
|
|
fnName: 'getRecordList',
|
|
params: {},
|
|
}
|
|
syncSendCmd(params).then((res) => {
|
|
if (res.ackcode === 0 && res.rely && res.rely.length) {
|
|
const list: string[] = res.rely.map((item: Setting.History) => {
|
|
return {
|
|
name: item,
|
|
}
|
|
})
|
|
tableData.value = list
|
|
}
|
|
})
|
|
}
|
|
const showDetail = (historyItem: Setting.History) => {
|
|
const detailParams = {
|
|
className: 'DisinfectionLogsService',
|
|
fnName: 'getRecord',
|
|
params: {
|
|
logName: historyItem.name,
|
|
},
|
|
}
|
|
syncSendCmd(detailParams).then((res) => {
|
|
// 把值附给详情的列表
|
|
detailData.value = res.rely
|
|
visible.value = true
|
|
})
|
|
}
|
|
const printDetail = (historyItem: Setting.History) => {
|
|
FtMessage.info('开始打印!')
|
|
const detailParams = {
|
|
className: 'DisinfectionLogsService',
|
|
fnName: 'printRecord',
|
|
params: {
|
|
logName: historyItem.name,
|
|
},
|
|
}
|
|
syncSendCmd(detailParams).then(() => {
|
|
FtMessage.success('正在打印中!')
|
|
})
|
|
}
|
|
// const onDelHistory = () => {
|
|
// if (!selectedRecords.value.length) {
|
|
// FtMessage.warning('请选择要删除的数据')
|
|
// return
|
|
// }
|
|
// ElMessageBox.confirm('请确认是否删除?', '删除', {
|
|
// confirmButtonText: '确认',
|
|
// cancelButtonText: '取消',
|
|
// type: 'warning',
|
|
// }).then(() => {
|
|
// const delParams = {
|
|
// className: 'DisinfectionLogsService',
|
|
// fnName: 'deleteReports',
|
|
// params: {
|
|
// logNames: selectedRecords.value.map(item => item.name),
|
|
// },
|
|
// }
|
|
// syncSendCmd(delParams).then((res) => {
|
|
// if (res.ackcode === 0) {
|
|
// FtMessage.success('删除成功')
|
|
// getRecord()
|
|
// }
|
|
// })
|
|
// })
|
|
// }
|
|
const onExportHistory = () => {
|
|
if (!selectedRecords.value.length) {
|
|
FtMessage.warning('请选择要导出的数据')
|
|
return
|
|
}
|
|
const loading = ElLoading.service({
|
|
lock: true,
|
|
text: '正在导出',
|
|
background: 'rgba(255, 255, 255, 0.8)',
|
|
})
|
|
const exportParams = {
|
|
className: 'DisinfectionLogsService',
|
|
fnName: 'exportRecord',
|
|
params: {
|
|
logNames: selectedRecords.value.map(item => item.name),
|
|
},
|
|
}
|
|
syncSendCmd(exportParams)
|
|
.then((res) => {
|
|
if (res.ackcode === 0) {
|
|
FtMessage.success('导出成功')
|
|
}
|
|
})
|
|
.catch((error) => {
|
|
console.error('导出记录失败:', error)
|
|
})
|
|
.finally(() => {
|
|
loading.close()
|
|
})
|
|
}
|
|
|
|
const handleSelectionChange = (rows: Setting.History[]) => {
|
|
selectedRecords.value = rows
|
|
}
|
|
|
|
const onClose = () => {
|
|
visible.value = false
|
|
}
|
|
// const deleteBtnVisible = computed(() => {
|
|
// return systemStore.systemUser?.name === 'admin'
|
|
// })
|
|
const currentPage = ref(1)
|
|
const pageSize = ref(9)
|
|
const handleCurrentChange = (page: number) => {
|
|
currentPage.value = page
|
|
}
|
|
// 计算当前页数据
|
|
const currentPageData = computed(() => {
|
|
const start = (currentPage.value - 1) * pageSize.value
|
|
const end = start + pageSize.value
|
|
return tableData.value?.slice(start, end)
|
|
})
|
|
</script>
|
|
|
|
<template>
|
|
<div>
|
|
<div class="history-export">
|
|
<bt-button type="primary" button-text="导出" @click="onExportHistory" />
|
|
<!-- <bt-button v-if="deleteBtnVisible" type="primary" button-text="删除" @click="onDelHistory" /> -->
|
|
</div>
|
|
<div class="history-table">
|
|
<el-table :data="currentPageData" style="width: 100%" height="100%" @selection-change="handleSelectionChange">
|
|
<el-table-column type="selection" width="55" />
|
|
<!-- <el-table-column type="index" label="序号" width="80" /> -->
|
|
<el-table-column prop="name" label="消毒日期" />
|
|
<el-table-column prop="detail" label="操作" width="200">
|
|
<template #default="scoped">
|
|
<div class="user-opera">
|
|
<el-button type="primary" @click.stop="showDetail(scoped.row)">
|
|
查看
|
|
</el-button>
|
|
<el-button type="primary" @click.stop="printDetail(scoped.row)">
|
|
打印
|
|
</el-button>
|
|
</div>
|
|
</template>
|
|
</el-table-column>
|
|
</el-table>
|
|
</div>
|
|
<div class="audit-pagination">
|
|
<el-pagination
|
|
layout="prev, pager, next"
|
|
:total="tableData.length"
|
|
:page-size="pageSize"
|
|
:current-page="currentPage"
|
|
@current-change="handleCurrentChange"
|
|
/>
|
|
</div>
|
|
<ft-dialog v-model="visible" title="消毒详情" width="80vw" @cancel="onClose">
|
|
<div>
|
|
<HistoryDetail :data="detailData" />
|
|
</div>
|
|
</ft-dialog>
|
|
</div>
|
|
</template>
|
|
|
|
<style lang="scss" scoped>
|
|
.user-opera {
|
|
display: flex;
|
|
align-items: center;
|
|
}
|
|
.main-content {
|
|
height: $main-container-height;
|
|
padding: 10px;
|
|
background: $gradient-color;
|
|
.history-export {
|
|
height: 50px;
|
|
display: flex;
|
|
align-items: center;
|
|
}
|
|
.history-table {
|
|
height: 68vh;
|
|
overflow: auto;
|
|
}
|
|
.view-button,
|
|
.delete-button,
|
|
.print-button {
|
|
border: none;
|
|
padding: 4px 8px;
|
|
border-radius: 3px;
|
|
cursor: pointer;
|
|
margin-right: 5px;
|
|
transition: all 0.3s;
|
|
font-family: serif;
|
|
}
|
|
.print-button {
|
|
background-color: #e6f0ff;
|
|
color: #1890ff;
|
|
}
|
|
.view-button {
|
|
background-color: #e6f0ff;
|
|
color: #1890ff;
|
|
}
|
|
|
|
.view-button:hover {
|
|
background-color: #1890ff;
|
|
color: white;
|
|
}
|
|
.print-button:hover {
|
|
background-color: #1890ff;
|
|
color: white;
|
|
}
|
|
.delete-button {
|
|
background-color: #ffe6e6;
|
|
color: #ff4d4f;
|
|
}
|
|
|
|
.delete-button:hover {
|
|
background-color: #ff4d4f;
|
|
color: white;
|
|
}
|
|
}
|
|
.audit-pagination {
|
|
height: 50px;
|
|
display: flex;
|
|
align-items: center;
|
|
float: right;
|
|
}
|
|
</style>
|