condition.js
2.84 KB
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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
import dateInstance from '../../common/date.js'
import fetch from '../../api/fetch.js'
import { CONDITIONS } from '../mutation-types.js'
const state = {
// 门店
storeMallList: [], // 门店/商场列表
checkedMallId: null, // 单选门店
multiCheckedMallId: [], // 多选门店
// 监控点
storeGateList: [], // 监控点/出入口列表
checkedGateId: null, // 单选监控点
multiCheckedGateId: [], // 多选监控点
// 时间
dateData: [], // 基本时间数据 年月日
// 天级日期
selectedDayTime: '', // 选中天级日期字符串
dayAnchor: [], // 选中天级日期picker下标
// 开始结束日期
selectedStartDayTime: '', // 选中开始日期时间字符串
startDayAnchor: [], // 选中开始日期时间picker下标
selectedEndDayTime: '', // 选中结束日期时间字符串
endDayAnchor: [], // 选中结束日期时间picker下标
}
const getter = {};
const mutations = {
// 门店/商场
[CONDITIONS.SET_MALLS] (state, mallList) {
state.mallList = mallList;
},
[CONDITIONS.CHECKED_MALL_ID] (state, mallId) {
state.checkedMallId = mallId;
},
[CONDITIONS.CHECKED_MULTI_MALL_ID] (state, multiMallId) {
state.multiCheckedMallId = multiMallId;
},
}
const actions = {
getMalls({ commit }, { data, header }) {
fetch.loadAccountList('get', data, header)
.then(res => {
console.log('actions fetch mallList-=-=-=-=-=->', res)
let result = res.data;
let buildMallData = result.data.map(item => {
item._selected = false; // 结合数据展现新增属性
return item;
})
commit(CONDITIONS.SET_MALLS, buildMallData)
let mallId = null
, multiMallId = [];
multiMallId = buildMallData.map((item, index) => {
if(index == 0) {
mallId = {
id: item.id,
name: item.name
};
}
return {
id: item.id,
name: item.name
};
});
commit(CONDITIONS.CHECKED_MALL_ID, mallId)
commit(CONDITIONS.CHECKED_MULTI_MALL_ID, multiMallId)
})
},
getGates({ commit }, { data, header }) {
fetch.loadGateList({
data, header
})
.then(res => {
console.log('actions fetch gateList-=-=-=-=-=->', res)
let result = res.data;
let buildGateData = result.data.map(item => {
item._selected = false; // 结合数据展现新增属性
return item;
})
commit(CONDITIONS.SET_GATES, buildGateData)
let gateId = null
, multiGateId = [];
multiGateId = buildGateData.map((item, index) => {
if(index == 0) {
gateId = {
id: item.id,
name: item.name
};
}
return {
id: item.id,
name: item.name
};
});
commit(CONDITIONS.CHECKED_GATE_ID, gateId)
commit(CONDITIONS.CHECKED_MULTI_GATE_ID, multiGateId)
})
},
}
const conditionList = {
state: state,
getters: getter,
mutations: mutations,
actions: actions
}
export default conditionList;