<script setup lang="ts">
import { ref, reactive } from "vue";
import { ElMessageBox, ElMessage } from "element-plus";
const dialogVisibleAdd = ref(false);
const copyTitle = ref("");
const copyMould = () => {
  return "复制来源:" + copyTitle.value;
};
const form = reactive({
  name: "",
  region: "",
  date1: "",
  date2: "",
  delivery: false,
  type: [],
  resource: "",
  desc: ""
});
const handleClose = () => {
  ElMessageBox.confirm("确认关闭弹窗吗？")
    .then(() => {
      dialogVisibleAdd.value = !dialogVisibleAdd.value;
      ElMessage({
        message: "已关闭"
      });
    })
    .catch(() => {
      // catch error
    });
};
// 添加部门保存
const saveDepartment = () => {
  dialogVisibleAdd.value = false;
  ElMessage({
    message: "添加成功",
    type: "success"
  });
};
const open = (item: any) => {
  copyTitle.value = item.name;
  dialogVisibleAdd.value = true;
};
defineExpose({
  open
});
</script>

<template>
  <div>
    <el-dialog
      v-model="dialogVisibleAdd"
      :title="copyMould()"
      width="500"
      :before-close="handleClose"
    >
      <el-form :model="form" label-width="auto" style="max-width: 600px">
        <el-form-item label="名称">
          <el-select
            v-model="form.region"
            placeholder="please select your zone"
          >
            <el-option label="Zone one" value="shanghai" />
            <el-option label="Zone two" value="beijing" />
          </el-select>
        </el-form-item>
      </el-form>
      <template #footer>
        <div class="dialog-footer">
          <el-button @click="handleClose">取消</el-button>
          <el-button type="primary" @click="saveDepartment"> 确认 </el-button>
        </div>
      </template>
    </el-dialog>
  </div>
</template>
