generateOptions.js 535 B

1234567891011121314151617181920212223242526
  1. import { nanoid } from './nanoid'
  2. import { globalConfig } from '@ER/formEditor/componentsConfig.js'
  3. import _ from 'lodash-es'
  4. export const generateOptions = len => {
  5. const result = []
  6. while (len--) {
  7. result.push({
  8. label: 'Option',
  9. value: nanoid()
  10. })
  11. }
  12. return result
  13. }
  14. export const generateData = (layoutType = 1) => {
  15. const result = {
  16. config: _.cloneDeep(globalConfig)
  17. }
  18. result.logic = result.data = {}
  19. if (layoutType === 1) {
  20. result.list = []
  21. }
  22. if (layoutType === 2) {
  23. result.layout = []
  24. }
  25. return result
  26. }