Newer
Older
jh-business-system / src / views / certManage / components / printRecord.vue
<!-- 证书管理 打印记录 -->
<script name="taskMeasureCertificateChangeRecord" lang="ts" setup>
import type { Ref } from 'vue'
import { onMounted, ref } from 'vue'
import dayjs from 'dayjs'
import type { TableColumn } from '@/components/NormalTable/table_interface'
import useUserStore from '@/store/modules/user'
import { getPrintRecordList } from '@/api/business/certManage/cert'

const props = defineProps({
  pageType: { // 页面类型 add新建 edit编辑 detail详情
    type: String,
    default: 'detail',
  },
})
const listQuery = ref({
  id: '',
  limit: 20,
  offset: 1,
})
const user = useUserStore() // 用户信息
const loadingTable = ref(false)
const list = ref([]) // 表格数据
const total = ref(0) // 表格数据
const infoId = ref('') // id
const columns = ref<TableColumn[]>([ // 表头
  { text: '打印人', value: 'userName', align: 'center' },
  { text: '打印时间', value: 'updateTime', align: 'center' },
])
// -----------------------------------------路由参数--------------------------------------------
// 从路由中获取页面类型参数
const $route = useRoute()
if ($route.params) {
  if ($route.params.id) {
    infoId.value = $route.params.id as string
  }
}
// ---------------------------------------------------------------------------------------------

// 数据查询
function fetchData(isNowPage = false) {
  loadingTable.value = true
  if (!isNowPage) {
    // 是否显示当前页,否则跳转第一页
    listQuery.value.offset = 1
  }
  listQuery.value.id = infoId.value
  getPrintRecordList(listQuery.value).then((response) => {
    list.value = response.data
    total.value = parseInt(response.data.total)
    loadingTable.value = false
  })
}
// -------------------------------------------钩子------------------------------------------------
onMounted(() => {
  fetchData()
})
</script>

<template>
  <detail-block title="打印记录">
    <el-table
      v-loading="loadingTable"
      :data="list"
      border
      style="width: 100%;"
    >
      <el-table-column align="center" label="序号" width="80" type="index" />
      <el-table-column
        v-for="item in columns"
        :key="item.value"
        :prop="item.value"
        :label="item.text"
        :width="item.width"
        align="center"
      />
    </el-table>
  </detail-block>
</template>