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
| 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;
| let namePairs = []
| this.data.imgFiles.forEach(f=>{
| // 除了图片外的文档需要传输原始名字
| if (f.name) {
| const ulist = f.url.split('/')
| namePairs.push({
| first: ulist[ulist.length - 1], // 上传的临时文件名字
| second: f.name // 文件原始名字
| })
| }
| })
| 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,
| namePairs, 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,
| // })
| },
| },
| );
| },
|
| _uploadCopyLedger(copyLedgerList) {
| const time = moment().format('YYYY-MM');
| ledgerservice.copyLedger(app.globalData.accessToken.userId, time,copyLedgerList, {
| success:res=>{
| this.setData({ loading: false });
| if (typeof this._success === 'function') {
| this._success(res);
| }
| },
| fail(err) {
| this.setData({ loading: false });
| },
| })
| }
| },
| });
|
|