<template>
  <baseTitle title="基础信息"></baseTitle>
  <fvForm :schema="schema" @getInstance="(e)=>baseForm = e"></fvForm>
  <fvSearchForm :searchConfig="searchConfig" @search="search"></fvSearchForm>
  <fvTable ref="tableIns" :tableConfig="tableConfig">
    <template #empty>
      <el-empty description="暂无数据"/>
    </template>
  </fvTable>
</template>

<script setup lang="jsx">
import {computed, ref} from "vue";
import {getBaseInfoApi} from "@/components/steps/api";

const route = useRoute()
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 searchConfig = reactive([
  {
    label: '项目人员',
    prop: 'researchPersonnel',
    component: 'el-input',
    props: {
      placeholder: '请输入项目人员查询'
    }
  },
  {
    label: '时间',
    prop: 'time',
    component: 'el-date-picker',
    props: {
      type:'month',
      placeholder: '请选择月份',
      clearable: true,
      format: 'YYYY-MM',
      valueFormat: 'YYYY-MM-DD HH:mm:ss',
    }
  }
])
const tableIns = ref()
const tableConfig = reactive({
  columns: [
    {
      prop: 'name',
      type: 'index',
      label: '序号',
      align: 'center',
      width:'80'
    },
    {
      prop: 'time',
      label: '时间',
      align: 'center'
    },
    {
      prop: 'researchPersonnel',
      label: '研发人员',
      align: 'center'
    },
    {
      prop: 'wagesPayable',
      label: '应发工资',
      align: 'center'
    },
    {
      prop: 'performance',
      label: '绩效',
      align: 'center'
    },
    {
      prop: 'reserveFund',
      label: '公积金',
      align: 'center'
    },
    {
      prop: 'socialSecurity',
      label: '社保',
      align: 'center'
    },
    {
      prop: 'annuity',
      label: '年金',
      align: 'center'
    },
    {
      prop: 'workday',
      label: '工作日(天)',
      align: 'center'
    },
    {
      prop: 'researchDuration',
      label: '研发工时(天)',
      align: 'center'
    },
    {
      prop: 'subtotal',
      label: '小计',
      align: 'center'
    }
  ],
  api: '/workflow/mosr/project/implementation/allocation/info',
  params: {
    projectId: route.query.id
  }
})
const search = (val) => {
  tableConfig.params = {...val, projectId: route.query.id}
  tableIns.value.refresh()
}
// const researchOptions = ref([])
// const getResearchOptions = async () => {
//   const res = await getResearchUser()
//   researchOptions.value = res.data
// }
// const getResearchName=(id)=>{
//   if(!id)return;
//   let label=''
//   researchOptions.value.forEach(item=>{
//     if(item.value==id){
//       label=item.label
//     }
//   })
//   return label
// }
const getBaseInfo = async () => {
  try {
    const {code, data} = await getBaseInfoApi(route.query.id)
    baseForm.value.setValues(data)
  } catch {
  }
}

// getResearchOptions()
getBaseInfo()
</script>

<style scoped>

</style>
