12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849 |
- const state = {
- products: [],
- selectedProducts: []
- }
- const getters = {
- getProducts (state) {
- return state.products
- },
- hasSelectedProducts (state) {
- return state.selectedProducts.length !== 0
- }
- }
- const mutations = {
- pushProducts(state, payload) {
- state.products = payload.products
- },
- selectProducts (state, payload) {
- state.selectedProducts = []
- payload.products.forEach(item => {
- state.products.push(item)
- });
- }
- }
- const actions = {
- fetchProducts ({ commit }) {
- let product = new openerp.web.Model('product.product')
- product.query(['name', 'display_name', 'list_price', 'qty_available', 'image_medium']).all().then(response => {
- commit('pushProducts', {
- products: response
- })
- }).fail(error => {
- console.log(error)
- })
- },
- selectProduct({ commit }) {
- }
- }
- export default {
- state,
- getters,
- mutations,
- actions
- }
|