<template>
  <sd-webflow ref="webflow">
    <template v-slot:form="{ model, FlowData }">
      <sd-form-by-builder
        ref="builderform"
        :form-data="FlowData.processFormData"
        @changedClick="changebj"
      />
    </template>
  </sd-webflow>
</template>

<script>
import CpmService from '../../cpm-service'
import components from './_import-components/cpm-project-report-form-import'

export default {
  name: 'CpmProjectReportForm',
  metaInfo: {
    title: 'CpmProjectReportForm',
  },
  components,
  data() {
    return {
      projectId: '',
      flag: true,
    }
  },
  created() {
    // 初始化项目信息
    if (this.$route.query.extParams) {
      const ep = JSON.parse(this.$route.query.extParams)
      this.initData(ep.PROJECT_ID)
    }
  },
  methods: {
    // 初始化项目信息
    initData(projectId) {
      if (projectId) {
        // 获取项目信息
        CpmService.getProjectData(projectId).then((res) => {
          const title = res.data[0].title
          this.$refs.webflow.setFieldValue('PROJECT_NAME', title)
          const code = res.data[0].currentNumber
          this.$refs.webflow.setFieldValue('PROJECT_CODE', code)

           this.$refs.webflow.setFieldValue('REPORT_TITLE', title+'检查报告')
        })
      }
    },
    changebj() {
      console.log('---change')
    },
  },
}
</script>

<style module lang="scss">
@use '@/common/design' as *;
</style>
