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
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
| import serviceutils from "./serviceutils";
| const Multipart = require('../utils/Multipart.min');
| const $f = require('./baserequest');
| const util = require('../utils/util');
|
| module.exports = {
| //获取台账类型
| getLedgerSummary: function (userId, sceneType, time, fun) {
| let cb = {
| url: `/ledger/${userId}/summary`,
| params: {
| sceneType: sceneType,
| time: time,
| },
| };
| Object.assign(cb, fun);
|
| let fun1 = util.deepCopy(cb);
| fun1.success = function (res) {
| res.forEach(r => {
| r.iconUrl = $f.basePicUrl + r.iconUrl;
| });
| cb.success(res);
| };
| $f.get(fun1);
| },
|
| //上传台账
| uploadLedger: function (userId, ledger, namePairs, paths, fun) {
| const fields = [
| {
| name: 'params',
| value: JSON.stringify([ledger]),
| },
| {
| name: 'fileNames',
| value: JSON.stringify(namePairs),
| }
| ];
| const files = [];
| paths.forEach(p => {
| files.push({
| name: 'images',
| filePath: p,
| });
| });
| console.log(files);
| let p = new Multipart({
| fields,
| files,
| }).submit($f.baseUrl + `/ledger/${userId}/upload`);
| p.then(res => {
| fun.success(res);
| });
| },
|
| // 上传不涉及台账
| uploadNoLedger: function (userId, time, remark, ledgerIdList, fun) {
| let cb = {
| url: '/ledger/upload/noLedger',
| params: {
| userId: userId,
| time: time,
| remark: remark,
| },
| data: ledgerIdList,
| };
| Object.assign(cb, fun);
|
| $f.post(cb);
| },
|
| //获取台账详情
| getLedgerDetail: function (userId, ledgerSubTypeId, sceneType, time, fun) {
| let cb = {
| url: `/ledger/${userId}/detail2`,
| params: {
| sceneType: sceneType,
| },
| };
| if (ledgerSubTypeId) {
| cb.params.ledgerSubTypeId = ledgerSubTypeId;
| }
| if (time) {
| cb.params.time = time;
| }
| Object.assign(cb, fun);
|
| let fun1 = util.deepCopy(cb);
| fun1.success = function (res) {
| res.forEach(r => {
| r.path1 = r.path1.split(';').map((value, index) => {
| return $f.basePicUrl + value;
| });
| r._files = serviceutils.formatLedgerPath(r.path1)
| r._fileType = serviceutils.judgeLedgerFileType(r._files)
| });
| cb.success(res);
| };
|
| $f.get(fun1);
| },
|
| /**
| * 复制台账
| * @param {string} userId 用户id
| * @param {string} time 年月,格式YYYY-MM
| * @param {Array} sourceLedgerList 台账复制源{subTypeId:待复制的台账类型id, time: 待复制的台账所在月份,不填写则默认使用最新一条记录作为复制源}
| * @param {*} fun
| */
| copyLedger: function (userId, time, sourceLedgerList, fun) {
| let cb = {
| url: '/ledger/copy',
| params: {
| userId: userId,
| time: time,
| },
| data: sourceLedgerList,
| };
| Object.assign(cb, fun);
|
| $f.post(cb);
| },
| };
|
|