riku
2024-11-13 ab70c6eb4a181b282af0eb200275cd8a4d2ab172
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
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, paths, fun) {
    const fields = [
      {
        name: 'params',
        value: JSON.stringify([ledger]),
      },
    ];
    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;
        });
      });
      cb.success(res);
    };
 
    $f.get(fun1);
  },
};