import bUpload from '../../../base/behaviors/bUpload'; import ledgerservice from '../../../service/ledgerservice'; import bLoadingStatus from '../../../base/behaviors/bLoadingStatus'; import moment from '../../../utils/moment.min'; const app = getApp(); /** * 台账上传管理 */ module.exports = Behavior({ behaviors: [bUpload, bLoadingStatus], data: { // 台账类型 ledger: {}, // 台账详情 detail: undefined, remark: '', }, methods: { _uploadLedger() { if (this.data.imgFiles.length == 0) return; var that = this; let path = []; this.data.imgFiles.forEach(f => { path.push(f.url); }); let ledger = this.data.ledger; ledger.remark1 = this.data.remark; if (this.data.detail) { ledger.id = this.data.detail.id } this.setData({ loading: true }); ledgerservice.uploadLedger( app.globalData.accessToken.userId, ledger, path, { success(res) { that.setData({ loading: false }); if (typeof that._success === 'function') { that._success(res); } }, fail(err) { that.setData({ loading: false }); // wx.showToast({ // title: '上传失败', // duration: 1000, // icon: 'none', // mask: true, // }) }, complete(res) {}, }, ); }, _uploadNoLedger() { var that = this; const time = moment().format('YYYY-MM-DD'); const idList = [this.data.ledger.ledgerSubTypeId]; this.setData({ loading: true }); ledgerservice.uploadNoLedger( app.globalData.accessToken.userId, time, this.data.remark, idList, { success(res) { that.setData({ loading: false }); if (typeof that._success === 'function') { that._success(res); } }, fail(err) { that.setData({ loading: false }); // wx.showToast({ // title: '上传失败', // duration: 1000, // icon: 'none', // mask: true, // }) }, }, ); }, }, });