<template>
  <BasicModal v-bind="$attrs" @register="registerModal" width="75%" title="评审信息" @ok="handleSubmit" destroyOnClose>
    <!-- <Border title="修改后材料" v-model="isreview" v-show="data?.xghdcl">
      <label>修改后材料:</label> <a-button type="primary" @click="down(data?.xghdcl, '修改材料')"> 下载</a-button>
    </Border> -->
    <Border title="评审材料" v-model="isreview">
      <!-- 默认是可以编辑，disabled:true，代表该表单不能编辑 -->
      <!-- 风险管控效果评估 修复效果评估 风险管控与修复效果评估 都是S6,需要额外的参数判断-->
      <InvestigateMaterialUpload class="w-[98%] mx-auto" :data="data" :disabled="true" :dksdzt="dksdzt" v-if="isreview && data?.scjdbm === 'S2'" />
      <FxpgMaterialUpload class="w-[98%] mx-auto" :data="data" :disabled="true" :dksdzt="dksdzt" v-if="isreview && data?.scjdbm === 'S3'" />
      <FxgkMaterialUpload class="w-[98%] mx-auto" :data="data" :disabled="true" v-if="isreview && data?.scjdbm === 'S4'" />
      <GkpgMaterialUpload
        class="w-[98%] mx-auto"
        :data="data"
        :dksdzt="dksdzt"
        :disabled="true"
        v-if="isreview && data?.scjdbm === 'S6' && type === 'gkpg'"
      />
      <RepairMaterialUpload class="w-[98%] mx-auto" :data="data" :disabled="true" v-if="isreview && data?.scjdbm === 'S5'" />
      <XfpgMaterialUpload
        class="w-[98%] mx-auto"
        :data="data"
        :disabled="true"
        :dksdzt="dksdzt"
        v-if="isreview && data?.scjdbm === 'S6' && type === 'xfpg'"
      />
      <GkxfMaterialUpload class="w-[98%] mx-auto" :data="data" :disabled="true" v-if="isreview && data?.scjdbm === 'S10'" />
      <GkxfpgMaterialUpload
        class="w-[98%] mx-auto"
        :data="data"
        :disabled="true"
        :dksdzt="dksdzt"
        v-if="isreview && data?.scjdbm === 'S6' && type === 'gkxfpg'"
      />
    </Border>
    <!-- 专家组意见 -->
    <Border title="专家组意见" v-model="isexpert">
      <ViewZjz class="w-[98%] mx-auto" :data="data?.zjz || []" :dcjdPsfs="data?.dcjdPsfs" v-show="isexpert" />
    </Border>
    <!-- 参会人员信息 -->
    <Border title="参会人员信息" v-model="isparticipant">
      <ViewChry class="w-[98%] mx-auto" :data="data?.chry || []" :dcjdPsfs="data?.dcjdPsfs" v-show="isparticipant" />
    </Border>
    <!-- 归档材料信息 -->
    <!-- <Border title="归档材料信息" v-model="ismaterial"> -->
    <!-- <ViewGdcl class="w-[98%] mx-auto" :data="data?.gdcl || []" v-show="ismaterial" /> -->
    <!-- </Border> -->
  </BasicModal>
</template>

<script lang="ts" name="HistoryInfoModal" setup>
  import { ref } from 'vue';
  import { BasicModal, useModalInner } from '/@/components/Modal';
  import Border from '/@/components/customComponent/Border.vue'; // 公共组件
  import ViewZjz from '/@/views/dkgl/investigate/components/ViewZjz.vue'; // 公共组件
  import ViewChry from '/@/views/dkgl/investigate/components/ViewChry.vue'; // 公共组件

  import InvestigateMaterialUpload from '/@/views/dkgl/investigate/components/MaterialUpload.vue'; // 地块调查
  import FxpgMaterialUpload from '/@/views/dkgl/fxpg/components/MaterialUpload.vue'; // 风险评估
  import FxgkMaterialUpload from '/@/views/dkgl/fxgk/components/MaterialUpload.vue'; // 风险管控
  import GkpgMaterialUpload from '/@/views/dkgl/gkpg/components/MaterialUpload.vue'; // 风险管控效果评估
  import RepairMaterialUpload from '/@/views/dkgl/repair/components/MaterialUpload.vue'; // 修复
  import XfpgMaterialUpload from '/@/views/dkgl/xfpg/components/MaterialUpload.vue'; // 修复效果评估
  import GkxfMaterialUpload from '/@/views/dkgl/gkxf/components/MaterialUpload.vue'; // 风险管控与修复
  import GkxfpgMaterialUpload from '/@/views/dkgl/gkxfpg/components/MaterialUpload.vue'; // 风险管控与修复效果评估
  import { downloadFile } from '/@/api/common/api';

  const data = ref<any>({ wrdkid: '' });
  const type = ref('');
  // 评审信息
  const isreview = ref(true);
  const isexpert = ref(true);
  const isparticipant = ref(true);
  const dksdzt = ref();

  const [registerModal, { closeModal }] = useModalInner(async (d) => {
    data.value = await d.record;
    type.value = await d.type;
    dksdzt.value = d.dksdz || '';
  });
  async function handleSubmit() {
    //关闭弹窗
    closeModal();
  }
  function down(url, name) {
    let fileExtension = url.split('.').pop();
    downloadFile('/sys/common/static' + url, `${name}.${fileExtension}`);
  }
</script>
