<template>
  <!-- 列表 -->
  <ContentWrap>
    <el-table v-loading="loading" :data="list" :stripe="true" :show-overflow-tooltip="true">
      <el-table-column label="工序" align="center" prop="type">
      <template #default="scope">
          <dict-tag :type="DICT_TYPE.MES_ORG_TYPE" :value="scope.row.type" />
        </template>
      </el-table-column>  
      <el-table-column label="名称" align="center" prop="name" />
      <el-table-column label="单位" align="center" prop="unit" />
      <el-table-column label="上限值" align="center" prop="upperVal" />
      <el-table-column label="下限值" align="center" prop="lowerVal" />
      <el-table-column label="备注" align="center" prop="remark" />
    </el-table>
    <!-- 分页 -->
    <Pagination
      :total="total"
      v-model:page="queryParams.pageNo"
      v-model:limit="queryParams.pageSize"
      @pagination="getList"
    />
  </ContentWrap>

  <!-- 表单弹窗：添加/修改 -->
  <ZjProductForm ref="formRef" @success="getList" />
</template>

<script setup lang="ts">
import { dateFormatter } from '@/utils/formatTime'
import { ZjProductApi, ZjProductVO } from '@/api/mes/zjproduct'
import ZjProductForm from './ZjProductForm.vue'
import {DICT_TYPE} from '@/utils/dict'

/** 质量管理-质检参数 列表 */
defineOptions({ name: 'ZjProductPreList' })

const props = defineProps<{
  productId?: number // 产品id（主表的关联字段）
}>()

const message = useMessage() // 消息弹窗
const { t } = useI18n() // 国际化


const loading = ref(false) // 列表的加载中
const list = ref<ZjProductVO[]>([]) // 列表的数据
const total = ref(0) // 列表的总页数
const queryParams = reactive({
  pageNo: 1,
  pageSize: 10,
  type: undefined,
  name: undefined,
  unit: undefined,
  upperVal: undefined,
  lowerVal: undefined,
  remark: undefined,
  createTime: [],
  productId: undefined
})


/** 查询列表 */
const getList = async () => {
  loading.value = true
  try {
    list.value = await ZjProductApi.getZjProductByProductId(props.productId)
  } finally {
    loading.value = false
  }
}



/** 初始化 **/
onMounted(() => {
  getList()
})
</script>
