<script setup name="basicInfo">
import { onMounted, ref } from 'vue'
import { applicationList } from '@/http/apis/declareMange'
import { storeToRefs } from 'pinia'
import store from '@/store'

const userInfo = storeToRefs(store.userStore).userInfo,
  props = defineProps({
    detailData: {
      type: Object,
      default: () => {}
    }
  }),
  column = [
    {
      label: '序号',
      type: 'index',
      width: 60
    },
    {
      label: '关联IRS应用名称',
      prop: 'applicationName',
      key: 'applicationName'
    },
    {
      label: 'IRS应用编码',
      prop: 'applicationCode',
      key: 'applicationCode'
    },
    {
      label: '一本账重大应用名称',
      prop: 'baseAccountAppName',
      key: 'baseAccountAppName'
    },
    {
      label: '"领域大脑"一本账名称',
      prop: 'baseBrainName',
      key: 'baseBrainName'
    }
  ],
  data = ref([]),
  appList = ref([])
onMounted(async () => {
  const res = await applicationList({ areaCode: userInfo.value.regionCode })
  appList.value = res.data
  data.value = props?.detailData?.baseProjSysCode?.split('；')?.map((i, k) => {
    return {
      applicationCode: i,
      applicationName: props?.detailData?.baseProjSys?.split('；')[k] || '',
      baseAccountAppName: props?.detailData?.baseAccountAppName?.split('；')[k] || '',
      baseBrainName: props?.detailData?.baseBrainName?.split('；')[k] || ''
    }
  }) || []
})
</script>

<template>
  <el-descriptions :column="2" border>
    <el-descriptions-item label="关联IRS应用名称">
      <table-list
        :pagination="false"
        style="width: 100%"
        :column="column"
        :data="data"
        :empty-temp="false"
      />
    </el-descriptions-item>
  </el-descriptions>
</template>
