<!--
 * @Author: tengmingxue 1473375109@qq.com
 * @Date: 2023-08-15 16:19:10
 * @LastEditors: tengmingxue 1473375109@qq.com
 * @LastEditTime: 2023-08-28 13:57:55
 * @FilePath: \xld-gis-admin\src\views\resource\map\MapSourceModal.vue
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
-->
<template>
  <BasicModal
    width="1200px"
    v-bind="$attrs"
    @register="registerModal"
    :title="getTitle"
    @ok="handleSubmit"
  >
    <div style="height: 60vh" class="res-form-container">
      <a-tabs v-model:activeKey="activeKey" class="res-a-tabs">
        <a-tab-pane key="1" tab="地图资源信息">
          <!-- <BasicForm @register="registerForm"></BasicForm> -->
          <source-detail ref="refSourceDetail" @RtnMain="RtnMain" :formData="formData" :isUpdate="isUpdate" :isView="isView"></source-detail>
        </a-tab-pane>
        <a-tab-pane key="2" tab="流程信息" force-render>
          <div class="tab2"></div>
        </a-tab-pane>
      </a-tabs>
    </div>
  </BasicModal>
</template>
  <script lang="ts">
import { defineComponent, ref, computed, unref, reactive, onMounted } from 'vue';
import { BasicModal, useModalInner } from '/@/components/Modal';
import { BasicForm, useForm } from '/@/components/Form/index';
import { BasicTree } from '/@/components/Tree';
import { PlusOutlined } from '@ant-design/icons-vue';
import SourceDetail from './SourceDetail.vue';

export default defineComponent({
  name: 'AccountModal',
  components: {
    BasicModal,
    BasicForm,
    BasicTree,
    PlusOutlined,
    SourceDetail,
    VNodes: (_, { attrs }) => {
      return attrs.vnodes;
    },
  },
  emits: ['success', 'register'],
  setup(_, { emit }) {
    let activeKey = '1';
    const refSourceDetail = ref(null);
    let formData = ref(null)
    let isUpdate = ref(true);
    let isView = ref(false)
    const [registerModal, { setModalProps, closeModal }] = useModalInner(async (data) => {
      setModalProps({ confirmLoading: false });
      isUpdate.value = !!data?.isUpdate;
      isView.value = !!data?.isView;
      if(isUpdate.value) formData.value = data.record
    });
    const getTitle = computed(() => (!unref(isUpdate) ? '新增地图资源' : '编辑地图资源'));

    async function handleSubmit() {
      refSourceDetail.value.submitForm();
    }
    const RtnMain = (status) => {
      emit('success')
    }

    onMounted(() => {});
    return {
      activeKey,
      registerModal,
      handleSubmit,
      getTitle,
      refSourceDetail,
      isUpdate,
      isView,
      formData,
      RtnMain,
    };
  },
});
</script>
  <style scoped lang="less">
:deep(.vben-basic-tree) {
  width: 100% !important;
}

:deep(.is-unflod) {
  display: none !important;
}

:deep(.is-flod) {
  display: none !important;
}
:deep(.res-form-container) {
  .res-a-tabs {
    margin-top: 61px !important;
  }
}
</style>
  