riku
2023-11-29 9b09d13712c0c005891450a3bf4b6d848ec0ff37
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
import { parseLedgerStat, refreshLedgerStatus } from '../../../../model/ledger';
const ledgerservice = require('../../../../service/ledgerservice');
const moment = require('../../../../utils/moment.min');
const app = getApp();
 
Component({
  /**
   * 组件的属性列表
   */
  properties: {},
 
  /**
   * 组件的初始数据
   */
  data: {
    refresh: false,
    thisMonth: '',
    tags1: { count: 0 },
    pageList1: [],
  },
 
  lifetimes: {
    attached: function () {
      this.init();
    },
  },
 
  /**
   * 组件的方法列表
   */
  methods: {
    init() {
      const now = moment();
      const nowStr = now.format('YYYY-MM-DD');
      const thisMonth = now.format('YYYY年MM月');
      this.setData({ thisMonth });
      this.getLedgerType(nowStr, r => {
        this.setData({
          tags1: {
            count: r[0][0].tag,
          },
          pageList1: r[1][0],
          progress: r[2].percent2,
          finished: r[2].finishedSelf,
          tabList: [r[0][0]],
          refresh: false,
        });
      });
    },
 
    getLedgerType(time, success, lastMonth) {
      var that = this;
      ledgerservice.getLedgerSummary(
        app.globalData.accessToken.userId,
        app.globalData.userInfo.extension2,
        time,
        {
          success(res) {
            let r = parseLedgerStat(res, lastMonth);
            success(r);
          },
        },
      );
    },
 
    gotoLedgerDetail(e) {
      const { index } = e.currentTarget.dataset;
      const indexGroup = index;
      var ledger = this.data.pageList1[index];
      var that = this;
      wx.navigateTo({
        url: '/pages/mLedger/ledgerupload/ledgerupload',
        events: {
          uploadOver: function (data) {
            let i = data.indexGroup;
            let s = that.data.pageList1[i];
            s.upLoad = true;
            refreshLedgerStatus(s);
            that.setData({
              [`pageList1[${i}]`]: s,
            });
            that.init();
          },
        },
        success: res => {
          // 通过 eventChannel 向被打开页面传送数据
          res.eventChannel.emit('acceptDataFromOpenerPage', {
            ledger: ledger,
            indexGroup: indexGroup,
            type: 0,
            barTitle: '上传自巡查',
          });
        },
      });
    },
 
    gotoHistory() {
      let tabList = this.data.tabList;
      wx.navigateTo({
        url: '/pages/mLedger/ledgerhistory/ledgerhistory',
        success: res => {
          // 通过 eventChannel 向被打开页面传送数据
          res.eventChannel.emit('acceptDataFromOpenerPage', {
            tabList: tabList,
          });
        },
      });
    },
  },
});