index.vue 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. <script setup lang="ts">
  2. import { ref } from "vue";
  3. // https://plus-pro-components.com/components/form.html
  4. import "plus-pro-components/es/components/form/style/css";
  5. import {
  6. type PlusColumn,
  7. type FieldValues,
  8. PlusForm
  9. } from "plus-pro-components";
  10. import { text } from "stream/consumers";
  11. const state = ref<FieldValues>({
  12. status: "1",
  13. name: "",
  14. rate: 4,
  15. progress: 100,
  16. switch: true,
  17. time: new Date().toString(),
  18. endTime: []
  19. });
  20. const rules = {
  21. name: [
  22. {
  23. required: true,
  24. message: "请输入名称"
  25. }
  26. ]
  27. };
  28. const columns: PlusColumn[] = [
  29. ];
  30. const submitLoading = ref(false)
  31. const handleChange = (values: FieldValues, prop: PlusColumn) => {
  32. console.log(values, prop, "change");
  33. };
  34. const handleSubmit = (values: FieldValues) => {
  35. console.log(values, "Submit");
  36. };
  37. const handleSubmitError = (err: any) => {
  38. console.log(err, "err");
  39. };
  40. </script>
  41. <template>
  42. <el-card shadow="never" :body-style="{ height: 'calc(100vh - 260px)' }">
  43. <PlusForm
  44. v-model="state"
  45. class="w-[450px] m-auto"
  46. :columns="columns"
  47. :rules="rules"
  48. label-position="right"
  49. @change="handleChange"
  50. @submit="handleSubmit"
  51. @submit-error="handleSubmitError"
  52. >
  53. <template #footer="{ handleSubmit }">
  54. <div style="margin: 0 auto">
  55. <el-button type="primary" :loading="submitLoading" @click="handleSubmit">热更新</el-button>
  56. </div>
  57. </template>
  58. </PlusForm>
  59. </el-card>
  60. </template>