<template>
  <sd-webflow ref="webflow" :validate-form="validForm" :class="$style.form">
    <template v-slot:form="{ model, FlowData }">
      <sd-form-by-builder
        ref="builderform"
        :form-data="initDaF(FlowData.processFormData)"
        :keepHiddenCell="false"
      />
    </template>
  </sd-webflow>
</template>

<script>
import { transpileModule } from 'typescript'
import components from './_import-components/law-record-form-import'

export default {
  name: 'lawRecordForm',
  metaInfo: {
    title: '服务记录',
  },
  components,
  data() {
    return {
      flag: true,
    }
  },

  methods: {
    initDaF(array) {
      if (array) {
        array.attrFD.keepHiddenCell = false
      }
      return array
    },
    validForm() {
      setTimeout(() => {
        this.$refs.docform.setFieldValue('JBXX', 'true')
        this.$refs.docform.setFieldValue('LAW_FIRM_LSPJ', 'true')
        this.$refs.docform.setFieldValue('LAW_LAWYER_LSPJ', 'true')
      }, 0)
      return new Promise((resolve, reject) => {
        var lawyer = this.$refs.webflow.getFieldValue('LAWYER_NAME_QUOTE')
        if (lawyer !== undefined) {
          var lawyerObj = JSON.parse(lawyer)
          this.$refs.webflow.setFieldValue('LAWYER_ID', lawyerObj[0].id)
          this.$refs.webflow.setFieldValue('LAWYER_NAME', lawyerObj[0].name)
        }

        var choose = this.$refs.webflow.getFieldValue('CHOOSE_ID_QUOTE')
        if (choose !== undefined) {
          var chooseObj = JSON.parse(choose)
          this.$refs.webflow.setFieldValue('CHOOSE_ID', chooseObj[0].id)
          this.$refs.webflow.setFieldValue('CHOOSE_NAME', chooseObj[0].name)
        }
        resolve(true)
      })
    },
  },
}
</script>

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