UpdateHome.vue 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. <template>
  2. <BasicModal v-bind="$attrs" @register="registerModal" title="切换风格" @ok="handleSubmit" width="600px">
  3. <BasicForm @register="registerForm" />
  4. </BasicModal>
  5. </template>
  6. <script lang="ts" setup>
  7. import { ref, unref, defineExpose } from 'vue';
  8. import { BasicModal, useModalInner } from '/@/components/Modal';
  9. import { BasicForm, useForm } from '/@/components/Form/index';
  10. import { useMessage } from '/@/hooks/web/useMessage';
  11. // 声明Emits
  12. const emit = defineEmits(['register']);
  13. const $message = useMessage();
  14. const formRef = ref();
  15. //表单配置
  16. const [registerForm, { validate }] = useForm({
  17. schemas: [
  18. {
  19. label: '页面风格',
  20. field: 'pageType',
  21. component: 'RadioGroup',
  22. defaultValue: 1,
  23. componentProps: {
  24. options: [
  25. {
  26. label: '6.0',
  27. value: 1,
  28. },
  29. {
  30. label: '5.5',
  31. value: 0,
  32. },
  33. ],
  34. },
  35. },
  36. ],
  37. showActionButtonGroup: false,
  38. });
  39. //表单赋值
  40. const [registerModal, { setModalProps, closeModal }] = useModalInner();
  41. //表单提交事件
  42. async function handleSubmit() {
  43. try {
  44. const values = await validate();
  45. setModalProps({ confirmLoading: true });
  46. //设置页面风格
  47. if(values['pageType'] == 1){
  48. // 6.0页面
  49. }else if(values['pageType'] == 0) {
  50. // 5.5页面
  51. }
  52. closeModal();
  53. } finally {
  54. setModalProps({ confirmLoading: false });
  55. }
  56. }
  57. async function show() {
  58. await setModalProps({ visible: true });
  59. }
  60. defineExpose({
  61. show,
  62. });
  63. </script>