<template>
  <!-- <BasicDrawer v-bind="$attrs" @register="registerDrawer" title="资料填报"  width="80%" @ok="handleSubmit" destroyOnClose> -->
  <div class="bg-[#fff]">
    <a-page-header style="border: 1px solid rgb(235, 237, 240)" @back="router.go(-1)">
      <template #backIcon>
        <div><a-button type="primary">返回</a-button></div>
      </template>
      <template #title>
        <div></div>
      </template>
    </a-page-header>
    <a-collapse v-model:activeKey="activeKey" :bordered="false">
      <a-collapse-panel key="1" header="地块信息" v-if="data.wrdkjbxxb">
        <DkTable :data="data.wrdkjbxxb" />
      </a-collapse-panel>
      <a-collapse-panel key="2" v-if="data?.wrdkjbxxb?.dclx == 3 || data?.wrdkjbxxb?.dclx == 1" header="初步调查报告基本信息">
        <suBainTable :data="data.cbdc" />
      </a-collapse-panel>

      <a-collapse-panel header="初步调查报告编制单位基本信息" v-if="data?.wrdkjbxxb?.dclx == 3 || data?.wrdkjbxxb?.dclx == 1"
        v-for="(item, index) in cbdcBzdw" :key="'6-' + index">
        <unitMessageTable :data="item" />
      </a-collapse-panel>
      <a-collapse-panel header="初步调查检测单位信息" v-if="data?.wrdkjbxxb?.dclx == 3 || data?.wrdkjbxxb?.dclx == 1"
        v-for="(item, index) in cbjcdw" :key="'7-' + index">
        <unitMessageTable :data="item" />
      </a-collapse-panel>
      <a-collapse-panel key="3" v-if="data?.wrdkjbxxb?.dclx == 3 || data?.wrdkjbxxb?.dclx == 2" header="详细调查报告基本信息">
        <suBainTable :data="data.xxdc" :text-lable="'详细'"/>
      </a-collapse-panel>
      <a-collapse-panel header="详细调查报告编制单位基本信息" v-if="data?.wrdkjbxxb?.dclx == 3 || data?.wrdkjbxxb?.dclx == 2"
        v-for="(item, index) in xxdcBzdw" :key="'8-' + index">
        <unitMessageTable :data="item" />
      </a-collapse-panel>
      <a-collapse-panel header="详细调查检测单位信息" v-if="data?.wrdkjbxxb?.dclx == 3 || data?.wrdkjbxxb?.dclx == 2"
        v-for="(item, index) in xxjcdw" :key="'9-' + index">
        <unitMessageTable :labelFirst="'详细'" :data="item" />
      </a-collapse-panel>
      <a-collapse-panel header="土壤环境质量信息" key="10" v-if="data.trhjzlxx">
        <soilMessageTable :data="data.trhjzlxx" />
      </a-collapse-panel>
      <a-collapse-panel header="敏感受体信息" key="11" v-if="data.mgst">
        <sensitivityTable :data="data.mgst" />
      </a-collapse-panel>
      <!-- <a-collapse-panel header="修复方案基本信息" key="10">
        <repairBainTable />
      </a-collapse-panel> -->
      <!-- <a-collapse-panel header="技术路线" key="11">
        <technicalLines />
      </a-collapse-panel> -->
      <!-- <a-collapse-panel key="12" header="修复方案编制单位基本信息">
              <suBainTable />
            </a-collapse-panel> -->
      <!-- <a-collapse-panel key="13" header="修复方案编制单位基本信息">
            </a-collapse-panel> -->
      <a-collapse-panel key="13" header="初步调查文件上传" v-if="data?.wrdkjbxxb?.dclx == 3 || data?.wrdkjbxxb?.dclx == 1 || data.cbdc">
        <CdUpload :data="data.cbdc" :objec="[{ name: '公式照片' }, { name: '初步调查报告' }]" />
      </a-collapse-panel>
      <a-collapse-panel key="14" header="详细调查文件上传" v-if="data?.wrdkjbxxb?.dclx == 3 || data?.wrdkjbxxb?.dclx == 2 || data.xxdc">
        <CdUpload labelFirst="详细调查" :objec="[{ name: '公式照片' }, { name: '详细调查报告' }]" :data="data.xxdc" />
      </a-collapse-panel>
      <a-collapse-panel header="填报进度" key="15">
        <fillProgress :List="data.lzjd" />
      </a-collapse-panel>
    </a-collapse>
  </div>
  <!-- </BasicDrawer> -->
</template>
<script lang="ts" setup>
import { ref, watch, } from 'vue';
// import { BasicDrawer, useDrawerInner } from '/src/components/Drawer';
// import DkTable from "/src/components/customComponent/DkTable.vue";
import DkTable from "/@/components/customComponent/DkTable.vue"
import suBainTable from '/@/components/customComponent/suBainTable.vue';
import unitMessageTable from '/@/components/customComponent/unitMessageTable.vue'; // 单位检测信息请传不同的obj
import soilMessageTable from '/@/components/customComponent/soilMessageTable.vue'
import sensitivityTable from '/@/components/customComponent/sensitivityTable.vue'
import CdUpload from '/@/components/customComponent/CdUpload.vue';
import fillProgress from '/@/components/customComponent/fillProgress.vue'
import { useRouter } from 'vue-router';
import { plotDetails, } from '/@/api/common/api'
let router = useRouter();// 注册路由
const data = ref<any>({})
const param = ref<any>(router.currentRoute.value.query)
// const [registerDrawer, { }] = useDrawerInner();

let cbdcBzdw = ref([
  { id: null },
]);
let xxdcBzdw = ref([
  { id: null },
])
let cbjcdw = ref([
  { id: null },
]);
let xxjcdw = ref([
  { id: null },
]);
//手风琴
const activeKey = ref(['1', '2', '3', '10', '11', '13', '14', '15']);
watch(activeKey, val => {
  console.log(val);
});
function init() {
  getInfor()
  // getRecord()
}
init()
// 获取地块基本信息
async function getInfor() {
  data.value = await plotDetails({
    wrdkid: param.value.wrdkid,
    scjdbm: 'S2'
  })
  // 判断是详细调查的还是初步调查的
  cbdcBzdw.value = []
  xxdcBzdw.value = []
  data.value.bzdw.forEach(item => {
    if (item.scjdbm == 'S1') {
      cbdcBzdw.value.push(item)
    } else if (item.scjdbm == 'S2') {
      xxdcBzdw.value.push(item)
    }
  })
  cbjcdw.value = []
  xxjcdw.value = []
  data.value.jcdw.forEach(item => {
    if (item.scjdbm == 'S1') {
      cbjcdw.value.push(item)
    } else if (item.scjdbm == 'S2') {
      xxjcdw.value.push(item)
    }
  })
    //  默认展开所有面板
  const prefixes = ['6-', '7-', '8-', '9-'];
  const arrays = [cbdcBzdw.value, cbjcdw.value, xxdcBzdw.value, xxjcdw.value];

  for (let i = 0; i < arrays.length; i++) {
    arrays[i].forEach((el, index) => {
      activeKey.value.push(prefixes[i] + index);
    });
  }
}
</script>
<style scoped>
:deep(.ant-collapse-borderless) {
  width: 100%;
}
</style>
  