| | |
| | | const Multipart = require('../utils/Multipart.min') |
| | | const $f = require('./baserequest') |
| | | const util = require('../utils/util') |
| | | const Multipart = require('../utils/Multipart.min'); |
| | | const $f = require('./baserequest'); |
| | | const util = require('../utils/util'); |
| | | |
| | | module.exports = { |
| | | //获取台账类型 |
| | |
| | | url: `/ledger/${userId}/summary`, |
| | | params: { |
| | | sceneType: sceneType, |
| | | time: time |
| | | time: time, |
| | | }, |
| | | } |
| | | Object.assign(cb, fun) |
| | | }; |
| | | Object.assign(cb, fun); |
| | | |
| | | let fun1 = util.deepCopy(cb) |
| | | let fun1 = util.deepCopy(cb); |
| | | fun1.success = function (res) { |
| | | res.forEach(r => { |
| | | r.iconUrl = $f.basePicUrl + r.iconUrl |
| | | r.iconUrl = $f.basePicUrl + r.iconUrl; |
| | | }); |
| | | cb.success(res) |
| | | } |
| | | $f.get(fun1) |
| | | cb.success(res); |
| | | }; |
| | | $f.get(fun1); |
| | | }, |
| | | |
| | | //上传台账 |
| | | uploadLedger: function (userId, ledger, paths, fun) { |
| | | const fields = [{ |
| | | name: 'params', |
| | | value: JSON.stringify([ledger]) |
| | | }] |
| | | const files = [] |
| | | const fields = [ |
| | | { |
| | | name: 'params', |
| | | value: JSON.stringify([ledger]), |
| | | }, |
| | | ]; |
| | | const files = []; |
| | | paths.forEach(p => { |
| | | files.push({ |
| | | name: 'images', |
| | | filePath: p |
| | | }) |
| | | filePath: p, |
| | | }); |
| | | }); |
| | | console.log(files); |
| | | let p = new Multipart({ |
| | | fields, |
| | | files |
| | | }).submit($f.baseUrl + `/ledger/${userId}/upload`) |
| | | files, |
| | | }).submit($f.baseUrl + `/ledger/${userId}/upload`); |
| | | p.then(res => { |
| | | fun.success(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); |
| | | }, |
| | | |
| | | //获取台账详情 |
| | |
| | | params: { |
| | | sceneType: sceneType, |
| | | }, |
| | | } |
| | | }; |
| | | if (ledgerSubTypeId) { |
| | | cb.params.ledgerSubTypeId = ledgerSubTypeId |
| | | cb.params.ledgerSubTypeId = ledgerSubTypeId; |
| | | } |
| | | if (time) { |
| | | cb.params.time = time |
| | | cb.params.time = time; |
| | | } |
| | | Object.assign(cb, fun) |
| | | Object.assign(cb, fun); |
| | | |
| | | let fun1 = util.deepCopy(cb) |
| | | let fun1 = util.deepCopy(cb); |
| | | fun1.success = function (res) { |
| | | res.forEach(r => { |
| | | r.path1 = r.path1.split(';').map((value, index) => { |
| | | return $f.basePicUrl + value |
| | | }) |
| | | return $f.basePicUrl + value; |
| | | }); |
| | | }); |
| | | cb.success(res) |
| | | } |
| | | |
| | | $f.get(fun1) |
| | | 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); |
| | | }, |
| | | }; |