<template>
  <Dialog v-model="dialogVisible" title="生成工资条" style="width: 800px">
    <el-form :model="formData" ref="formRef" :rules="rules" label-width="80px">
      <el-row :gutter="20">
        <el-col :span="12" :offset="0">
          <el-form-item label="年月" prop="yearmonth">
            <el-date-picker v-model="formData.yearmonth" type="month" placeholder="选择年月" />
          </el-form-item>
        </el-col>
      </el-row>
      <el-row :gutter="20">
        <el-col :span="12" :offset="0">
          <el-form-item label="导入奖金">
            <UploadFile
              v-model="formData.files1"
              :limit="1"
              :fileType="['xls', 'xlsx']"
              accept=".xls,.xlsx"
              :isShowTip="false"
            >
              <template #tip>
                <div>
                  <el-link
                    type="primary"
                    :underline="false"
                    href="https://ss-cloud.ahduima.com/1011/1808052748575576064.pdf"
                    target="_blank"
                  >
                    点击下载模板文件
                  </el-link>
                </div>
              </template>
            </UploadFile>
          </el-form-item>
        </el-col>
        <el-col :span="12" :offset="0">
          <el-form-item label="导入考勤" prop="files2">
            <UploadFile
              v-model="formData.files2"
              :limit="1"
              :fileType="['xls', 'xlsx']"
              accept=".xls,.xlsx"
              :isShowTip="false"
            >
              <template #tip>
                <div>
                  <el-link
                    type="primary"
                    :underline="false"
                    href="https://ss-cloud.ahduima.com/1011/1808052748575576064.pdf"
                    target="_blank"
                  >
                    点击下载模板文件
                  </el-link>
                </div>
              </template>
            </UploadFile>
          </el-form-item>
        </el-col>
      </el-row>
    </el-form>
    <template #footer>
      <span>
        <el-button @click="dialogVisible = false">取 消</el-button>
        <el-button type="primary" :disabled="formLoading" @click="handleSave"> 确认生成 </el-button>
      </span>
    </template>
  </Dialog>
</template>

<script setup name="DialogCreateSalary">
const dialogVisible = ref(false)

const formData = ref({})

const formLoading = ref(false)

const rules = {
  yearmonth: { required: true, message: '年月不可为空', trigger: 'blur,change' },
  files2: { required: true, message: '考勤文件不可为空', trigger: 'blur,change' }
}

function open() {
  dialogVisible.value = true
  resetForm()
}

function resetForm() {
  formData.value = {
    yearmonth: new Date().getFullYear(),
    files1: '',
    files2: ''
  }
}

defineExpose({ open })

function handleSave() {}
</script>

<style lang="scss" scoped></style>
