<template>
    <global-page title="品质跟踪闭环要求详情">
        <global-table :columns="columns" :data="details?.qualityTraceList">
            <template #index="{ index }">
                {{ index + 1 }}
            </template>
            <template #unit="{ row }">
                {{ getCompany(row.unit) }}
            </template>
            <template #endTime="{ row }">
                {{ timeStampFormat(row.endTime) }}
            </template>
        </global-table>
    </global-page>
</template>

<script setup>
import { ref } from 'vue'
import { storeToRefs } from 'pinia'
import { timeStampFormat } from 'mocp/utils/tool'
import useQualityAnalysisStore from 'mocp/store/qualityAnalysis'

const qualityAnalysisStore = useQualityAnalysisStore()
const { details } = storeToRefs(qualityAnalysisStore)
const columns = ref([
    { title: '序号', dataIndex: 'index', width: 60 },
    { title: '责任单位', dataIndex: 'unit' },
    { title: '事件类型', dataIndex: 'eventType' },
    { title: '反馈期限', dataIndex: 'callbackLimit' }
])
const getCompany = (company) => {
    return company
        .split(',')
        .map((v) => {
            return qualityAnalysisStore.getEnetRepeatOrg(v) || qualityAnalysisStore.getEnetOrg(v)
        })
        .join('，')
}
</script>
<style lang="scss" scoped></style>
