<template>
  <SysDialog
    :title="dialog.title"
    :width="dialog.width"
    :height="dialog.height"
    :visible="dialog.visible"
    @onClose="onClose"
    @onConfirm="confirm"
  >
    <template #content>
      <el-form
        ref="addCurrencyRateForm"
        :model="addModel"
        :rules="rules"
        label-width="80px"
        size="mini"
      >
        <el-row>
          <el-col
            :span="12"
            :offset="0"
          >
            <el-form-item
              prop="id"
              label="序号"
            >
              <el-input
                v-model="addModel.id"
                :disabled="true"
              />
            </el-form-item>
          </el-col>
          <el-col
            :span="12"
            :offset="0"
          >
            <el-form-item
              prop="currencyCode"
              label="简码"
            >
              <el-input
                v-model="addModel.currencyCode"
                :disabled="addModel.type == '1'"
              />
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col
            :span="12"
            :offset="0"
          >
            <el-form-item
              prop="currencyRate"
              label="汇率"
            >
              <el-input v-model="addModel.currencyRate" />
            </el-form-item>
          </el-col>
          
          <el-col
            :span="12"
            :offset="0"
          >
            <el-form-item
              prop="startDate"
              label="生效时间"
            >
              <el-date-picker 
                v-model="addModel.startDate"                            
                type="daterange" 
                start-placeholder="生效时间"
                end-placeholder="失效时间"
                :picker-options="pickerOptions"
              />
              <!-- :disabled-date="disabledDate" 注释过去时间不能选择 -->
            </el-form-item>
          </el-col>
        </el-row>
      </el-form>
    </template>
  </SysDialog>
</template>
<script setup lang='ts'>
import SysDialog from '@/components/SysDialog.vue';
import useDialog from '@/hooks/useDialog';
import useBaseModel from '@/composables/costdata/currencyrate/useBaseModel'
import useAddCurrencyRate from '@/composables/costdata/currencyrate/useAddCurrencyRate';
//弹框属性
const { dialog, onClose, onShow } = useDialog()

//声明事件
const emit = defineEmits(['save'])

const { rules } = useBaseModel();

const { confirm, show, addModel, addCurrencyRateForm,pickerOptions,disabledDate } = useAddCurrencyRate(dialog, onClose, onShow, emit)

//父组件调用子组件显示弹框
//暴露出去给外部使用
defineExpose({
  show
})
</script>
<style scoped lang='scss'>

</style>