<script name="biddingRegistration" setup>
import Accessory from '@/components/accessory/index.vue'
import { ref, onMounted } from 'vue'
import NoData from '@/components/noData/index.vue'
import { dictionary } from '@/http/apis/projectCollection/projectCollectionEnter'

const props = defineProps({
  detailData: Object
})
const data = ref(),
  getInfo = async () => {
    data.value = props.detailData?.purchases
  },
  dictionaryList = ref([])
onMounted(async () => {
  dictionaryList.value = (await dictionary()).data
  getInfo()
})
</script>

<template>
  <template v-if="data?.length">
    <el-descriptions
      v-for="(item,index) in data"
      :key="index"
      :column="2"
      border
      :title="`标段${index+1}`"
      class="mb-16"
    >
      <el-descriptions-item label="标段名称">
        {{ item.bidName||'-' }}
      </el-descriptions-item>
      <el-descriptions-item label="供应商">
        {{ item.supplier||'-' }}
      </el-descriptions-item>
      <el-descriptions-item label="供应商统一社会信用代码">
        {{ item.supplierSocialCreditCode||'-' }}
      </el-descriptions-item>
      <el-descriptions-item label="供应商联系人">
        {{ item.supplierContact||'-' }}
      </el-descriptions-item>
      <el-descriptions-item label="供应商联系方式">
        {{ item.supplierContactInfo||'-' }}
      </el-descriptions-item>
      <el-descriptions-item label="采购方式">
        {{ dictionaryList?.filter(i => i.type === 'PURCHASE_METHOD').find(i=>i.value===item.purchaseMethod)?.label ||'-' }}
      </el-descriptions-item>
      <el-descriptions-item label="成交金额（万元）">
        {{ item.transactionAmount||'-' }}
      </el-descriptions-item>
      <el-descriptions-item label="成交时间">
        {{ item.transactionTime||'-' }}
      </el-descriptions-item>
      <el-descriptions-item label="采购代理机构">
        {{ item.agency||'-' }}
      </el-descriptions-item>
      <el-descriptions-item label="采购代理机构统一社会信用代码">
        {{ item.purchaseSocialCreditCode||'-' }}
      </el-descriptions-item>
      <el-descriptions-item label="预算执行确认书编号">
        {{ item.budgetExecConfirmNo||'-' }}
      </el-descriptions-item>
      <el-descriptions-item label="投标文件" :span="2">
        <p v-for="(file,key) in item.biddingDoc&&JSON.parse(item.biddingDoc)" :key="key" class="mb-4">
          <accessory :file-name="file.originalFileName" :file-id="file.id" />
        </p>
      </el-descriptions-item>
      <el-descriptions-item label="招标文件" :span="2">
        <p v-for="(file,key) in item.bidDoc&&JSON.parse(item.bidDoc)" :key="key" class="mb-4">
          <accessory :file-name="file.originalFileName" :file-id="file.id" />
        </p>
      </el-descriptions-item>
      <el-descriptions-item label="中标通知书" :span="2">
        <p v-for="(file,key) in item.acceptanceLetter&&JSON.parse(item.acceptanceLetter)" :key="key" class="mb-4">
          <accessory :file-name="file.originalFileName" :file-id="file.id" />
        </p>
      </el-descriptions-item>
    </el-descriptions>
  </template>
  <no-data v-else />
</template>
