<template>
  <sd-webflow
    ref="webflow"
    @afterDispatch="afterDispatch"
    @saveproject="save"
    @sdFormReady="initDatap"
    @actionBtnClick="actionBtnClick"
  >
    <template v-slot:form="{ model, FlowData }">
      <sd-form-by-builder ref="builderform" :form-data="FlowData.processFormData" />
    </template>
  </sd-webflow>
</template>

<script>
import LawService from '../../law-service'
import CaseMixins from '../case-mixins.js'
import components from './_import-components/case-progress-gxqyy-form-import'

export default {
  name: 'CaseProgressGxqyyForm',
  metaInfo: {
    title: '案件进展-管辖权异议',
  },
  components,
  mixins: [CaseMixins],
  data() {
    return {}
  },
  created() {
    this.type = 'progress'
  },
  mounted() {
    this.type = 'progress'
  },
  methods: {
    initDatap() {
      if (this.create) {
        // 获取案件信息
        this.initData()
        LawService.getBeanByFormId(
          this.$route.query.id,
          'onl:d0bb8202233c48f0b5148776754461e1'
        ).then((res) => {
          const obj = res.data.pageFormData.pageFieldInfos
          obj.forEach((item) => {
            if (item.name === 'LAW_CASE_PLAINTIFF') {
              const ll = JSON.parse(item.value)
              var mm = ''
              if (ll.length > 0) {
                ll.forEach((element) => {
                  mm = mm + element.USER_NAME + ','
                })
                mm = mm.substring(0, mm.length - 1)
              }

              this.$refs.webflow.setFieldValue('APPEAL_USER', mm)
            }
          })
        })
      }
    },
  },
}
</script>

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