FanLineModal .vue 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  1. <template>
  2. <div> </div>
  3. <div class="vent-form">
  4. <BasicForm @register="registerForm" />
  5. <div class="j-box-bottom-button offset-20" style="margin-top: 30px">
  6. <div class="j-box-bottom-button-float">
  7. <a-button preIcon="ant-design:sync-outlined" @click="onReset">重置</a-button>
  8. <a-button type="primary" preIcon="ant-design:save-filled" @click="handleSubmit">保存</a-button>
  9. </div>
  10. </div>
  11. </div>
  12. </template>
  13. <script lang="ts" setup>
  14. import { inject, nextTick, watch, unref } from 'vue';
  15. import { BasicForm, useForm } from '/@/components/Form/index';
  16. // 声明Emits
  17. const emit = defineEmits(['saveOrUpdate']);
  18. const testData = inject('formData') as any;
  19. //表单配置
  20. const [registerForm, { resetFields, setFieldsValue, validate }] = useForm({
  21. schemas: [
  22. {
  23. label: 'R',
  24. field: 'fr',
  25. component: 'Input',
  26. colProps: { span: 6 },
  27. },
  28. {
  29. label: '角度',
  30. field: 'strangle',
  31. component: 'InputNumber',
  32. colProps: { span: 6 },
  33. },
  34. {
  35. label: '频率',
  36. field: 'fhz',
  37. component: 'InputNumber',
  38. colProps: { span: 6 },
  39. },
  40. {
  41. label: '最大风量',
  42. field: 'fqmax',
  43. component: 'InputNumber',
  44. colProps: { span: 6 },
  45. },
  46. {
  47. label: '最小风量',
  48. field: 'fqmin',
  49. component: 'InputNumber',
  50. colProps: { span: 6 },
  51. },
  52. {
  53. label: '系数a',
  54. field: 'ha',
  55. component: 'InputNumber',
  56. colProps: { span: 6 },
  57. },
  58. {
  59. label: '系数b',
  60. field: 'hb',
  61. component: 'InputNumber',
  62. colProps: { span: 6 },
  63. },
  64. {
  65. label: '系数c',
  66. field: 'hc',
  67. component: 'InputNumber',
  68. colProps: { span: 6 },
  69. },
  70. ],
  71. showActionButtonGroup: false,
  72. layout: 'horizontal',
  73. labelWidth: 80,
  74. });
  75. watch(
  76. testData,
  77. (newV) => {
  78. nextTick(() => {
  79. setFieldsValue({ ...newV });
  80. });
  81. },
  82. { immediate: true }
  83. );
  84. // 重置表单
  85. async function onReset() {
  86. await resetFields();
  87. await setFieldsValue({ ...testData });
  88. }
  89. //表单提交事件
  90. async function handleSubmit(v) {
  91. try {
  92. let values = await validate();
  93. emit('saveOrUpdate', values);
  94. } finally {
  95. // setModalProps({ confirmLoading: false });
  96. }
  97. }
  98. </script>
  99. <style lang="less" scoped>
  100. @ventSpace: zxm;
  101. .j-box-bottom-button-float {
  102. border: none !important;
  103. padding-bottom: 30px;
  104. left: 0px !important;
  105. right: 0px !important;
  106. bottom: 0px !important;
  107. }
  108. .vent-form {
  109. // width: 100%;
  110. max-height: 700px;
  111. overflow-y: auto;
  112. .@{ventSpace}-select-selection-item {
  113. color: rgba(255, 255, 255, 1) !important;
  114. }
  115. }
  116. </style>