<template>
  <ContentWrap>
    <el-descriptions :column="2" border>

        <el-descriptions-item label="名称" span="1">
          {{ detailData.name }}
        </el-descriptions-item>
        <el-descriptions-item label="跟踪编号" span="1">
          {{ detailData.trackingCode }}
        </el-descriptions-item>
        <el-descriptions-item label="项目编号" span="1">
          {{ detailData.code }}
        </el-descriptions-item>
        <el-descriptions-item label="类型" span="1">
          <dict-tag :type="DICT_TYPE.PROJECT_TYPE" :value="detailData.type" />
        </el-descriptions-item>
        <el-descriptions-item label="省份" span="1">
          {{ detailData.province }}
        </el-descriptions-item>
        <el-descriptions-item label="城市" span="1">
          {{ detailData.city }}
        </el-descriptions-item>
        <el-descriptions-item label="预计金额(万)" span="1">
          {{ detailData.contractAmount }}
        </el-descriptions-item>
        <el-descriptions-item label="客户公司" :span="1">
          {{ detailData.customerCompanyName }}
        </el-descriptions-item>
        <el-descriptions-item label="客户联系人" :span="1">
          {{ detailData.customerUser }}
        </el-descriptions-item>
        <el-descriptions-item label="客户电话" span="1">
          {{ detailData.customerPhone }}
        </el-descriptions-item>
        <el-descriptions-item label="出图公司" span="1">
          {{ detailData.drawingCompany }}
        </el-descriptions-item>
        <el-descriptions-item label="跟踪部门" span="1">
          {{ detailData.trackingDepName }}
        </el-descriptions-item>
        <el-descriptions-item label="项目经理" span="1">
          {{ detailData.projectManagerName }}
        </el-descriptions-item>
        <el-descriptions-item label="开始时间" span="1">
          {{ formatDate(detailData.startTime, 'YYYY-MM-DD') }}
        </el-descriptions-item>
        <el-descriptions-item label="跟踪情况" span="2">
          {{ detailData.situation }}
        </el-descriptions-item>
        <el-descriptions-item label="落地可能性" span="1">
          <dict-tag :type="DICT_TYPE.POSSIBILITY_OF_LANDING" :value="detailData.possibility" />
        </el-descriptions-item>
        <el-descriptions-item label="漏斗预期" span="1">
          {{ detailData.funnelExpectation }}
        </el-descriptions-item>
        <el-descriptions-item label="委托方式" span="1">
          <dict-tag :type="DICT_TYPE.ENTRUST_METHOD" :value="detailData.entrustMethod" />
        </el-descriptions-item>
        <el-descriptions-item label="是否落地" span="1">
          <dict-tag :type="DICT_TYPE.INFRA_BOOLEAN_STRING" :value="detailData.confirmation" />
        </el-descriptions-item>
<!--        <el-descriptions-item label="审批状态" span="1">-->
<!--          <dict-tag :type="DICT_TYPE.BPM_PROCESS_INSTANCE_STATUS" :value="detailData.processStatus" />-->
<!--        </el-descriptions-item>-->
        <el-descriptions-item label="落地时间" v-if="detailData.confirmation === '是' || detailData.confirmation === true" span="1">
          {{ formatDate(detailData.endTime, 'YYYY-MM-DD') }}
        </el-descriptions-item>
        <el-descriptions-item label="未落地原因" v-if="detailData.confirmation === '否' || detailData.confirmation === false" span="2">
          {{ detailData.reason }}
        </el-descriptions-item>
    </el-descriptions>
    <el-descriptions :column="1" border>
      <el-descriptions-item label="评审附件">
        <UploadFile v-model="detailData.reviewFileUrl" :disabled="true"/>
      </el-descriptions-item>

      <el-descriptions-item label="中标附件">
        <UploadFile v-model="detailData.winFileUrl" :disabled="true"/>
      </el-descriptions-item>
    </el-descriptions>
  </ContentWrap>
</template>
<script lang="ts" setup>
import { DICT_TYPE } from '@/utils/dict'
import { formatDate } from '@/utils/formatTime'
import { propTypes } from '@/utils/propTypes'
import {ProjectApi} from "@/api/pms/project";

defineOptions({ name: 'ProjectBpmDetail' })

const { query } = useRoute() // 查询参数

const props = defineProps({
  id: propTypes.number.def(undefined)
})
const detailLoading = ref(false) // 表单的加载中
const detailData = ref<any>({}) // 详情数据
const queryId = query.id as unknown as number // 从 URL 传递过来的 id 编号

/** 获得数据 */
const getInfo = async () => {
  detailLoading.value = true
  try {
    detailData.value = await ProjectApi.getProject(props.id || queryId)
  } finally {
    detailLoading.value = false
  }
}
defineExpose({ open: getInfo }) // 提供 open 方法，用于打开弹窗

/** 初始化 **/
onMounted(() => {
  getInfo()
})
</script>
