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

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

export default {
  name: 'LawFirmForm',
  metaInfo: {
    title: '律所管理',
  },
  components,
  data() {
    return {
      flag: true,
    }
  },
  created() {
    const ini = setInterval(() => {
      if (
        this.$refs.webflow &&
        (this.$refs.webflow.$refs.form || this.$refs.webflow.$refs.sdForm)
      ) {
        clearInterval(ini)
        if (this.$refs.webflow.getFieldValue('FLOW_STATUS')) {
          // 隐藏 律师信息/ 律所选聘信息/  服务记录与信息评价
          this.$refs.webflow.setFieldValue(
            'STATUS',
            '' + this.$refs.webflow.getFieldValue('FLOW_STATUS')
          )
        }
      }
    }, 100)
  },
  methods: {
    initDaF(array) {
      if (array) {
        array.attrFD.keepHiddenCell = false
      }
      return array
    },
    validForm() {
      setTimeout(() => {
        this.$refs.docform.setFieldValue('JBXX', 'true')
        this.$refs.docform.setFieldValue('LXRXX', 'true')
        this.$refs.docform.setFieldValue('ZZXX', 'true')
        this.$refs.docform.setFieldValue('LAW_LAWYER_LSPJ', 'true')
        this.$refs.docform.setFieldValue('LAW_FIRM_LSPJ', 'true')
        this.$refs.docform.setFieldValue('LAW_EVALUATE', 'true')
      }, 0)
      return new Promise((resolve, reject) => {
        resolve(true)
      })
    },
  },
}
</script>

<style module lang="scss">
@use '@/common/design' as *;
.form {
  :global .header_sd-data-table_common {
    display: none;
  }
}
</style>
