<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-choose-form-import'

export default {
  name: 'lawChooseForm',
  metaInfo: {
    title: 'lawChooseForm',
  },
  components,
  data() {
    return {
      flag: true,
    }
  },

  methods: {
    initDaF(array) {
      if (array) {
        array.attrFD.keepHiddenCell = false
      }
      return array
    },
    validForm() {
      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)
        }
        resolve(true)
      })
    },
  },
}
</script>

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