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

<script>
import { Message, Modal } from 'ant-design-vue'
import FlowService from '@/webflow/flow-service'
import crossWindowWatcher from '@/common/services/cross-window-watcher'
import LawService from '../law-service'
import CaseMixins from '../case/case-mixins.js'
import components from './_import-components/law-case-execute-finish-form-import'

export default {
  name: 'LawCaseExecuteFinishForm',
  metaInfo: {
    title: '案件执行结案',
  },
  components,
  mixins: [CaseMixins],
  data() {
    return { caseId: '' }
  },
  created() {
    this.caseId = this.$route.query?.id
    this.initData(this.caseId)
  },
  mounted() {
    this.type = 'executefinish'
  },
  methods: {
    validForm() {
      return new Promise((resolve, reject) => {
        resolve(true)
      })
    },
    // 初始化案件信息
    initData(caseId) {
      if (caseId) {
        // 获取案件信息
        LawService.getCaseData(caseId).then((res) => {
          this.$refs.webflow.setFieldValue('CASE_ID', caseId)
          this.$refs.webflow.setFieldValue('title', res.data.caseName + '-案件执行结案')
          this.$refs.webflow.setFieldValue('CASE_STAGE', '仲裁')
          this.$refs.webflow.setFieldValue('CASE_NAME', res.data.caseName)
          this.$refs.webflow.setFieldValue('REPORT_UNIT_NAME', res.data.reportUnitName)
          this.$refs.webflow.setFieldValue('CASE_TYPE', res.data.caseType)
          this.$refs.webflow.setFieldValue('CASE_AMOUNT', res.data.caseAmount)
          this.$refs.webflow.setFieldValue('OWNER_POSITION', res.data.ownerPosition)
          this.$refs.webflow.setFieldValue('IMPORTANT', res.data.important)
          this.$refs.webflow.setFieldValue('EXECUTE_AMOUNT_HOST', res.data.executeAmountHost)
          this.$refs.webflow.setFieldValue('EXECUTE_DATE', res.data.executeDate)
          this.$refs.webflow.setFieldValue('OPPONENT_PARTY', res.data.defendantUserName)
        })
      }
    },
  },
}
</script>

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