<template>
  <baseTitle title="基础信息"></baseTitle>
  <fvForm :schema="schema" @getInstance="(e)=>baseForm = e" style="margin-left:27px"></fvForm>
  <baseTitle title="阶段变更详情" style="margin-top: -10px"></baseTitle>
  <div style="color: #606266;font-size: 14px;height:25px;"><span style="display:inline-block;width: 84px;text-align: right;margin-right: 14px">抄送人</span>{{copyName?copyName:'--'}}</div>
  <ApprovalDetail :formData="summaryData.formData" :data="summaryData" type="phase"
                  :processViewer="summaryProcessViewer" :loading="loading" :fileListShow="fileListShow"  v-model:value="auditOpinion"/>
  <opinion v-if="summaryData.taskId" :formData="summaryData.formData" :taskId="summaryData.taskId"  v-model:value="auditOpinion"></opinion>
</template>

<script setup lang="jsx">
import {ElNotification} from "element-plus";
import {useProcessStore} from '@/stores/processStore.js';
import {getPhaseDetail} from "@/api/project-manage";
import {computed, ref} from "vue";
import {getBaseInfoApi} from "@/components/steps/api";

const route = useRoute()
const summaryData = ref({})
const summaryProcessViewer = ref(true)
const processStore = useProcessStore()
const loading = ref(false)
const auditOpinion = ref('')
const copyName = ref('')
const fileListShow = ref('READ')
const schema = computed(() => {
  return [
    {
      label: '征集名称',
      prop: 'requirementName',
      colProps: {
        span: 12
      }
    },
    {
      label: '项目名称',
      prop: 'projectName',
      colProps: {
        span: 12
      }
    },
    {
      label: '征集描述',
      prop: 'collectExplain',
      colProps: {
        span: 12
      }
    },
    {
      label: '所属公司',
      prop: 'affiliatedCompany',
      colProps: {
        span: 12
      }
    },
  ]
})
const baseForm = ref()
const getBaseInfo = async () => {
  try {
    const {code, data} = await getBaseInfoApi(route.query.projectId)
    baseForm.value.setValues(data)
  } catch {
  }
}

getBaseInfo()
const getInfo = async () => {
  fileListShow.value = 'READ'
  const projectId = route.query.projectId
  summaryProcessViewer.value = false
  loading.value = true
  const {code, data, msg} = await getPhaseDetail(projectId)
  if (code === 1000) {
    summaryData.value = data;
    copyName.value= data.formData.userInfoList?.map(item=>item.name).join('，')
    loading.value = false
    processStore.setDesign(data)
    processStore.runningList.value = data.runningList;
    processStore.endList.value = data.endList;
    processStore.noTakeList.value = data.noTakeList;
    processStore.refuseList.value = data.refuseList;
    processStore.passList.value = data.passList;
    nextTick(() => {
      summaryProcessViewer.value = true
      if (data.formPermMap["fileList"]) {
        fileListShow.value = data.formPermMap["fileList"].perm
      }
    })
  } else {
    ElNotification({
      title: '提示',
      message: msg,
      type: 'error'
    })
    if (msg === '查询结果为空') {
      summaryData.value = []
    }
    loading.value = false
  }
}
getInfo()
</script>

<style scoped>

</style>
