<template>
    <BasicModal v-bind="$attrs" @register="registerModal" destroyOnClose :title="title" :width="800" @ok="handleSubmit">
        <!--<BasicForm @register="registerForm"/>-->
        <PlanSelect :actinfo="actinfo"></PlanSelect>
    </BasicModal>
  </template>
  
  <script lang="ts" setup>
  import { computed, ref, toRaw, unref } from 'vue';
import { BasicModal, useModalInner } from '/@/components/Modal';
import PlanSelect from '/@/views/project/components/ProblemSelect.vue';

import { addPro } from '../StProjectExecTwo.api';
      // Emits声明
      const emit = defineEmits(['register','success']);
      const isUpdate = ref(true);
      const actinfo = ref({});
      const formModal = ref({});
      //表单赋值
      const [registerModal, {setModalProps, closeModal}] = useModalInner(async (data) => {
          //重置表单
          //await resetFields();
          setModalProps({confirmLoading: false,showCancelBtn:!!data?.showFooter,showOkBtn:!!data?.showFooter});
          isUpdate.value = !!data?.isUpdate;
          formModal.value = Object.assign(data.record)
      });
      //设置标题
      const title = computed(() => (!unref(isUpdate) ? '新增' : '编辑'));
      //表单提交事件
      async function handleSubmit(v) {
          try {
           
              setModalProps({confirmLoading: true});
              //提交表单
              console.log('formModal');
                console.log(formModal.value);
              console.log('actinfo');
                console.log(actinfo.value);
              formModal.value = Object.assign(actinfo.value,formModal.value);
                           console.log('formModal');
              console.log(formModal.value);
              await addPro(formModal.value, isUpdate.value);
              //关闭弹窗
              closeModal();
              emit('success');
          } finally {
              setModalProps({confirmLoading: false});
          }
      }
  </script>
  
  <style lang="less" scoped>
      /** 时间和数字输入框样式 */
    :deep(.ant-input-number){
          width: 100%
      }
  
      :deep(.ant-calendar-picker){
          width: 100%
      }
  </style>