You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
91 lines
2.7 KiB
91 lines
2.7 KiB
import {createStore} from 'vuex'; |
|
import {toValue} from 'vue' |
|
|
|
const updateModule = { |
|
namespaced: true, |
|
state: { |
|
update_dialog_show: false, |
|
update_config: {}, |
|
update_status: {}, |
|
}, |
|
getter: { |
|
dialog_change: state => { |
|
state.update_dialog_show = !state.update_dialog_show |
|
return state.update_dialog_show |
|
}, |
|
}, |
|
mutations: { |
|
add_update_cine: (state, payload) => { |
|
state.update_config[payload.ip] = payload.config |
|
}, |
|
add_update_status: (state, payload) => { |
|
state.update_status[payload.ip] = payload.status |
|
}, |
|
change_update_status: (state, ip) => { |
|
if (state.update_status[ip] !== undefined) { |
|
state.update_status[ip] = !state.update_status[ip] |
|
} |
|
}, |
|
clear_update_status: (state, ip) => { |
|
if (state.update_status[ip]) { |
|
delete state.update_status[ip] |
|
} |
|
}, |
|
}, |
|
actions: {}, |
|
} |
|
|
|
const ecApiModule = { |
|
namespaced: true, |
|
state: { |
|
ec_api_data: {api:[]}, // 所有api数据 |
|
// ec_select_api: [], // 默认选中的api |
|
first_tab_api_id: 1 |
|
}, |
|
getters: { |
|
ec_api_data_getter: state => { |
|
return state.ec_api_data |
|
}, |
|
ec_select_api_getter: state => { |
|
let select_api_id = [] |
|
state.ec_api_data.api.forEach(item => { |
|
select_api_id.push(item.id) |
|
}) |
|
return select_api_id |
|
}, |
|
}, |
|
mutations: { |
|
change_ec_select_api: (state, payload) => { |
|
// console.log('payload', payload) |
|
// console.log('state.ec_api_data.api', state.ec_api_data.api) |
|
payload.forEach((item) => { |
|
if (state.ec_api_data.api.indexOf(item) === -1) { |
|
state.ec_api_data.api.push(item) |
|
} |
|
}) |
|
state.ec_api_data.api.forEach((item) => { |
|
if (payload.indexOf(item) === -1) { |
|
state.ec_api_data.api.splice(state.ec_api_data.api.indexOf(item), 1) |
|
} |
|
}) |
|
// console.log('state.ec_api_data.api', state.ec_api_data.api) |
|
}, |
|
handle_sort_ec_select_api: (state, payload) => { |
|
const movedTab = state.ec_api_data.api.splice(payload.oldIndex-1, 1)[0]; |
|
state.ec_api_data.api.splice(payload.newIndex-1, 0, movedTab); |
|
}, |
|
add_ec_api_data: (state, payload) => { |
|
// console.log('payload', payload) |
|
state.ec_api_data = payload |
|
} |
|
|
|
}, |
|
actions: {}, |
|
} |
|
|
|
export default createStore({ |
|
modules: { |
|
updateModule, |
|
ecApiModule, |
|
}, |
|
})
|
|
|