石墨仪设备 前端仓库
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

39 lines
1.1 KiB

  1. <template>
  2. <div class="bg-white text-xl text-text px-5 py-7 rounded-lg">
  3. <h1 class="font-medium">添加矿石</h1>
  4. <section>
  5. <div class="grid grid-cols-[5rem_1fr] gap-x-8 gap-y-4 min-w-[30rem] mt-4 mb-7 px-4">
  6. <span class="text-right">矿石名称</span>
  7. <input type="text" class="border border-[#eee] rounded-sm px-2" v-model="oreObj.oresName" />
  8. </div>
  9. </section>
  10. <footer class="flex justify-center gap-x-6">
  11. <button class="btn-dark px-6 py-1" @click="onConfirm">确定</button>
  12. <button class="btn-light px-6 py-1" @click="$emit('cancel')">取消</button>
  13. </footer>
  14. </div>
  15. </template>
  16. <script setup lang="ts">
  17. import type { Ore } from "@/services/ore/oreManage";
  18. import { showToast } from "vant";
  19. import { ref } from "vue";
  20. const props = defineProps<{ ore: Ore | undefined }>();
  21. const oreObj = ref<Ore>(props.ore || { oresName: "" } as Ore);
  22. const emit = defineEmits<{
  23. (e: "confirm", ore: Ore): void;
  24. (e: "cancel"): void;
  25. }>();
  26. function onConfirm() {
  27. if (oreObj.value.oresName === "") {
  28. showToast("名称不能为空");
  29. return;
  30. }
  31. emit("confirm", oreObj.value);
  32. }
  33. </script>