| | |
| | | |
| | | module.exports = { |
| | | //获取台账类型 |
| | | getLedgerType: function (sceneType, fun) { |
| | | getLedgerSummary: function (userId, sceneType, time, fun) { |
| | | let cb = { |
| | | url: `/ledger/type`, |
| | | url: `/ledger/${userId}/summary`, |
| | | params: { |
| | | sceneType: sceneType, |
| | | time: time |
| | | }, |
| | | } |
| | | Object.assign(cb, fun) |
| | |
| | | }, |
| | | |
| | | //上传台账 |
| | | // uploadLedger: function (userId, ledger, files, fun) { |
| | | // let formData = new FormData(); |
| | | |
| | | // // 用法 |
| | | // // formData.append("name", "value"); // value 表单值 |
| | | // // formData.appendFile("file", filepath); // filepath 文件路径 |
| | | |
| | | // // formData.append("params", JSON.stringify([ledger])) |
| | | // files.forEach(f => { |
| | | // formData.appendFile("images", f); |
| | | // }); |
| | | |
| | | // // formData.getData() => { |
| | | // // buffer:<ArrayBuffer>[], // buffer 表单数据的ArrayBuffer对象 |
| | | // // contentType: string, // http请求Content-Type头部内容 |
| | | // // } |
| | | // const data = formData.getData(); |
| | | |
| | | // let cb = { |
| | | // url: `/ledger/${userId}/upload`, |
| | | // params: { |
| | | // params: JSON.stringify([ledger]), |
| | | // }, |
| | | // header: { |
| | | // 'content-type': data.contentType |
| | | // }, |
| | | // data: data.buffer, |
| | | // } |
| | | |
| | | // Object.assign(cb, fun) |
| | | // $f.post(cb) |
| | | // } |
| | | uploadLedger: function (userId, ledger, paths, fun) { |
| | | const fields = [{ |
| | | name: 'params', |
| | |
| | | }) |
| | | }); |
| | | console.log(files); |
| | | new Multipart({ |
| | | let p = new Multipart({ |
| | | fields, |
| | | files |
| | | }).submit($f.baseUrl + `/ledger/${userId}/upload`) |
| | | } |
| | | p.then(res => { |
| | | fun.success(res) |
| | | }) |
| | | }, |
| | | |
| | | //获取台账详情 |
| | | getLedgerDetail: function (userId, ledgerSubTypeId, sceneType, time, fun) { |
| | | let cb = { |
| | | url: `/ledger/${userId}/detail2`, |
| | | params: { |
| | | sceneType: sceneType, |
| | | time: time |
| | | }, |
| | | } |
| | | if (ledgerSubTypeId) { |
| | | cb.params.ledgerSubTypeId = ledgerSubTypeId |
| | | } |
| | | 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) |
| | | }, |
| | | } |