<template>
  <TabFormEditModal
    v-model:open="openTabEditModal" 
    :is-restore-data="tabEditViewIsRestoreData" 
    :window-no="curdWindowNo" 
    :tab-index="tabIndex" 
    :type="tabEditViewType"
    :model-data-id="tabEditViewRecordId"
    width="100%" 
    :current-page="tabEditViewCurrentPage"
    :current-index="tabEditViewCurrentIndex"
    :total-records="tabEditViewTotalRecords"
    :task-info-id="tabEditViewTaskInfoId"
    :workflow-type="tabEditViewWorkflowType"
    :mask-closable="false"
    @open-tab-form-view="openTabFormViewModal"
  />
  <TabFormViewModal
    v-model:open="openTabViewModal" 
    :window-no="curdWindowNo" 
    :tab-index="tabIndex" 
    :type="tabFormViewType"
    :model-data-id="tabFormViewRecordId"  
    width="100%"
    :current-page="tabFormViewCurrentPage"
    :current-index="tabFormViewCurrentIndex"
    :total-records="tabFormViewTotalRecords"
    :task-info-id="tabFormViewTaskInfoId"
    :workflow-type="tabFormViewWorkflowType"
    :mask-closable="false"
    @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(true);
const tabEditViewType = ref('create');
const tabEditViewRecordId = ref(null);
const tabEditViewCurrentPage = ref(null);
const tabEditViewCurrentIndex = ref(null);
const tabEditViewTotalRecords = ref(null);
const tabEditViewIsRestoreData = ref(false);
const tabEditViewTaskInfoId = ref(null);
const tabEditViewWorkflowType = ref(null);

const openTabViewModal = ref(false);
const tabFormViewType = ref('view');
const tabFormViewRecordId = ref(null);
const tabFormViewCurrentPage = ref(null);
const tabFormViewCurrentIndex = ref(null);
const tabFormViewTotalRecords = ref(null);
const tabFormViewTaskInfoId = ref(null);
const tabFormViewWorkflowType = ref(null);

/**
 * 打开页签视图模式
 * @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){  

  console.log('openTabFormViewModal', param);

  tabFormViewType.value = param.type;
  curdWindowNo.value = param.windowNo;
  tabIndex.value = param.tabIndex;
  tabFormViewRecordId.value = param.modelDataId;
  tabFormViewCurrentPage.value = param.currentPage;
  tabFormViewCurrentIndex.value = param.currentIndex;
  tabFormViewTotalRecords.value = param.totalRecords;

  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>