<template>
  <sd-webflow
    ref="webflow"
    @afterDispatch="afterDispatch"
    @saveproject="save"
    @sdFormReady="initDatap"
    @actionBtnClick="actionBtnClick"
  >
    <template v-slot:form="{ model, FlowData }">
      <sd-form-by-builder ref="builderform" :form-data="FlowData.processFormData" />
    </template>
  </sd-webflow>
</template>

<script>
import LawService from '../../law-service'
import CaseMixins from '../case-mixins.js'
import components from './_import-components/case-progress-sshf-form-import'

export default {
  name: 'CaseProgressSshfForm',
  metaInfo: {
    title: '案件进展-诉讼恢复',
  },
  components,
  mixins: [CaseMixins],
  data() {
    return {}
  },
  created() {
    this.type = 'progress'
  },
  mounted() {
    this.type = 'progress'
  },
  methods: {
    initDatap() {
      if (this.create) {
        this.initData()

        // 获取案件信息
        LawService.getBeanByFormId(
          this.$route.query.id,
          'onl:d0bb8202233c48f0b5148776754461e1'
        ).then((res) => {
          const obj = res.data.pageFormData.pageFieldInfos
          obj.forEach((item) => {
            if (item.name === 'REPORT_USER_OPT') {
              var userObj = JSON.parse(item.value)
              this.$refs.webflow.setFieldValue('APPLY_USER_NAME', userObj)
            }
            if (item.name === 'REPORT_USER_ID') {
              this.$refs.webflow.setFieldValue('APPLY_USER_ID', item.value)
            }
            if (item.name === 'REPORT_USER_CODE') {
              this.$refs.webflow.setFieldValue('APPLY_USER_CODE', item.value)
            }
          })
        })
      }
    },
  },
}
</script>

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