<!-- 标准装置台账信息详情 技术指标修改记录 -->
<script name="StandardBookChangeRecord" lang="ts" setup>
import type { Ref } from 'vue'
import { onMounted, ref } from 'vue'
import dayjs from 'dayjs'
import { ElLoading, ElMessage } from 'element-plus'
import type { FormRules } from 'element-plus'
import type { IChangeRecord, IForm, ITechFiles } from '../book-interface'
import { getDictByCode } from '@/api/system/dict'
import type { TableColumn } from '@/components/NormalTable/table_interface'
import useUserStore from '@/store/modules/user'
import { getTechChangeList } from '@/api/equipment/standard/book'
import type { deptType, dictType } from '@/global'
import { getDeptTreeList } from '@/api/system/dept'
import { getUserList } from '@/api/system/user'
import showPhoto from '@/components/showPhoto/index.vue'
import { UploadFile } from '@/api/file'
import { toTreeList } from '@/utils/structure'
import { useCheckList } from '@/commonMethods/useCheckList'
import { useSetAllRowReadable } from '@/commonMethods/useSetAllRowReadable'
import { isNumber } from '@/utils/validate'
const props = defineProps({
  pageType: { // 页面类型 add新建 edit编辑 detail详情
    type: String,
    default: 'detail',
  },
  standardId: { // id
    type: String,
  },
})

// 查询条件
const listQuery = ref({
  standardId: props.standardId!,
  offset: 1,
  limit: 20,
})
const loadingTable = ref(false) // 表格loading
const user = useUserStore() // 用户信息
const list = ref<IChangeRecord[]>([]) // 表格数据
const total = ref()
const columns = ref<TableColumn[]>([ // 表头
  { text: '测量范围', value: 'measureRange', align: 'center' },
  { text: '不确定度或允许误差极限或准确度等级', value: 'uncertainty', align: 'center' },
  { text: '检定或校准项目', value: 'measureItem', align: 'center' },
  { text: '修改时间', value: 'updateTime', align: 'center' },
])

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

<template>
  <detail-block title="技术指标修改记录">
    <el-table
      v-loading="loadingTable"
      :data="list"
      border
      stripe
      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>
