actions.js
2.16 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
import * as Types from './types';
import {first, get, flatten} from 'lodash';
export default {
async fetchProduct({commit}, {productId, page = 1, refresh = false}) {
commit(Types.FETCH_ORDER_PRODUCT_REQUEST);
let result;
if (refresh) {
const results = await Promise.all(Array.from(new Array(page)).map((v, i) => {
return this.$api.get('/api/ufo/seller/entryGoodsSizeList', {
productId,
page: i + 1
});
}));
result = {
code: 200,
data: {
productInfo: get(first(results), 'data.productInfo'),
data: flatten(results.map(r => get(r, 'data.data', [])))
}
};
} else {
result = await this.$api.get('/api/ufo/seller/entryGoodsSizeList', {
productId,
page
});
}
if (result && result.code === 200) {
commit(Types.FETCH_ORDER_PRODUCT_SUCCESS, {
order: result.data,
refresh,
});
} else {
commit(Types.FETCH_ORDER_PRODUCT_FAILD);
}
return result;
},
async postNoSale({commit}, payload) {
commit(Types.POST_NOSALE_REQUEST);
const result = await this.$api.get('/api/ufo/sellerOrder/batchDownShelf', payload);
if (result && result.code === 200) {
commit(Types.POST_NOSALE_SUCCESS, {
order: result.data
});
} else {
commit(Types.POST_NOSALE_FAILD);
}
return result || {};
},
async postCalcPrice({commit}, payload) {
commit(Types.POST_CALCPRICE_REQUEST);
const result = await this.$api.get('/api/ufo/sellerOrder/computeAdjustPrice', payload);
if (result && result.code === 200) {
commit(Types.POST_CALCPRICE_SUCCESS, {
order: result.data
});
} else {
commit(Types.POST_CALCPRICE_FAILD);
}
return result || {};
},
async postChangePrice({commit}, payload) {
commit(Types.POST_CHANGEPRICE_REQUEST);
const result = await this.$api.get('/api/ufo/sellerOrder/batchAdjustPrice', payload);
if (result && result.code === 200) {
commit(Types.POST_CHANGEPRICE_SUCCESS, {
order: result.data
});
} else {
commit(Types.POST_CHANGEPRICE_FAILD);
}
return result || {};
}
};