<template>
  <ContentWrap title="" style="padding: 17px;">
    <el-descriptions>
      <el-descriptions-item label="记录编号">{{detailData.id}}</el-descriptions-item>
      <el-descriptions-item label="任务名称">{{detailData.taskName}}</el-descriptions-item>
      <el-descriptions-item label="任务类型">{{detailData.tagList}}</el-descriptions-item>
      <el-descriptions-item label="企业名称">{{detailData.enterpriseName}}</el-descriptions-item>
      <el-descriptions-item label="执法部门">{{detailData.department}}</el-descriptions-item>
      <el-descriptions-item label="执法人员">
        {{detailData.inspectName}}
        <el-tag type="primary">变更</el-tag>
      </el-descriptions-item>
    </el-descriptions>
  </ContentWrap>
  <ContentWrap title="">
    <el-table v-loading="loading" :data="list" :stripe="true" :show-overflow-tooltip="true">
      <!-- <el-table-column label="检查记录ID，主键" align="center" prop="id" /> -->
      
      <el-table-column label="执法人员" align="center" prop="inspectName" />
      <el-table-column label="协同执法" align="center" prop="cooperateWithName" />
      <el-table-column
        label="执法时间"
        align="center"
        prop="createTime"
        :formatter="dateFormatter"
        width="180px"
      />
      <el-table-column label="进度状态" align="center" prop="inspectionStatus">
        <template #default="scope">
        <dict-tag :type="DICT_TYPE.INSPECTIONS_STATUS" :value="scope.row.status"   />
      </template>
      </el-table-column>
      <el-table-column label="操作" align="center" min-width="120px">
        <template #default="scope">
          <el-button
            link
            v-if="scope.row.status > 1"
            type="primary"
            @click="openForm(scope.row.id)"
          >
            查看
          </el-button>
          
          <span  v-if="scope.row.status == 1">-</span>

        </template>

      </el-table-column>
    </el-table>
    <!-- 分页 -->
    <Pagination
      :total="total"
      v-model:page="queryParams.pageNo"
      v-model:limit="queryParams.pageSize"
      @pagination="getList"
    />
  </ContentWrap>
  <EnterpriseInspectionsForm ref="formRef" @success="getList" />
</template>

<script setup>

import { EnterpriseInspectionsApi } from '@/api/enterpriseinspections'
import { DICT_TYPE, getIntDictOptions, getStrDictOptions } from '@/utils/dict'
import EnterpriseInspectionsForm from './EnterpriseInspectionsForm.vue'


defineOptions({ name: 'EnterpriseInspections' })
import { ref } from 'vue'
const message = ref('Hello, Vue 3!')

const loading = ref(true) // 列表的加载中
const list = ref() // 列表的数据
const total = ref(0) // 列表的总页数
const queryParams = ref({
 inspectionsId: undefined
})
const queryFormRef = ref() 

const route = useRoute()

/** 添加/修改操作 */
const formRef = ref()
const openForm = (id) => {
  const type = 'create'
  formRef.value.open(type, id)
}


/** 查询列表 */
const getList = async () => {
  loading.value = true
  try {
    const data = await EnterpriseInspectionsApi.inspectionsLogList(queryParams.value)
    list.value = data
    total.value = data.total
  } finally {
    loading.value = false
  }
}

const detailData = ref({
    enterpriseName: undefined,
    taskName: undefined,
    tagList: undefined,
    department: undefined,
    inspectName: undefined,
    cooperateWithName: undefined,
    id: undefined
})

/** 初始化 **/
onMounted(() => {

    const data = JSON.parse(route.query.data)
    detailData.value = {
        enterpriseName: data.enterpriseName,
        taskName: data.taskName,
        tagList: data.tagList,
        department: data.department,
        inspectName: data.inspectName,
        cooperateWithName: data.cooperateWithName,
        id: data.id
    }
    
    queryParams.value.inspectionsId = data.id


  getList()
})

</script>

<style scoped></style>
