resource-service.js
1.35 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
import Service from './service';
import ResourceApi from '@/api/resource-api';
class ResourceService extends Service {
constructor() {
super();
this.api = new ResourceApi();
}
list() {
return this.api.list();
}
info(id) {
return this.api.info(id).then(result => {
// let {resGoodsPools, resContentInfos} = result.data;
let resGoodsPools = result.data.resGoodsPools;
let resContentInfos = result.data.resContentInfos || [];
resContentInfos.sort((a, b) => {
if (a.orderBy < b.orderBy) {
return -1;
}
if (a.orderBy > b.orderBy) {
return 1;
}
return 0;
});
if (resGoodsPools) {
resContentInfos.push({
type: 'resGoodsPoools',
data: resGoodsPools
});
}
return resContentInfos;
});
}
editGoodsPool(data) {
return this.api.editGoodsPool(data);
}
editResource(data) {
return this.api.editResource(data);
}
addOrUpdateResource(data) { // 添加或删除资源位
if (data.id) {
return this.api.editResourceListItem(data);
} else {
return this.api.addResourceListItem(data);
}
}
addOrUpdateResourceDetail(data) { // 添加或修改资源位内容(一张图两张图用)
return this.api.addOrUpdateResourceDetail(data);
}
}
export default ResourceService;