index.vue 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. <template>
  2. <el-card shadow="never" :body-style="{ height: 'calc(100vh - 260px)' }">
  3. <PlusForm
  4. v-model="state"
  5. class="w-[450px] m-auto"
  6. :columns="columns"
  7. :rules="rules"
  8. label-position="right"
  9. label-width="140px"
  10. @change="handleChange"
  11. @submit="handleSubmit"
  12. @submit-error="handleSubmitError"
  13. @reset="handleReset"
  14. />
  15. </el-card>
  16. </template>
  17. <script setup lang="ts">
  18. import { ref, onMounted } from "vue";
  19. // https://plus-pro-components.com/components/form.html
  20. import "plus-pro-components/es/components/form/style/css";
  21. import {
  22. type PlusColumn,
  23. type FieldValues,
  24. PlusForm
  25. } from "plus-pro-components";
  26. import { useColumns } from "./columns";
  27. const vGlobal = window.vueGlobal;
  28. const state = ref({});
  29. const rules = {
  30. name: [
  31. {
  32. required: true,
  33. message: "请输入名称"
  34. }
  35. ]
  36. };
  37. const { columns } = useColumns();
  38. const handleChange = (values: FieldValues, prop: PlusColumn) => {
  39. console.log(values, prop, "change");
  40. };
  41. const handleSubmit = (values: FieldValues) => {
  42. console.log(values, "Submit");
  43. };
  44. const handleSubmitError = (err: any) => {
  45. console.log(err, "err");
  46. };
  47. const handleReset = () => {
  48. console.log("handleReset");
  49. };
  50. onMounted(() => {
  51. const ci = setInterval(() => {
  52. if (vGlobal.isInited()) {
  53. clearInterval(ci);
  54. state.value = vGlobal.sysCfg ? vGlobal.sysCfg.sysCfgView : null;
  55. }
  56. }, 100);
  57. });
  58. </script>