<template>
  <sd-webflow ref="webflow" :validate-form="validForm">
    <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 moment from 'moment'
import { getUserInfo } from '@/common/store-mixin'
import components from './_import-components/cpm-contract-check-import'

export default {
  name: 'CpmContractCheck',
  metaInfo: {
    title: 'CpmContractCheck',
  },
  components,
  data() {
    return {}
  },
  created() {
    this.initData()
  },
  methods: {
    validForm() {
      this.$refs.webflow.setFieldValue('JBXX', 'true')
      this.$refs.webflow.setFieldValue('FLHGBYJ', 'true')
      return new Promise((resolve, reject) => {
        resolve(true)
      })
    },
    initDaF(array) {
      if (array) {
        array.attrFD.keepHiddenCell = false
      }
      return array
    },
    initData() {
      setTimeout(() => {
        if (this.$refs.webflow.flowData.processActiveLogInfo.length > 0) {
          const stepId = this.$refs.webflow.flowData.processActiveLogInfo[0].stepId
          if (stepId === 'G_1_CPM_CONTRACT_CHECK.4') {
            this.$refs.webflow.setFieldValue('LAW_EDIT_ID', getUserInfo().id)
            this.$refs.webflow.setFieldValue('LAW_EDIT_ACCOUNT', getUserInfo().account)
            this.$refs.webflow.setFieldValue('LAW_EDIT_NAME', getUserInfo().name)
            this.$refs.webflow.setFieldValue('LAW_EDIT_TIME', moment(new Date()))
          }
        }
      })
    },
  },
}
</script>

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