modal.vue 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. <template>
  2. <a-modal v-model:visible="visible" :title="title" @ok="handleOk" @cancel="handleCancel">
  3. <div class="modal-container">
  4. <div class="vent-flex-row">
  5. <ExclamationCircleFilled style="color: #ffb700; font-size: 30px" />
  6. <div class="warning-text">您是否要进行{{ title }}操作?</div>
  7. </div>
  8. <div class="vent-flex-row input-box">
  9. <div class="label">风窗面积:</div>
  10. <a-input-number size="small" placeholder="0" :min="0" :max="90" :step="1" v-model:value="area" />
  11. </div>
  12. <div class="vent-flex-row input-box">
  13. <div class="label">操作密码:</div>
  14. <a-input size="small" type="password" v-model:value="passWord" />
  15. </div>
  16. </div>
  17. </a-modal>
  18. </template>
  19. <script setup lang="ts">
  20. import { watch, ref } from 'vue';
  21. import { ExclamationCircleFilled } from '@ant-design/icons-vue';
  22. const props = defineProps({
  23. modalIsShow: {
  24. type: Boolean,
  25. default: false,
  26. },
  27. modalTitle: {
  28. type: String,
  29. default: '',
  30. },
  31. modalType: {
  32. type: String,
  33. default: '',
  34. },
  35. });
  36. const emit = defineEmits(['handleOk', 'handleCancel']);
  37. const visible = ref<Boolean>(false);
  38. const title = ref<String>('');
  39. const type = ref<String>('');
  40. const passWord = ref('');
  41. const area = ref(0);
  42. watch([() => props.modalIsShow, () => props.modalTitle, () => props.modalType], ([newVal, newModalTitle, newModalType]) => {
  43. visible.value = newVal;
  44. if (newModalTitle) title.value = newModalTitle;
  45. if (newModalType) type.value = newModalType;
  46. passWord.value = '';
  47. area.value = 0;
  48. });
  49. function handleOk() {
  50. //
  51. emit('handleOk', passWord.value, type.value, area.value);
  52. }
  53. function handleCancel() {
  54. //
  55. emit('handleCancel');
  56. }
  57. </script>
  58. <style scoped lang="less">
  59. .label {
  60. width: 80px;
  61. }
  62. .ant-input,
  63. .ant-input-number {
  64. width: 150px;
  65. }
  66. </style>