<template>
    <HcTable ui="no-border" is-new :index-style="{ width: 60 }" :column="tableColumn" :datas="tableData" :loading="tableLoading">
        <template #opinion="{ row }">
            <span class="text-blue text-hover" @click="opinionClick(row)">{{ row.opinion }}</span>
        </template>
    </HcTable>
</template>

<script setup>
import { onMounted, ref, watch } from 'vue'
import { getArrValue } from 'js-fast-way'
import initialgApi from '~api/initial/initial'

//参数
const props = defineProps({
    projectId: {
        type: [String, Number],
        default: '',
    },
    contractId: {
        type: [String, Number],
        default: '',
    },
    currentId:{
        type: [String, Number],
        default: '',
    },

})

//事件
const emit = defineEmits(['opinionTap'])
//变量
const projectId = ref(props.projectId)
const contractId = ref(props.contractId)
const currentId = ref(props.currentId)

//渲染完成
onMounted(() => {
    getTableData()
})

//监听
watch(() => [
props.currentId,
], ([cuId]) => {
    currentId.value = cuId
})
//表格数据
const tableColumn = ref([
    { key:'expertName', name: '专家', width: 80 },
    { key:'unitName', name: '抽检所属', width: 100 },
    { key:'opinion', name: '抽检意见' },
])
const tableData = ref([])

const tableLoading = ref(false)
const getTableData = async () => {
        tableLoading.value = true
        const { error, code, data } = await initialgApi.getUserInspectInfo2({
            current:1,
            size:10000,
            projectId: projectId.value,
            conclusionId:currentId.value,
        })
        tableLoading.value = false
        if (!error && code === 200) {
            tableData.value = getArrValue(data['records'])
        
        } else {
            tableData.value = []
     
        }
    

}
//编辑
const editClick = (row) => {
    row.isEdit = true
}
//保存
const saveClick = (row) => {
    row.isEdit = false
}
//删除
const delClick = (row) => {

}

//查看意见
const opinionClick = (row) => {
    emit('opinionTap', row)
}
</script>

<style lang="scss" scoped>

</style>
