modal.vue 2.8 KB

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