<template>
  <TabFormEditModal
    v-model:open="openTabEditModal" 
    :is-restore-data="tabEditViewIsRestoreData" 
    :window-no="curdWindowNo" 
    :tab-index="tabIndex" 
    :type="tabEditViewType"
    :model-data-id="tabEditViewRecordId"
    width="100%" 
    @open-tab-form-view="openTabFormViewModal"
  />
  <TabFormViewModal
    v-model:open="openTabViewModal" 
    :window-no="curdWindowNo" 
    :tab-index="tabIndex" 
    :type="tabFormViewType"
    :model-data-id="tabFormViewRecordId"  
    width="100%"
    @open-tab-edit-view="openTabEditView"
  />
</template>

<script setup>
import { ref } from 'vue';

import TabFormEditModal from '../../src/window1/tabFormEdit/TabFormEditModal.vue';
import TabFormViewModal from '../../src/window1/tabFormView/TabFormViewModal.vue';

const curdWindowNo = ref('20240910_193059');
const tabIndex = ref(0);



const openTabEditModal = ref(false);

const tabEditViewType = ref('');
const tabEditViewRecordId = ref(null);
const tabEditViewCurrentPage = ref(null);
const tabEditViewCurrentIndex = ref(null);
const tabEditViewTotalRecords = ref(null);
const tabEditViewIsRestoreData = ref(false);

const openTabViewModal = ref(true);
const tabFormViewRecordId = ref(476306266914880);
const tabFormViewType = ref('view');

/**
 * 打开页签视图模式
 * @param param 信息
 *          属性1: type: 类型,
 *          属性1: windowNo: CURD窗口编号,
 *          属性2: tabIndex: CURD页签编号,
 *          属性3: modelDataId: 数据记录id,
 *          属性4: currentPage: 当前记录所在的页码,
 *          属性5: currentIndex: 当前记录的排序,
 *          属性6: totalRecords: 记录的总数量,
 *          属性7: uuid: 窗口唯一Id,
 */
const openTabFormViewModal = function(param){
  tabFormViewRecordId.value = param.modelDataId;
  openTabEditModal.value = false;
  openTabViewModal.value = true;
};

/**
 * 打开页签编辑模式
 * @param param 信息
 *          属性1: type: 类型,
 *          属性1: windowNo: CURD窗口编号,
 *          属性2: tabIndex: CURD页签编号,
 *          属性3: modelDataId: 数据记录id,
 *          属性4: currentPage: 当前记录所在的页码,
 *          属性5: currentIndex: 当前记录的排序,
 *          属性6: totalRecords: 记录的总数量,
 *          属性7: uuid: 窗口唯一Id,
 */
const openTabEditView = function(param){
  tabEditViewType.value = param.type;
  curdWindowNo.value = param.windowNo;
  tabIndex.value = param.tabIndex;
  tabEditViewRecordId.value = param.modelDataId;
  tabEditViewCurrentPage.value = param.currentPage;
  tabEditViewCurrentIndex.value = param.currentIndex;
  tabEditViewTotalRecords.value = param.totalRecords;
  tabEditViewIsRestoreData.value = param.isRestoreData;
  
  openTabViewModal.value = false;
  openTabEditModal.value = true;
};

</script>