@/utils#createUUID JavaScript Examples

The following examples show how to use @/utils#createUUID. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: DataModel.js    From see-h5-editor with Apache License 2.0 6 votes vote down vote up
getElementConfig = function (element, extendStyle = {}) {
    let elementData = cloneDeep(element)
    let type = elementData.valueType || 'String' // 默认string类型
    let dict = {
        'Sting': '',
        'Array': [],
        'Object': {},
        'Boolean': false,
        'Number': 0
        // 待扩展数据类型
    }
    const uuid = createUUID()
    let elementConfigData = cloneDeep(elementConfig)
    let config = {
        ...elementConfigData,
        uuid: uuid,
        brotherUuid: uuid,
        elName: elementData.elName,
        propsValue: cloneDeep(elementData.needProps || {})
    }

    // 样式
    config.commonStyle = merge(config.commonStyle, elementData.defaultStyle)
    config.commonStyle = merge(config.commonStyle, extendStyle)

    config.resizable = elementData.resizable
    config.movable = elementData.movable
    config.autoHeight = elementData.autoHeight || false
    config.autoWidth = elementData.autoWidth || false

    config.value = element.defaultValue || dict[type]
    config.valueType = type
    config.isForm = !!element.isForm
    config.componentsType = element.componentsType
    config.visible = typeof element.visible === 'string' ? element.visible : 'return true'
    config.hasSlot = !!element.hasSlot

    return config
}
Example #2
Source File: DataModel.js    From see-h5-editor with Apache License 2.0 6 votes vote down vote up
copyElement = function (element, extendStyle = {}) {
    const uuid = createUUID()
    element = cloneDeep(element)
    element.uuid = uuid
    element.brotherUuid = uuid
    element.commonStyle = merge(element.commonStyle, extendStyle)
    // 加上一点偏移量,以作区分
    element.commonStyle.top = element.commonStyle.top + 10
    element.commonStyle.left = element.commonStyle.left + 10
    if (element.elements) {
        element.elements = element.elements.map(item => copyElement(item))
    }
    return element
}
Example #3
Source File: DataModel.js    From see-h5-editor with Apache License 2.0 6 votes vote down vote up
copyPage = function (data, pageName) {
    let pageData = cloneDeep(data)
    pageData.uuid = createUUID()
    pageData.name = pageName
    pageData.elements = pageData.elements.map(element => {
        return {
            ...element,
            uuid: createUUID()
        }
    })
    return pageData
}
Example #4
Source File: DataModel.js    From see-h5-editor with Apache License 2.0 5 votes vote down vote up
getPageConfig = function (pageName = 1) {
    return {
        ...cloneDeep(pageConfig),
        uuid: createUUID(),
        name: pageName
    }
}