<script setup lang="ts">
import XFormGroup from '@af-mobile-client-vue3/components/data/XFormGroup/index.vue'
import NormalDataLayout from '@af-mobile-client-vue3/components/layout/NormalDataLayout/index.vue'
import { showDialog } from 'vant'
import { ref } from 'vue'
import { useRoute } from 'vue-router'

// 纯表单
const configName = ref('form_check_test')
const serviceName = ref('af-system')

// const configName = ref("计划下发Form")
// const serviceName = ref("af-linepatrol")

// 表单组
// const configName = ref('lngChargeAuditMobileFormGroup')
// const serviceName = ref('af-gaslink')

const formData = ref({})
const formGroup = ref(null)
const route = useRoute()
const isInit = ref(false)
function submit(_result) {
  showDialog({ message: '提交成功' }).then(() => {
    history.back()
  })
}

// 表单组——数据
// function initComponents () {
//   runLogic('getlngChargeAuditMobileFormGroupData', {id: 29}, 'af-gaslink').then((res) => {
//     formData.value = {...res}
//   })
// }

// 纯表单——数据
// function initComponents() {
//   formData.value = { plan_name: 'af-llllll', plan_point: '1号点位', plan_single: '1号点位', plan_range: '2024-12-12' }
// }

// function initComponents() {
//   runLogic('getlngChargeAuditMobileFormGroupData', { id: route.query?.id, o_id: route.query?.o_id }, 'af-gaslink').then((res) => {
//     console.log('res------', res)
//     formData.value = { ...res }
// formGroup.value.init({
//   configName: configName.value,
//   serviceName: serviceName.value,
//   groupFormData: { ...res },
//   mode: "新增"
// })
//     isInit.value = true
//   })
// }

// onBeforeMount(() => {
//   initComponents()
// })
</script>

<template>
  <NormalDataLayout id="XFormGroupView" title="纯表单">
    <template #layout_content>
      <!--      v-if="isInit" -->
      <XFormGroup
        ref="formGroup"
        :config-name="configName"
        :service-name="serviceName"
        :group-form-data="formData"
        mode="新增"
        @submit="submit"
      />
    </template>
  </NormalDataLayout>
</template>

<style scoped lang="less">

</style>
