tanghaolin
2022-07-27 fd4d1d9296ba620de15b47bd1d58383d46ecb626
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
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
var Constant = require('../../utils/constant.js');
var app = getApp();
Page({
 
  /**
   * 页面的初始数据
   */
  data: {
    navBarIndex: 0,
    curGrpTabName: '', //当前顶部导航栏的菜单名称
    worryCount: '', //总隐患条数
    scrollLeft: 0, //顶部导航栏每个标题之间的间距
    userInfo: '', //用户基本信息
    productId: '', //产品id
    employeeID: '', //员工id
    day: '', //查询的产品日期
    groupNameList: [], //顶部导航标签数组
    contentList: [], //内容数组
    inspectNote: '', //巡检记录的备注
    inspectFiles: [], //巡检记录的图片路径
    modalName: '', //当前滑动的项
  },
 
  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    this.setData({
      employeeID: options.EmployeeID,
      productId: options.ProductID,
      day: options.Day,
      userInfo: app.globalData.userInfo
    });
    wx.setNavigationBarTitle({
      title: options.Day + '巡检记录'
    })
 
    var userInfo = this.data.userInfo;
    //console.log('登录之后的用户信息', userInfo)
    if (userInfo == null) {
      wx.redirectTo({
        url: '/login/login/index',
      })
      return;
    } else {
      this.setData({
        userInfo: app.globalData.userInfo,
      });
    }
    this.getRecordDetail()
  },
  //获取记录详情
  getRecordDetail: function () {
    var that = this
    wx.showLoading({
      title: '数据获取中...',
    })
    let EmployeeID = that.data.employeeID
    let ProductID = that.data.productId
    let Day = that.data.day
    wx.request({
      method: 'GET',
      cache: false,
      url: Constant.BASE_SERVER_URL + 'repair/Mobile/InspectRecord/GetRecordDetail',
      data: {
        CorpID: Constant.CorpID,
        EmployeeID: EmployeeID,
        ProductID: ProductID,
        Day: Day
      },
      success: res => {
        wx.hideLoading()
        // console.log(res, '59')
        let result = res.data
        if (result.Code != 0) {
          wx.showModal({
            title: '提示',
            content: result.Message,
          })
          return;
        }
        var details = result.Data.Details;
        if (details == null || details.length == 0)
          return;
        // console.log(res, '巡检内容打印')
        //console.log(details);
 
        var defaultGroupName = details[0].GroupName
 
        let groupNameList = [] //顶部到导航栏组名数组
        let contentList = [] //内容数组
        let worryTotalCount = 0 //隐患条数
        let inspectFiles = [] //图片存放位置
 
        if (result.Data.Files != null) {
          for (let j = 0; j < result.Data.Files.length; j++) {
            inspectFiles.push(result.Data.Files[j].Path)
          }
        }
        for (let i = 0; i < details.length; i++) {
          let item = details[i];
          item.OldValue = item.Value;
          if (item.ValueStatus == 2) {
            worryTotalCount = worryTotalCount + 1;
          }
          //处理值类型
          this.handleValue(item)
 
          //设置样式
          this.setContentDetailStyle(item);
 
          if (groupNameList.indexOf(item.GroupName) == -1) {
            groupNameList.push(item.GroupName);
          }
          item.isShowTipInfo = false; //提示对话框弹出的动画状态
 
          if (item.ValueRangeMax != null && item.ValueRangeMin == null)
            item.TipInfo = item.TipInfo + " 正常值小于" + item.ValueRangeMax;
          if (item.ValueRangeMax == null && item.ValueRangeMin != null)
            item.TipInfo = item.TipInfo + " 正常值大于" + item.ValueRangeMin;
          if (item.ValueRangeMax != null && item.ValueRangeMin != null)
            item.TipInfo = item.TipInfo + " 正常值在" + item.ValueRangeMin + " ~ " + item.ValueRangeMax;
 
 
          // groupList.push({
          //   GroupName: item.GroupName
          // })
          contentList.push(item)
        }
        that.setData({
          curGrpTabName: defaultGroupName,
          groupNameList: groupNameList,
          contentList: contentList,
          recordId: result.Data.RecordID,
          inspectNote: result.Data.Note,
          inspectFiles: inspectFiles,
          worryCount: worryTotalCount
        })
        //  console.log(result.Data)
      },
      fail: err => {
        console.log(err)
      }
    })
  },
  //处理值类型对应的参数值
  handleValue: function (record) {
    // console.log(record)
    if (record.ValueType == 3) {
      if (record.Value == 1) {
        record.Value = "正常"
      }
      if (record.Value == 0) {
        record.Value = "异常"
      }
      return record
    }
  },
  //设置样式
  setContentDetailStyle(recordContent) {
    if (recordContent.ValueStatus == 2) {
      recordContent.valueDispClass = "worryValue";
      recordContent.statusDispClass = "cuIcon-warn text-grey";
    } else if (recordContent.ValueStatus == 1) {
      recordContent.statusDispClass = "cuIcon-roundcheckfill text-grey";
      recordContent.valueDispClass = "normalValue";
    } else {
      recordContent.statusDispClass = "cuIcon-title text-white";
      recordContent.valueDispClass = "normalValue";
    }
  },
  //查看照片
  tapViewImage(e) {
    // console.log(e)
    wx.previewImage({
      showmenu: true,
      urls: this.data.inspectFiles, //this.data.imageList,
      current: e.currentTarget.dataset.url,
      success: res => {
        console.log(res, '图片预览成功')
      },
      fail: err => {
        console.log(err, '图片预览失败')
      }
    });
  },
 
  // ListTouch触摸开始
  ListTouchStart(e) {
    this.setData({
      ListTouchStart: e.touches[0].pageX
    })
  },
 
  // ListTouch计算方向
  ListTouchMove(e) {
    this.setData({
      ListTouchDirection: e.touches[0].pageX - this.data.ListTouchStart > -50 ? 'right' : 'left'
    })
  },
 
  // ListTouch计算滚动
  ListTouchEnd(e) {
    if (this.data.ListTouchDirection == 'left') {
      this.setData({
        modalName: e.currentTarget.dataset.target
      })
    } else {
      this.setData({
        modalName: null
      })
    }
    this.setData({
      ListTouchDirection: null
    })
  },
 
  //跳转到单个巡检点的历史详情
  jumpSinglePointDetail: function (e) {
    // console.log(e)
    let valueType = e.currentTarget.dataset.valueType
    let item = JSON.stringify(e.currentTarget.dataset.item)
    wx.navigateTo({
      url: '../historyBySinglePointDetail/index?valueType=' + valueType + '&item=' + item,
    })
  },
 
 
  //消除隐患
  clearnWorry: function (e) {
 
  },
  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {
 
  },
 
  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {
 
  },
 
  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {
 
  },
 
  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {
 
  },
 
  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {
 
  },
 
  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {
 
  },
 
  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {
 
  }
})