1
0

modal.vue 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  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 v-if="type == '10'">
  9. <div class="vent-flex-row input-box">
  10. <div class="label">风窗开启角度:</div>
  11. <a-input-number size="small" placeholder="0" :min="0" v-model:value="frontSetValue" />
  12. </div>
  13. </div>
  14. <div class="vent-flex-row input-box">
  15. <div class="label">操作密码:</div>
  16. <a-input size="small" type="password" v-model:value="passWord" />
  17. </div>
  18. </div>
  19. </a-modal>
  20. </template>
  21. <script setup lang="ts">
  22. import { watch, ref } from 'vue';
  23. import { ExclamationCircleFilled } from '@ant-design/icons-vue';
  24. const props = defineProps({
  25. modalIsShow: {
  26. type: Boolean,
  27. default: false,
  28. },
  29. modalTitle: {
  30. type: String,
  31. default: '',
  32. },
  33. modalType: {
  34. type: String,
  35. default: '',
  36. },
  37. });
  38. const emit = defineEmits(['handleOk', 'handleCancel']);
  39. const visible = ref<Boolean>(false);
  40. const title = ref<String>('');
  41. const type = ref<String>('');
  42. const passWord = ref('');
  43. const frontSetValue = ref(0);
  44. watch([() => props.modalIsShow, () => props.modalTitle, () => props.modalType], ([newVal, newModalTitle, newModalType]) => {
  45. visible.value = newVal;
  46. if (newModalTitle) title.value = newModalTitle;
  47. if (newModalType) type.value = newModalType;
  48. passWord.value = '';
  49. });
  50. function handleOk() {
  51. //
  52. if (type.value == '10') {
  53. emit('handleOk', passWord.value, type.value, frontSetValue.value);
  54. } else {
  55. emit('handleOk', passWord.value, type.value);
  56. }
  57. }
  58. function handleCancel() {
  59. //
  60. emit('handleCancel');
  61. }
  62. </script>
  63. <style scoped lang="less">
  64. @ventSpace: zxm;
  65. .label {
  66. width: 120px;
  67. }
  68. .@{ventSpace}-input {
  69. width: 150px;
  70. }
  71. .@{ventSpace}-input-number {
  72. width: 150px;
  73. }
  74. </style>