<template>
  <SysDialog class="formula-modle" :title="getBindValue.title" :width="getBindValue.width" :height="getBindValue.height"
    :visible="dialog.visible" @onClose="hanleOnClose" @onConfirm="confirm">
    <template #content>
      <!-- 重算-账单 -->
      <el-form class="el-recount-form" :model="state.form" :inline="true">
        <el-form-item class="item-search" label="汇率版本：">
          <el-select v-model="state.form.rateVersionId" placeholder="请选择汇率版本" @change="changeRateVersion">
            <el-option v-for="item in billrateList" :key="item.value" :label="item.label" :value="item.value" />
          </el-select>
        </el-form-item> 
      </el-form>
      <BaseTable @register="registerTableRateVersions" />
    </template>
  </SysDialog>
</template>
<script lang="ts" setup>
import { ref } from 'vue';
import SysDialog from '@/components/SysDialog.vue';
import useDialog from '@/hooks/useDialog';
import useAddBillMainRecount from '@/composables/business/billmain/useAddBillMainRecount';
import { ListIitem } from '@/api/base/BaseDataModel';
import { BaseTable, useTable } from '@/components/Table';
import useBillMainTable from '@/composables/business/billmain/useBillMainTable';
import { useRateVersionList } from '@/composables/business/billmain/useRateversionLis';

// 弹框一些配置
const getBindValue = ref<Recordable>({
  title: "重算",
  width: 460,
  height: 0
})

//声明事件
const emit = defineEmits(['saveRecount']);
defineProps<{
  billrateList: ListIitem[]
}>()


//弹框属性
const { dialog, onClose, onShow } = useDialog()

// 基础数据处理
const { viewBillRateTable } = useBillMainTable()
const [registerTableRateVersions] = useTable(viewBillRateTable)
const { show, confirm, hanleOnClose, changeRateVersion, getRateVersionId, state } = useAddBillMainRecount(onClose, onShow, emit)
// 汇率版本列表
useRateVersionList(viewBillRateTable, getRateVersionId)

//父组件调用子组件显示弹框
//暴露出去给外部使用
defineExpose({
  show
})
</script>
    
<style lang="scss" scoped>
.el-recount-form {
  // text-align: center;
  padding-bottom: 10px;

  .el-form-item {
    margin-bottom: 0;
    margin-right: 0;
  }
}
</style>