fuliqi
2024-01-24 29c1e7eb5ac16e90d8991a86c1c071bc312ec8d9
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
import factoryCreate from '../views/diy-form/page/components/class/factoryCreate'
 
export default {
    initDiyList(state, diyList) {
        state.diyList = diyList
        state.mousedown.zIndex = 100 + diyList.length - 1
        state.mousedown.activeId = 'basicSet'
    },
    resetDiy(state) {
        state.diyList = [{
            id: 'basicSet',
            type: 'basicSet',
            titleImg: '',
            bgImg: [],
            titleColor: '',
            title: '基础设置',
            activityName: null // 专区名称(活动)
        }]
        state.mousedown = {
            startTime: 0,
            moveDom: null,
            activeId: 'basicSet',
            zIndex: 100
        }
    },
    addDiyList(state, obj) {
        state.diyList.push(obj)
    },
    updateDiylistById(state, obj) {
        if (!obj.id) return
        const arr = state.diyList.filter(v => {
            return v.id === obj.id
        })
        arr[0] = Object.assign(arr[0], obj.update)
    },
    updateCurrent(state, update) {
        const arr = state.diyList.filter(v => {
            return v.id === state.mousedown.activeId
        })
        arr[0] = Object.assign(arr[0], update)
    },
    // 设置按钮样式
    setBtnStyle(state, val) {
        const obj = val || {
            type: 'text',
            size: ''
        }
        state.btnStyleVal = obj
    },
    delPopDiyList(state) {
        state.diyList.pop()
    },
    changeTypeDiyList(state, type) {
        let beforeObj
        let index
        for (let i = 0; i < state.diyList.length; i++) {
            if (state.diyList[i].id === state.mousedown.activeId) {
                beforeObj = state.diyList[i]
                index = i
                break
            }
        }
        const obj = factoryCreate({
            x: beforeObj.x,
            y: beforeObj.y,
            w: beforeObj.w,
            h: beforeObj.h,
            z: beforeObj.z,
            type: type,
            title: beforeObj.title
        })
        state.mousedown.activeId = obj.id
        state.diyList.splice(index, 1, obj)
    },
    updateMousedown(state, mousedown) {
        state.mousedown = Object.assign(state.mousedown, mousedown)
    }
}