<template>
  <a-spin
    :spinning="spinning"
    :tip="tipContent"
  >
    <a-divider orientation="left">开关配置</a-divider>
    <SwitchConfigForm ref="switchForm"></SwitchConfigForm>

    <a-divider orientation="left">运营配置</a-divider>
    <OperateConfigForm ref="operateForm"></OperateConfigForm>

    <a-divider orientation="left">用车配置</a-divider>
    <UseCarConfigForm ref="useCarForm"></UseCarConfigForm>

    <a-divider orientation="left">锁车配置</a-divider>
    <LockCarConfigForm ref="lockCarForm"></LockCarConfigForm>

    <a-divider orientation="left">还车配置</a-divider>
    <ReturnCarConfigForm ref="returnCarForm"></ReturnCarConfigForm>

    <a-divider orientation="left">客服配置</a-divider>
    <CustomerServiceConfigForm ref="customerServiceForm"></CustomerServiceConfigForm>
  </a-spin>
</template>
  

<style scoped>
.a-tabs-card {
  position: relative;
}
</style>
<script setup>
import { ref, defineProps } from 'vue'
import { callOperate } from '@/apis/call.js'
import _ from 'lodash'
import SwitchConfigForm from './SwitchConfigForm.vue';
import UseCarConfigForm from './UseCarConfigForm.vue';
import LockCarConfigForm from './LockCarConfigForm.vue';
import ReturnCarConfigForm from './ReturnCarConfigForm.vue';
import CustomerServiceConfigForm from './CustomerServiceConfigForm.vue';
import OperateConfigForm from './OperateConfigForm.vue';


const props = defineProps({
  onCallBack: {
    type: Function,
    required: true
  },
});

const switchForm = ref(null);
const operateForm = ref(null);
const useCarForm = ref(null);
const lockCarForm = ref(null);
const returnCarForm = ref(null);
const customerServiceForm = ref(null);

const spinning = ref(false);
const tipContent = ref("加载中...");

const openForm = (params = {}) => {
  if (params['regionId']) {
    spinning.value = true;
    callOperate("/ebikesysrcostset/getRegionFeeConfigById?regionId="
      + params['regionId'], {}, "get").then(res => {
        spinning.value = false;

      })
  }
};

const formSave = () => {
  const forms = [switchForm, operateForm, useCarForm, lockCarForm, returnCarForm, customerServiceForm];
  let flag = false;
  for (let form of forms) {
    if (form.value) {
      form.value.validateForm().then(res => {
        debugger
      }).catch(() => {
        flag = true;
      });
    }
  }
  if (!flag) {

  }
};

defineExpose({ openForm, formSave });
</script>