<template>
|
<div class="flow-step-log-page art-full-height">
|
<ArtSearchBar
|
v-model="searchForm"
|
:items="searchItems"
|
:showExpand="true"
|
@search="handleSearch"
|
@reset="handleReset"
|
/>
|
|
<ElCard class="art-table-card">
|
<ArtTableHeader v-model:columns="columnChecks" :loading="loading" @refresh="refreshData">
|
<template #left>
|
<ListExportPrint
|
class="inline-flex"
|
:preview-visible="previewVisible"
|
@update:previewVisible="handlePreviewVisibleChange"
|
:report-title="reportTitle"
|
:selected-rows="selectedRows"
|
:query-params="reportQueryParams"
|
:columns="reportColumns"
|
:preview-rows="previewRows"
|
:preview-meta="previewMeta"
|
:total="pagination.total"
|
:disabled="loading"
|
@export="handleExport"
|
@print="handlePrint"
|
/>
|
</template>
|
</ArtTableHeader>
|
|
<ArtTable
|
:loading="loading"
|
:data="data"
|
:columns="columns"
|
:pagination="pagination"
|
@selection-change="handleSelectionChange"
|
@pagination:size-change="handleSizeChange"
|
@pagination:current-change="handleCurrentChange"
|
/>
|
</ElCard>
|
|
<FlowStepLogDetailDrawer v-model:visible="detailDrawerVisible" :detail="detailData" />
|
</div>
|
</template>
|
|
<script setup>
|
import { computed, ref } from 'vue'
|
import { useUserStore } from '@/store/modules/user'
|
import { useTable } from '@/hooks/core/useTable'
|
import { usePrintExportPage } from '@/views/system/common/usePrintExportPage'
|
import ListExportPrint from '@/components/biz/list-export-print/index.vue'
|
import { defaultResponseAdapter } from '@/utils/table/tableUtils'
|
import {
|
fetchExportFlowStepLogReport,
|
fetchFlowStepLogPage,
|
fetchGetFlowStepLogDetail,
|
fetchGetFlowStepLogMany
|
} from '@/api/flow-step-log'
|
import {
|
buildFlowStepLogPageQueryParams,
|
buildFlowStepLogPrintRows,
|
buildFlowStepLogSearchParams,
|
createFlowStepLogSearchState,
|
getFlowStepLogPaginationKey,
|
getFlowStepLogReportColumns,
|
normalizeFlowStepLogRow,
|
FLOW_STEP_LOG_REPORT_TITLE
|
} from './flowStepLogPage.helpers'
|
import { createFlowStepLogTableColumns } from './flowStepLogTable.columns'
|
import FlowStepLogDetailDrawer from './modules/flow-step-log-detail-drawer.vue'
|
|
defineOptions({ name: 'FlowStepLog' })
|
|
const userStore = useUserStore()
|
const searchForm = ref(createFlowStepLogSearchState())
|
const detailDrawerVisible = ref(false)
|
const detailData = ref({})
|
const selectedRows = ref([])
|
const reportTitle = FLOW_STEP_LOG_REPORT_TITLE
|
const reportQueryParams = computed(() => buildFlowStepLogSearchParams(searchForm.value))
|
const reportColumns = getFlowStepLogReportColumns()
|
|
const searchItems = computed(() => [
|
{
|
label: '关键字',
|
key: 'condition',
|
type: 'input',
|
props: {
|
clearable: true,
|
placeholder: '请输入流程实例ID/步骤实例ID/日志内容'
|
}
|
},
|
{
|
label: '流程实例ID',
|
key: 'flowInstanceId',
|
type: 'inputNumber',
|
props: {
|
clearable: true,
|
controlsPosition: 'right',
|
placeholder: '请输入流程实例ID'
|
}
|
},
|
{
|
label: '步骤实例ID',
|
key: 'stepInstanceId',
|
type: 'inputNumber',
|
props: {
|
clearable: true,
|
controlsPosition: 'right',
|
placeholder: '请输入步骤实例ID'
|
}
|
},
|
{
|
label: '日志类型',
|
key: 'logType',
|
type: 'input',
|
props: {
|
clearable: true,
|
placeholder: '请输入日志类型'
|
}
|
},
|
{
|
label: '日志级别',
|
key: 'logLevel',
|
type: 'input',
|
props: {
|
clearable: true,
|
placeholder: '请输入日志级别'
|
}
|
},
|
{
|
label: '开始日期',
|
key: 'timeStart',
|
type: 'date',
|
props: {
|
clearable: true,
|
valueFormat: 'YYYY-MM-DD',
|
type: 'date'
|
}
|
},
|
{
|
label: '结束日期',
|
key: 'timeEnd',
|
type: 'date',
|
props: {
|
clearable: true,
|
valueFormat: 'YYYY-MM-DD',
|
type: 'date'
|
}
|
}
|
])
|
|
function openDetail(row) {
|
detailDrawerVisible.value = true
|
loadDetail(row.id, row)
|
}
|
|
const {
|
columns,
|
columnChecks,
|
data,
|
loading,
|
pagination,
|
getData,
|
replaceSearchParams,
|
resetSearchParams,
|
handleSizeChange,
|
handleCurrentChange,
|
refreshData
|
} = useTable({
|
core: {
|
apiFn: fetchFlowStepLogPage,
|
apiParams: buildFlowStepLogPageQueryParams(searchForm.value),
|
paginationKey: getFlowStepLogPaginationKey(),
|
columnsFactory: () => createFlowStepLogTableColumns({ handleView: openDetail })
|
},
|
transform: {
|
dataTransformer: (records) =>
|
Array.isArray(records) ? records.map((item) => normalizeFlowStepLogRow(item)) : []
|
}
|
})
|
|
const resolvePrintRecords = async (payload) => {
|
if (Array.isArray(payload?.ids) && payload.ids.length > 0) {
|
return defaultResponseAdapter(await fetchGetFlowStepLogMany(payload.ids)).records
|
}
|
return defaultResponseAdapter(
|
await fetchFlowStepLogPage({
|
...reportQueryParams.value,
|
current: 1,
|
pageSize: Number(pagination.total) > 0 ? Number(pagination.total) : 20
|
})
|
).records
|
}
|
|
const {
|
previewVisible,
|
previewRows,
|
previewMeta,
|
handlePreviewVisibleChange,
|
handleExport,
|
handlePrint
|
} = usePrintExportPage({
|
downloadFileName: 'flow-step-log.xlsx',
|
requestExport: (payload) =>
|
fetchExportFlowStepLogReport(payload, {
|
headers: {
|
Authorization: userStore.accessToken || ''
|
}
|
}),
|
resolvePrintRecords,
|
buildPreviewRows: (records) => buildFlowStepLogPrintRows(records),
|
buildPreviewMeta: (rows) => ({
|
reportTitle,
|
reportDate: new Date().toLocaleDateString('zh-CN'),
|
printedAt: new Date().toLocaleString('zh-CN', { hour12: false }),
|
operator: userStore.getUserInfo?.name || userStore.getUserInfo?.username || '',
|
count: rows.length
|
})
|
})
|
|
async function loadDetail(id, fallback) {
|
const detail = await fetchGetFlowStepLogDetail(id)
|
detailData.value = normalizeFlowStepLogRow({
|
...fallback,
|
...detail
|
})
|
}
|
|
function handleSelectionChange(rows) {
|
selectedRows.value = Array.isArray(rows) ? rows : []
|
}
|
|
function handleSearch(params) {
|
replaceSearchParams(buildFlowStepLogSearchParams(params))
|
getData()
|
}
|
|
function handleReset() {
|
Object.assign(searchForm.value, createFlowStepLogSearchState())
|
resetSearchParams()
|
}
|
</script>
|