<template>
    <el-container>
        <el-header>
            <div class="left-panel">
                <el-button type="primary" @click="handleAdd">新增</el-button>
                <ExportBtn :getTableRef="() => $refs.table" :columns="exportCols" fileName="供应商审核台账" />
            </div>

        </el-header>
        <el-main class="nopadding">
            <scTable
            ref="table"
            :apiObj="API.pum.supplieraudit.list"
            row-key="id"
            stripe
            :query="query"
            @row-click="(row)=>{t_id=row.id;mode='show';drawerVisible=true;}"
            >
            <el-table-column label="供应商名称" prop="name" width="200" show-overflow-tooltip></el-table-column>
            <el-table-column label="审批状态" width="250" show-overflow-tooltip>
                <template #default="scope">
                                <el-tag :type="actStateEnum[scope.row.ticket_?.act_state]?.type">
                        {{ actStateEnum[scope.row.ticket_?.act_state]?.text }}
                    </el-tag>
            <el-tag type="info" effect="plain">{{ scope.row.ticket_?.state_.name }}</el-tag>

          </template>
            </el-table-column>
            <el-table-column label="物料名称" prop="material_name" width="200" show-overflow-tooltip></el-table-column>`
            <el-table-column label="物料类别" prop="material_cate" width="200" show-overflow-tooltip></el-table-column>
            <el-table-column label="调查表" prop="survery_form" width="100" show-overflow-tooltip>
                <template #default="scope">
                    <el-link v-if="scope.row.survery_form_" type="text" :href="scope.row.survery_form_.path" target="_blank" style="color:blue" @click.stop="">下载</el-link>
                </template>
            </el-table-column>
            <el-table-column label="营业执照" prop="business_license" width="100" show-overflow-tooltip>
                <template #default="scope">
                    <el-link v-if="scope.row.business_license_" type="text" :href="scope.row.business_license_.path" target="_blank" style="color:blue" @click.stop="">下载</el-link>
                </template>
            </el-table-column>
            <el-table-column label="质量证书" prop="quality_certificate" show-overflow-tooltip>
                <template #default="scope">
                    <el-link v-if="scope.row.quality_certificate_" type="text" :href="scope.row.quality_certificate_.path" target="_blank" style="color:blue" @click.stop="">下载</el-link>
                </template>
            </el-table-column>
            </scTable>
        </el-main>
    </el-container>
    <el-drawer title="新供应商审核" v-model="drawerVisible" :size="'80%'" destroy-on-close>
        <supplieraudit_form :mode="mode" :t_id="t_id"></supplieraudit_form>
    </el-drawer>
</template>
<script setup>
import { ref } from 'vue'
import API from '@/api'
import supplieraudit_form from './supplieraudit_form.vue'
import ExportBtn from '@/components/scExportBtn/index.vue'
import { actStateEnum, interveneTypeEnum } from "@/utils/enum.js";
const query = ref({});
const drawerVisible = ref(false);
const mode = ref('add');
const t_id = ref(null);
const handleAdd = () => {
    mode.value = 'add';
    drawerVisible.value = true;
}
const exportCols = [
  { header: "供应商名称", key: "name", wch: 20 },
  { header: "审批状态", key: "_act_state_text", wch: 10 },
  { header: "物料名称", key: "material_name", wch: 20 },
  { header: "物料类别", key: "material_cate", wch: 20 },
]
</script>