<template>
  <sd-webflow
    ref="webflow"
    @afterDispatch="afterDispatch"
    @saveproject="save"
    @sdFormReady="initData"
    @actionBtnClick="actionBtnClick"
  >
    <template v-slot:form="{ model, FlowData }">
      <!-- 申请人监听 -->
      <action-name-watcher :model="model" @actionNameChange="actionNameChange" />
      <sd-form-by-builder ref="builderform" :form-data="FlowData.processFormData" />
    </template>
  </sd-webflow>
</template>

<script>
import CaseMixins from '../case-mixins.js'
import components from './_import-components/case-progress-xyzx-form-import'

export default {
  name: 'CaseProgressXyzxForm',
  metaInfo: {
    title: '案件进展-先予执行详情',
  },
  components: {
    actionNameWatcher: {
      props: ['model'],
      created() {
        this.$watch(
          () => {
            return this.model.APPLY_USER
          },
          (nVal, oVal) => {
            this.$emit('actionNameChange', nVal, oVal)
          },
          { immediate: false }
        )
      },
      render: () => {},
    },
    ...components,
  },
  mixins: [CaseMixins],
  data() {
    return {}
  },
  created() {
    this.type = 'progress'
  },
  mounted() {
    this.type = 'progress'
  },
  methods: {
    actionNameChange(nval, lval) {
      if (!nval) return
      // 自定义组件不会直接校验，加校验
      this.$refs.webflow.validateField('APPLY_USER')
    },
  },
}
</script>

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