<template>
  <baseTitle title="需求上报"></baseTitle>
  <fvForm :schema="schame" @getInstance="getInstance"></fvForm>
  <div class="oper-page-btn">
      <el-button type="primary" @click="staging">存为草稿</el-button>
      <el-button type="primary" @click="handleSubmit">发布</el-button>
    </div>
</template>

<script setup lang="jsx">
import fvSelect from '@/fvcomponents/fvSelect/index.vue'
import {markRaw} from 'vue';
import FileUpload from './components/FileUpload.vue';
import {requirementReported} from "./api";
import {ElNotification} from "element-plus";
import {useTagsView} from '@/stores/tagsview.js'

const router = useRouter()
const tagsViewStore = useTagsView()
const localData = reactive({
  form: null
})

const schame = computed(()=>{
  return [
    {
      label: '名称',
      prop: 'projectName',
      component: 'el-input',
      props: {},
      colProps: {
        span: 12
      }
    },
    {
      label: '专项资金',
      prop: 'projectType',
      component: markRaw(fvSelect),
      props: {},
      colProps: {
        span: 12
      }
    },
    {
      label: '开始时间',
      prop: 'startTime',
      component: 'el-date-picker',
      props: {},
      colProps: {
        span: 12
      }
    },
    {
      label: '所属公司',
      prop: 'companyName',
      component: 'el-input',
      props: {},
      colProps: {
        span: 12
      }
    },
    {
      label: '项目类型',
      prop: 'projectType',
      component: markRaw(fvSelect),
      props: {},
      colProps: {
        span: 12
      }
    },
    {
      label: '结束时间',
      prop: 'endTime',
      component: 'el-date-picker',
      props: {},
      colProps: {
        span: 12
      }
    },
    {
      label: '出资类型',
      prop: 'investmentType',
      component: markRaw(fvSelect),
      props: {},
      colProps: {
        span: 12
      }
    },
    {
      label: '项目影响',
      prop: 'projectImpact',
      component: markRaw(fvSelect),
      props: {},
      colProps: {
        span: 12
      }
    },
    {
      label: '所属业务板块',
      prop: 'businessSegment',
      component: markRaw(fvSelect),
      props: {},
      colProps: {
        span: 12
      }
    },
    {
      label: '预期成果形式',
      prop: 'resultForm',
      component: markRaw(fvSelect),
      props: {},
      colProps: {
        span: 12
      }
    },
    {
      label: '预期技术标准制定',
      prop: 'technicalStandard',
      component: markRaw(fvSelect),
      props: {},
      colProps: {
        span: 12
      }
    },
    {
      label: '产学研联合',
      prop: 'industryUniversityResearch',
      component: markRaw(fvSelect),
      props: {},
      colProps: {
        span: 12
      }
    },
    {
      label: '开展政府申报',
      prop: 'governmentDeclaration',
      component: markRaw(fvSelect),
      props: {},
      colProps: {
        span: 12
      }
    },
    {
      label: '知识产权状况',
      prop: 'intellectualProperty',
      component: markRaw(fvSelect),
      props: {},
      colProps: {
        span: 12
      }
    },

    {
      label: '发明专利',
      prop: 'inventionPatent',
      component: 'el-input',
      props: {},
      colProps: {
        span: 6
      }
    },
    {
      label: '实用性新型专利',
      prop: 'newPatent',
      component: 'el-input',
      props: {},
      colProps: {
        span: 6
      }
    },
    {
      label: '软件著作权',
      prop: 'softwareCopyright',
      component: 'el-input',
      props: {},
      colProps: {
        span: 6
      }
    },
    {
      label: '著作权',
      prop: 'copyright',
      component: 'el-input',
      props: {},
      colProps: {
        span: 6
      }
    },
    {
      label: '其他',
      prop: 'other',
      component: 'el-input',
      props: {},
      colProps: {
        span: 6
      }
    }, {
      label: '经济概算',
      prop: 'economicEstimate',
      component: 'el-input',
      props: {},
      colProps: {
        span: 6
      }
    },{
      label: '申请公司总部科技创新专项资金',
      prop: 'specialFundAmount',
      component: 'el-input',
      props: {},
      colProps: {
        span: 6
      }
    },


    {
      label: '现有业务描述',
      prop: 'serviceDescription',
      component: 'el-input',
      props: {
        type: 'textarea'
      },
      colProps: {
        span: 24
      }
    },
    {
      label: '研发项目关键内容描述',
      prop: 'contentDescription',
      component: 'el-input',
      props: {
        type: 'textarea'
      },
      colProps: {
        span: 24
      }
    },
    {
      label: '',
      prop: 'fileList',
      component: markRaw(FileUpload),
      props: {
        url: '',
        tip: '上传txt文件'
      },
      colProps: {
        span: 24
      }
    }
  ]
})

const getInstance = (e) => {
  localData.form = e
}

const handleSubmit = async () => {
  // let params={
  //   localData.form.getValues(),
  //   files:[]
  // }
  let res = await requirementReported(localData.form.getValues())
  ElNotification({
    title: '提示',
    message: res.msg,
    type: res.code === 1000 ? 'success' : 'error'
  })
  if (res.code === 1000) {
    tagsViewStore.delVisitedViews(router.currentRoute.value.path)
    await router.push({
      name: 'Summary'
    })
  }
}

const staging = async () => {}
</script>
