PageConfig.vue 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  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. import { useAcionStore } from '@/store/modules/action';
  10. const projectStore = useProjectStore();
  11. const actionStore = useAcionStore();
  12. const formItems = computed(() => [
  13. {
  14. label: '项目名称',
  15. prop: 'name',
  16. type: 'input',
  17. defaultValue: projectStore.projectInfo.name
  18. },
  19. {
  20. label: '宽度',
  21. prop: 'width',
  22. type: 'inputNumber',
  23. fieldProps: {
  24. addonAfter: 'px',
  25. min: 100
  26. },
  27. defaultValue: projectStore.projectInfo.width
  28. },
  29. {
  30. label: '高度',
  31. prop: 'height',
  32. type: 'inputNumber',
  33. fieldProps: {
  34. addonAfter: 'px',
  35. min: 100
  36. },
  37. defaultValue: projectStore.projectInfo.height
  38. },
  39. {
  40. label: '页面背景',
  41. prop: 'background',
  42. type: 'backgroundSelect',
  43. defaultValue: projectStore.currentPage.background
  44. }
  45. ]);
  46. const handleChange = (value: Record<string, any>) => {
  47. if(!isEqual(value.background, projectStore.currentPage.background)) {
  48. projectStore.setCurrentPageBackground(value.background);
  49. };
  50. projectStore.updateProjectInfo(omit(value, ['background']));
  51. actionStore.addRecord();
  52. };
  53. </script>
  54. <style scoped>
  55. </style>