PageConfig.vue 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. <template>
  2. <CusForm :columns="formItems" @change="handleChange"/>
  3. </template>
  4. <script setup lang="ts">
  5. import { computed } from 'vue';
  6. import { CusForm } from 'shalu-dashboard-ui';
  7. import { useProjectStore } from '@/store/modules/project';
  8. import { isEqual, omit } from 'lodash';
  9. const projectStore = useProjectStore();
  10. const formItems = computed(() => [
  11. {
  12. label: '项目名称',
  13. prop: 'name',
  14. type: 'input',
  15. defaultValue: projectStore.projectInfo.name
  16. },
  17. {
  18. label: '宽度',
  19. prop: 'width',
  20. type: 'inputNumber',
  21. fieldProps: {
  22. addonAfter: 'px',
  23. min: 100
  24. },
  25. defaultValue: projectStore.projectInfo.width
  26. },
  27. {
  28. label: '高度',
  29. prop: 'height',
  30. type: 'inputNumber',
  31. fieldProps: {
  32. addonAfter: 'px',
  33. min: 100
  34. },
  35. defaultValue: projectStore.projectInfo.height
  36. },
  37. {
  38. label: '页面背景',
  39. prop: 'background',
  40. type: 'backgroundSelect',
  41. defaultValue: projectStore.currentPage.background
  42. }
  43. ]);
  44. const handleChange = (value: Record<string, any>) => {
  45. if(!isEqual(value.background, projectStore.currentPage.background)) {
  46. projectStore.setCurrentPageBackground(value.background);
  47. };
  48. projectStore.updateProjectInfo(omit(value, ['background']));
  49. };
  50. </script>
  51. <style scoped>
  52. </style>