<template>
  <BasicModal
    v-bind="$attrs"
    @register="registerModal"
    title="文件详情"
    width="1200px"
    :showOkBtn="false"
  >
    <el-divider content-position="left">{{ taskName }}</el-divider>
    <div>
      <BasicForm @register="registerMoneyForm" v-if="taskName == '联合技术审查'" />
      <BasicForm @register="registerApprovalMoneyForm" v-if="taskName == '立项审批'" />
      <BasicForm @register="registerContractMoneyForm" v-if="taskName == '合同签订'" />
      <el-divider content-position="left">项目计划资料详情</el-divider>
      <PlanFileDetail :planinfoid="planinfoid" :stage="1" :key="planFileDetailkey"/>
      <el-divider content-position="left" v-if="taskName != '联合技术审查'"
        >项目计划审批文件列表</el-divider
      >
      <PlanFileDetail :planinfoid="planinfoid" :stage="2" v-if="taskName != '联合技术审查'" />
      <div v-if="isfinish == 1">
        <ApprovalDetails :projectid="planinfoid" :stage="processName" />
      </div>
    </div>
  </BasicModal>
</template>
<script lang="ts" name="Detailpage" setup>
  import { ref, onMounted } from 'vue';
  import { BasicModal, useModalInner } from '@/components/Modal';
  import { getProcessName } from './projectPlan.api';
  import ApprovalDetails from '../../ProcessApprovalSubPage/component/ApprovalDetails.vue';
  import PlanFileDetail from '@/views/ProcessApprovalSubPage/component/PlanFileDetail.vue';
  import { EstimateAmountFormSchemas } from '@/views/projectLib/projectPlan/projectPlan.data';
  import { queryProjectInfoById } from '@/views/projectLib/projectInfo/projectInfo.api';

  import { useForm, BasicForm } from '@/components/Form';
  const [registerMoneyForm, { setFieldsValue: setMoneyFieldsValue }] = useForm({
    //注册表单列
    schemas: EstimateAmountFormSchemas,
    showActionButtonGroup: false,
    //回车提交
    // autoSubmitOnEnter: true,
    // //不显示重置按钮
    // showResetButton: false,
    //自定义提交按钮文本和图标
    // submitButtonOptions: { text: '提交', preIcon: '' },
    //查询列占比 24代表一行 取值范围 0-24
    // actionColOptions: { span: 17 },
    disabled: true,
    // size: "small",
    // labelCol: { style: { width: '120px' } },
    wrapperCol: { style: { width: 'auto' } },
  });
  import { getProjectinfoMoneyInfo } from '@/views/projectLib/projectPlan/projectPlan.api';
  import {
    ApprovalMoneyFormSchemas,
    ContractMoneyFormSchemas,
  } from '@/views/projectLib/projectPlan/projectPlan.data';
  const [registerApprovalMoneyForm, { setFieldsValue: setApprovalMoneyFieldsValue }] = useForm({
    //注册表单列
    schemas: ApprovalMoneyFormSchemas,
    showActionButtonGroup: false,
    //回车提交
    // autoSubmitOnEnter: true,
    // //不显示重置按钮
    // showResetButton: false,
    //自定义提交按钮文本和图标
    // submitButtonOptions: { text: '提交', preIcon: '' },
    //查询列占比 24代表一行 取值范围 0-24
    // actionColOptions: { span: 17 },
    // size: "small",
    // labelCol: { style: { width: '120px' } },
    disabled: true,
    wrapperCol: { style: { width: 'auto' } },
  });
  const [registerContractMoneyForm, { setFieldsValue: setContractMoneyFieldsValue }] = useForm({
    //注册表单列
    schemas: ContractMoneyFormSchemas,
    showActionButtonGroup: false,
    //回车提交
    // autoSubmitOnEnter: true,
    // //不显示重置按钮
    // showResetButton: false,
    //自定义提交按钮文本和图标
    // submitButtonOptions: { text: '提交', preIcon: '' },
    //查询列占比 24代表一行 取值范围 0-24
    // actionColOptions: { span: 17 },
    // size: "small",
    // labelCol: { style: { width: '120px' } },
    disabled: true,
    wrapperCol: { style: { width: 'auto' } },
  });
  const [registerModal, { closeModal }] = useModalInner(init);
  let processName = ref('');
  let planinfoid = ref();
  let taskName = ref();
  let isfinish = ref(0);
  let planFileDetailkey = ref(0);
  onMounted(async () => {
    // processName.value =await getProcessName(dataTo.planinfoid)
  });
  async function init(data) {
    processName.value = await getProcessName({ pid: data.planinfoid });
    planinfoid.value = data.planinfoid;
    taskName.value = data.taskName;
    isfinish.value = data.isfinish;
    planFileDetailkey.value+=1
    if (taskName.value == '立项审批') {
      let res = await getProjectinfoMoneyInfo({
        projectid: data.projectid,
      });
      setApprovalMoneyFieldsValue(res);
    } else if (taskName.value == '合同签订') {
      let res = await getProjectinfoMoneyInfo({
        projectid: data.projectid,
      });
      setContractMoneyFieldsValue(res);
    } else if (taskName.value == '联合技术审查') {
      let param: any = {
        projectid: data.projectid,
      };
      let res = await queryProjectInfoById(param);
      setMoneyFieldsValue(res);
    }
  }
</script>
<style></style>
